mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #2653: Get zone id using xml-rpc api
This commit is contained in:
parent
2c6049b754
commit
af28d07d15
@ -52,6 +52,8 @@ protected:
|
||||
clpool(0),
|
||||
vmpool(0),
|
||||
vmapool(0),
|
||||
dspool(0),
|
||||
img_dspool(0),
|
||||
acls(0),
|
||||
timer(0),
|
||||
url(""),
|
||||
@ -66,45 +68,18 @@ protected:
|
||||
|
||||
virtual ~Scheduler()
|
||||
{
|
||||
if ( hpool != 0)
|
||||
{
|
||||
delete hpool;
|
||||
}
|
||||
delete hpool;
|
||||
delete clpool;
|
||||
|
||||
if ( clpool != 0)
|
||||
{
|
||||
delete clpool;
|
||||
}
|
||||
delete vmpool;
|
||||
delete vmapool;
|
||||
|
||||
if ( vmpool != 0)
|
||||
{
|
||||
delete vmpool;
|
||||
}
|
||||
delete dspool;
|
||||
delete img_dspool;
|
||||
|
||||
if ( vmapool != 0)
|
||||
{
|
||||
delete vmapool;
|
||||
}
|
||||
delete acls;
|
||||
|
||||
if ( dspool != 0)
|
||||
{
|
||||
delete dspool;
|
||||
}
|
||||
|
||||
if ( img_dspool != 0)
|
||||
{
|
||||
delete img_dspool;
|
||||
}
|
||||
|
||||
if ( acls != 0)
|
||||
{
|
||||
delete acls;
|
||||
}
|
||||
|
||||
if ( client != 0)
|
||||
{
|
||||
delete client;
|
||||
}
|
||||
delete client;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
@ -201,11 +176,21 @@ private:
|
||||
*/
|
||||
float hypervisor_mem;
|
||||
|
||||
/**
|
||||
* OpenNebula zone id.
|
||||
*/
|
||||
int zone_id;
|
||||
|
||||
/**
|
||||
* XML_RPC client
|
||||
*/
|
||||
Client * client;
|
||||
|
||||
/**
|
||||
* oned runtime configuration values
|
||||
*/
|
||||
Template oned_conf;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Timer to periodically schedule and dispatch VMs
|
||||
// ---------------------------------------------------------------
|
||||
|
@ -215,9 +215,77 @@ void Scheduler::start()
|
||||
|
||||
xmlInitParser();
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// Get oned configuration, and init zone_id
|
||||
// -------------------------------------------------------------------------
|
||||
int tries = 0;
|
||||
|
||||
while (tries < 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
xmlrpc_c::value result;
|
||||
|
||||
client->call(client->get_endpoint(), // serverUrl
|
||||
"one.system.config", // methodName
|
||||
"s", // arguments format
|
||||
&result, // resultP
|
||||
client->get_oneauth().c_str());// auth string
|
||||
|
||||
vector<xmlrpc_c::value> values =
|
||||
xmlrpc_c::value_array(result).vectorValueValue();
|
||||
|
||||
bool success = xmlrpc_c::value_boolean(values[0]);
|
||||
string message = xmlrpc_c::value_string(values[1]);
|
||||
|
||||
if (!success ||(oned_conf.from_xml(message) != 0))
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "Wrong oned response: " << message;
|
||||
|
||||
NebulaLog::log("SCHED", Log::WARNING, message);
|
||||
|
||||
tries++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
catch (exception const& e)
|
||||
{
|
||||
tries++;
|
||||
NebulaLog::log("SCHED", Log::WARNING, e.what());
|
||||
}
|
||||
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
if (tries >= 3)
|
||||
{
|
||||
throw runtime_error("Error contacting oned, check sched.log");
|
||||
}
|
||||
|
||||
vector<const Attribute*> fed;
|
||||
|
||||
zone_id = 0;
|
||||
|
||||
if (oned_conf.get("FEDERATION", fed) > 0)
|
||||
{
|
||||
const VectorAttribute * va=static_cast<const VectorAttribute *>(fed[0]);
|
||||
|
||||
if (va->vector_value("ZONE_ID", zone_id) != 0)
|
||||
{
|
||||
zone_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
oss.str("");
|
||||
oss << "Configuring scheduler for Zone ID: " << zone_id;
|
||||
|
||||
NebulaLog::log("SCHED", Log::INFO, oss);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Pools
|
||||
// -----------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
hpool = new HostPoolXML(client, hypervisor_mem);
|
||||
clpool = new ClusterPoolXML(client);
|
||||
@ -228,10 +296,6 @@ void Scheduler::start()
|
||||
dspool = new SystemDatastorePoolXML(client);
|
||||
img_dspool = new ImageDatastorePoolXML(client);
|
||||
|
||||
// TODO: In stand alone mode, Nebula.cc inits zone_id to 0. But we need
|
||||
// to know the local zone id in the sched. Either from sched.conf, or
|
||||
// from one.system.config
|
||||
int zone_id = 0;
|
||||
acls = new AclXML(client, zone_id);
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user