1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

feature #687: Place holder for ACL integration ready

This commit is contained in:
Ruben S. Montero 2011-07-03 04:56:05 +02:00
parent 2a12216760
commit facdf35009
4 changed files with 56 additions and 4 deletions

View File

@ -41,6 +41,11 @@ public:
return oid;
};
set<int> get_groups()
{
return group_ids;
};
private:
int oid;
int gid;

View File

@ -46,6 +46,11 @@ public:
return oid;
};
int get_uid() const
{
return uid;
};
/**
* Adds a new share to the map of suitable shares to start this VM
* @param hid of the selected host
@ -138,6 +143,8 @@ protected:
*/
int oid;
int uid;
int memory;
float cpu;

View File

@ -22,7 +22,8 @@ void VirtualMachineXML::init_attributes()
{
vector<string> result;
oid = atoi(((*this)["/VM/ID"] )[0].c_str() );
oid = atoi(((*this)["/VM/ID"] )[0].c_str());
uid = atoi(((*this)["/VM/UID"])[0].c_str());
result = ((*this)["/VM/TEMPLATE/MEMORY"]);
if (result.size() > 0)

View File

@ -230,7 +230,7 @@ int Scheduler::set_up_pools()
}
//--------------------------------------------------------------------------
//Cleans the cache and get the pending VMs
//Cleans the cache and get the users
//--------------------------------------------------------------------------
rc = upool->set_up();
@ -240,6 +240,14 @@ int Scheduler::set_up_pools()
return rc;
}
//--------------------------------------------------------------------------
//Cleans the cache and get the ACLs
//--------------------------------------------------------------------------
//TODO
// 1.- one.acl.list
// 2.- from_xml
//--------------------------------------------------------------------------
//Get the matching hosts for each VM
//--------------------------------------------------------------------------
@ -258,6 +266,7 @@ void Scheduler::match()
int vm_memory;
int vm_cpu;
int vm_disk;
int uid;
string reqs;
HostXML * host;
@ -266,6 +275,9 @@ void Scheduler::match()
char * error;
bool matched;
UserXML * user;
set<int> gids;
int rc;
map<int, ObjectXML*>::const_iterator vm_it;
@ -280,8 +292,9 @@ void Scheduler::match()
vm = static_cast<VirtualMachineXML*>(vm_it->second);
reqs = vm->get_requirements();
uid = vm->get_uid();
for (h_it=hosts.begin(); h_it != hosts.end(); h_it++)
for (h_it=hosts.begin(), matched=false; h_it != hosts.end(); h_it++)
{
host = static_cast<HostXML *>(h_it->second);
@ -310,12 +323,38 @@ void Scheduler::match()
{
matched = true;
}
if ( matched == false )
{
continue;
}
// -----------------------------------------------------------------
// Check host capacity
// -----------------------------------------------------------------
user = upool->get(uid);
matched = false;
if ( user != 0 )
{
set<int> groups = user->get_groups();
//TODO Authorization test for this user on this host
// 1.- user = uid
// 2.- gid
// 3.- groups
// 4.- DEPLOY on host->get_hid
}
else
{
//TODO Log debug info (user not authorized)?
continue;
}
if ( matched == false )
{
continue;
}
// -----------------------------------------------------------------
// Check host capacity
// -----------------------------------------------------------------