1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-27 03:21:29 +03:00

feature #212: Added dispatch method to the Scheduler

This commit is contained in:
Carlos Martin and Ruben S. Montero 2010-05-14 17:15:22 +02:00 committed by Ruben S. Montero
parent 2f3e35988d
commit a3f77963de
3 changed files with 59 additions and 1 deletions

View File

@ -44,6 +44,8 @@ public:
return static_cast<VirtualMachineXML *>(PoolXML::get(oid));
};
int dispatch(int vid, int hid) const;
protected:
int get_suitable_nodes(vector<xmlNodePtr>& content)

View File

@ -122,3 +122,59 @@ int VirtualMachinePoolXML::load_info(xmlrpc_c::value &result)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachinePoolXML::dispatch(int vid, int hid) const
{
ostringstream oss;
xmlrpc_c::value deploy_result;
oss.str("");
oss << "Dispatching virtual machine " << vid
<< " to HID: " << hid;
NebulaLog::log("VM",Log::INFO,oss);
try
{
client->call( client->get_endpoint(), // serverUrl
"one.vm.deploy", // methodName
"sii", // arguments format
&deploy_result, // resultP
client->get_oneauth().c_str(), // argument 0
vid, // argument 1
hid // argument 2
);
}
catch (exception const& e)
{
oss.str("");
oss << "Exception raised: " << e.what() << '\n';
NebulaLog::log("VM",Log::ERROR,oss);
return -1;
}
// See how ONE handled the deployment
vector<xmlrpc_c::value> values =
xmlrpc_c::value_array(deploy_result).vectorValueValue();
bool success = xmlrpc_c::value_boolean( values[0] );
if ( !success )
{
string message = xmlrpc_c::value_string( values[1] );
oss.str("");
oss << "Error deploying virtual machine " << vid
<< " to HID: " << hid << ". Reason: " << message;
NebulaLog::log("VM",Log::ERROR,oss);
return -1;
}
return 0;
}

View File

@ -394,7 +394,7 @@ void Scheduler::dispatch()
if (rc == 0)
{
//vm->dispatch(hid,client);
vmpool->dispatch(vm_it->first,hid);
}
}
}