feature #3383: Deploy handles imported VMs. Monitor returns UUID as DEPLOY_ID

This commit is contained in:
Ruben S. Montero committed 2015-02-05 20:06:59 +01:00
1 parent 1babf402d4
commit 943ae3d8b7
3 files changed
+30 -4

No files matched your search

+26 -1
View File
@@ -640,6 +640,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
int id = xmlrpc_c::value_int(paramList.getInt(1));
int hid = xmlrpc_c::value_int(paramList.getInt(2));
bool enforce = false;
bool imported= false;
int ds_id = -1;
if ( paramList.size() > 3 )
@@ -688,6 +689,10 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
{
ds_id = vm->get_ds_id();
}
else if (!vm->get_deploy_id().empty()) //deploy_id && not a Stopped VM
{
imported = true;
}
vm->unlock();
@@ -795,7 +800,27 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
dm->deploy(vm);
if (!imported)
{
dm->deploy(vm);
}
else
{
LifeCycleManager * lcm = nd.get_lcm();
VirtualMachinePool * vmpool = nd.get_vmpool();
HostPool * hpool = nd.get_hpool();
int cpu,mem,disk;
vm->get_requirements(cpu,mem,disk);
hpool->add_capacity(vm->get_hid(), id, cpu, mem, disk);
vm->set_state(VirtualMachine::ACTIVE);
vm->set_state(VirtualMachine::BOOT);
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DEPLOY_SUCCESS, id);
}
vm->unlock();
+3 -2
View File
@@ -567,14 +567,15 @@ int VirtualMachinePool::db_int_cb(void * _min_stime, int num, char **values, cha
int VirtualMachinePool::get_vmid (const string& deploy_id)
{
int vmid, rc;
int rc;
int vmid = -1;
ostringstream oss;
set_callback(static_cast<Callbackable::Callback>(&VirtualMachinePool::db_int_cb),
static_cast<void *>(&vmid));
oss << "SELECT vmid FROM " << import_table
<< "WHERE deploy_id = " << db->escape_str(deploy_id.c_str());
<< " WHERE deploy_id = '" << db->escape_str(deploy_id.c_str()) << "'";
rc = db->exec(oss, this);
@@ -603,7 +603,7 @@ class VCenterHost < ::OpenNebula::Host
str_info << "\nVM = ["
str_info << "ID=#{number},"
str_info << "DEPLOY_ID=\"#{name}\","
str_info << "DEPLOY_ID=\"#{vm.vm.config.uuid}\","
str_info << "POLL=\"#{vm.info}\"]"
}