1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-03 01:17:41 +03:00

F #1764: updateconf for running VM

L #-: Use nullptr, cpplint rules

co-authored-by: Pavel Czerny <pczerny@opennebula.systems>
This commit is contained in:
Ruben S. Montero 2019-07-26 13:45:26 +02:00
parent 65aabd760a
commit a6481bb038
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
17 changed files with 757 additions and 442 deletions

View File

@ -53,10 +53,10 @@ public:
};
DMAction(Actions a, int v):ActionRequest(ActionRequest::USER),
_action(a), _vm_id(v){};
_action(a), _vm_id(v){}
DMAction(const DMAction& o):ActionRequest(o._type), _action(o._action),
_vm_id(o._vm_id){};
_vm_id(o._vm_id){}
Actions action() const
{
@ -89,7 +89,7 @@ public:
am.addListener(this);
};
~DispatchManager(){};
~DispatchManager() = default;
/**
* Initializes internal pointers to other managers. Must be called when
@ -492,6 +492,18 @@ public:
*/
int disk_resize(int vid, int did, long long new_size,
const RequestAttributes& ra, string& error_str);
/**
* Update virtual machine context
*
* @param vid VirtualMachine identification
* @param ra information about the API call request
* @param error_str Error reason, if any
*
* @return 0 on success, -1 otherwise
*/
int live_updateconf(int vid, const RequestAttributes& ra, string& error_str);
private:
/**
* Thread id for the Dispatch Manager

View File

@ -102,15 +102,17 @@ public:
DISK_LOCK_SUCCESS, /**< Sent by IM, image moves from locked to ready */
DISK_LOCK_FAILURE, /**< Sent by IM, image moves from locked to error */
DISK_RESIZE_SUCCESS,/**< Sent by TM/VMM when a disk resize succeeds */
DISK_RESIZE_FAILURE /**< Sent by TM/VMM when a disk resize fails */
DISK_RESIZE_FAILURE,/**< Sent by TM/VMM when a disk resize fails */
UPDATE_CONF_SUCCESS,/**< Sent by TM/VMM when a update conf succeeds */
UPDATE_CONF_FAILURE /**< Sent by TM/VMM when a update conf fails */
};
LCMAction(Actions a, int v, int u, int g, int r):
ActionRequest(ActionRequest::USER), _action(a), _vm_id(v), _uid(u),
_gid(g), _req_id(r){};
_gid(g), _req_id(r){}
LCMAction(const LCMAction& o):ActionRequest(o._type), _action(o._action),
_vm_id(o._vm_id), _uid(o._uid), _gid(o._gid), _req_id(o._req_id){};
_vm_id(o._vm_id), _uid(o._uid), _gid(o._gid), _req_id(o._req_id){}
Actions action() const
{
@ -168,7 +170,7 @@ public:
am.addListener(this);
};
~LifeCycleManager(){};
~LifeCycleManager() = default;
/**
* Triggers specific actions to the Life-cycle Manager. This function
@ -369,6 +371,9 @@ private:
void disk_resize_success(int vid);
void disk_resize_failure(int vid);
void update_conf_success(int vid);
void update_conf_failure(int vid);
// -------------------------------------------------------------------------
// External Actions, triggered by user requests
// -------------------------------------------------------------------------

View File

@ -59,10 +59,10 @@ public:
};
TMAction(Actions a, int v):ActionRequest(ActionRequest::USER),
_action(a), _vm_id(v){};
_action(a), _vm_id(v){}
TMAction(const TMAction& o):ActionRequest(o._type), _action(o._action),
_vm_id(o._vm_id){};
_vm_id(o._vm_id){}
Actions action() const
{
@ -100,7 +100,7 @@ public:
am.addListener(this);
};
~TransferManager(){};
~TransferManager() = default;
/**
* Triggers specific actions to the Information Manager. This function

View File

@ -59,7 +59,8 @@ public:
SNAPSHOT_REVERT,
SNAPSHOT_DELETE,
DISK_SNAPSHOT_CREATE,
DISK_RESIZE
DISK_RESIZE,
UPDATE_CONF
};
VMMAction(Actions a, int v):ActionRequest(ActionRequest::USER),
@ -501,6 +502,14 @@ private:
*/
void disk_resize_action(
int vid);
/**
* Update VM context
*
* @param vid the id of the VM.
*/
void update_conf_action(
int vid);
};
#endif /*VIRTUAL_MACHINE_MANAGER_H*/

View File

@ -424,6 +424,18 @@ private:
write_drv("RESIZEDISK", oid, drv_msg);
}
/**
* Sends an updateconf request to the MAD: "UPDATECONF ID XML_DRV_MSG"
* @param oid the virtual machine id.
* @param drv_msg xml data for the mad operation
*/
void update_conf(
const int oid,
const string& drv_msg) const
{
write_drv("UPDATECONF", oid, drv_msg);
}
/**
* Sends a request to update the VM security groups:
* "UPDATESG ID XML_DRV_MSG"

View File

@ -39,7 +39,7 @@ int DispatchManager::deploy (VirtualMachine * vm, const RequestAttributes& ra)
VirtualMachineTemplate quota_tmpl;
bool do_quotas = false;
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -112,7 +112,7 @@ int DispatchManager::import(VirtualMachine * vm, const RequestAttributes& ra)
string error;
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -186,7 +186,7 @@ int DispatchManager::migrate(VirtualMachine * vm, int poff_migrate,
ostringstream oss;
int vid;
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -243,7 +243,7 @@ int DispatchManager::live_migrate(VirtualMachine * vm,
ostringstream oss;
int vid;
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -322,7 +322,7 @@ void DispatchManager::free_vm_resources(VirtualMachine * vm, bool check_images)
VectorAttribute * graphics = vm->get_template_attribute("GRAPHICS");
if ( graphics != 0 && graphics->vector_value("PORT", port) == 0
if ( graphics != nullptr && graphics->vector_value("PORT", port) == 0
&& vm->hasHistory())
{
graphics->remove("PORT");
@ -365,7 +365,7 @@ void DispatchManager::free_vm_resources(VirtualMachine * vm, bool check_images)
{
VirtualRouter* vr = vrouterpool->get(vrid);
if (vr != 0)
if (vr != nullptr)
{
vr->del_vmid(vmid);
@ -387,7 +387,7 @@ int DispatchManager::terminate(int vid, bool hard, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -478,7 +478,7 @@ int DispatchManager::undeploy(int vid, bool hard, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get_ro(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -533,7 +533,7 @@ int DispatchManager::poweroff (int vid, bool hard, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get_ro(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -588,7 +588,7 @@ int DispatchManager::hold(int vid, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -636,7 +636,7 @@ int DispatchManager::release(int vid, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -704,7 +704,7 @@ int DispatchManager::stop(int vid, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get_ro(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -751,7 +751,7 @@ int DispatchManager::suspend(int vid, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get_ro(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -797,7 +797,7 @@ int DispatchManager::resume(int vid, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -876,7 +876,7 @@ int DispatchManager::reboot(int vid, bool hard, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -934,7 +934,7 @@ int DispatchManager::resched(int vid, bool do_resched,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return -1;
}
@ -1093,7 +1093,7 @@ int DispatchManager::delete_vm(VirtualMachine * vm, const RequestAttributes& ra,
{
Host * host = hpool->get_ro(host_id);
if ( host == 0 )
if ( host == nullptr )
{
oss << "Error getting host " << host_id;
error = oss.str();
@ -1176,7 +1176,7 @@ int DispatchManager::delete_recreate(VirtualMachine * vm,
int rc = 0;
Template * vm_quotas_snp = 0;
Template * vm_quotas_snp = nullptr;
VirtualMachineTemplate quota_tmpl;
bool do_quotas = false;
@ -1254,7 +1254,7 @@ int DispatchManager::delete_recreate(VirtualMachine * vm,
Quotas::ds_del_recreate(vm_uid, vm_gid, ds_quotas_snp);
}
if ( vm_quotas_snp != 0 )
if ( vm_quotas_snp != nullptr )
{
Quotas::vm_del(vm_uid, vm_gid, vm_quotas_snp);
@ -1319,7 +1319,7 @@ int DispatchManager::attach(int vid, VirtualMachineTemplate * tmpl,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not attach a new disk to VM " << vid
<< ", VM does not exist";
@ -1424,7 +1424,7 @@ int DispatchManager::detach(int vid, int disk_id, const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "VirtualMachine " << vid << " no longer exists";
error_str = oss.str();
@ -1519,7 +1519,7 @@ int DispatchManager::snapshot_create(int vid, string& name, int& snap_id,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not create a new snapshot for VM " << vid
<< ", VM does not exist";
@ -1570,7 +1570,7 @@ int DispatchManager::snapshot_revert(int vid, int snap_id,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not revert VM " << vid << " to snapshot " << snap_id
<< ", VM does not exist";
@ -1633,7 +1633,7 @@ int DispatchManager::snapshot_delete(int vid, int snap_id,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not delete snapshot " << snap_id << " for VM " << vid
<< ", VM does not exist";
@ -1703,7 +1703,7 @@ int DispatchManager::attach_nic(int vid, VirtualMachineTemplate* tmpl,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not add a new NIC to VM " << vid
<< ", VM does not exist";
@ -1812,7 +1812,7 @@ int DispatchManager::detach_nic(int vid, int nic_id,const RequestAttributes& ra,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "VirtualMachine " << vid << " no longer exists";
error_str = oss.str();
@ -1920,7 +1920,7 @@ int DispatchManager::disk_snapshot_create(int vid, int did, const string& name,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not create a new disk snapshot for VM " << vid
<< ", VM does not exist";
@ -2034,7 +2034,7 @@ int DispatchManager::disk_snapshot_revert(int vid, int did, int snap_id,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not revert to disk snapshot for VM " << vid
<< ", VM does not exist";
@ -2063,7 +2063,7 @@ int DispatchManager::disk_snapshot_revert(int vid, int did, int snap_id,
const Snapshots * snaps = vm->get_disk_snapshots(did, error_str);
if (snaps == 0)
if (snaps == nullptr)
{
vm->unlock();
return -1;
@ -2110,7 +2110,7 @@ int DispatchManager::disk_snapshot_delete(int vid, int did, int snap_id,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not delete disk snapshot from VM " << vid
<< ", VM does not exist";
@ -2140,7 +2140,7 @@ int DispatchManager::disk_snapshot_delete(int vid, int did, int snap_id,
const Snapshots * snaps = vm->get_disk_snapshots(did, error_str);
if (snaps == 0)
if (snaps == nullptr)
{
vm->unlock();
return -1;
@ -2233,7 +2233,7 @@ int DispatchManager::disk_resize(int vid, int did, long long new_size,
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
oss << "Could not resize disk for VM " << vid << ", VM does not exist";
error_str = oss.str();
@ -2338,3 +2338,44 @@ int DispatchManager::disk_resize(int vid, int did, long long new_size,
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int DispatchManager::live_updateconf(int vid, const RequestAttributes& ra, string& error_str)
{
ostringstream oss;
VirtualMachine * vm = vmpool->get(vid);
VirtualMachine::VmState state = vm->get_state();
VirtualMachine::LcmState lstate = vm->get_lcm_state();
// Allowed only for state ACTIVE and RUNNING
if (state != VirtualMachine::ACTIVE || lstate != VirtualMachine::RUNNING)
{
oss << "Could not perform live updateconf for " << vid << ", wrong state "
<< vm->state_str() << ".";
error_str = oss.str();
NebulaLog::log("DiM", Log::ERROR, error_str);
vm->unlock();
return -1;
}
// Set VM state
vm->set_state(VirtualMachine::HOTPLUG);
vm->set_resched(false);
// Trigger UPDATE CONF action
vmm->trigger(VMMAction::UPDATE_CONF, vid);
vmpool->update(vm);
vmpool->update_search(vm);
vm->unlock();
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -229,6 +229,12 @@ void LifeCycleManager::user_action(const ActionRequest& ar)
case LCMAction::DISK_RESIZE_FAILURE:
disk_resize_failure(vid);
break;
case LCMAction::UPDATE_CONF_SUCCESS:
update_conf_success(vid);
break;
case LCMAction::UPDATE_CONF_FAILURE:
update_conf_failure(vid);
break;
// -------------------------------------------------------------------------
// External Actions, triggered by user requests
// -------------------------------------------------------------------------

View File

@ -132,7 +132,7 @@ void LifeCycleManager::save_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -216,7 +216,7 @@ void LifeCycleManager::save_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -264,7 +264,7 @@ void LifeCycleManager::deploy_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -344,7 +344,7 @@ void LifeCycleManager::deploy_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -476,7 +476,7 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -582,7 +582,7 @@ void LifeCycleManager::shutdown_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -635,7 +635,7 @@ void LifeCycleManager::prolog_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -768,7 +768,7 @@ void LifeCycleManager::prolog_failure_action(int vid)
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -894,7 +894,7 @@ void LifeCycleManager::epilog_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -956,7 +956,7 @@ void LifeCycleManager::epilog_success_action(int vid)
VectorAttribute * graphics = vm->get_template_attribute("GRAPHICS");
//Do not free VNC ports for STOP as it is stored in checkpoint file
if ( graphics != 0 && (graphics->vector_value("PORT", port) == 0) &&
if ( graphics != nullptr && (graphics->vector_value("PORT", port) == 0) &&
state != VirtualMachine::EPILOG_STOP )
{
graphics->remove("PORT");
@ -991,7 +991,7 @@ void LifeCycleManager::cleanup_callback_action(int vid)
vm = vmpool->get_ro(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1024,7 +1024,7 @@ void LifeCycleManager::epilog_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1074,7 +1074,7 @@ void LifeCycleManager::monitor_suspend_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1132,7 +1132,7 @@ void LifeCycleManager::monitor_done_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1165,7 +1165,7 @@ void LifeCycleManager::monitor_poweroff_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1208,7 +1208,8 @@ void LifeCycleManager::monitor_poweroff_action(int vid)
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
} else if ( vm->get_lcm_state() == VirtualMachine::SHUTDOWN ||
}
else if ( vm->get_lcm_state() == VirtualMachine::SHUTDOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY )
{
@ -1229,7 +1230,7 @@ void LifeCycleManager::monitor_poweron_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1299,7 +1300,7 @@ void LifeCycleManager::attach_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1340,7 +1341,7 @@ void LifeCycleManager::attach_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1354,7 +1355,7 @@ void LifeCycleManager::attach_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1390,7 +1391,7 @@ void LifeCycleManager::detach_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1404,7 +1405,7 @@ void LifeCycleManager::detach_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1441,7 +1442,7 @@ void LifeCycleManager::detach_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1480,7 +1481,7 @@ void LifeCycleManager::snapshot_create_success(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1510,7 +1511,7 @@ void LifeCycleManager::snapshot_create_failure(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1543,7 +1544,7 @@ void LifeCycleManager::snapshot_revert_success(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1581,7 +1582,7 @@ void LifeCycleManager::snapshot_delete_success(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1611,7 +1612,7 @@ void LifeCycleManager::snapshot_delete_failure(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1641,7 +1642,7 @@ void LifeCycleManager::attach_nic_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1672,7 +1673,7 @@ void LifeCycleManager::attach_nic_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1685,7 +1686,7 @@ void LifeCycleManager::attach_nic_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1712,7 +1713,7 @@ void LifeCycleManager::detach_nic_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1725,7 +1726,7 @@ void LifeCycleManager::detach_nic_success_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1753,7 +1754,7 @@ void LifeCycleManager::detach_nic_failure_action(int vid)
vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1788,7 +1789,7 @@ void LifeCycleManager::saveas_success_action(int vid)
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1819,7 +1820,7 @@ void LifeCycleManager::saveas_success_action(int vid)
Image * image = ipool->get(image_id);
if (image == 0)
if (image == nullptr)
{
return;
}
@ -1845,7 +1846,7 @@ void LifeCycleManager::saveas_failure_action(int vid)
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1876,7 +1877,7 @@ void LifeCycleManager::saveas_failure_action(int vid)
Image * image = ipool->get(image_id);
if (image == 0)
if (image == nullptr)
{
return;
}
@ -1897,8 +1898,8 @@ void LifeCycleManager::disk_snapshot_success(int vid)
int disk_id, ds_id, snap_id;
int img_id = -1;
Template *ds_quotas = 0;
Template *vm_quotas = 0;
Template *ds_quotas = nullptr;
Template *vm_quotas = nullptr;
bool img_owner, vm_owner;
@ -1909,7 +1910,7 @@ void LifeCycleManager::disk_snapshot_success(int vid)
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -1962,7 +1963,7 @@ void LifeCycleManager::disk_snapshot_success(int vid)
vm->clear_snapshot_disk();
tmp_snaps = vm->get_disk_snapshots(disk_id, error_str);
if (tmp_snaps != 0)
if (tmp_snaps != nullptr)
{
snaps = *tmp_snaps;
}
@ -1978,13 +1979,13 @@ void LifeCycleManager::disk_snapshot_success(int vid)
vm->unlock();
if ( ds_quotas != 0 )
if ( ds_quotas != nullptr )
{
if ( img_owner )
{
Image* img = ipool->get_ro(img_id);
if(img != 0)
if (img != nullptr)
{
int img_uid = img->get_uid();
int img_gid = img->get_gid();
@ -2003,7 +2004,7 @@ void LifeCycleManager::disk_snapshot_success(int vid)
delete ds_quotas;
}
if ( vm_quotas != 0 )
if ( vm_quotas != nullptr )
{
Quotas::vm_del(vm_uid, vm_gid, vm_quotas);
@ -2046,8 +2047,8 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
int disk_id, ds_id, snap_id;
int img_id = -1;
Template *ds_quotas = 0;
Template *vm_quotas = 0;
Template *ds_quotas = nullptr;
Template *vm_quotas = nullptr;
const VirtualMachineDisk* disk;
Snapshots snaps(-1, Snapshots::DENY);
@ -2058,7 +2059,7 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -2106,7 +2107,7 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
vm->clear_snapshot_disk();
tmp_snaps = vm->get_disk_snapshots(disk_id, error_str);
if (tmp_snaps != 0)
if (tmp_snaps != nullptr)
{
snaps = *tmp_snaps;
}
@ -2122,13 +2123,13 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
vm->unlock();
if ( ds_quotas != 0 )
if ( ds_quotas != nullptr )
{
if ( img_owner )
{
Image* img = ipool->get_ro(img_id);
if(img != 0)
if (img != nullptr)
{
int img_uid = img->get_uid();
int img_gid = img->get_gid();
@ -2147,7 +2148,7 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
delete ds_quotas;
}
if ( vm_quotas != 0 )
if ( vm_quotas != nullptr )
{
Quotas::vm_del(vm_uid, vm_gid, vm_quotas);
@ -2188,7 +2189,7 @@ void LifeCycleManager::disk_lock_success(int vid)
VirtualMachine * vm = vmpool->get_ro(vid);
Image * image;
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -2215,7 +2216,7 @@ void LifeCycleManager::disk_lock_success(int vid)
{
image = ipool->get_ro(*id);
if (image != 0)
if (image != nullptr)
{
switch (image->get_state()) {
case Image::USED:
@ -2244,7 +2245,7 @@ void LifeCycleManager::disk_lock_success(int vid)
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2303,14 +2304,14 @@ void LifeCycleManager::disk_resize_success(int vid)
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
VirtualMachineDisk * disk = vm->get_resize_disk();
if ( disk == 0 )
if ( disk == nullptr )
{
vm->unlock();
return;
@ -2370,6 +2371,7 @@ void LifeCycleManager::disk_resize_success(int vid)
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void LifeCycleManager::disk_resize_failure(int vid)
@ -2382,14 +2384,14 @@ void LifeCycleManager::disk_resize_failure(int vid)
VirtualMachine * vm = vmpool->get(vid);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
VirtualMachineDisk * disk = vm->get_resize_disk();
if ( disk == 0 )
if ( disk == nullptr )
{
vm->unlock();
return;
@ -2435,7 +2437,7 @@ void LifeCycleManager::disk_resize_failure(int vid)
{
Image* img = ipool->get_ro(img_id);
if(img != 0)
if (img != nullptr)
{
int img_uid = img->get_uid();
int img_gid = img->get_gid();
@ -2473,5 +2475,57 @@ void LifeCycleManager::disk_resize_failure(int vid)
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void LifeCycleManager::update_conf_success(int vid)
{
VirtualMachine * vm = vmpool->get(vid);
if ( vm == nullptr )
{
return;
}
if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG )
{
vm->set_state(VirtualMachine::RUNNING);
vmpool->update(vm);
}
else
{
vm->log("LCM",Log::ERROR,"update_conf_success, VM in a wrong state");
}
vm->unlock();
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void LifeCycleManager::update_conf_failure(int vid)
{
VirtualMachine * vm = vmpool->get(vid);
if ( vm == nullptr )
{
return;
}
if ( vm->get_lcm_state() == VirtualMachine::HOTPLUG )
{
vm->set_state(VirtualMachine::RUNNING);
vmpool->update(vm);
vm->unlock();
}
else
{
vm->log("LCM",Log::ERROR,"update_conf_failure, VM in a wrong state");
vm->unlock();
}
}
/* -------------------------------------------------------------------------- */

View File

@ -51,7 +51,8 @@ class VirtualMachineDriver < OpenNebulaDriver
:detach_nic => "DETACHNIC",
:disk_snapshot_create => "DISKSNAPSHOTCREATE",
:resize_disk => "RESIZEDISK",
:update_sg => "UPDATESG"
:update_sg => "UPDATESG",
:update_conf => "UPDATECONF"
}
POLL_ATTRIBUTE = OpenNebula::VirtualMachine::Driver::POLL_ATTRIBUTE
@ -96,6 +97,7 @@ class VirtualMachineDriver < OpenNebulaDriver
register_action(ACTION[:disk_snapshot_create].to_sym, method("disk_snapshot_create"))
register_action(ACTION[:resize_disk].to_sym, method("resize_disk"))
register_action(ACTION[:update_sg].to_sym, method("update_sg"))
register_action(ACTION[:update_conf].to_sym, method("update_conf"))
end
# Decodes the encoded XML driver message received from the core
@ -220,6 +222,11 @@ class VirtualMachineDriver < OpenNebulaDriver
send_message(ACTION[:cleanup],RESULT[:failure],id,error)
end
def update_conf(id, drv_message)
error = "Action not implemented by driver #{self.class}"
send_message(ACTION[:update_conf],RESULT[:failure],id,error)
end
private
# Interface to handle the pending events from the ActionManager Interface

View File

@ -38,7 +38,7 @@ bool RequestManagerVirtualMachine::vm_authorization(
object = pool->get(oid);
if ( object == 0 )
if ( object == nullptr )
{
att.resp_id = oid;
failure_response(NO_EXISTS, att);
@ -54,12 +54,12 @@ bool RequestManagerVirtualMachine::vm_authorization(
ar.add_auth(op, vm_perms);
if (host_perm != 0)
if (host_perm != nullptr)
{
ar.add_auth(AuthRequest::MANAGE, *host_perm);
}
if (tmpl != 0)
if (tmpl != nullptr)
{
string t_xml;
@ -67,17 +67,17 @@ bool RequestManagerVirtualMachine::vm_authorization(
tmpl->to_xml(t_xml));
}
if ( vtmpl != 0 )
if ( vtmpl != nullptr )
{
VirtualMachine::set_auth_request(att.uid, ar, vtmpl, true);
}
if ( ds_perm != 0 )
if ( ds_perm != nullptr )
{
ar.add_auth(AuthRequest::USE, *ds_perm);
}
if ( img_perm != 0 )
if ( img_perm != nullptr )
{
ar.add_auth(AuthRequest::MANAGE, *img_perm);
}
@ -104,7 +104,7 @@ bool RequestManagerVirtualMachine::quota_resize_authorization(
PoolObjectAuth vm_perms;
VirtualMachine * vm = Nebula::instance().get_vmpool()->get_ro(oid);
if (vm == 0)
if (vm == nullptr)
{
att.resp_obj = PoolObjectSQL::VM;
att.resp_id = oid;
@ -140,7 +140,7 @@ bool RequestManagerVirtualMachine::quota_resize_authorization(
{
User * user = upool->get(vm_perms.uid);
if ( user != 0 )
if ( user != nullptr )
{
rc = user->quota.quota_update(Quotas::VM, deltas, user_dquotas, att.resp_msg);
@ -170,7 +170,7 @@ bool RequestManagerVirtualMachine::quota_resize_authorization(
{
Group * group = gpool->get(vm_perms.gid);
if ( group != 0 )
if ( group != nullptr )
{
rc = group->quota.quota_update(Quotas::VM, deltas, group_dquotas, att.resp_msg);
@ -222,7 +222,7 @@ int RequestManagerVirtualMachine::get_default_ds_information(
cluster = clpool->get_ro(cluster_id);
if (cluster == 0)
if (cluster == nullptr)
{
att.resp_obj = PoolObjectSQL::CLUSTER;
att.resp_id = cluster_id;
@ -273,7 +273,7 @@ int RequestManagerVirtualMachine::get_ds_information(int ds_id,
ds_cluster_ids.clear();
if ( ds == 0 )
if ( ds == nullptr )
{
att.resp_obj = PoolObjectSQL::DATASTORE;
att.resp_id = ds_id;
@ -329,7 +329,7 @@ int RequestManagerVirtualMachine::get_host_information(
Host * host = hpool->get_ro(hid);
if ( host == 0 )
if ( host == nullptr )
{
att.resp_obj = PoolObjectSQL::HOST;
att.resp_id = hid;
@ -378,7 +378,7 @@ bool RequestManagerVirtualMachine::check_host(
Host * host = hpool->get_ro(hid);
if (host == 0)
if (host == nullptr)
{
error = "Host no longer exists";
return false;
@ -415,7 +415,7 @@ VirtualMachine * RequestManagerVirtualMachine::get_vm(int id,
vm = static_cast<VirtualMachinePool *>(pool)->get(id);
if ( vm == 0 )
if ( vm == nullptr )
{
att.resp_id = id;
failure_response(NO_EXISTS, att);
@ -432,7 +432,7 @@ VirtualMachine * RequestManagerVirtualMachine::get_vm_ro(int id,
vm = static_cast<VirtualMachinePool *>(pool)->get_ro(id);
if ( vm == 0 )
if ( vm == nullptr )
{
att.resp_id = id;
failure_response(NO_EXISTS, att);
@ -522,7 +522,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
@ -698,7 +698,7 @@ int set_vnc_port(VirtualMachine *vm, int cluster_id, RequestAttributes& att)
unsigned int port;
int rc;
if (graphics == 0)
if (graphics == nullptr)
{
return 0;
}
@ -809,7 +809,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
// ------------------------------------------------------------------------
// Get information about the system DS to use (tm_mad & permissions)
// ------------------------------------------------------------------------
if ((vm = get_vm_ro(id, att)) == 0)
if ((vm = get_vm_ro(id, att)) == nullptr)
{
return;
}
@ -882,7 +882,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
{
Datastore * ds = dspool->get_ro(ds_id);
if (ds == 0 )
if (ds == nullptr )
{
att.resp_obj = PoolObjectSQL::DATASTORE;
att.resp_id = ds_id;
@ -943,7 +943,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
// - VM States are right
// - Host capacity if required
// ------------------------------------------------------------------------
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
@ -1115,7 +1115,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
{
Datastore * ds = dspool->get_ro(ds_id);
if (ds == 0 )
if (ds == nullptr )
{
att.resp_obj = PoolObjectSQL::DATASTORE;
att.resp_id = ds_id;
@ -1152,7 +1152,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
// - New or old host are not public cloud
// ------------------------------------------------------------------------
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
@ -1268,7 +1268,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
// Check we are migrating to a compatible cluster
Host * host = nd.get_hpool()->get_ro(c_hid);
if (host == 0)
if (host == nullptr)
{
att.resp_obj = PoolObjectSQL::HOST;
att.resp_id = c_hid;
@ -1306,7 +1306,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
VirtualMachineManager * vmm = Nebula::instance().get_vmm();
const VirtualMachineManagerDriver * vmmd = vmm->get(vmm_mad);
if ( vmmd == 0 )
if ( vmmd == nullptr )
{
att.resp_msg = "Cannot find vmm driver: " + vmm_mad;
failure_response(ACTION, att);
@ -1369,7 +1369,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
// Add a new history record and update volatile DISK attributes
// ------------------------------------------------------------------------
if ( (vm = get_vm(id, att)) == 0 )
if ( (vm = get_vm(id, att)) == nullptr )
{
return;
}
@ -1463,7 +1463,7 @@ void VirtualMachineDiskSaveas::request_execute(
// -------------------------------------------------------------------------
// Prepare and check the VM/DISK to be saved as
// -------------------------------------------------------------------------
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
@ -1489,7 +1489,7 @@ void VirtualMachineDiskSaveas::request_execute(
// -------------------------------------------------------------------------
img = ipool->get_ro(iid_orig);
if ( img == 0 )
if ( img == nullptr )
{
goto error_image;
}
@ -1524,7 +1524,7 @@ void VirtualMachineDiskSaveas::request_execute(
// -------------------------------------------------------------------------
// Get the data of the DataStore for the new image & size
// -------------------------------------------------------------------------
if ((ds = dspool->get_ro(ds_id)) == 0 )
if ((ds = dspool->get_ro(ds_id)) == nullptr )
{
goto error_ds;
}
@ -1628,7 +1628,7 @@ void VirtualMachineDiskSaveas::request_execute(
ds = dspool->get(ds_id);
if (ds == 0)
if (ds == nullptr)
{
goto error_ds_removed;
}
@ -1694,7 +1694,7 @@ error_allocate:
goto error_common;
error_common:
if ((vm = vmpool->get(id)) != 0)
if ((vm = vmpool->get(id)) != nullptr)
{
vm->clear_saveas_state();
@ -1759,7 +1759,7 @@ void VirtualMachineAttach::request_execute(
// -------------------------------------------------------------------------
// Check if the VM is a Virtual Router
// -------------------------------------------------------------------------
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
@ -1846,7 +1846,7 @@ Request::ErrorCode VirtualMachineAttach::request_execute(int id,
}
}
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return NO_EXISTS;
}
@ -1920,7 +1920,7 @@ void VirtualMachineDetach::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
@ -1966,7 +1966,7 @@ static int test_set_capacity(VirtualMachine * vm, float cpu, long mem, int vcpu,
Host * host = hpool->get(vm->get_hid());
if ( host == 0 )
if ( host == nullptr )
{
error = "Could not update host";
return -1;
@ -2094,7 +2094,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
/* ---------------------------------------------------------------------- */
VirtualMachine * vm = vmpool->get_ro(id);
if (vm == 0)
if (vm == nullptr)
{
att.resp_id = id;
failure_response(NO_EXISTS, att);
@ -2148,7 +2148,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
/* ---------------------------------------------------------------------- */
vm = vmpool->get(id);
if (vm == 0)
if (vm == nullptr)
{
att.resp_msg = id;
failure_response(NO_EXISTS, att);
@ -2331,7 +2331,7 @@ void VirtualMachineAttachNic::request_execute(
// -------------------------------------------------------------------------
// Check if the VM is a Virtual Router
// -------------------------------------------------------------------------
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
@ -2394,7 +2394,7 @@ Request::ErrorCode VirtualMachineAttachNic::request_execute(int id,
// -------------------------------------------------------------------------
vm = vmpool->get_ro(id);
if ( vm == 0 )
if ( vm == nullptr )
{
att.resp_id = id;
att.resp_obj = PoolObjectSQL::VM;
@ -2466,7 +2466,7 @@ void VirtualMachineDetachNic::request_execute(
// Check if the VM is a Virtual Router
// -------------------------------------------------------------------------
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
@ -2515,7 +2515,7 @@ Request::ErrorCode VirtualMachineDetachNic::request_execute(int id, int nic_id,
// -------------------------------------------------------------------------
vm = vmpool->get_ro(id);
if ( vm == 0 )
if ( vm == nullptr )
{
return NO_EXISTS;
}
@ -2592,7 +2592,7 @@ void VirtualMachineRecover::request_execute(
VirtualMachine * vm = (static_cast<VirtualMachinePool *>(pool))->get(id);
if (vm == 0)
if (vm == nullptr)
{
att.resp_id = id;
failure_response(NO_EXISTS, att);
@ -2705,14 +2705,14 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
// ------------------------------------------------------------------------
// Check request consistency (VM & disk exists, no volatile)
// ------------------------------------------------------------------------
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
disk = (const_cast<const VirtualMachine *>(vm))->get_disk(did);
if (disk == 0)
if (disk == nullptr)
{
att.resp_msg = "VM disk does not exist";
failure_response(ACTION, att);
@ -2761,7 +2761,7 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
Image* img = ipool->get_ro(img_id);
if (img == 0)
if (img == nullptr)
{
att.resp_obj = PoolObjectSQL::IMAGE;
att.resp_id = img_id;
@ -2912,14 +2912,14 @@ void VirtualMachineDiskSnapshotDelete::request_execute(
int did = xmlrpc_c::value_int(paramList.getInt(2));
int snap_id = xmlrpc_c::value_int(paramList.getInt(3));
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
disk = (const_cast<const VirtualMachine *>(vm))->get_disk(did);
if (disk == 0)
if (disk == nullptr)
{
att.resp_msg = "VM disk does not exist";
failure_response(ACTION, att);
@ -2942,7 +2942,7 @@ void VirtualMachineDiskSnapshotDelete::request_execute(
Image* img = ipool->get_ro(img_id);
if (img == 0)
if (img == nullptr)
{
att.resp_obj = PoolObjectSQL::IMAGE;
att.resp_id = img_id;
@ -3003,7 +3003,7 @@ void VirtualMachineDiskSnapshotRename::request_execute(xmlrpc_c::paramList const
return;
}
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
oss << "Could not rename the snapshot for VM " << id
<< ", VM does not exist";
@ -3015,7 +3015,7 @@ void VirtualMachineDiskSnapshotRename::request_execute(xmlrpc_c::paramList const
disk = (const_cast<const VirtualMachine *>(vm))->get_disk(did);
if (disk == 0)
if (disk == nullptr)
{
att.resp_msg = "VM disk does not exist";
failure_response(ACTION, att);
@ -3056,6 +3056,7 @@ void VirtualMachineUpdateConf::request_execute(
VirtualMachine * vm;
VirtualMachineTemplate tmpl;
VirtualMachinePool * vmpool = static_cast<VirtualMachinePool *>(pool);
// -------------------------------------------------------------------------
// Parse template
@ -3079,9 +3080,9 @@ void VirtualMachineUpdateConf::request_execute(
/* ---------------------------------------------------------------------- */
/* Update VirtualMachine Configuration */
/* ---------------------------------------------------------------------- */
vm = static_cast<VirtualMachinePool *>(pool)->get(id);
vm = vmpool->get(id);
if (vm == 0)
if (vm == nullptr)
{
att.resp_id = id;
failure_response(NO_EXISTS, att);
@ -3122,9 +3123,11 @@ void VirtualMachineUpdateConf::request_execute(
VectorAttribute * graphics = vm->get_template_attribute("GRAPHICS");
unsigned int port;
VirtualMachine::VmState state = vm->get_state();
if (graphics != 0 && graphics->vector_value("PORT", port) == -1 &&
VirtualMachine::VmState state = vm->get_state();
VirtualMachine::LcmState lcm_state = vm->get_lcm_state();
if (graphics != nullptr && graphics->vector_value("PORT", port) == -1 &&
(state == VirtualMachine::ACTIVE || state == VirtualMachine::POWEROFF ||
state == VirtualMachine::SUSPENDED))
{
@ -3144,11 +3147,25 @@ void VirtualMachineUpdateConf::request_execute(
graphics->replace("PORT", port);
}
static_cast<VirtualMachinePool *>(pool)->update(vm);
static_cast<VirtualMachinePool *>(pool)->update_search(vm);
vmpool->update(vm);
vmpool->update_search(vm);
vm->unlock();
// Apply the change for running VM
if (state == VirtualMachine::VmState::ACTIVE &&
lcm_state == VirtualMachine::LcmState::RUNNING)
{
auto dm = Nebula::instance().get_dm();
if (dm->live_updateconf(id, att, att.resp_msg) != 0)
{
failure_response(INTERNAL, att);
return;
}
}
success_response(id, att);
}
@ -3156,8 +3173,7 @@ void VirtualMachineUpdateConf::request_execute(
/* -------------------------------------------------------------------------- */
void VirtualMachineDiskResize::request_execute(
xmlrpc_c::paramList const& paramList,
RequestAttributes& att)
xmlrpc_c::paramList const& paramList, RequestAttributes& att)
{
Nebula& nd = Nebula::instance();
DispatchManager * dm = nd.get_dm();
@ -3190,14 +3206,14 @@ void VirtualMachineDiskResize::request_execute(
return;
}
if ((vm = get_vm(id, att)) == 0)
if ((vm = get_vm(id, att)) == nullptr)
{
return;
}
VirtualMachineDisk * disk = vm->get_disk(did);
if (disk == 0)
if (disk == nullptr)
{
att.resp_msg = "VM disk does not exist";
failure_response(ACTION, att);
@ -3255,7 +3271,7 @@ void VirtualMachineDiskResize::request_execute(
{
Image* img = ipool->get_ro(img_id);
if (img == 0)
if (img == nullptr)
{
att.resp_obj = PoolObjectSQL::IMAGE;
att.resp_id = img_id;

View File

@ -33,7 +33,7 @@ extern "C" void * tm_action_loop(void *arg)
{
TransferManager * tm;
if ( arg == 0 )
if ( arg == nullptr )
{
return 0;
}
@ -88,7 +88,7 @@ void TransferManager::user_action(const ActionRequest& ar)
VirtualMachine * vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -576,7 +576,7 @@ void TransferManager::prolog_action(int vid)
// -------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -596,7 +596,7 @@ void TransferManager::prolog_action(int vid)
vm_tm_mad = vm->get_tm_mad();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty() )
if ( tm_md == nullptr || vm_tm_mad.empty() )
{
goto error_drivers;
}
@ -631,7 +631,7 @@ void TransferManager::prolog_action(int vid)
// -------------------------------------------------------------------------
os_attr = vm->get_template_attribute("OS");
if ( os_attr != 0 )
if ( os_attr != nullptr )
{
string kernel;
string initrd;
@ -671,7 +671,7 @@ void TransferManager::prolog_action(int vid)
vm->unlock();
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
goto error_attributes;
}
@ -739,7 +739,7 @@ void TransferManager::prolog_migr_action(int vid)
// -------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -754,7 +754,7 @@ void TransferManager::prolog_migr_action(int vid)
vm_tm_mad = vm->get_tm_mad();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty())
if ( tm_md == nullptr || vm_tm_mad.empty())
{
goto error_drivers;
}
@ -870,7 +870,7 @@ void TransferManager::prolog_resume_action(int vid)
// -------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -890,7 +890,7 @@ void TransferManager::prolog_resume_action(int vid)
vm_tm_mad = vm->get_tm_mad();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty())
if ( tm_md == nullptr || vm_tm_mad.empty())
{
goto error_drivers;
}
@ -1004,7 +1004,7 @@ void TransferManager::prolog_attach_action(int vid)
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1017,7 +1017,7 @@ void TransferManager::prolog_attach_action(int vid)
vm_tm_mad = vm->get_tm_mad();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty() )
if ( tm_md == nullptr || vm_tm_mad.empty() )
{
goto error_drivers;
}
@ -1037,7 +1037,7 @@ void TransferManager::prolog_attach_action(int vid)
// -------------------------------------------------------------------------
disk = vm->get_attach_disk();
if ( disk == 0 )
if ( disk == nullptr )
{
goto error_disk;
}
@ -1186,7 +1186,7 @@ void TransferManager::epilog_action(bool local, int vid)
// ------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1201,7 +1201,7 @@ void TransferManager::epilog_action(bool local, int vid)
vm_tm_mad = vm->get_tm_mad();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty())
if ( tm_md == nullptr || vm_tm_mad.empty())
{
goto error_drivers;
}
@ -1295,7 +1295,7 @@ void TransferManager::epilog_stop_action(int vid)
// ------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1310,7 +1310,7 @@ void TransferManager::epilog_stop_action(int vid)
vm_tm_mad = vm->get_tm_mad();
tm_md = get();
if (tm_md == 0 || vm_tm_mad.empty())
if (tm_md == nullptr || vm_tm_mad.empty())
{
goto error_drivers;
}
@ -1544,14 +1544,14 @@ void TransferManager::epilog_delete_action(bool local, int vid)
// ------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
tm_md = get();
if ( tm_md == 0 )
if ( tm_md == nullptr )
{
goto error_driver;
}
@ -1617,14 +1617,14 @@ void TransferManager::epilog_delete_previous_action(int vid)
// ------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
tm_md = get();
if (tm_md == 0)
if (tm_md == nullptr)
{
goto error_driver;
}
@ -1690,14 +1690,14 @@ void TransferManager::epilog_delete_both_action(int vid)
// ------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
tm_md = get();
if (tm_md == 0)
if (tm_md == nullptr)
{
goto error_driver;
}
@ -1765,7 +1765,7 @@ void TransferManager::epilog_detach_action(int vid)
// ------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1778,7 +1778,7 @@ void TransferManager::epilog_detach_action(int vid)
vm_tm_mad = vm->get_tm_mad();
tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty())
if ( tm_md == nullptr || vm_tm_mad.empty())
{
goto error_drivers;
}
@ -1797,7 +1797,7 @@ void TransferManager::epilog_detach_action(int vid)
disk = vm->get_attach_disk();
if ( disk == 0 )
if ( disk == nullptr )
{
goto error_disk;
}
@ -1857,14 +1857,14 @@ void TransferManager::driver_cancel_action(int vid)
// ------------------------------------------------------------------------
tm_md = get();
if ( tm_md == 0 )
if ( tm_md == nullptr )
{
return;
}
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1914,7 +1914,7 @@ void TransferManager::saveas_hot_action(int vid)
// ------------------------------------------------------------------------
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1931,7 +1931,7 @@ void TransferManager::saveas_hot_action(int vid)
tm_md = get();
if (tm_md == 0)
if (tm_md == nullptr)
{
goto error_driver;
}
@ -2058,14 +2058,14 @@ void TransferManager::do_snapshot_action(int vid, const char * snap_action)
tm_md = get();
if (tm_md == 0)
if (tm_md == nullptr)
{
goto error_driver;
}
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2182,14 +2182,14 @@ void TransferManager::resize_action(int vid)
const TransferManagerDriver * tm_md = get();
if (tm_md == 0)
if (tm_md == nullptr)
{
goto error_driver;
}
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2209,7 +2209,7 @@ void TransferManager::resize_action(int vid)
disk = vm->get_resize_disk();
if ( disk == 0 )
if ( disk == nullptr )
{
goto error_disk;
}
@ -2260,8 +2260,8 @@ int TransferManager::load_mads(int uid)
int rc;
string name;
const VectorAttribute * vattr = 0;
TransferManagerDriver * tm_driver = 0;
const VectorAttribute * vattr = nullptr;
TransferManagerDriver * tm_driver = nullptr;
oss << "Loading Transfer Manager driver.";
@ -2272,7 +2272,7 @@ int TransferManager::load_mads(int uid)
vattr = mad_conf[0];
}
if ( vattr == 0 )
if ( vattr == nullptr )
{
NebulaLog::log("TM",Log::ERROR,"Failed to load Transfer Manager driver.");
return -1;

View File

@ -2962,6 +2962,7 @@ int VirtualMachine::updateconf(VirtualMachineTemplate& tmpl, string &err)
{
case LCM_INIT:
case PROLOG:
case RUNNING:
case EPILOG:
case SHUTDOWN:
case CLEANUP_RESUBMIT:
@ -2990,6 +2991,7 @@ int VirtualMachine::updateconf(VirtualMachineTemplate& tmpl, string &err)
err = "configuration cannot be updated in state " + state_str();
return -1;
};
break;
case INIT:
case DONE:

View File

@ -58,7 +58,7 @@ extern "C" void * vmm_action_loop(void *arg)
{
VirtualMachineManager * vmm;
if ( arg == 0 )
if ( arg == nullptr )
{
return 0;
}
@ -178,6 +178,9 @@ void VirtualMachineManager::user_action(const ActionRequest& ar)
case VMMAction::DISK_RESIZE:
disk_resize_action(vid);
break;
case VMMAction::UPDATE_CONF:
update_conf_action(vid);
break;
}
}
@ -204,7 +207,7 @@ string * VirtualMachineManager::format_message(
string ds_tmpl = "";
Datastore * ds = ds_pool->get_ro(ds_id);
if ( ds != 0 )
if ( ds != nullptr )
{
ds->to_xml(ds_tmpl);
ds->unlock();
@ -348,7 +351,7 @@ void VirtualMachineManager::deploy_action(int vid)
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -362,7 +365,7 @@ void VirtualMachineManager::deploy_action(int vid)
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -375,7 +378,7 @@ void VirtualMachineManager::deploy_action(int vid)
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -470,7 +473,7 @@ void VirtualMachineManager::save_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -483,7 +486,7 @@ void VirtualMachineManager::save_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -571,7 +574,7 @@ void VirtualMachineManager::shutdown_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -584,7 +587,7 @@ void VirtualMachineManager::shutdown_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -667,7 +670,7 @@ void VirtualMachineManager::reboot_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -680,7 +683,7 @@ void VirtualMachineManager::reboot_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -737,7 +740,7 @@ void VirtualMachineManager::reset_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -750,7 +753,7 @@ void VirtualMachineManager::reset_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -810,7 +813,7 @@ void VirtualMachineManager::cancel_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -823,7 +826,7 @@ void VirtualMachineManager::cancel_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -907,7 +910,7 @@ void VirtualMachineManager::cancel_previous_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -920,7 +923,7 @@ void VirtualMachineManager::cancel_previous_action(
// Get the driver for this VM
vmd = get(vm->get_previous_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -983,7 +986,7 @@ void VirtualMachineManager::cleanup_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -996,7 +999,7 @@ void VirtualMachineManager::cleanup_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -1077,7 +1080,7 @@ void VirtualMachineManager::cleanup_previous_action(int vid)
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1090,7 +1093,7 @@ void VirtualMachineManager::cleanup_previous_action(int vid)
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -1160,7 +1163,7 @@ void VirtualMachineManager::migrate_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1173,7 +1176,7 @@ void VirtualMachineManager::migrate_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -1251,7 +1254,7 @@ void VirtualMachineManager::restore_action(
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1265,7 +1268,7 @@ void VirtualMachineManager::restore_action(
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1277,7 +1280,7 @@ void VirtualMachineManager::restore_action(
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -1351,7 +1354,7 @@ void VirtualMachineManager::poll_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1364,7 +1367,7 @@ void VirtualMachineManager::poll_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -1419,7 +1422,7 @@ void VirtualMachineManager::driver_cancel_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1432,7 +1435,7 @@ void VirtualMachineManager::driver_cancel_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -1507,7 +1510,7 @@ void VirtualMachineManager::timer_action(const ActionRequest& ar)
{
vm = vmpool->get(*it);
if ( vm == 0 )
if ( vm == nullptr )
{
continue;
}
@ -1537,7 +1540,7 @@ void VirtualMachineManager::timer_action(const ActionRequest& ar)
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
vm->unlock();
continue;
@ -1599,7 +1602,7 @@ void VirtualMachineManager::attach_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1613,14 +1616,14 @@ void VirtualMachineManager::attach_action(
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
disk = vm->get_attach_disk();
if ( disk == 0 )
if ( disk == nullptr )
{
goto error_disk;
}
@ -1740,7 +1743,7 @@ void VirtualMachineManager::detach_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1753,14 +1756,14 @@ void VirtualMachineManager::detach_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
disk = vm->get_attach_disk();
if ( disk == 0 )
if ( disk == nullptr )
{
goto error_disk;
}
@ -1844,7 +1847,7 @@ void VirtualMachineManager::snapshot_create_action(int vid)
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1857,7 +1860,7 @@ void VirtualMachineManager::snapshot_create_action(int vid)
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -1922,7 +1925,7 @@ void VirtualMachineManager::snapshot_revert_action(int vid)
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -1935,7 +1938,7 @@ void VirtualMachineManager::snapshot_revert_action(int vid)
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -2000,7 +2003,7 @@ void VirtualMachineManager::snapshot_delete_action(int vid)
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2013,7 +2016,7 @@ void VirtualMachineManager::snapshot_delete_action(int vid)
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -2089,7 +2092,7 @@ void VirtualMachineManager::disk_snapshot_create_action(int vid)
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2101,7 +2104,7 @@ void VirtualMachineManager::disk_snapshot_create_action(int vid)
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -2199,7 +2202,7 @@ void VirtualMachineManager::disk_resize_action(int vid)
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2211,14 +2214,14 @@ void VirtualMachineManager::disk_resize_action(int vid)
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
disk = vm->get_resize_disk();
if ( disk == 0 )
if ( disk == nullptr )
{
goto error_disk;
}
@ -2287,6 +2290,90 @@ error_common:
vm->unlock();
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManager::update_conf_action(int vid)
{
ostringstream os;
string vm_tmpl;
string* drv_msg;
string password;
string prolog_cmd;
string resize_cmd;
string disk_path;
VirtualMachine *vm = vmpool->get(vid);
const VirtualMachineManagerDriver * vmd;
int uid, owner_id;
if (vm == nullptr)
{
return;
}
if (!vm->hasHistory())
{
os << "update_conf_action, VM has no history";
goto error;
}
vmd = get(vm->get_vmm_mad());
if ( vmd == nullptr )
{
os << "update_conf_action, error getting driver " << vm->get_vmm_mad();
goto error;
}
uid = vm->get_created_by_uid();
owner_id = vm->get_uid();
password = Nebula::instance().get_upool()->get_token_password(uid, owner_id);
if ( do_context_command(vm, password, prolog_cmd, disk_path) == -1 )
{
os << "Cannot set context disk to update it for VM " << vm->get_oid();
goto error;
}
// Invoke driver method
drv_msg = format_message(
vm->get_hostname(),
"",
vm->get_deploy_id(),
"",
"",
"",
prolog_cmd,
"",
disk_path,
vm->to_xml(vm_tmpl),
vm->get_ds_id(),
-1);
vmd->update_conf(vid, *drv_msg);
vm->unlock();
delete drv_msg;
return;
error:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LCMAction::UPDATE_CONF_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -2308,7 +2395,7 @@ void VirtualMachineManager::attach_nic_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2321,7 +2408,7 @@ void VirtualMachineManager::attach_nic_action(
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2334,7 +2421,7 @@ void VirtualMachineManager::attach_nic_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -2415,7 +2502,7 @@ void VirtualMachineManager::detach_nic_action(
// Get the VM from the pool
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2428,7 +2515,7 @@ void VirtualMachineManager::detach_nic_action(
vm = vmpool->get(vid);
if (vm == 0)
if (vm == nullptr)
{
return;
}
@ -2441,7 +2528,7 @@ void VirtualMachineManager::detach_nic_action(
// Get the driver for this VM
vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
goto error_driver;
}
@ -2518,7 +2605,7 @@ int VirtualMachineManager::updatesg(VirtualMachine * vm, int sgid)
// Get the driver for this VM
const VirtualMachineManagerDriver * vmd = get(vm->get_vmm_mad());
if ( vmd == 0 )
if ( vmd == nullptr )
{
return -1;
}
@ -2557,7 +2644,7 @@ int VirtualMachineManager::load_mads(int uid)
int rc;
string name;
string type;
VirtualMachineManagerDriver * vmm_driver = 0;
VirtualMachineManagerDriver * vmm_driver = nullptr;
oss << "Loading Virtual Machine Manager drivers.";

View File

@ -42,7 +42,7 @@ VirtualMachineManagerDriver::VirtualMachineManagerDriver(
ds_live_migration(false), vmpool(pool)
{
map<string,string>::const_iterator it;
char * error_msg = 0;
char * error_msg = nullptr;
const char * cfile;
string file;
int rc;
@ -70,7 +70,7 @@ VirtualMachineManagerDriver::VirtualMachineManagerDriver(
{
ostringstream oss;
if ( error_msg != 0 )
if ( error_msg != nullptr )
{
oss << "Error loading driver configuration file " << cfile <<
" : " << error_msg;
@ -291,7 +291,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
SecurityGroupPool* sgpool = ne.get_secgrouppool();
SecurityGroup* sg = sgpool->get(sgid);
if ( sg != 0 )
if ( sg != nullptr )
{
sg->del_updating(id);
@ -311,7 +311,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
vm = vmpool->get(id);
if ( vm != 0 )
if ( vm != nullptr )
{
if ( result == "SUCCESS" )
{
@ -336,7 +336,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
// -------------------------------------------------------------------------
vm = vmpool->get(id);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}
@ -643,6 +643,22 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
lcm->trigger(LCMAction::DISK_RESIZE_FAILURE, id);
}
}
else if ( action == "UPDATECONF" )
{
if ( result == "SUCCESS" )
{
vm->log("VMM", Log::INFO, "VM update conf succesfull.");
lcm->trigger(LCMAction::UPDATE_CONF_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error updating conf for VM");
vmpool->update(vm);
lcm->trigger(LCMAction::UPDATE_CONF_FAILURE, id);
}
}
else if ( action == "CLEANUP" )
{
if ( result == "SUCCESS" )
@ -694,7 +710,7 @@ void VirtualMachineManagerDriver::process_poll(int id,const string& monitor_str)
// Get the VM from the pool
VirtualMachine* vm = Nebula::instance().get_vmpool()->get(id);
if ( vm == 0 )
if ( vm == nullptr )
{
return;
}

View File

@ -164,6 +164,12 @@ class DummyDriver < VirtualMachineDriver
send_message(ACTION[:disk_snapshot_create], result, id, "dummy-snap")
end
def update_conf(id, drv_message)
result = retrieve_result("update_conf")
send_message(ACTION[:update_conf], result, id)
end
def cleanup(id, drv_message)
result = retrieve_result("cleanup")

View File

@ -1109,6 +1109,48 @@ class ExecDriver < VirtualMachineDriver
action.run(steps)
end
#
# UPDATECONF action to update context for running machine
#
def update_conf(id, drv_message)
xml_data = decode(drv_message)
tm_command = xml_data.elements['TM_COMMAND']
tm_command = tm_command.text if tm_command
target_path = xml_data.elements['DISK_TARGET_PATH']
target_path = target_path.text if target_path
target_device = xml_data.elements['VM/TEMPLATE/CONTEXT/TARGET']
target_device = target_device.text if target_device
action = VmmAction.new(self, id, :update_conf, drv_message)
steps = []
steps << {
:driver => :vmm,
:action => :prereconfigure,
:parameters => [:deploy_id, target_device]
}
if tm_command && !tm_command.empty?
steps << {
:driver => :tm,
:action => :tm_context,
:parameters => tm_command.strip.split(' ')
}
end
steps << {
:driver => :vmm,
:action => :reconfigure,
:parameters => [:deploy_id, target_device, target_path]
}
action.run(steps)
end
#
# UPDATESG action, deletes iptables rules and regenerate them
#