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:
parent
65aabd760a
commit
a6481bb038
@ -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
|
||||
@ -202,7 +202,7 @@ public:
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int undeploy (int vid, bool hard, const RequestAttributes& ra,
|
||||
int undeploy(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
@ -213,7 +213,7 @@ public:
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int poweroff (int vid, bool hard, const RequestAttributes& ra,
|
||||
int poweroff(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
@ -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
|
||||
|
@ -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
|
||||
@ -304,7 +306,7 @@ private:
|
||||
* @param image_id If the VM is in the middle of a save as operation, an
|
||||
* image may need to be set to error state.
|
||||
*/
|
||||
void clean_up_vm (VirtualMachine *vm, bool dispose, int& image_id,
|
||||
void clean_up_vm(VirtualMachine *vm, bool dispose, int& image_id,
|
||||
const LCMAction& la);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -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
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
@ -294,7 +294,7 @@ public:
|
||||
* Updates VM dynamic information (id).
|
||||
* @param _deploy_id the VMM driver specific id
|
||||
*/
|
||||
void set_deploy_id (const string& _deploy_id)
|
||||
void set_deploy_id(const string& _deploy_id)
|
||||
{
|
||||
deploy_id = _deploy_id;
|
||||
};
|
||||
@ -709,7 +709,7 @@ public:
|
||||
*/
|
||||
void set_stime(time_t _stime)
|
||||
{
|
||||
history->stime=_stime;
|
||||
history->stime = _stime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -734,7 +734,7 @@ public:
|
||||
*/
|
||||
void set_etime(time_t _etime)
|
||||
{
|
||||
history->etime=_etime;
|
||||
history->etime = _etime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -743,7 +743,7 @@ public:
|
||||
*/
|
||||
void set_previous_etime(time_t _etime)
|
||||
{
|
||||
previous_history->etime=_etime;
|
||||
previous_history->etime = _etime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -752,7 +752,7 @@ public:
|
||||
*/
|
||||
void set_prolog_stime(time_t _stime)
|
||||
{
|
||||
history->prolog_stime=_stime;
|
||||
history->prolog_stime = _stime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -761,7 +761,7 @@ public:
|
||||
*/
|
||||
void set_prolog_etime(time_t _etime)
|
||||
{
|
||||
history->prolog_etime=_etime;
|
||||
history->prolog_etime = _etime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -770,7 +770,7 @@ public:
|
||||
*/
|
||||
void set_running_stime(time_t _stime)
|
||||
{
|
||||
history->running_stime=_stime;
|
||||
history->running_stime = _stime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -787,7 +787,7 @@ public:
|
||||
*/
|
||||
void set_running_etime(time_t _etime)
|
||||
{
|
||||
history->running_etime=_etime;
|
||||
history->running_etime = _etime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -796,7 +796,7 @@ public:
|
||||
*/
|
||||
void set_previous_running_etime(time_t _etime)
|
||||
{
|
||||
previous_history->running_etime=_etime;
|
||||
previous_history->running_etime = _etime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -805,7 +805,7 @@ public:
|
||||
*/
|
||||
void set_epilog_stime(time_t _stime)
|
||||
{
|
||||
history->epilog_stime=_stime;
|
||||
history->epilog_stime = _stime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -814,7 +814,7 @@ public:
|
||||
*/
|
||||
void set_epilog_etime(time_t _etime)
|
||||
{
|
||||
history->epilog_etime=_etime;
|
||||
history->epilog_etime = _etime;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1453,7 +1453,7 @@ public:
|
||||
|
||||
one_util::split_unique(nic->vector_value("ALIAS_IDS"), ',', a_ids);
|
||||
|
||||
for(std::set<int>::iterator it = a_ids.begin(); it != a_ids.end(); it++)
|
||||
for (std::set<int>::iterator it = a_ids.begin(); it != a_ids.end(); it++)
|
||||
{
|
||||
VirtualMachineNic * nic_a = nics.delete_nic(*it);
|
||||
|
||||
|
@ -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*/
|
||||
|
@ -182,7 +182,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void deploy (
|
||||
void deploy(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -194,7 +194,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void shutdown (
|
||||
void shutdown(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -206,7 +206,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void reset (
|
||||
void reset(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -218,7 +218,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void reboot (
|
||||
void reboot(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -230,7 +230,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void cancel (
|
||||
void cancel(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -242,7 +242,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void cleanup (
|
||||
void cleanup(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -254,7 +254,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void checkpoint (
|
||||
void checkpoint(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -266,7 +266,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void save (
|
||||
void save(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -279,7 +279,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void restore (
|
||||
void restore(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -292,7 +292,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void migrate (
|
||||
void migrate(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -304,7 +304,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void poll (
|
||||
void poll(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -316,7 +316,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void attach (
|
||||
void attach(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -328,7 +328,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void detach (
|
||||
void detach(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -340,7 +340,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void attach_nic (
|
||||
void attach_nic(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -352,7 +352,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void detach_nic (
|
||||
void detach_nic(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -365,7 +365,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void snapshot_create (
|
||||
void snapshot_create(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -378,7 +378,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void snapshot_revert (
|
||||
void snapshot_revert(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -391,7 +391,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void snapshot_delete (
|
||||
void snapshot_delete(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -404,7 +404,7 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void disk_snapshot_create (
|
||||
void disk_snapshot_create(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
@ -417,20 +417,32 @@ private:
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void disk_resize (
|
||||
void disk_resize(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
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"
|
||||
* @param oid the virtual machine id.
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void updatesg (
|
||||
void updatesg(
|
||||
const int oid,
|
||||
const string& drv_msg) const
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::deploy (VirtualMachine * vm, const RequestAttributes& ra)
|
||||
int DispatchManager::deploy(VirtualMachine * vm, const RequestAttributes& ra)
|
||||
{
|
||||
ostringstream oss;
|
||||
int vid;
|
||||
@ -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;
|
||||
}
|
||||
@ -132,7 +132,7 @@ int DispatchManager::import(VirtualMachine * vm, const RequestAttributes& ra)
|
||||
|
||||
import_state = vm->get_import_state();
|
||||
|
||||
if(import_state == "POWEROFF")
|
||||
if (import_state == "POWEROFF")
|
||||
{
|
||||
vm->set_state(VirtualMachine::POWEROFF);
|
||||
vm->set_state(VirtualMachine::LCM_INIT);
|
||||
@ -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;
|
||||
}
|
||||
@ -526,14 +526,14 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::poweroff (int vid, bool hard, const RequestAttributes& ra,
|
||||
int DispatchManager::poweroff(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
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;
|
||||
}
|
||||
@ -1082,18 +1082,18 @@ int DispatchManager::delete_vm(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
bool is_public_host = false;
|
||||
int host_id = -1;
|
||||
|
||||
if(vm->hasHistory())
|
||||
if (vm->hasHistory())
|
||||
{
|
||||
host_id = vm->get_hid();
|
||||
}
|
||||
|
||||
int vid = vm->get_oid();
|
||||
|
||||
if(host_id != -1)
|
||||
if (host_id != -1)
|
||||
{
|
||||
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,10 +1319,10 @@ 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" ;
|
||||
<< ", VM does not exist";
|
||||
err = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, err);
|
||||
@ -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,10 +1519,10 @@ 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" ;
|
||||
<< ", VM does not exist";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
@ -1570,10 +1570,10 @@ 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" ;
|
||||
<< ", VM does not exist";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
@ -1633,10 +1633,10 @@ 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" ;
|
||||
<< ", VM does not exist";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
@ -1703,10 +1703,10 @@ 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" ;
|
||||
<< ", VM does not exist";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
@ -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,10 +1920,10 @@ 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" ;
|
||||
<< ", VM does not exist";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
@ -1960,7 +1960,7 @@ int DispatchManager::disk_snapshot_create(int vid, int did, const string& name,
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case VirtualMachine::POWEROFF:
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
@ -1980,7 +1980,7 @@ int DispatchManager::disk_snapshot_create(int vid, int did, const string& name,
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case VirtualMachine::POWEROFF:
|
||||
case VirtualMachine::SUSPENDED:
|
||||
@ -2034,10 +2034,10 @@ 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" ;
|
||||
<< ", VM does not exist";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
@ -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;
|
||||
@ -2075,7 +2075,7 @@ int DispatchManager::disk_snapshot_revert(int vid, int did, int snap_id,
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case VirtualMachine::POWEROFF:
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
@ -2110,10 +2110,10 @@ 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" ;
|
||||
<< ", VM does not exist";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
@ -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;
|
||||
@ -2161,7 +2161,7 @@ int DispatchManager::disk_snapshot_delete(int vid, int did, int snap_id,
|
||||
// Set the VM info in the history before the snapshot is removed from the VM
|
||||
vm->set_vm_info();
|
||||
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case VirtualMachine::POWEROFF:
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
@ -2181,7 +2181,7 @@ int DispatchManager::disk_snapshot_delete(int vid, int did, int snap_id,
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case VirtualMachine::ACTIVE:
|
||||
the_time = time(0);
|
||||
@ -2233,9 +2233,9 @@ 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" ;
|
||||
oss << "Could not resize disk for VM " << vid << ", VM does not exist";
|
||||
error_str = oss.str();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
@ -2271,7 +2271,7 @@ int DispatchManager::disk_resize(int vid, int did, long long new_size,
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case VirtualMachine::POWEROFF:
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
@ -2291,7 +2291,7 @@ int DispatchManager::disk_resize(int vid, int did, long long new_size,
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case VirtualMachine::POWEROFF:
|
||||
case VirtualMachine::UNDEPLOYED:
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -49,8 +49,8 @@ int LifeCycleManager::start()
|
||||
int rc;
|
||||
pthread_attr_t pattr;
|
||||
|
||||
pthread_attr_init (&pattr);
|
||||
pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE);
|
||||
pthread_attr_init(&pattr);
|
||||
pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
NebulaLog::log("LCM",Log::INFO,"Starting Life-cycle Manager...");
|
||||
|
||||
@ -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
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -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,12 +768,12 @@ void LifeCycleManager::prolog_failure_action(int vid)
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid);
|
||||
|
||||
if ( vm == 0 )
|
||||
if ( vm == nullptr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch(vm->get_lcm_state())
|
||||
switch (vm->get_lcm_state())
|
||||
{
|
||||
case VirtualMachine::PROLOG:
|
||||
vm->set_state(VirtualMachine::PROLOG_FAILURE);
|
||||
@ -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,12 +2216,12 @@ 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:
|
||||
case Image::USED_PERS:
|
||||
ready.push_back( make_pair(*id, image->get_source()) );
|
||||
ready.push_back(make_pair(*id, image->get_source()));
|
||||
break;
|
||||
|
||||
case Image::ERROR:
|
||||
@ -2244,7 +2245,7 @@ void LifeCycleManager::disk_lock_success(int vid)
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
|
||||
if (vm == 0)
|
||||
if (vm == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -2260,7 +2261,7 @@ void LifeCycleManager::disk_lock_success(int vid)
|
||||
|
||||
vm->get_template_attribute("SUBMIT_ON_HOLD", on_hold);
|
||||
|
||||
if(on_hold)
|
||||
if (on_hold)
|
||||
{
|
||||
vm->set_state(VirtualMachine::HOLD);
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -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
|
||||
|
@ -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,12 +1152,12 @@ 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;
|
||||
}
|
||||
|
||||
if( vm->is_previous_history_open() ||
|
||||
if (vm->is_previous_history_open() ||
|
||||
(vm->get_state() != VirtualMachine::POWEROFF &&
|
||||
vm->get_state() != VirtualMachine::SUSPENDED &&
|
||||
(vm->get_state() != VirtualMachine::ACTIVE ||
|
||||
@ -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;
|
||||
}
|
||||
@ -2590,9 +2590,9 @@ void VirtualMachineRecover::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachine * vm=(static_cast<VirtualMachinePool *>(pool))->get(id);
|
||||
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();
|
||||
@ -3173,31 +3189,31 @@ void VirtualMachineDiskResize::request_execute(
|
||||
int did = xmlrpc_c::value_int(paramList.getInt(2));
|
||||
string size_s = xmlrpc_c::value_string(paramList.getString(3));
|
||||
|
||||
long long size , current_size;
|
||||
long long size , current_size;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Check request consistency (VM & disk exists, size, and no snapshots)
|
||||
// ------------------------------------------------------------------------
|
||||
istringstream iss(size_s);
|
||||
istringstream iss(size_s);
|
||||
|
||||
iss >> size;
|
||||
iss >> size;
|
||||
|
||||
if (iss.fail() || !iss.eof())
|
||||
{
|
||||
att.resp_msg = "Disk SIZE is not a valid integer";
|
||||
if (iss.fail() || !iss.eof())
|
||||
{
|
||||
att.resp_msg = "Disk SIZE is not a valid integer";
|
||||
failure_response(ACTION, att);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((vm = get_vm(id, att)) == 0)
|
||||
if ((vm = get_vm(id, att)) == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineDisk * disk =vm->get_disk(did);
|
||||
VirtualMachineDisk * disk = vm->get_disk(did);
|
||||
|
||||
if (disk == 0)
|
||||
if (disk == nullptr)
|
||||
{
|
||||
att.resp_msg = "VM disk does not exist";
|
||||
failure_response(ACTION, att);
|
||||
@ -3205,29 +3221,29 @@ void VirtualMachineDiskResize::request_execute(
|
||||
vm->unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
disk->vector_value("SIZE", current_size);
|
||||
disk->vector_value("SIZE", current_size);
|
||||
|
||||
if ( size <= current_size )
|
||||
{
|
||||
if ( size <= current_size )
|
||||
{
|
||||
att.resp_msg = "New disk size has to be greater than current one";
|
||||
failure_response(ACTION, att);
|
||||
|
||||
vm->unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( disk->has_snapshots() )
|
||||
{
|
||||
if ( disk->has_snapshots() )
|
||||
{
|
||||
att.resp_msg = "Cannot resize a disk with snapshots";
|
||||
failure_response(ACTION, att);
|
||||
|
||||
vm->unlock();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------- Get information about the disk and image --------------- */
|
||||
bool img_ds_quota, vm_ds_quota;
|
||||
@ -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;
|
||||
|
@ -33,7 +33,7 @@ extern "C" void * tm_action_loop(void *arg)
|
||||
{
|
||||
TransferManager * tm;
|
||||
|
||||
if ( arg == 0 )
|
||||
if ( arg == nullptr )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -65,8 +65,8 @@ int TransferManager::start()
|
||||
|
||||
NebulaLog::log("TrM",Log::INFO,"Starting Transfer Manager...");
|
||||
|
||||
pthread_attr_init (&pattr);
|
||||
pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE);
|
||||
pthread_attr_init(&pattr);
|
||||
pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
rc = pthread_create(&tm_thread,&pattr,tm_action_loop,(void *) this);
|
||||
|
||||
@ -88,7 +88,7 @@ void TransferManager::user_action(const ActionRequest& ar)
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid);
|
||||
|
||||
if (vm == 0)
|
||||
if (vm == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -104,7 +104,7 @@ void TransferManager::user_action(const ActionRequest& ar)
|
||||
|
||||
vm->unlock();
|
||||
|
||||
switch(tm_ar.action())
|
||||
switch (tm_ar.action())
|
||||
{
|
||||
case TMAction::PROLOG:
|
||||
if (host_is_cloud)
|
||||
@ -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;
|
||||
}
|
||||
@ -1140,7 +1140,7 @@ void TransferManager::epilog_transfer_command(
|
||||
if ( disk->is_volatile() == true )
|
||||
{
|
||||
tm_mad = vm->get_tm_mad();
|
||||
ds_id_i= vm->get_ds_id();
|
||||
ds_id_i = vm->get_ds_id();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -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;
|
||||
|
@ -171,127 +171,127 @@ int VirtualMachine::lcm_state_from_str(string& st, LcmState& state)
|
||||
|
||||
if ( st == "LCM_INIT" ){
|
||||
state = LCM_INIT;
|
||||
} else if ( st == "PROLOG") {
|
||||
} else if ( st == "PROLOG" ) {
|
||||
state = PROLOG;
|
||||
} else if ( st == "BOOT") {
|
||||
} else if ( st == "BOOT" ) {
|
||||
state = BOOT;
|
||||
} else if ( st == "RUNNING") {
|
||||
} else if ( st == "RUNNING" ) {
|
||||
state = RUNNING;
|
||||
} else if ( st == "MIGRATE") {
|
||||
} else if ( st == "MIGRATE" ) {
|
||||
state = MIGRATE;
|
||||
} else if ( st == "SAVE_STOP") {
|
||||
} else if ( st == "SAVE_STOP" ) {
|
||||
state = SAVE_STOP;
|
||||
} else if ( st == "SAVE_SUSPEND") {
|
||||
} else if ( st == "SAVE_SUSPEND" ) {
|
||||
state = SAVE_SUSPEND;
|
||||
} else if ( st == "SAVE_MIGRATE") {
|
||||
} else if ( st == "SAVE_MIGRATE" ) {
|
||||
state = SAVE_MIGRATE;
|
||||
} else if ( st == "PROLOG_MIGRATE") {
|
||||
} else if ( st == "PROLOG_MIGRATE" ) {
|
||||
state = PROLOG_MIGRATE;
|
||||
} else if ( st == "PROLOG_RESUME") {
|
||||
} else if ( st == "PROLOG_RESUME" ) {
|
||||
state = PROLOG_RESUME;
|
||||
} else if ( st == "EPILOG_STOP") {
|
||||
} else if ( st == "EPILOG_STOP" ) {
|
||||
state = EPILOG_STOP;
|
||||
} else if ( st == "EPILOG") {
|
||||
} else if ( st == "EPILOG" ) {
|
||||
state = EPILOG;
|
||||
} else if ( st == "SHUTDOWN") {
|
||||
} else if ( st == "SHUTDOWN" ) {
|
||||
state = SHUTDOWN;
|
||||
} else if ( st == "CLEANUP_RESUBMIT") {
|
||||
} else if ( st == "CLEANUP_RESUBMIT" ) {
|
||||
state = CLEANUP_RESUBMIT;
|
||||
} else if ( st == "UNKNOWN") {
|
||||
} else if ( st == "UNKNOWN" ) {
|
||||
state = UNKNOWN;
|
||||
} else if ( st == "HOTPLUG") {
|
||||
} else if ( st == "HOTPLUG" ) {
|
||||
state = HOTPLUG;
|
||||
} else if ( st == "SHUTDOWN_POWEROFF") {
|
||||
} else if ( st == "SHUTDOWN_POWEROFF" ) {
|
||||
state = SHUTDOWN_POWEROFF;
|
||||
} else if ( st == "BOOT_UNKNOWN") {
|
||||
} else if ( st == "BOOT_UNKNOWN" ) {
|
||||
state = BOOT_UNKNOWN;
|
||||
} else if ( st == "BOOT_POWEROFF") {
|
||||
} else if ( st == "BOOT_POWEROFF" ) {
|
||||
state = BOOT_POWEROFF;
|
||||
} else if ( st == "BOOT_SUSPENDED") {
|
||||
} else if ( st == "BOOT_SUSPENDED" ) {
|
||||
state = BOOT_SUSPENDED;
|
||||
} else if ( st == "BOOT_STOPPED") {
|
||||
} else if ( st == "BOOT_STOPPED" ) {
|
||||
state = BOOT_STOPPED;
|
||||
} else if ( st == "CLEANUP_DELETE") {
|
||||
} else if ( st == "CLEANUP_DELETE" ) {
|
||||
state = CLEANUP_DELETE;
|
||||
} else if ( st == "HOTPLUG_SNAPSHOT") {
|
||||
} else if ( st == "HOTPLUG_SNAPSHOT" ) {
|
||||
state = HOTPLUG_SNAPSHOT;
|
||||
} else if ( st == "HOTPLUG_NIC") {
|
||||
} else if ( st == "HOTPLUG_NIC" ) {
|
||||
state = HOTPLUG_NIC;
|
||||
} else if ( st == "HOTPLUG_SAVEAS") {
|
||||
} else if ( st == "HOTPLUG_SAVEAS" ) {
|
||||
state = HOTPLUG_SAVEAS;
|
||||
} else if ( st == "HOTPLUG_SAVEAS_POWEROFF") {
|
||||
} else if ( st == "HOTPLUG_SAVEAS_POWEROFF" ) {
|
||||
state = HOTPLUG_SAVEAS_POWEROFF;
|
||||
} else if ( st == "HOTPLUG_SAVEAS_SUSPENDED") {
|
||||
} else if ( st == "HOTPLUG_SAVEAS_SUSPENDED" ) {
|
||||
state = HOTPLUG_SAVEAS_SUSPENDED;
|
||||
} else if ( st == "SHUTDOWN_UNDEPLOY") {
|
||||
} else if ( st == "SHUTDOWN_UNDEPLOY" ) {
|
||||
state = SHUTDOWN_UNDEPLOY;
|
||||
} else if ( st == "EPILOG_UNDEPLOY") {
|
||||
} else if ( st == "EPILOG_UNDEPLOY" ) {
|
||||
state = EPILOG_UNDEPLOY;
|
||||
} else if ( st == "PROLOG_UNDEPLOY") {
|
||||
} else if ( st == "PROLOG_UNDEPLOY" ) {
|
||||
state = PROLOG_UNDEPLOY;
|
||||
} else if ( st == "BOOT_UNDEPLOY") {
|
||||
} else if ( st == "BOOT_UNDEPLOY" ) {
|
||||
state = BOOT_UNDEPLOY;
|
||||
} else if ( st == "HOTPLUG_PROLOG_POWEROFF") {
|
||||
} else if ( st == "HOTPLUG_PROLOG_POWEROFF" ) {
|
||||
state = HOTPLUG_PROLOG_POWEROFF;
|
||||
} else if ( st == "HOTPLUG_EPILOG_POWEROFF") {
|
||||
} else if ( st == "HOTPLUG_EPILOG_POWEROFF" ) {
|
||||
state = HOTPLUG_EPILOG_POWEROFF;
|
||||
} else if ( st == "BOOT_MIGRATE") {
|
||||
} else if ( st == "BOOT_MIGRATE" ) {
|
||||
state = BOOT_MIGRATE;
|
||||
} else if ( st == "BOOT_FAILURE") {
|
||||
} else if ( st == "BOOT_FAILURE" ) {
|
||||
state = BOOT_FAILURE;
|
||||
} else if ( st == "BOOT_MIGRATE_FAILURE") {
|
||||
} else if ( st == "BOOT_MIGRATE_FAILURE" ) {
|
||||
state = BOOT_MIGRATE_FAILURE;
|
||||
} else if ( st == "PROLOG_MIGRATE_FAILURE") {
|
||||
} else if ( st == "PROLOG_MIGRATE_FAILURE" ) {
|
||||
state = PROLOG_MIGRATE_FAILURE;
|
||||
} else if ( st == "PROLOG_FAILURE") {
|
||||
} else if ( st == "PROLOG_FAILURE" ) {
|
||||
state = PROLOG_FAILURE;
|
||||
} else if ( st == "EPILOG_FAILURE") {
|
||||
} else if ( st == "EPILOG_FAILURE" ) {
|
||||
state = EPILOG_FAILURE;
|
||||
} else if ( st == "EPILOG_STOP_FAILURE") {
|
||||
} else if ( st == "EPILOG_STOP_FAILURE" ) {
|
||||
state = EPILOG_STOP_FAILURE;
|
||||
} else if ( st == "EPILOG_UNDEPLOY_FAILURE") {
|
||||
} else if ( st == "EPILOG_UNDEPLOY_FAILURE" ) {
|
||||
state = EPILOG_UNDEPLOY_FAILURE;
|
||||
} else if ( st == "PROLOG_MIGRATE_POWEROFF") {
|
||||
} else if ( st == "PROLOG_MIGRATE_POWEROFF" ) {
|
||||
state = PROLOG_MIGRATE_POWEROFF;
|
||||
} else if ( st == "PROLOG_MIGRATE_POWEROFF_FAILURE") {
|
||||
} else if ( st == "PROLOG_MIGRATE_POWEROFF_FAILURE" ) {
|
||||
state = PROLOG_MIGRATE_POWEROFF_FAILURE;
|
||||
} else if ( st == "PROLOG_MIGRATE_SUSPEND") {
|
||||
} else if ( st == "PROLOG_MIGRATE_SUSPEND" ) {
|
||||
state = PROLOG_MIGRATE_SUSPEND;
|
||||
} else if ( st == "PROLOG_MIGRATE_SUSPEND_FAILURE") {
|
||||
} else if ( st == "PROLOG_MIGRATE_SUSPEND_FAILURE" ) {
|
||||
state = PROLOG_MIGRATE_SUSPEND_FAILURE;
|
||||
} else if ( st == "BOOT_STOPPED_FAILURE") {
|
||||
} else if ( st == "BOOT_STOPPED_FAILURE" ) {
|
||||
state = BOOT_STOPPED_FAILURE;
|
||||
} else if ( st == "BOOT_UNDEPLOY_FAILURE") {
|
||||
} else if ( st == "BOOT_UNDEPLOY_FAILURE" ) {
|
||||
state = BOOT_UNDEPLOY_FAILURE;
|
||||
} else if ( st == "PROLOG_RESUME_FAILURE") {
|
||||
} else if ( st == "PROLOG_RESUME_FAILURE" ) {
|
||||
state = PROLOG_RESUME_FAILURE;
|
||||
} else if ( st == "PROLOG_UNDEPLOY_FAILURE") {
|
||||
} else if ( st == "PROLOG_UNDEPLOY_FAILURE" ) {
|
||||
state = PROLOG_UNDEPLOY_FAILURE;
|
||||
} else if ( st == "DISK_SNAPSHOT_POWEROFF") {
|
||||
} else if ( st == "DISK_SNAPSHOT_POWEROFF" ) {
|
||||
state = DISK_SNAPSHOT_POWEROFF;
|
||||
} else if ( st == "DISK_SNAPSHOT_REVERT_POWEROFF") {
|
||||
} else if ( st == "DISK_SNAPSHOT_REVERT_POWEROFF" ) {
|
||||
state = DISK_SNAPSHOT_REVERT_POWEROFF;
|
||||
} else if ( st == "DISK_SNAPSHOT_DELETE_POWEROFF") {
|
||||
} else if ( st == "DISK_SNAPSHOT_DELETE_POWEROFF" ) {
|
||||
state = DISK_SNAPSHOT_DELETE_POWEROFF;
|
||||
} else if ( st == "DISK_SNAPSHOT_SUSPENDED") {
|
||||
} else if ( st == "DISK_SNAPSHOT_SUSPENDED" ) {
|
||||
state = DISK_SNAPSHOT_SUSPENDED;
|
||||
} else if ( st == "DISK_SNAPSHOT_REVERT_SUSPENDED") {
|
||||
} else if ( st == "DISK_SNAPSHOT_REVERT_SUSPENDED" ) {
|
||||
state = DISK_SNAPSHOT_REVERT_SUSPENDED;
|
||||
} else if ( st == "DISK_SNAPSHOT_DELETE_SUSPENDED") {
|
||||
} else if ( st == "DISK_SNAPSHOT_DELETE_SUSPENDED" ) {
|
||||
state = DISK_SNAPSHOT_DELETE_SUSPENDED;
|
||||
} else if ( st == "DISK_SNAPSHOT") {
|
||||
} else if ( st == "DISK_SNAPSHOT" ) {
|
||||
state = DISK_SNAPSHOT;
|
||||
} else if ( st == "DISK_SNAPSHOT_DELETE") {
|
||||
} else if ( st == "DISK_SNAPSHOT_DELETE" ) {
|
||||
state = DISK_SNAPSHOT_DELETE;
|
||||
} else if ( st == "PROLOG_MIGRATE_UNKNOWN") {
|
||||
} else if ( st == "PROLOG_MIGRATE_UNKNOWN" ) {
|
||||
state = PROLOG_MIGRATE_UNKNOWN;
|
||||
} else if ( st == "PROLOG_MIGRATE_UNKNOWN_FAILURE") {
|
||||
} else if ( st == "PROLOG_MIGRATE_UNKNOWN_FAILURE" ) {
|
||||
state = PROLOG_MIGRATE_UNKNOWN_FAILURE;
|
||||
} else if ( st == "DISK_RESIZE") {
|
||||
} else if ( st == "DISK_RESIZE" ) {
|
||||
state = DISK_RESIZE;
|
||||
} else if ( st == "DISK_RESIZE_POWEROFF") {
|
||||
} else if ( st == "DISK_RESIZE_POWEROFF" ) {
|
||||
state = DISK_RESIZE_POWEROFF;
|
||||
} else if ( st == "DISK_RESIZE_UNDEPLOYED") {
|
||||
} else if ( st == "DISK_RESIZE_UNDEPLOYED" ) {
|
||||
state = DISK_RESIZE_UNDEPLOYED;
|
||||
} else {
|
||||
return -1;
|
||||
@ -535,13 +535,13 @@ int VirtualMachine::select(SqlDB * db)
|
||||
// Rebuild the VirtualMachine object
|
||||
rc = PoolObjectSQL::select(db);
|
||||
|
||||
if( rc != 0 )
|
||||
if ( rc != 0 )
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
//Get History Records.
|
||||
if( hasHistory() )
|
||||
if ( hasHistory() )
|
||||
{
|
||||
last_seq = history->seq;
|
||||
|
||||
@ -599,7 +599,7 @@ int VirtualMachine::select(SqlDB * db)
|
||||
log_system = nd.get_log_system();
|
||||
clevel = nd.get_debug_level();
|
||||
|
||||
switch(log_system)
|
||||
switch (log_system)
|
||||
{
|
||||
case NebulaLog::FILE_TS:
|
||||
case NebulaLog::FILE:
|
||||
@ -1339,7 +1339,7 @@ static int get_cluster_requirements(Template *tmpl, set<int>& cluster_ids,
|
||||
// Get cluster id from all DISK vector attributes (IMAGE Datastore)
|
||||
num_vatts = tmpl->get("DISK",vatts);
|
||||
|
||||
for(int i=0; i<num_vatts; i++)
|
||||
for (int i=0; i<num_vatts; i++)
|
||||
{
|
||||
update_disk_cluster_id(vatts[i]);
|
||||
|
||||
@ -1357,7 +1357,7 @@ static int get_cluster_requirements(Template *tmpl, set<int>& cluster_ids,
|
||||
// Get cluster id from all NIC vector attributes
|
||||
num_vatts = tmpl->get("NIC", vatts);
|
||||
|
||||
for(int i=0; i<num_vatts; i++)
|
||||
for (int i=0; i<num_vatts; i++)
|
||||
{
|
||||
update_nic_cluster_id(vatts[i]);
|
||||
|
||||
@ -1375,7 +1375,7 @@ static int get_cluster_requirements(Template *tmpl, set<int>& cluster_ids,
|
||||
// Get cluster id from all PCI attibutes, TYPE = NIC
|
||||
num_vatts = tmpl->get("PCI", vatts);
|
||||
|
||||
for(int i=0; i<num_vatts; i++)
|
||||
for (int i=0; i<num_vatts; i++)
|
||||
{
|
||||
if ( vatts[i]->vector_value("TYPE") != "NIC" )
|
||||
{
|
||||
@ -1499,7 +1499,7 @@ static int get_datastore_requirements(Template *tmpl, set<int>& ds_ids,
|
||||
// Get cluster id from all DISK vector attributes (IMAGE Datastore)
|
||||
int num_vatts = tmpl->get("DISK",vatts);
|
||||
|
||||
for(int i=0; i<num_vatts; i++, csystem_ds.clear())
|
||||
for (int i=0; i<num_vatts; i++, csystem_ds.clear())
|
||||
{
|
||||
int val;
|
||||
|
||||
@ -1602,7 +1602,7 @@ int VirtualMachine::automatic_requirements(set<int>& cluster_ids,
|
||||
|
||||
oss << " | (PUBLIC_CLOUD = YES & (";
|
||||
|
||||
oss << "HYPERVISOR = " << *it ;
|
||||
oss << "HYPERVISOR = " << *it;
|
||||
|
||||
for (++it; it != clouds.end() ; ++it)
|
||||
{
|
||||
@ -1719,7 +1719,7 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
goto error_text;
|
||||
}
|
||||
|
||||
if(replace)
|
||||
if (replace)
|
||||
{
|
||||
oss << "UPDATE " << table << " SET "
|
||||
<< "name = '" << sql_name << "', "
|
||||
@ -2131,7 +2131,7 @@ void VirtualMachine::remove_security_group(int sgid)
|
||||
|
||||
num_sgs = obj_template->get("SECURITY_GROUP_RULE", sgs);
|
||||
|
||||
for(int i=0; i<num_sgs; i++)
|
||||
for (int i=0; i<num_sgs; i++)
|
||||
{
|
||||
sgs[i]->vector_value("SECURITY_GROUP_ID", ssgid);
|
||||
|
||||
@ -2177,7 +2177,7 @@ void VirtualMachine::set_auth_request(int uid,
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
VirtualMachineDisks tdisks(tmpl, false);
|
||||
|
||||
for( disk = tdisks.begin(); disk != tdisks.end(); ++disk)
|
||||
for (disk = tdisks.begin(); disk != tdisks.end(); ++disk)
|
||||
{
|
||||
(*disk)->authorize(uid, &ar, check_lock);
|
||||
}
|
||||
@ -2185,7 +2185,7 @@ void VirtualMachine::set_auth_request(int uid,
|
||||
VirtualMachineNics::nic_iterator nic;
|
||||
VirtualMachineNics tnics(tmpl);
|
||||
|
||||
for( nic = tnics.begin(); nic != tnics.end(); ++nic)
|
||||
for (nic = tnics.begin(); nic != tnics.end(); ++nic)
|
||||
{
|
||||
(*nic)->authorize(uid, &ar, check_lock);
|
||||
}
|
||||
@ -2262,7 +2262,7 @@ string& VirtualMachine::to_xml_extended(string& xml, int n_history) const
|
||||
|
||||
VirtualMachineDisks::disk_iterator disk;
|
||||
|
||||
for ( disk = const_cast<VirtualMachineDisks *>(&disks)->begin() ;
|
||||
for (disk = const_cast<VirtualMachineDisks *>(&disks)->begin() ;
|
||||
disk != const_cast<VirtualMachineDisks *>(&disks)->end() ; ++disk)
|
||||
{
|
||||
const Snapshots * snapshots = (*disk)->get_snapshots();
|
||||
@ -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:
|
||||
@ -3510,7 +3512,7 @@ int VirtualMachine::set_up_attach_nic(VirtualMachineTemplate * tmpl, string& err
|
||||
|
||||
obj_template->set(new_nic);
|
||||
|
||||
for(vector<VectorAttribute*>::iterator it=sgs.begin(); it!=sgs.end(); ++it)
|
||||
for (vector<VectorAttribute*>::iterator it=sgs.begin(); it!=sgs.end(); ++it)
|
||||
{
|
||||
obj_template->set(*it);
|
||||
}
|
||||
@ -3555,7 +3557,7 @@ int VirtualMachine::set_detach_nic(int nic_id)
|
||||
|
||||
one_util::split_unique(nic->vector_value("ALIAS_IDS"), ',', a_ids);
|
||||
|
||||
for(std::set<int>::iterator it = a_ids.begin(); it != a_ids.end(); ++it)
|
||||
for (std::set<int>::iterator it = a_ids.begin(); it != a_ids.end(); ++it)
|
||||
{
|
||||
if ( *it == nic_id )
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ extern "C" void * vmm_action_loop(void *arg)
|
||||
{
|
||||
VirtualMachineManager * vmm;
|
||||
|
||||
if ( arg == 0 )
|
||||
if ( arg == nullptr )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -90,8 +90,8 @@ int VirtualMachineManager::start()
|
||||
|
||||
NebulaLog::log("VMM",Log::INFO,"Starting Virtual Machine Manager...");
|
||||
|
||||
pthread_attr_init (&pattr);
|
||||
pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE);
|
||||
pthread_attr_init(&pattr);
|
||||
pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_JOINABLE);
|
||||
|
||||
rc = pthread_create(&vmm_thread,&pattr,vmm_action_loop,(void *) this);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -2111,7 +2114,7 @@ void VirtualMachineManager::disk_snapshot_create_action(int vid)
|
||||
goto error_disk;
|
||||
}
|
||||
|
||||
rc = tm->snapshot_transfer_command( vm, "SNAP_CREATE", os);
|
||||
rc = tm->snapshot_transfer_command(vm, "SNAP_CREATE", os);
|
||||
|
||||
snap_cmd = os.str();
|
||||
|
||||
@ -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,20 +2644,20 @@ 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.";
|
||||
|
||||
NebulaLog::log("VMM",Log::INFO,oss);
|
||||
|
||||
for(i=0,oss.str("");i<mad_conf.size();i++,oss.str(""),vmm_driver=0)
|
||||
for (i=0, oss.str(""); i<mad_conf.size(); i++, oss.str(""), vmm_driver=0)
|
||||
{
|
||||
vattr = static_cast<const VectorAttribute *>(mad_conf[i]);
|
||||
|
||||
name = vattr->vector_value("NAME");
|
||||
type = vattr->vector_value("TYPE");
|
||||
|
||||
transform (type.begin(),type.end(),type.begin(),(int(*)(int))toupper);
|
||||
transform(type.begin(), type.end(), type.begin(), (int(*)(int))toupper);
|
||||
|
||||
oss << "\tLoading driver: " << name << " (" << type << ")";
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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")
|
||||
|
||||
|
@ -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
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user