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:
parent
2f3e35988d
commit
a3f77963de
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ void Scheduler::dispatch()
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
//vm->dispatch(hid,client);
|
||||
vmpool->dispatch(vm_it->first,hid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user