diff --git a/src/scheduler/include/UserXML.h b/src/scheduler/include/UserXML.h index 56e01040da..ef791274a0 100644 --- a/src/scheduler/include/UserXML.h +++ b/src/scheduler/include/UserXML.h @@ -41,6 +41,11 @@ public: return oid; }; + set get_groups() + { + return group_ids; + }; + private: int oid; int gid; diff --git a/src/scheduler/include/VirtualMachineXML.h b/src/scheduler/include/VirtualMachineXML.h index ed2ad44b7c..5a6baec137 100644 --- a/src/scheduler/include/VirtualMachineXML.h +++ b/src/scheduler/include/VirtualMachineXML.h @@ -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; diff --git a/src/scheduler/src/pool/VirtualMachineXML.cc b/src/scheduler/src/pool/VirtualMachineXML.cc index d64ede4c47..ce0cdb4667 100644 --- a/src/scheduler/src/pool/VirtualMachineXML.cc +++ b/src/scheduler/src/pool/VirtualMachineXML.cc @@ -22,7 +22,8 @@ void VirtualMachineXML::init_attributes() { vector 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) diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index 6b22e106f3..0ea7eae18f 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -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 gids; + int rc; map::const_iterator vm_it; @@ -280,8 +292,9 @@ void Scheduler::match() vm = static_cast(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(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 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 // -----------------------------------------------------------------