mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-11 04:58:16 +03:00
F #5005: Add request information to events and callbacks from API calls.
This commit is contained in:
parent
7a2face60c
commit
d143012eb6
@ -73,8 +73,18 @@ protected:
|
||||
*/
|
||||
virtual void user_action(const ActionRequest& ar){};
|
||||
|
||||
/**
|
||||
* Periodic timer action, executed each time the time_out expires. Listener
|
||||
* needs to re-implement the default timer action if needed.
|
||||
* @param ar the ActionRequest
|
||||
*/
|
||||
virtual void timer_action(const ActionRequest& ar){};
|
||||
|
||||
/**
|
||||
* Action executed when the Manager finlizes. Listener needs to re-implement
|
||||
* the default action if needed.
|
||||
* @param ar the ActionRequest
|
||||
*/
|
||||
virtual void finalize_action(const ActionRequest& ar){};
|
||||
|
||||
private:
|
||||
@ -118,7 +128,8 @@ public:
|
||||
|
||||
virtual ~ActionManager();
|
||||
|
||||
/** Function to trigger an action to this manager.
|
||||
/**
|
||||
* Function to trigger an action to this manager.
|
||||
* @param action the action name
|
||||
* @param args arguments for the action
|
||||
*/
|
||||
@ -150,21 +161,23 @@ public:
|
||||
{
|
||||
ActionRequest trequest(ActionRequest::TIMER);
|
||||
|
||||
loop (timeout, trequest);
|
||||
loop(timeout, trequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* The calling thread will be suspended until an action is triggered.
|
||||
* The calling thread will be suspended until an action is triggered. No
|
||||
* periodic action is defined.
|
||||
*/
|
||||
void loop()
|
||||
{
|
||||
ActionRequest trequest(ActionRequest::TIMER);
|
||||
|
||||
loop (0, trequest);
|
||||
loop(0, trequest);
|
||||
}
|
||||
|
||||
/** Register the calling object in this action manager.
|
||||
* @param listener a pointer to the action listner
|
||||
/**
|
||||
* Register the calling object in this action manager.
|
||||
* @param listener a pointer to the action listner
|
||||
*/
|
||||
void addListener(ActionListener * listener)
|
||||
{
|
||||
|
@ -32,6 +32,8 @@ class LifeCycleManager;
|
||||
class VirtualMachineManager;
|
||||
class ImageManager;
|
||||
|
||||
struct RequestAttributes;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -128,19 +130,19 @@ public:
|
||||
* function. Also the VM MUST have its mutex locked. If the function fails
|
||||
* the calling funtion is responsible for recovering from the error.
|
||||
* @param vm pointer to a VirtualMachine with its mutex locked.
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success
|
||||
*/
|
||||
int deploy (
|
||||
VirtualMachine * vm);
|
||||
int deploy(VirtualMachine * vm, const RequestAttributes& request);
|
||||
|
||||
/**
|
||||
* Sets an imported VM to RUNNING state, a history record MUST be added,
|
||||
* and the VM MUST be locked.
|
||||
* @param vm pointer to a VirtualMachine with its mutex locked.
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success
|
||||
*/
|
||||
int import (
|
||||
VirtualMachine * vm);
|
||||
int import(VirtualMachine * vm, const RequestAttributes& ra);
|
||||
|
||||
/**
|
||||
* Migrates a VM. The following actions must be performed before calling
|
||||
@ -151,10 +153,10 @@ public:
|
||||
* If the function fails the calling funtion is responsible for recovering
|
||||
* from the error.
|
||||
* @param vm pointer to a VirtualMachine with its mutex locked.
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success
|
||||
*/
|
||||
int migrate(
|
||||
VirtualMachine * vm);
|
||||
int migrate(VirtualMachine * vm, const RequestAttributes& request);
|
||||
|
||||
/**
|
||||
* Migrates a VM. The following actions must be performed before calling
|
||||
@ -165,108 +167,102 @@ public:
|
||||
* If the function fails the calling funtion is responsible for recovering
|
||||
* from the error.
|
||||
* @param vm pointer to a VirtualMachine with its mutex locked.
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success
|
||||
*/
|
||||
int live_migrate(
|
||||
VirtualMachine * vm);
|
||||
int live_migrate(VirtualMachine * vm, const RequestAttributes& request);
|
||||
|
||||
/**
|
||||
* Terminates a VM.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param hard True to force the shutdown (cancel instead of shutdown)
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int terminate (
|
||||
int vid,
|
||||
bool hard,
|
||||
int terminate(int vid, bool hard, const RequestAttributes& request,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Shuts down a VM, but it is saved in the system DS instead of destroyed.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param hard True to force the shutdown (cancel instead of shutdown)
|
||||
* @param ra information about the API call request
|
||||
* @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,
|
||||
string& error_str);
|
||||
int undeploy (int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Powers off a VM.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param ra information about the API call request
|
||||
* @param hard True to force the poweroff (cancel instead of shutdown)
|
||||
* @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,
|
||||
string& error_str);
|
||||
int poweroff (int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Holds a VM.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int hold(
|
||||
int vid,
|
||||
string& error_str);
|
||||
int hold(int vid, const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Releases a VM.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int release(
|
||||
int vid,
|
||||
string& error_str);
|
||||
int release(int vid, const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Stops a VM.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int stop(
|
||||
int vid,
|
||||
string& error_str);
|
||||
int stop(int vid, const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Suspends a VM.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int suspend(
|
||||
int vid,
|
||||
string& error_str);
|
||||
int suspend(int vid, const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Resumes a VM.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int resume(
|
||||
int vid,
|
||||
string& error_str);
|
||||
int resume(int vid, const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Ends a VM life cycle inside ONE.
|
||||
* @param vm VirtualMachine object
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success, the VM mutex is unlocked
|
||||
*/
|
||||
int delete_vm(VirtualMachine * vm, string& error_str);
|
||||
int delete_vm(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* VM ID interface
|
||||
*/
|
||||
int delete_vm(int vid, string& error_str)
|
||||
int delete_vm(int vid, const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
||||
@ -278,107 +274,107 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return delete_vm(vm, error_str);
|
||||
return delete_vm(vm, ra, error_str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a VM to PENDING state preserving any resource (i.e. leases) and id
|
||||
* @param vm VirtualMachine object
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success
|
||||
*/
|
||||
int delete_recreate(VirtualMachine * vm, string& error_str);
|
||||
int delete_recreate(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Recover the last operation on the VM
|
||||
* @param vm VirtualMachine object
|
||||
* @param success if the operation is assumed to succeed or not
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success
|
||||
*/
|
||||
int recover(VirtualMachine * vm, bool success, string& error_str);
|
||||
int recover(VirtualMachine * vm, bool success, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Retry the last operation on the VM
|
||||
* @param vm VirtualMachine object
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success
|
||||
*/
|
||||
int retry(VirtualMachine * vm, string& error_str);
|
||||
int retry(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Reboots a VM preserving any resource and RUNNING state
|
||||
* @param vid VirtualMachine identification
|
||||
* @param hard True to force the shutdown (cancel instead of shutdown)
|
||||
* @param ra information about the API call request
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int reboot(
|
||||
int vid,
|
||||
bool hard,
|
||||
string& error_str);
|
||||
int reboot(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Set the re-scheduling flag for the VM (must be in RUNNING state)
|
||||
* @param vid VirtualMachine identification
|
||||
* @param do_resched set or unset the flag
|
||||
* @param ra information about the API call request
|
||||
*
|
||||
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||
* in a wrong a state
|
||||
*/
|
||||
int resched(
|
||||
int vid,
|
||||
bool do_resched,
|
||||
string& error_str);
|
||||
int resched(int vid, bool do_resched, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the attach disk action.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param tmpl Template containing the new DISK attribute.
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int attach(
|
||||
int vid,
|
||||
VirtualMachineTemplate * tmpl,
|
||||
string& error_str);
|
||||
int attach(int vid, VirtualMachineTemplate * tmpl,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the detach disk action.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param disk_id Disk to detach
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int detach(
|
||||
int id,
|
||||
int disk_id,
|
||||
string& error_str);
|
||||
int detach(int id, int disk_id, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the attach NIC action.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param tmpl Template containing the new NIC attribute.
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int attach_nic(
|
||||
int vid,
|
||||
VirtualMachineTemplate * tmpl,
|
||||
string& error_str);
|
||||
int attach_nic(int vid, VirtualMachineTemplate * tmpl,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the detach NIC action.
|
||||
* @param vid VirtualMachine identification
|
||||
* @param nic_id NIC to detach
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int detach_nic(
|
||||
int id,
|
||||
int nic_id,
|
||||
string& error_str);
|
||||
int detach_nic(int id, int nic_id, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the snapshot create action
|
||||
@ -386,43 +382,39 @@ public:
|
||||
* @param vid VirtualMachine identification
|
||||
* @param name Name for the new snapshot
|
||||
* @param snap_id Will contain the new snapshot ID
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int snapshot_create(
|
||||
int vid,
|
||||
string& name,
|
||||
int& snap_id,
|
||||
string& error_str);
|
||||
int snapshot_create(int vid, string& name, int& snap_id,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the snapshot revert action
|
||||
*
|
||||
* @param vid VirtualMachine identification
|
||||
* @param snap_id Snapshot to be restored
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int snapshot_revert(
|
||||
int vid,
|
||||
int snap_id,
|
||||
string& error_str);
|
||||
int snapshot_revert(int vid, int snap_id, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the snapshot delete action
|
||||
*
|
||||
* @param vid VirtualMachine identification
|
||||
* @param snap_id Snapshot to be deleted
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int snapshot_delete(
|
||||
int vid,
|
||||
int snap_id,
|
||||
string& error_str);
|
||||
int snapshot_delete(int vid, int snap_id, const RequestAttributes& ra,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the disk snapshot create action
|
||||
@ -431,16 +423,13 @@ public:
|
||||
* @param did DISK identification
|
||||
* @param name Description for the new snapshot
|
||||
* @param snap_id Will contain the new snapshot ID
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int disk_snapshot_create(
|
||||
int vid,
|
||||
int did,
|
||||
const string& name,
|
||||
int& snap_id,
|
||||
string& error_str);
|
||||
int disk_snapshot_create(int vid, int did, const string& name, int& snap_id,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Reverts the disk state to a previous snapshot
|
||||
@ -448,15 +437,13 @@ public:
|
||||
* @param vid VirtualMachine identification
|
||||
* @param did DISK identification
|
||||
* @param snap_id Snapshot to be restored
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int disk_snapshot_revert(
|
||||
int vid,
|
||||
int did,
|
||||
int snap_id,
|
||||
string& error_str);
|
||||
int disk_snapshot_revert(int vid, int did, int snap_id,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Deletes a disk snapshot
|
||||
@ -464,15 +451,13 @@ public:
|
||||
* @param vid VirtualMachine identification
|
||||
* @param did DISK identification
|
||||
* @param snap_id Snapshot to be restored
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int disk_snapshot_delete(
|
||||
int vid,
|
||||
int did,
|
||||
int snap_id,
|
||||
string& error_str);
|
||||
int disk_snapshot_delete(int vid, int did, int snap_id,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
|
||||
/**
|
||||
* Starts the disk resize create action
|
||||
@ -480,16 +465,13 @@ public:
|
||||
* @param vid VirtualMachine identification
|
||||
* @param did DISK identification
|
||||
* @param size new size for the disk
|
||||
* @param ra information about the API call request
|
||||
* @param error_str Error reason, if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int disk_resize(
|
||||
int vid,
|
||||
int did,
|
||||
long long new_size,
|
||||
string& error_str);
|
||||
|
||||
int disk_resize(int vid, int did, long long new_size,
|
||||
const RequestAttributes& ra, string& error_str);
|
||||
private:
|
||||
/**
|
||||
* Thread id for the Dispatch Manager
|
||||
|
@ -33,6 +33,7 @@ class TransferManager;
|
||||
class DispatchManager;
|
||||
class VirtualMachineManager;
|
||||
class ImageManager;
|
||||
struct RequestAttributes;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -102,8 +103,9 @@ public:
|
||||
DISK_RESIZE_FAILURE /**< Sent by TM/VMM when a disk resize fails */
|
||||
};
|
||||
|
||||
LCMAction(Actions a, int v):ActionRequest(ActionRequest::USER),
|
||||
_action(a), _vm_id(v){};
|
||||
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){};
|
||||
|
||||
Actions action() const
|
||||
{
|
||||
@ -115,10 +117,30 @@ public:
|
||||
return _vm_id;
|
||||
}
|
||||
|
||||
int uid() const
|
||||
{
|
||||
return _uid;
|
||||
}
|
||||
|
||||
int gid() const
|
||||
{
|
||||
return _gid;
|
||||
}
|
||||
|
||||
int req_id() const
|
||||
{
|
||||
return _req_id;
|
||||
}
|
||||
|
||||
private:
|
||||
Actions _action;
|
||||
|
||||
int _vm_id;
|
||||
int _vm_id;
|
||||
|
||||
int _uid;
|
||||
int _gid;
|
||||
|
||||
int _req_id;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -144,13 +166,12 @@ public:
|
||||
* @param action the LCM action
|
||||
* @param vid VM unique id. This is the argument of the passed to the
|
||||
* invoked action.
|
||||
* @param r RM request attributes to copy to the action request: uid,
|
||||
* gid and request_id.
|
||||
*/
|
||||
void trigger(LCMAction::Actions action, int vid)
|
||||
{
|
||||
LCMAction lcm_ar(action, vid);
|
||||
void trigger(LCMAction::Actions action, int id, const RequestAttributes& r);
|
||||
|
||||
am.trigger(lcm_ar);
|
||||
}
|
||||
void trigger(LCMAction::Actions action, int id);
|
||||
|
||||
void finalize()
|
||||
{
|
||||
@ -184,7 +205,7 @@ public:
|
||||
* @param vm to be recovered
|
||||
* @param success trigger successful transition if true, fail otherwise
|
||||
*/
|
||||
void recover(VirtualMachine * vm, bool success);
|
||||
void recover(VirtualMachine * vm, bool success, const RequestAttributes& ra);
|
||||
|
||||
/**
|
||||
* Retries the last VM operation that lead to a failure. The underlying
|
||||
@ -275,113 +296,98 @@ private:
|
||||
*/
|
||||
void clean_up_vm (VirtualMachine *vm, bool dispose, int& image_id);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Internal Actions, triggered by OpenNebula components & drivers
|
||||
// -------------------------------------------------------------------------
|
||||
void save_success_action(int vid);
|
||||
|
||||
void save_failure_action(int vid);
|
||||
|
||||
void deploy_success_action(int vid);
|
||||
|
||||
void deploy_failure_action(int vid);
|
||||
|
||||
void shutdown_success_action(int vid);
|
||||
|
||||
void shutdown_failure_action(int vid);
|
||||
|
||||
void monitor_suspend_action(int vid);
|
||||
|
||||
void monitor_done_action(int vid);
|
||||
|
||||
void monitor_poweroff_action(int vid);
|
||||
|
||||
void monitor_poweron_action(int vid);
|
||||
|
||||
void prolog_success_action(int vid);
|
||||
|
||||
void prolog_failure_action(int vid);
|
||||
|
||||
void epilog_success_action(int vid);
|
||||
|
||||
void epilog_failure_action(int vid);
|
||||
|
||||
void attach_success_action(int vid);
|
||||
|
||||
void attach_failure_action(int vid);
|
||||
|
||||
void detach_success_action(int vid);
|
||||
|
||||
void detach_failure_action(int vid);
|
||||
|
||||
void saveas_success_action(int vid);
|
||||
|
||||
void saveas_failure_action(int vid);
|
||||
|
||||
void attach_nic_success_action(int vid);
|
||||
|
||||
void attach_nic_failure_action(int vid);
|
||||
|
||||
void detach_nic_success_action(int vid);
|
||||
|
||||
void detach_nic_failure_action(int vid);
|
||||
|
||||
void cleanup_callback_action(int vid);
|
||||
|
||||
void snapshot_create_success(int vid);
|
||||
|
||||
void snapshot_create_failure(int vid);
|
||||
|
||||
void snapshot_revert_success(int vid);
|
||||
|
||||
void snapshot_revert_failure(int vid);
|
||||
|
||||
void snapshot_delete_success(int vid);
|
||||
|
||||
void snapshot_delete_failure(int vid);
|
||||
|
||||
void disk_snapshot_success(int vid);
|
||||
|
||||
void disk_snapshot_failure(int vid);
|
||||
|
||||
void disk_lock_success(int vid);
|
||||
|
||||
void disk_lock_failure(int vid);
|
||||
|
||||
void disk_resize_success(int vid);
|
||||
|
||||
void disk_resize_failure(int vid);
|
||||
|
||||
void deploy_action(int vid);
|
||||
// -------------------------------------------------------------------------
|
||||
// External Actions, triggered by user requests
|
||||
// -------------------------------------------------------------------------
|
||||
void deploy_action(const LCMAction& la);
|
||||
|
||||
void suspend_action(int vid);
|
||||
void suspend_action(const LCMAction& la);
|
||||
|
||||
void restore_action(int vid);
|
||||
void restore_action(const LCMAction& la);
|
||||
|
||||
void stop_action(int vid);
|
||||
void stop_action(const LCMAction& la);
|
||||
|
||||
void checkpoint_action(int vid);
|
||||
void checkpoint_action(const LCMAction& la);
|
||||
|
||||
void migrate_action(int vid);
|
||||
void migrate_action(const LCMAction& la);
|
||||
|
||||
void live_migrate_action(int vid);
|
||||
void live_migrate_action(const LCMAction& la);
|
||||
|
||||
void shutdown_action(int vid, bool hard);
|
||||
void shutdown_action(const LCMAction& la, bool hard);
|
||||
|
||||
void undeploy_action(int vid, bool hard);
|
||||
void undeploy_action(const LCMAction& la, bool hard);
|
||||
|
||||
void poweroff_action(int vid);
|
||||
void poweroff_action(const LCMAction& la);
|
||||
|
||||
void poweroff_hard_action(int vid);
|
||||
void poweroff_hard_action(const LCMAction& la);
|
||||
|
||||
void poweroff_action(int vid, bool hard);
|
||||
|
||||
void updatesg_action(int sgid);
|
||||
void updatesg_action(const LCMAction& la);
|
||||
|
||||
void restart_action(int vid);
|
||||
void restart_action(const LCMAction& la);
|
||||
|
||||
void delete_action(int vid);
|
||||
void delete_action(const LCMAction& la);
|
||||
|
||||
void delete_recreate_action(int vid);
|
||||
|
||||
void timer_action();
|
||||
void delete_recreate_action(const LCMAction& la);
|
||||
};
|
||||
|
||||
#endif /*LIFE_CYCLE_MANAGER_H_*/
|
||||
|
@ -404,6 +404,9 @@ public:
|
||||
};
|
||||
|
||||
~VirtualRouterDelete(){};
|
||||
|
||||
protected:
|
||||
int drop(PoolObjectSQL * obj, bool resive, RequestAttributes& att);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
struct RequestAttributes;
|
||||
|
||||
/**
|
||||
* The VirtualRouter class.
|
||||
@ -167,6 +168,20 @@ public:
|
||||
return SUPPORTED_ACTIONS.is_set(action);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// VM Management
|
||||
// -------------------------------------------------------------------------
|
||||
//
|
||||
/**
|
||||
* Tries to shutdown, or delete, all this Virtual Router's VMs
|
||||
* @param ra attributes for the VirtualRouter delete operation
|
||||
* @param vms implementing the VirtualRouter
|
||||
* @param nics IP leased to the VirtualRouter
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
static int shutdown_vms(const set<int>& vms, const RequestAttributes& ra);
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------------
|
||||
// Friends
|
||||
@ -291,17 +306,6 @@ private:
|
||||
* @return nic if found, 0 if not found
|
||||
*/
|
||||
VectorAttribute* get_nic(int nic_id) const;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// VM Management
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Tries to shutdown, or delete, all this Virtual Router's VMs
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int shutdown_vms();
|
||||
};
|
||||
|
||||
#endif /*VIRTUAL_ROUTER_H_*/
|
||||
|
@ -21,7 +21,7 @@
|
||||
/* ActionManager constructor & destructor */
|
||||
/* ************************************************************************** */
|
||||
|
||||
ActionManager::ActionManager(): actions(), listener(0)
|
||||
ActionManager::ActionManager(): listener(0)
|
||||
{
|
||||
pthread_mutex_init(&mutex,0);
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::deploy (
|
||||
VirtualMachine * vm)
|
||||
int DispatchManager::deploy (VirtualMachine * vm, const RequestAttributes& ra)
|
||||
{
|
||||
ostringstream oss;
|
||||
int vid;
|
||||
@ -51,7 +50,7 @@ int DispatchManager::deploy (
|
||||
|
||||
vmpool->update(vm);
|
||||
|
||||
lcm->trigger(LCMAction::DEPLOY,vid);
|
||||
lcm->trigger(LCMAction::DEPLOY, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -72,8 +71,7 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::import (
|
||||
VirtualMachine * vm)
|
||||
int DispatchManager::import(VirtualMachine * vm, const RequestAttributes& ra)
|
||||
{
|
||||
ostringstream oss;
|
||||
string import_state;
|
||||
@ -129,8 +127,7 @@ int DispatchManager::import (
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::migrate(
|
||||
VirtualMachine * vm)
|
||||
int DispatchManager::migrate(VirtualMachine * vm, const RequestAttributes& ra)
|
||||
{
|
||||
ostringstream oss;
|
||||
int vid;
|
||||
@ -151,7 +148,7 @@ int DispatchManager::migrate(
|
||||
vm->get_state() == VirtualMachine::POWEROFF ||
|
||||
vm->get_state() == VirtualMachine::SUSPENDED)
|
||||
{
|
||||
lcm->trigger(LCMAction::MIGRATE,vid);
|
||||
lcm->trigger(LCMAction::MIGRATE, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -172,8 +169,8 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::live_migrate(
|
||||
VirtualMachine * vm)
|
||||
int DispatchManager::live_migrate(VirtualMachine * vm,
|
||||
const RequestAttributes& ra)
|
||||
{
|
||||
ostringstream oss;
|
||||
int vid;
|
||||
@ -191,7 +188,7 @@ int DispatchManager::live_migrate(
|
||||
if (vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING )
|
||||
{
|
||||
lcm->trigger(LCMAction::LIVE_MIGRATE,vid);
|
||||
lcm->trigger(LCMAction::LIVE_MIGRATE, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -271,9 +268,7 @@ void DispatchManager::free_vm_resources(VirtualMachine * vm)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::terminate(
|
||||
int vid,
|
||||
bool hard,
|
||||
int DispatchManager::terminate(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
int rc = 0;
|
||||
@ -296,7 +291,7 @@ int DispatchManager::terminate(
|
||||
case VirtualMachine::POWEROFF:
|
||||
case VirtualMachine::STOPPED:
|
||||
case VirtualMachine::UNDEPLOYED:
|
||||
lcm->trigger(LCMAction::SHUTDOWN, vid);
|
||||
lcm->trigger(LCMAction::SHUTDOWN, vid, ra);
|
||||
vm->unlock();
|
||||
break;
|
||||
|
||||
@ -319,11 +314,11 @@ int DispatchManager::terminate(
|
||||
case VirtualMachine::UNKNOWN:
|
||||
if (hard)
|
||||
{
|
||||
lcm->trigger(LCMAction::CANCEL,vid);
|
||||
lcm->trigger(LCMAction::CANCEL, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcm->trigger(LCMAction::SHUTDOWN,vid);
|
||||
lcm->trigger(LCMAction::SHUTDOWN, vid, ra);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -348,14 +343,12 @@ int DispatchManager::terminate(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::undeploy(
|
||||
int vid,
|
||||
bool hard,
|
||||
string& error_str)
|
||||
int DispatchManager::undeploy(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -372,11 +365,11 @@ int DispatchManager::undeploy(
|
||||
{
|
||||
if (hard)
|
||||
{
|
||||
lcm->trigger(LCMAction::UNDEPLOY_HARD,vid);
|
||||
lcm->trigger(LCMAction::UNDEPLOY_HARD, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcm->trigger(LCMAction::UNDEPLOY,vid);
|
||||
lcm->trigger(LCMAction::UNDEPLOY, vid, ra);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -405,14 +398,12 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::poweroff (
|
||||
int vid,
|
||||
bool hard,
|
||||
string& error_str)
|
||||
int DispatchManager::poweroff (int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -428,11 +419,11 @@ int DispatchManager::poweroff (
|
||||
{
|
||||
if (hard)
|
||||
{
|
||||
lcm->trigger(LCMAction::POWEROFF_HARD,vid);
|
||||
lcm->trigger(LCMAction::POWEROFF_HARD, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcm->trigger(LCMAction::POWEROFF,vid);
|
||||
lcm->trigger(LCMAction::POWEROFF, vid, ra);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -462,13 +453,12 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::hold(
|
||||
int vid,
|
||||
string& error_str)
|
||||
int DispatchManager::hold(int vid, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -511,13 +501,12 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::release(
|
||||
int vid,
|
||||
string& error_str)
|
||||
int DispatchManager::release(int vid, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -580,13 +569,12 @@ error_state:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::stop(
|
||||
int vid,
|
||||
string& error_str)
|
||||
int DispatchManager::stop(int vid, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -600,7 +588,7 @@ int DispatchManager::stop(
|
||||
(vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING ))
|
||||
{
|
||||
lcm->trigger(LCMAction::STOP,vid);
|
||||
lcm->trigger(LCMAction::STOP, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -628,13 +616,12 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::suspend(
|
||||
int vid,
|
||||
string& error_str)
|
||||
int DispatchManager::suspend(int vid, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -647,7 +634,7 @@ int DispatchManager::suspend(
|
||||
if (vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING )
|
||||
{
|
||||
lcm->trigger(LCMAction::SUSPEND,vid);
|
||||
lcm->trigger(LCMAction::SUSPEND, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -662,7 +649,7 @@ error:
|
||||
oss.str("");
|
||||
oss << "Could not suspend VM " << vid
|
||||
<< ", wrong state " << vm->state_str() << ".";
|
||||
NebulaLog::log("DiM",Log::ERROR,oss);
|
||||
NebulaLog::log("DiM", Log::ERROR, oss);
|
||||
|
||||
oss.str("");
|
||||
oss << "This action is not available for state " << vm->state_str();
|
||||
@ -675,13 +662,12 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::resume(
|
||||
int vid,
|
||||
string& error_str)
|
||||
int DispatchManager::resume(int vid, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -710,13 +696,13 @@ int DispatchManager::resume(
|
||||
}
|
||||
else if (vm->get_state() == VirtualMachine::SUSPENDED)
|
||||
{
|
||||
lcm->trigger(LCMAction::RESTORE,vid);
|
||||
lcm->trigger(LCMAction::RESTORE, vid, ra);
|
||||
}
|
||||
else if ( vm->get_state() == VirtualMachine::POWEROFF ||
|
||||
(vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::UNKNOWN))
|
||||
{
|
||||
lcm->trigger(LCMAction::RESTART,vid);
|
||||
lcm->trigger(LCMAction::RESTART, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -755,14 +741,12 @@ error_state:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::reboot(
|
||||
int vid,
|
||||
bool hard,
|
||||
string& error_str)
|
||||
int DispatchManager::reboot(int vid, bool hard, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -777,11 +761,11 @@ int DispatchManager::reboot(
|
||||
{
|
||||
if (hard)
|
||||
{
|
||||
vmm->trigger(VMMAction::RESET,vid);
|
||||
vmm->trigger(VMMAction::RESET, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
vmm->trigger(VMMAction::REBOOT,vid);
|
||||
vmm->trigger(VMMAction::REBOOT, vid);
|
||||
}
|
||||
|
||||
vm->set_resched(false); //Rebooting cancels re-scheduling actions
|
||||
@ -815,14 +799,12 @@ error:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::resched(
|
||||
int vid,
|
||||
bool do_resched,
|
||||
string& error_str)
|
||||
int DispatchManager::resched(int vid, bool do_resched,
|
||||
const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -890,25 +872,27 @@ error_state:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::recover(VirtualMachine * vm, bool success, string& error)
|
||||
int DispatchManager::recover(VirtualMachine * vm, bool success,
|
||||
const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
int rc = 0;
|
||||
int vid = vm->get_oid();
|
||||
|
||||
switch (vm->get_state())
|
||||
{
|
||||
case VirtualMachine::CLONING_FAILURE:
|
||||
if (success)
|
||||
{
|
||||
lcm->trigger(LCMAction::DISK_LOCK_SUCCESS,vm->get_oid());
|
||||
lcm->trigger(LCMAction::DISK_LOCK_SUCCESS, vid, ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcm->trigger(LCMAction::DISK_LOCK_FAILURE,vm->get_oid());
|
||||
lcm->trigger(LCMAction::DISK_LOCK_FAILURE, vid, ra);
|
||||
}
|
||||
break;
|
||||
|
||||
case VirtualMachine::ACTIVE:
|
||||
lcm->recover(vm, success);
|
||||
lcm->recover(vm, success, ra);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -917,7 +901,7 @@ int DispatchManager::recover(VirtualMachine * vm, bool success, string& error)
|
||||
ostringstream oss;
|
||||
oss << "Could not perform a recover operation on VM " << vm->get_oid()
|
||||
<< ", wrong state " << vm->state_str() << ".";
|
||||
error = oss.str();
|
||||
error_str = oss.str();
|
||||
|
||||
break;
|
||||
}
|
||||
@ -930,7 +914,8 @@ int DispatchManager::recover(VirtualMachine * vm, bool success, string& error)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::retry(VirtualMachine * vm, string& error)
|
||||
int DispatchManager::retry(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
@ -946,7 +931,7 @@ int DispatchManager::retry(VirtualMachine * vm, string& error)
|
||||
ostringstream oss;
|
||||
oss << "Could not perform a retry on VM " << vm->get_oid()
|
||||
<< ", wrong state " << vm->state_str() << ".";
|
||||
error = oss.str();
|
||||
error_str = oss.str();
|
||||
|
||||
break;
|
||||
}
|
||||
@ -959,7 +944,8 @@ int DispatchManager::retry(VirtualMachine * vm, string& error)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::delete_vm(VirtualMachine * vm, string& error)
|
||||
int DispatchManager::delete_vm(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
string& error)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1041,7 +1027,7 @@ int DispatchManager::delete_vm(VirtualMachine * vm, string& error)
|
||||
break;
|
||||
|
||||
case VirtualMachine::ACTIVE:
|
||||
lcm->trigger(LCMAction::DELETE, vid);
|
||||
lcm->trigger(LCMAction::DELETE, vid, ra);
|
||||
vm->unlock();
|
||||
break;
|
||||
|
||||
@ -1056,7 +1042,8 @@ int DispatchManager::delete_vm(VirtualMachine * vm, string& error)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::delete_recreate(VirtualMachine * vm, string& error)
|
||||
int DispatchManager::delete_recreate(VirtualMachine * vm,
|
||||
const RequestAttributes& ra, string& error)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1116,7 +1103,7 @@ int DispatchManager::delete_recreate(VirtualMachine * vm, string& error)
|
||||
break;
|
||||
|
||||
case VirtualMachine::ACTIVE: //Cleanup VM resources before PENDING
|
||||
lcm->trigger(LCMAction::DELETE_RECREATE, vm->get_oid());
|
||||
lcm->trigger(LCMAction::DELETE_RECREATE, vm->get_oid(), ra);
|
||||
break;
|
||||
|
||||
case VirtualMachine::DONE:
|
||||
@ -1158,7 +1145,8 @@ int DispatchManager::delete_recreate(VirtualMachine * vm, string& error)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::attach(int vid, VirtualMachineTemplate * tmpl, string & err)
|
||||
int DispatchManager::attach(int vid, VirtualMachineTemplate * tmpl,
|
||||
const RequestAttributes& ra, string & err)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1246,7 +1234,7 @@ int DispatchManager::attach(int vid, VirtualMachineTemplate * tmpl, string & err
|
||||
|
||||
//-----------------------------------------------
|
||||
|
||||
vmm->trigger(VMMAction::ATTACH,vid);
|
||||
vmm->trigger(VMMAction::ATTACH, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1263,10 +1251,8 @@ int DispatchManager::attach(int vid, VirtualMachineTemplate * tmpl, string & err
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::detach(
|
||||
int vid,
|
||||
int disk_id,
|
||||
string& error_str)
|
||||
int DispatchManager::detach(int vid, int disk_id, const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1341,7 +1327,7 @@ int DispatchManager::detach(
|
||||
|
||||
vm->set_state(VirtualMachine::HOTPLUG);
|
||||
|
||||
vmm->trigger(VMMAction::DETACH,vid);
|
||||
vmm->trigger(VMMAction::DETACH, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1361,11 +1347,8 @@ int DispatchManager::detach(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::snapshot_create(
|
||||
int vid,
|
||||
string& name,
|
||||
int& snap_id,
|
||||
string& error_str)
|
||||
int DispatchManager::snapshot_create(int vid, string& name, int& snap_id,
|
||||
const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1405,7 +1388,7 @@ int DispatchManager::snapshot_create(
|
||||
|
||||
vm->unlock();
|
||||
|
||||
vmm->trigger(VMMAction::SNAPSHOT_CREATE,vid);
|
||||
vmm->trigger(VMMAction::SNAPSHOT_CREATE, vid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1413,10 +1396,8 @@ int DispatchManager::snapshot_create(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::snapshot_revert(
|
||||
int vid,
|
||||
int snap_id,
|
||||
string& error_str)
|
||||
int DispatchManager::snapshot_revert(int vid, int snap_id,
|
||||
const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1471,7 +1452,7 @@ int DispatchManager::snapshot_revert(
|
||||
|
||||
vm->unlock();
|
||||
|
||||
vmm->trigger(VMMAction::SNAPSHOT_REVERT,vid);
|
||||
vmm->trigger(VMMAction::SNAPSHOT_REVERT, vid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1479,10 +1460,8 @@ int DispatchManager::snapshot_revert(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::snapshot_delete(
|
||||
int vid,
|
||||
int snap_id,
|
||||
string& error_str)
|
||||
int DispatchManager::snapshot_delete(int vid, int snap_id,
|
||||
const RequestAttributes& ra,string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1536,7 +1515,7 @@ int DispatchManager::snapshot_delete(
|
||||
|
||||
vm->unlock();
|
||||
|
||||
vmm->trigger(VMMAction::SNAPSHOT_DELETE,vid);
|
||||
vmm->trigger(VMMAction::SNAPSHOT_DELETE, vid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1544,10 +1523,8 @@ int DispatchManager::snapshot_delete(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::attach_nic(
|
||||
int vid,
|
||||
VirtualMachineTemplate* tmpl,
|
||||
string & error_str)
|
||||
int DispatchManager::attach_nic(int vid, VirtualMachineTemplate* tmpl,
|
||||
const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1629,7 +1606,7 @@ int DispatchManager::attach_nic(
|
||||
|
||||
//-----------------------------------------------
|
||||
|
||||
vmm->trigger(VMMAction::ATTACH_NIC,vid);
|
||||
vmm->trigger(VMMAction::ATTACH_NIC, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1648,10 +1625,8 @@ int DispatchManager::attach_nic(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::detach_nic(
|
||||
int vid,
|
||||
int nic_id,
|
||||
string& error_str)
|
||||
int DispatchManager::detach_nic(int vid, int nic_id,const RequestAttributes& ra,
|
||||
string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
string tmp_error;
|
||||
@ -1731,7 +1706,7 @@ int DispatchManager::detach_nic(
|
||||
|
||||
//---------------------------------------------------
|
||||
|
||||
vmm->trigger(VMMAction::DETACH_NIC,vid);
|
||||
vmm->trigger(VMMAction::DETACH_NIC, vid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1750,12 +1725,8 @@ int DispatchManager::detach_nic(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::disk_snapshot_create(
|
||||
int vid,
|
||||
int did,
|
||||
const string& name,
|
||||
int& snap_id,
|
||||
string& error_str)
|
||||
int DispatchManager::disk_snapshot_create(int vid, int did, const string& name,
|
||||
int& snap_id, const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
time_t the_time;
|
||||
@ -1830,7 +1801,7 @@ int DispatchManager::disk_snapshot_create(
|
||||
{
|
||||
case VirtualMachine::POWEROFF:
|
||||
case VirtualMachine::SUSPENDED:
|
||||
tm->trigger(TMAction::SNAPSHOT_CREATE,vid);
|
||||
tm->trigger(TMAction::SNAPSHOT_CREATE, vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::ACTIVE:
|
||||
@ -1869,11 +1840,8 @@ int DispatchManager::disk_snapshot_create(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::disk_snapshot_revert(
|
||||
int vid,
|
||||
int did,
|
||||
int snap_id,
|
||||
string& error_str)
|
||||
int DispatchManager::disk_snapshot_revert(int vid, int did, int snap_id,
|
||||
const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -1947,11 +1915,8 @@ int DispatchManager::disk_snapshot_revert(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::disk_snapshot_delete(
|
||||
int vid,
|
||||
int did,
|
||||
int snap_id,
|
||||
string& error_str)
|
||||
int DispatchManager::disk_snapshot_delete(int vid, int did, int snap_id,
|
||||
const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
time_t the_time;
|
||||
@ -2073,11 +2038,8 @@ int DispatchManager::disk_snapshot_delete(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int DispatchManager::disk_resize(
|
||||
int vid,
|
||||
int did,
|
||||
long long new_size,
|
||||
string& error_str)
|
||||
int DispatchManager::disk_resize(int vid, int did, long long new_size,
|
||||
const RequestAttributes& ra, string& error_str)
|
||||
{
|
||||
ostringstream oss;
|
||||
time_t the_time;
|
||||
|
@ -18,12 +18,15 @@
|
||||
#include "TransferManager.h"
|
||||
#include "DispatchManager.h"
|
||||
#include "VirtualMachineManager.h"
|
||||
#include "Request.h"
|
||||
|
||||
void LifeCycleManager::deploy_action(int vid)
|
||||
void LifeCycleManager::deploy_action(const LCMAction& la)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
ostringstream os;
|
||||
|
||||
int vid = la.vm_id();
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
@ -99,11 +102,11 @@ void LifeCycleManager::deploy_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::suspend_action(int vid)
|
||||
void LifeCycleManager::suspend_action(const LCMAction& la)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
int vid = la.vm_id();
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -144,9 +147,11 @@ void LifeCycleManager::suspend_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::stop_action(int vid)
|
||||
void LifeCycleManager::stop_action(const LCMAction& la)
|
||||
{
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
int vid = la.vm_id();
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -207,16 +212,16 @@ void LifeCycleManager::stop_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::migrate_action(int vid)
|
||||
void LifeCycleManager::migrate_action(const LCMAction& la)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
||||
int cpu, mem, disk;
|
||||
vector<VectorAttribute *> pci;
|
||||
|
||||
time_t the_time = time(0);
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
int vid = la.vm_id();
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -326,12 +331,13 @@ void LifeCycleManager::migrate_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::live_migrate_action(int vid)
|
||||
void LifeCycleManager::live_migrate_action(const LCMAction& la)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
ostringstream os;
|
||||
ostringstream os;
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
int vid = la.vm_id();
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -383,8 +389,9 @@ void LifeCycleManager::live_migrate_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::shutdown_action(int vid, bool hard)
|
||||
void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard)
|
||||
{
|
||||
int vid = la.vm_id();
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
@ -473,8 +480,9 @@ void LifeCycleManager::shutdown_action(int vid, bool hard)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::undeploy_action(int vid, bool hard)
|
||||
void LifeCycleManager::undeploy_action(const LCMAction& la, bool hard)
|
||||
{
|
||||
int vid = la.vm_id();
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
@ -548,16 +556,20 @@ void LifeCycleManager::undeploy_action(int vid, bool hard)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::poweroff_action(int vid)
|
||||
void LifeCycleManager::poweroff_action(const LCMAction& la)
|
||||
{
|
||||
int vid = la.vm_id();
|
||||
|
||||
poweroff_action(vid, false);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::poweroff_hard_action(int vid)
|
||||
void LifeCycleManager::poweroff_hard_action(const LCMAction& la)
|
||||
{
|
||||
int vid = la.vm_id();
|
||||
|
||||
poweroff_action(vid, true);
|
||||
}
|
||||
|
||||
@ -566,9 +578,7 @@ void LifeCycleManager::poweroff_hard_action(int vid)
|
||||
|
||||
void LifeCycleManager::poweroff_action(int vid, bool hard)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -619,12 +629,13 @@ void LifeCycleManager::poweroff_action(int vid, bool hard)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::restore_action(int vid)
|
||||
void LifeCycleManager::restore_action(const LCMAction& la)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
ostringstream os;
|
||||
ostringstream os;
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
int vid = la.vm_id();
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -673,11 +684,11 @@ void LifeCycleManager::restore_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::restart_action(int vid)
|
||||
void LifeCycleManager::restart_action(const LCMAction& la)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
int vid = la.vm_id();
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -728,13 +739,12 @@ void LifeCycleManager::restart_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::delete_action(int vid)
|
||||
void LifeCycleManager::delete_action(const LCMAction& la)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
|
||||
int image_id = -1;
|
||||
int vid = la.vm_id();
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -785,7 +795,7 @@ void LifeCycleManager::delete_action(int vid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::delete_recreate_action(int vid)
|
||||
void LifeCycleManager::delete_recreate_action(const LCMAction& la)
|
||||
{
|
||||
Template * vm_quotas_snp = 0;
|
||||
Template * vm_quotas_rsz = 0;
|
||||
@ -799,6 +809,8 @@ void LifeCycleManager::delete_recreate_action(int vid)
|
||||
|
||||
int image_id = -1;
|
||||
|
||||
int vid = la.vm_id();
|
||||
|
||||
vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
@ -1150,7 +1162,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::recover(VirtualMachine * vm, bool success)
|
||||
void LifeCycleManager::recover(VirtualMachine * vm, bool success,
|
||||
const RequestAttributes& ra)
|
||||
{
|
||||
LCMAction::Actions lcm_action = LCMAction::NONE;
|
||||
|
||||
@ -1373,7 +1386,7 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success)
|
||||
|
||||
if (lcm_action != LCMAction::NONE)
|
||||
{
|
||||
trigger(lcm_action, vm->get_oid());
|
||||
trigger(lcm_action, vm->get_oid(), ra);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1600,12 +1613,12 @@ void LifeCycleManager::retry(VirtualMachine * vm)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::updatesg_action(int sgid)
|
||||
void LifeCycleManager::updatesg_action(const LCMAction& la)
|
||||
{
|
||||
int vmid;
|
||||
VirtualMachine * vm;
|
||||
|
||||
int vmid;
|
||||
|
||||
int sgid = la.vm_id();
|
||||
SecurityGroup * sg = sgpool->get(sgid, true);
|
||||
|
||||
if ( sg == 0 )
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "LifeCycleManager.h"
|
||||
#include "Nebula.h"
|
||||
#include "NebulaLog.h"
|
||||
#include "Request.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -80,13 +81,34 @@ void LifeCycleManager::init_managers()
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::trigger(LCMAction::Actions action, int vid,
|
||||
const RequestAttributes& ra)
|
||||
{
|
||||
LCMAction lcm_ar(action, vid, ra.uid, ra.gid, ra.req_id);
|
||||
|
||||
am.trigger(lcm_ar);
|
||||
}
|
||||
|
||||
void LifeCycleManager::trigger(LCMAction::Actions action, int vid)
|
||||
{
|
||||
LCMAction lcm_ar(action, vid, -1, -1, -1);
|
||||
|
||||
am.trigger(lcm_ar);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void LifeCycleManager::user_action(const ActionRequest& ar)
|
||||
{
|
||||
const LCMAction& lcm_ar = static_cast<const LCMAction& >(ar);
|
||||
int vid = lcm_ar.vm_id();
|
||||
const LCMAction& la = static_cast<const LCMAction& >(ar);
|
||||
int vid = la.vm_id();
|
||||
|
||||
switch (lcm_ar.action())
|
||||
switch (la.action())
|
||||
{
|
||||
// -------------------------------------------------------------------------
|
||||
// Internal Actions, triggered by OpenNebula components & drivers
|
||||
// -------------------------------------------------------------------------
|
||||
case LCMAction::SAVE_SUCCESS:
|
||||
save_success_action(vid);
|
||||
break;
|
||||
@ -207,53 +229,56 @@ void LifeCycleManager::user_action(const ActionRequest& ar)
|
||||
case LCMAction::DISK_RESIZE_FAILURE:
|
||||
disk_resize_failure(vid);
|
||||
break;
|
||||
// -------------------------------------------------------------------------
|
||||
// External Actions, triggered by user requests
|
||||
// -------------------------------------------------------------------------
|
||||
case LCMAction::DEPLOY:
|
||||
deploy_action(vid);
|
||||
deploy_action(la);
|
||||
break;
|
||||
case LCMAction::SUSPEND:
|
||||
suspend_action(vid);
|
||||
suspend_action(la);
|
||||
break;
|
||||
case LCMAction::RESTORE:
|
||||
restore_action(vid);
|
||||
restore_action(la);
|
||||
break;
|
||||
case LCMAction::STOP:
|
||||
stop_action(vid);
|
||||
stop_action(la);
|
||||
break;
|
||||
case LCMAction::CANCEL:
|
||||
shutdown_action(vid, true);
|
||||
shutdown_action(la, true);
|
||||
break;
|
||||
case LCMAction::MIGRATE:
|
||||
migrate_action(vid);
|
||||
migrate_action(la);
|
||||
break;
|
||||
case LCMAction::LIVE_MIGRATE:
|
||||
live_migrate_action(vid);
|
||||
live_migrate_action(la);
|
||||
break;
|
||||
case LCMAction::SHUTDOWN:
|
||||
shutdown_action(vid, false);
|
||||
shutdown_action(la, false);
|
||||
break;
|
||||
case LCMAction::UNDEPLOY:
|
||||
undeploy_action(vid, false);
|
||||
undeploy_action(la, false);
|
||||
break;
|
||||
case LCMAction::UNDEPLOY_HARD:
|
||||
undeploy_action(vid, true);
|
||||
undeploy_action(la, true);
|
||||
break;
|
||||
case LCMAction::RESTART:
|
||||
restart_action(vid);
|
||||
restart_action(la);
|
||||
break;
|
||||
case LCMAction::DELETE:
|
||||
delete_action(vid);
|
||||
delete_action(la);
|
||||
break;
|
||||
case LCMAction::DELETE_RECREATE:
|
||||
delete_recreate_action(vid);
|
||||
delete_recreate_action(la);
|
||||
break;
|
||||
case LCMAction::POWEROFF:
|
||||
poweroff_action(vid);
|
||||
poweroff_action(la);
|
||||
break;
|
||||
case LCMAction::POWEROFF_HARD:
|
||||
poweroff_hard_action(vid);
|
||||
poweroff_hard_action(la);
|
||||
break;
|
||||
case LCMAction::UPDATESG:
|
||||
updatesg_action(vid);
|
||||
updatesg_action(la);
|
||||
break;
|
||||
case LCMAction::NONE:
|
||||
break;
|
||||
|
@ -461,6 +461,26 @@ int SecurityGroupDelete::drop(PoolObjectSQL * object, bool recursive,
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualRouterDelete::drop(PoolObjectSQL * object, bool recursive,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
VirtualRouter * vr = static_cast<VirtualRouter *>(object);
|
||||
|
||||
set<int> vms = vr->get_vms();
|
||||
|
||||
int rc = RequestManagerDelete::drop(object, false, att);
|
||||
|
||||
if ( rc == 0 && !vms.empty())
|
||||
{
|
||||
VirtualRouter::shutdown_vms(vms, att);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int MarketPlaceAppDelete::drop(PoolObjectSQL * object, bool recursive,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ void SecurityGroupCommit::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
sg->unlock();
|
||||
|
||||
lcm->trigger(LCMAction::UPDATESG, oid);
|
||||
lcm->trigger(LCMAction::UPDATESG, oid, att);
|
||||
|
||||
success_response(oid, att);
|
||||
|
||||
|
@ -545,49 +545,49 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
switch (action)
|
||||
{
|
||||
case History::TERMINATE_ACTION:
|
||||
rc = dm->terminate(id, false, error);
|
||||
rc = dm->terminate(id, false, att, error);
|
||||
break;
|
||||
case History::TERMINATE_HARD_ACTION:
|
||||
rc = dm->terminate(id, true, error);
|
||||
rc = dm->terminate(id, true, att, error);
|
||||
break;
|
||||
case History::HOLD_ACTION:
|
||||
rc = dm->hold(id, error);
|
||||
rc = dm->hold(id, att, error);
|
||||
break;
|
||||
case History::RELEASE_ACTION:
|
||||
rc = dm->release(id, error);
|
||||
rc = dm->release(id, att, error);
|
||||
break;
|
||||
case History::STOP_ACTION:
|
||||
rc = dm->stop(id, error);
|
||||
rc = dm->stop(id, att, error);
|
||||
break;
|
||||
case History::SUSPEND_ACTION:
|
||||
rc = dm->suspend(id, error);
|
||||
rc = dm->suspend(id, att, error);
|
||||
break;
|
||||
case History::RESUME_ACTION:
|
||||
rc = dm->resume(id, error);
|
||||
rc = dm->resume(id, att, error);
|
||||
break;
|
||||
case History::REBOOT_ACTION:
|
||||
rc = dm->reboot(id, false, error);
|
||||
rc = dm->reboot(id, false, att, error);
|
||||
break;
|
||||
case History::REBOOT_HARD_ACTION:
|
||||
rc = dm->reboot(id, true, error);
|
||||
rc = dm->reboot(id, true, att, error);
|
||||
break;
|
||||
case History::RESCHED_ACTION:
|
||||
rc = dm->resched(id, true, error);
|
||||
rc = dm->resched(id, true, att, error);
|
||||
break;
|
||||
case History::UNRESCHED_ACTION:
|
||||
rc = dm->resched(id, false, error);
|
||||
rc = dm->resched(id, false, att, error);
|
||||
break;
|
||||
case History::POWEROFF_ACTION:
|
||||
rc = dm->poweroff(id, false, error);
|
||||
rc = dm->poweroff(id, false, att, error);
|
||||
break;
|
||||
case History::POWEROFF_HARD_ACTION:
|
||||
rc = dm->poweroff(id, true, error);
|
||||
rc = dm->poweroff(id, true, att, error);
|
||||
break;
|
||||
case History::UNDEPLOY_ACTION:
|
||||
rc = dm->undeploy(id, false, error);
|
||||
rc = dm->undeploy(id, false, att, error);
|
||||
break;
|
||||
case History::UNDEPLOY_HARD_ACTION:
|
||||
rc = dm->undeploy(id, true, error);
|
||||
rc = dm->undeploy(id, true, att, error);
|
||||
break;
|
||||
default:
|
||||
rc = -3;
|
||||
@ -928,11 +928,11 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
if (vm->is_imported())
|
||||
{
|
||||
dm->import(vm);
|
||||
dm->import(vm, att);
|
||||
}
|
||||
else
|
||||
{
|
||||
dm->deploy(vm);
|
||||
dm->deploy(vm, att);
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
@ -1263,11 +1263,11 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
|
||||
if (live == true && vm->get_lcm_state() == VirtualMachine::RUNNING )
|
||||
{
|
||||
dm->live_migrate(vm);
|
||||
dm->live_migrate(vm, att);
|
||||
}
|
||||
else
|
||||
{
|
||||
dm->migrate(vm);
|
||||
dm->migrate(vm, att);
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
@ -1698,7 +1698,7 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
}
|
||||
}
|
||||
|
||||
rc = dm->attach(id, &tmpl, att.resp_msg);
|
||||
rc = dm->attach(id, &tmpl, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -1760,7 +1760,7 @@ void VirtualMachineDetach::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
vm->unlock();
|
||||
|
||||
rc = dm->detach(id, disk_id, att.resp_msg);
|
||||
rc = dm->detach(id, disk_id, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -2092,7 +2092,7 @@ void VirtualMachineSnapshotCreate::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
rc = dm->snapshot_create(id, name, snap_id, att.resp_msg);
|
||||
rc = dm->snapshot_create(id, name, snap_id, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -2130,7 +2130,7 @@ void VirtualMachineSnapshotRevert::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
rc = dm->snapshot_revert(id, snap_id, att.resp_msg);
|
||||
rc = dm->snapshot_revert(id, snap_id, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -2168,7 +2168,7 @@ void VirtualMachineSnapshotDelete::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
rc = dm->snapshot_delete(id, snap_id, att.resp_msg);
|
||||
rc = dm->snapshot_delete(id, snap_id, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -2312,7 +2312,7 @@ Request::ErrorCode VirtualMachineAttachNic::request_execute(int id,
|
||||
// Perform the attach
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
rc = dm->attach_nic(id, &tmpl, att.resp_msg);
|
||||
rc = dm->attach_nic(id, &tmpl, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -2413,7 +2413,7 @@ Request::ErrorCode VirtualMachineDetachNic::request_execute(int id, int nic_id,
|
||||
// -------------------------------------------------------------------------
|
||||
// Perform the detach
|
||||
// -------------------------------------------------------------------------
|
||||
if ( dm->detach_nic(id, nic_id, att.resp_msg) != 0 )
|
||||
if ( dm->detach_nic(id, nic_id, att, att.resp_msg) != 0 )
|
||||
{
|
||||
return ACTION;
|
||||
}
|
||||
@ -2477,23 +2477,23 @@ void VirtualMachineRecover::request_execute(
|
||||
switch (op)
|
||||
{
|
||||
case 0: //recover-failure
|
||||
rc = dm->recover(vm, false, error);
|
||||
rc = dm->recover(vm, false, att, error);
|
||||
break;
|
||||
|
||||
case 1: //recover-success
|
||||
rc = dm->recover(vm, true, error);
|
||||
rc = dm->recover(vm, true, att, error);
|
||||
break;
|
||||
|
||||
case 2: //retry
|
||||
rc = dm->retry(vm, error);
|
||||
rc = dm->retry(vm, att, error);
|
||||
break;
|
||||
|
||||
case 3: //delete
|
||||
rc = dm->delete_vm(vm, error);
|
||||
rc = dm->delete_vm(vm, att, error);
|
||||
break;
|
||||
|
||||
case 4: //delete-recreate
|
||||
rc = dm->delete_recreate(vm, error);
|
||||
rc = dm->delete_recreate(vm, att, error);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2686,7 +2686,7 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
// ------------------------------------------------------------------------
|
||||
// Do the snapshot
|
||||
// ------------------------------------------------------------------------
|
||||
rc = dm->disk_snapshot_create(id, did, name, snap_id, att.resp_msg);
|
||||
rc = dm->disk_snapshot_create(id, did, name, snap_id, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -2731,7 +2731,7 @@ void VirtualMachineDiskSnapshotRevert::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
rc = dm->disk_snapshot_revert(id, did, snap_id, att.resp_msg);
|
||||
rc = dm->disk_snapshot_revert(id, did, snap_id, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -2817,7 +2817,7 @@ void VirtualMachineDiskSnapshotDelete::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
rc = dm->disk_snapshot_delete(id, did, snap_id, att.resp_msg);
|
||||
rc = dm->disk_snapshot_delete(id, did, snap_id, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
@ -3066,7 +3066,7 @@ void VirtualMachineDiskResize::request_execute(
|
||||
// ------------------------------------------------------------------------
|
||||
// Resize the disk
|
||||
// ------------------------------------------------------------------------
|
||||
int rc = dm->disk_resize(id, did, size, att.resp_msg);
|
||||
int rc = dm->disk_resize(id, did, size, att, att.resp_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ void VirtualRouterInstantiate::request_execute(
|
||||
|
||||
for (vmid = vms.begin(); vmid != vms.end(); vmid++)
|
||||
{
|
||||
dm->delete_vm(*vmid, att.resp_msg);
|
||||
dm->delete_vm(*vmid, att, att.resp_msg);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -171,7 +171,7 @@ void VirtualRouterInstantiate::request_execute(
|
||||
{
|
||||
for (vmid = vms.begin(); vmid != vms.end(); vmid++)
|
||||
{
|
||||
dm->release(*vmid, att.resp_msg);
|
||||
dm->release(*vmid, att, att.resp_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "VirtualNetworkPool.h"
|
||||
#include "Nebula.h"
|
||||
#include "VirtualMachine.h"
|
||||
#include "Request.h"
|
||||
|
||||
static const History::VMAction action[15] = {
|
||||
History::MIGRATE_ACTION,
|
||||
@ -149,8 +150,6 @@ int VirtualRouter::drop(SqlDB * db)
|
||||
{
|
||||
release_network_leases();
|
||||
|
||||
shutdown_vms();
|
||||
|
||||
Quotas::quota_del(Quotas::VIRTUALROUTER, uid, gid, obj_template);
|
||||
}
|
||||
|
||||
@ -160,22 +159,22 @@ int VirtualRouter::drop(SqlDB * db)
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
int VirtualRouter::shutdown_vms()
|
||||
int VirtualRouter::shutdown_vms(const set<int>& _vms, const RequestAttributes& ra)
|
||||
{
|
||||
DispatchManager * dm = Nebula::instance().get_dm();
|
||||
|
||||
set<int> _vms;
|
||||
set<int>::iterator it;
|
||||
set<int>::const_iterator it;
|
||||
|
||||
string error;
|
||||
|
||||
int rc;
|
||||
int result = 0;
|
||||
|
||||
_vms = vms.get_collection();
|
||||
|
||||
for (it = _vms.begin(); it != _vms.end(); it++)
|
||||
{
|
||||
rc = dm->terminate(*it, true, error);
|
||||
int vm_id = *it;
|
||||
|
||||
rc = dm->terminate(vm_id, true, ra, error);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
@ -183,7 +182,7 @@ int VirtualRouter::shutdown_vms()
|
||||
|
||||
if (rc == -2)
|
||||
{
|
||||
dm->delete_vm(*it, error);
|
||||
dm->delete_vm(vm_id, ra, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user