1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-02 09:47:00 +03:00

Merge branch 'feature-5005'

This commit is contained in:
Ruben S. Montero 2017-02-10 18:17:58 +01:00
commit 6dd92c0828
58 changed files with 2004 additions and 2551 deletions

View File

@ -21,6 +21,7 @@
#include "AuthRequest.h"
#include "PoolObjectSQL.h"
#include "AclRule.h"
#include "NebulaLog.h"
#include "SqlDB.h"
@ -457,14 +458,18 @@ private:
*/
friend void * acl_action_loop(void *arg);
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(
const string & action,
void * arg);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
void timer_action(const ActionRequest& ar)
{
select();
};
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("ACL",Log::INFO,"Stopping ACL Manager...");
};
};
#endif /*ACL_MANAGER_H*/

View File

@ -22,43 +22,98 @@
#include <ctime>
#include <string>
using namespace std;
/**
* ActionListener class. Interface to be implemented by any class
* that need to handle actions. There are two predefined actions
* (each action is identified with its name, a string):
* - ACTION_TIMER, periodic action
* - ACTION_FINALIZE, to finalize the action loop
* Represents a generic request, pending actions are stored in a queue.
* Each element stores the base action type, additional data is added by each
* ActionListener implementation.
*/
class ActionListener
class ActionRequest
{
public:
/**
* Predefined string to refer to the periodic action
* Base Action types
*/
static const string ACTION_TIMER;
enum Type
{
FINALIZE,
TIMER,
USER
};
/**
* Predefined string to refer to the finalize action
*/
static const string ACTION_FINALIZE;
Type type() const
{
return _type;
}
ActionRequest(Type __type): _type(__type){};
virtual ~ActionRequest(){};
virtual ActionRequest * clone() const
{
return new ActionRequest(_type);
}
protected:
Type _type;
};
/**
* ActionListener class. Interface to be implemented by any class that need to
* handle actions.
*/
class ActionListener
{
protected:
ActionListener(){};
virtual ~ActionListener(){};
/**
* the do_action() function is executed upon action arrival.
* the user_action() function is executed upon action arrival.
* This function should check the action type, and perform the
* corresponding action.
* @param name the action name
* @param args action arguments
* @param ar the ActionRequest
*/
virtual void do_action(const string &name, void *args) = 0;
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:
friend class ActionManager;
/**
* Invoke the action handler
*/
void _do_action(const ActionRequest& ar)
{
switch(ar.type())
{
case ActionRequest::FINALIZE:
finalize_action(ar);
break;
case ActionRequest::TIMER:
timer_action(ar);
break;
case ActionRequest::USER:
user_action(ar);
break;
}
}
};
@ -66,73 +121,87 @@ public:
* ActionManager. Provides action support for a class implementing
* the ActionListener interface.
*/
class ActionManager
{
public:
ActionManager();
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
*/
void trigger(
const string &action,
void * args);
void trigger(const ActionRequest& ar);
/** The calling thread will be suspended until an action is triggeed.
* @param timeout for the periodic action. Use 0 to disable the timer.
* @param timer_args arguments for the timer action
/**
* Trigger the FINALIZE event
*/
void loop(
time_t timeout,
void * timer_args);
void finalize()
{
ActionRequest frequest(ActionRequest::FINALIZE);
/** Register the calling object in this action manager.
* @param listener a pointer to the action listner
trigger(frequest);
}
/**
* The calling thread will be suspended until an action is triggered.
* @param timeout for the periodic action.
* @param timer_args arguments for the timer action
*/
void addListener(
ActionListener * listener)
void loop(time_t timeout, const ActionRequest& trequest);
/**
* The calling thread will be suspended until an action is triggered.
* @param timeout for the periodic action, the timer action will recieve
* an "empty" ActionRequest.
*/
void loop(time_t timeout)
{
ActionRequest trequest(ActionRequest::TIMER);
loop(timeout, trequest);
}
/**
* 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);
}
/**
* Register the calling object in this action manager.
* @param listener a pointer to the action listner
*/
void addListener(ActionListener * listener)
{
this->listener = listener;
};
private:
/**
* Implementation class, pending actions are stored in a queue.
* Each element stores the action name and its arguments
*/
struct ActionRequest
{
string name;
void * args;
ActionRequest(
const string &aname = "",
void * aargs = 0):
name(aname),
args(aargs){};
};
/**
* Queue of pending actions, processed in a FIFO manner
*/
queue<ActionRequest> actions;
std::queue<ActionRequest *> actions;
/**
* Action synchronization is implemented using the pthread library,
* with condition variable and its associated mutex
*/
pthread_mutex_t mutex;
pthread_cond_t cond;
pthread_mutex_t mutex;
pthread_cond_t cond;
/**
* The listener notified by this manager
*/
ActionListener * listener;
ActionListener * listener;
/**
* Function to lock the Manager mutex
@ -149,6 +218,7 @@ private:
{
pthread_mutex_unlock(&mutex);
};
};
#endif /*ACTION_MANAGER_H_*/

View File

@ -20,6 +20,7 @@
#include <time.h>
#include "MadManager.h"
#include "NebulaLog.h"
#include "ActionManager.h"
#include "AuthManagerDriver.h"
#include "PoolObjectSQL.h"
@ -33,6 +34,45 @@ class PoolObjectAuth;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class AMAction : public ActionRequest
{
public:
enum Actions
{
AUTHENTICATE,
AUTHORIZE
};
AMAction(Actions a, AuthRequest *r):ActionRequest(ActionRequest::USER),
_action(a), _request(r){};
AMAction(const AMAction& o):ActionRequest(o._type), _action(o._action),
_request(o._request){};
Actions action() const
{
return _action;
}
AuthRequest * request() const
{
return _request;
}
ActionRequest * clone() const
{
return new AMAction(*this);
}
private:
Actions _action;
AuthRequest * _request;
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
extern "C" void * authm_action_loop(void *arg);
class AuthManager : public MadManager, public ActionListener
@ -49,22 +89,18 @@ public:
~AuthManager(){};
enum Actions
{
AUTHENTICATE,
AUTHORIZE,
FINALIZE
};
/**
* Triggers specific actions to the Auth Manager. This function
* wraps the ActionManager trigger function.
* @param action the Auth Manager action
* @param request an auth request
*/
void trigger(
Actions action,
AuthRequest* request);
void trigger(AMAction::Actions action, AuthRequest* request)
{
AMAction auth_ar(action, request);
am.trigger(auth_ar);
}
/**
* This functions starts the associated listener thread, and creates a
@ -157,21 +193,6 @@ private:
(MadManager::get(0,name,auth_driver_name));
};
/**
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * authm_action_loop(void *arg);
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(
const string & action,
void * arg);
/**
* This function authenticates a user
*/
@ -181,6 +202,29 @@ private:
* This function authorizes a user request
*/
void authorize_action(AuthRequest * ar);
/**
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * authm_action_loop(void *arg);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
void timer_action(const ActionRequest& ar)
{
check_time_outs_action();
};
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("AuM",Log::INFO,"Stopping Authorization Manager...");
MadManager::stop();
};
void user_action(const ActionRequest& ar);
};
#endif /*AUTH_MANAGER_H*/

View File

@ -32,6 +32,51 @@ class LifeCycleManager;
class VirtualMachineManager;
class ImageManager;
struct RequestAttributes;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class DMAction : public ActionRequest
{
public:
enum Actions
{
SUSPEND_SUCCESS, /**< Send by LCM when a VM is suspended*/
STOP_SUCCESS, /**< Send by LCM when a VM is stopped*/
UNDEPLOY_SUCCESS, /**< Send by LCM when a VM is undeployed and saved*/
POWEROFF_SUCCESS, /**< Send by LCM when a VM is powered off */
DONE, /**< Send by LCM when a VM is shut down*/
RESUBMIT /**< Send by LCM when a VM is ready for resubmission*/
};
DMAction(Actions a, int v):ActionRequest(ActionRequest::USER),
_action(a), _vm_id(v){};
DMAction(const DMAction& o):ActionRequest(o._type), _action(o._action),
_vm_id(o._vm_id){};
Actions action() const
{
return _action;
}
int vm_id() const
{
return _vm_id;
}
ActionRequest * clone() const
{
return new DMAction(*this);
}
private:
Actions _action;
int _vm_id;
};
class DispatchManager : public ActionListener
{
public:
@ -50,17 +95,6 @@ public:
*/
void init_managers();
enum Actions
{
SUSPEND_SUCCESS,/**< Send by LCM when a VM is suspended*/
STOP_SUCCESS, /**< Send by LCM when a VM is stopped*/
UNDEPLOY_SUCCESS, /**< Send by LCM when a VM is undeployed and saved*/
POWEROFF_SUCCESS, /**< Send by LCM when a VM is powered off */
DONE, /**< Send by LCM when a VM is shut down*/
RESUBMIT, /**< Send by LCM when a VM is ready for resubmission*/
FINALIZE
};
/**
* Triggers specific actions to the Dispatch Manager. This function
* wraps the ActionManager trigger function.
@ -68,9 +102,17 @@ public:
* @param vid VM unique id. This is the argument of the passed to the
* invoked action.
*/
void trigger(
Actions action,
int _vid);
void trigger(DMAction::Actions action, int vid)
{
DMAction dm_ar(action, vid);
am.trigger(dm_ar);
}
void finalize()
{
am.finalize();
}
/**
* This functions creates a new thread for the Dispatch Manager. This
@ -96,19 +138,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
@ -119,10 +161,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
@ -133,108 +175,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;
@ -246,107 +282,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
@ -354,43 +390,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
@ -399,16 +431,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
@ -416,15 +445,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
@ -432,15 +459,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
@ -448,16 +473,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
@ -504,21 +526,6 @@ private:
*/
ActionManager am;
/**
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * dm_action_loop(void *arg);
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(
const string & action,
void * arg);
/**
* Frees the resources associated to a VM: disks, ip addresses and Quotas
*/
@ -539,6 +546,22 @@ private:
void done_action(int vid);
void resubmit_action(int vid);
/**
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * dm_action_loop(void *arg);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("DiM",Log::INFO,"Stopping Dispatch Manager...");
};
void user_action(const ActionRequest& ar);
};
#endif /*DISPATCH_MANAGER_H*/

View File

@ -29,12 +29,6 @@ using namespace std;
class History:public ObjectSQL, public ObjectXML
{
public:
enum EndReason
{
NONE = 0, /** < History record is not closed yet */
ERROR = 1, /** < History record was closed because of an error */
USER = 2 /** < History record was closed because of a user action */
};
enum VMAction
{ //Associated XML-RPC API call
@ -81,7 +75,8 @@ public:
DISK_SAVEAS_ACTION = 40, // "one.vm.disksaveas"
DISK_SNAPSHOT_REVERT_ACTION = 41, // "one.vm.disksnapshotrevert"
RECOVER_ACTION = 42, // "one.vm.recover"
RETRY_ACTION = 43 // "one.vm.recover"
RETRY_ACTION = 43, // "one.vm.recover"
MONITOR_ACTION = 44 // internal, monitoring process
};
static string action_to_str(VMAction action);
@ -137,6 +132,10 @@ private:
int oid;
int seq;
int uid;
int gid;
int req_id;
int hid;
string hostname;
int cid;
@ -158,8 +157,6 @@ private:
time_t epilog_stime;
time_t epilog_etime;
EndReason reason;
VMAction action;
string vm_info;

View File

@ -65,7 +65,7 @@ public:
*/
void finalize()
{
am.trigger(ACTION_FINALIZE,0);
am.finalize();
};
/**
@ -110,14 +110,15 @@ private:
*/
friend void * hm_action_loop(void *arg);
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(
const string & action,
void * arg);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("HKM",Log::INFO,"Stopping Hook Manager...");
MadManager::stop();
};
};
#endif /*HOOK_MANAGER_H*/

View File

@ -23,6 +23,7 @@
#include "ActionManager.h"
#include "IPAMManagerDriver.h"
#include "Attribute.h"
#include "NebulaLog.h"
//Forward definitions
class IPAMRequest;
@ -30,6 +31,47 @@ class IPAMRequest;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class IPMAction : public ActionRequest
{
public:
enum Actions
{
REGISTER_ADDRESS_RANGE, /**< Register/Request a new IP network */
ALLOCATE_ADDRESS, /**< Request a specific IP (or range) */
GET_ADDRESS, /**< Request any free IP (or range) */
FREE_ADDRESS /**< Frees a previously requested IP */
};
IPMAction(Actions a, IPAMRequest *r):ActionRequest(ActionRequest::USER),
_action(a), _request(r){};
IPMAction(const IPMAction& o):ActionRequest(o._type), _action(o._action),
_request(o._request){};
Actions action() const
{
return _action;
}
IPAMRequest * request() const
{
return _request;
}
ActionRequest * clone() const
{
return new IPMAction(*this);
}
private:
Actions _action;
IPAMRequest * _request;
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
extern "C" void * ipamm_action_loop(void *arg);
class IPAMManager : public MadManager, public ActionListener
@ -44,22 +86,18 @@ public:
~IPAMManager(){};
enum Actions
{
REGISTER_ADDRESS_RANGE, /**< Register/Request a new IP network */
ALLOCATE_ADDRESS, /**< Request a specific IP (or range) */
GET_ADDRESS, /**< Request any free IP (or range) */
FREE_ADDRESS, /**< Frees a previously requested IP */
FINALIZE
};
/**
* Triggers specific action to the IPAM Manager. This function
* wraps the ActionManager trigger function.
* @param action to the IPAM Manager action
* @param request an IPAM request
*/
void trigger(Actions action, IPAMRequest* request);
void trigger(IPMAction::Actions action, IPAMRequest* request)
{
IPMAction ipam_ar(action, request);
am.trigger(ipam_ar);
}
/**
* This functions starts the associated listener thread, and creates a
@ -91,7 +129,7 @@ public:
*/
void finalize()
{
am.trigger(ACTION_FINALIZE,0);
am.finalize();
};
private:
@ -144,19 +182,6 @@ private:
(MadManager::get(0, name, ipam_driver_name));
};
/**
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * ipamm_action_loop(void *arg);
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(const std::string & action, void * arg);
/**
* Register (or requests) a new address range to the IPAM.
*/
@ -183,6 +208,29 @@ private:
* @return pointer to the IPAM driver to use, 0 on failure
*/
const IPAMManagerDriver * setup_request(IPAMRequest * ir);
/**
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * ipamm_action_loop(void *arg);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
void timer_action(const ActionRequest& ar)
{
check_time_outs_action();
};
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("IPM",Log::INFO,"Stopping IPAM Manager...");
MadManager::stop();
};
void user_action(const ActionRequest& ar);
};
#endif /*IPAM_MANAGER_H*/

View File

@ -20,6 +20,7 @@
#include "MadManager.h"
#include "ActionManager.h"
#include "ImageManagerDriver.h"
#include "NebulaLog.h"
using namespace std;
@ -79,7 +80,7 @@ public:
*/
void finalize()
{
am.trigger(ACTION_FINALIZE,0);
am.finalize();
};
/**************************************************************************/
@ -380,10 +381,19 @@ private:
const string& ds_data,
const string& extra_data);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
/**
* This function is executed periodically to monitor Datastores.
*/
void timer_action();
void timer_action(const ActionRequest& ar);
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("ImM",Log::INFO,"Stopping Image Manager...");
MadManager::stop();
};
};
#endif /*IMAGE_MANAGER_H*/

View File

@ -21,6 +21,7 @@
#include "ActionManager.h"
#include "InformationManagerDriver.h"
#include "MonitorThread.h"
#include "NebulaLog.h"
using namespace std;
@ -74,13 +75,12 @@ public:
return im_thread;
};
/**
*
*/
void finalize()
{
am.trigger(ACTION_FINALIZE,0);
am.finalize();
};
/**
@ -159,12 +159,6 @@ private:
*/
MonitorThreadPool mtpool;
/**
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * im_action_loop(void *arg);
/**
* Time in seconds to expire a monitoring action (5 minutes)
*/
@ -186,18 +180,25 @@ private:
};
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
void do_action(
const string & action,
void * arg);
friend void * im_action_loop(void *arg);
// ------------------------------------------------------------------------
// ActioListener Interface
// ------------------------------------------------------------------------
/**
* This function is executed periodically to monitor Nebula hosts.
*/
void timer_action();
void timer_action(const ActionRequest& ar);
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("InM",Log::INFO,"Stopping Information Manager...");
MadManager::stop();
};
};
#endif /*VIRTUAL_MACHINE_MANAGER_H*/

View File

@ -33,26 +33,18 @@ class TransferManager;
class DispatchManager;
class VirtualMachineManager;
class ImageManager;
struct RequestAttributes;
/**
* The Virtual Machine Life-cycle Manager module. This class is responsible for
* managing the life-cycle of a Virtual Machine.
*/
class LifeCycleManager : public ActionListener
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class LCMAction : public ActionRequest
{
public:
LifeCycleManager():
vmpool(0), hpool(0), ipool(0), sgpool(0), clpool(0), tm(0), vmm(0),
dm(0), imagem(0)
{
am.addListener(this);
};
~LifeCycleManager(){};
enum Actions
{
NONE,
SAVE_SUCCESS, /**< Sent by the VMM when a save action succeeds */
SAVE_FAILURE, /**< Sent by the VMM when a save action fails */
DEPLOY_SUCCESS, /**< Sent by the VMM deploy/restore/migrate succeeds*/
@ -108,21 +100,91 @@ 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, /**< Sent by DM to resize a disk */
FINALIZE
DISK_RESIZE_FAILURE /**< Sent by TM/VMM when a disk resize 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){};
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){};
Actions action() const
{
return _action;
}
int vm_id() const
{
return _vm_id;
}
int uid() const
{
return _uid;
}
int gid() const
{
return _gid;
}
int req_id() const
{
return _req_id;
}
ActionRequest * clone() const
{
return new LCMAction(*this);
}
private:
Actions _action;
int _vm_id;
int _uid;
int _gid;
int _req_id;
};
/**
* The Virtual Machine Life-cycle Manager module. This class is responsible for
* managing the life-cycle of a Virtual Machine.
*/
class LifeCycleManager : public ActionListener
{
public:
LifeCycleManager():
vmpool(0), hpool(0), ipool(0), sgpool(0), clpool(0), tm(0), vmm(0),
dm(0), imagem(0)
{
am.addListener(this);
};
~LifeCycleManager(){};
/**
* Triggers specific actions to the Life-cycle Manager. This function
* wraps the ActionManager trigger function.
* @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(
Actions action,
int vid);
void trigger(LCMAction::Actions action, int id, const RequestAttributes& r);
void trigger(LCMAction::Actions action, int id);
void finalize()
{
am.finalize();
}
/**
* This functions starts a new thread for the Life-cycle Manager. This
@ -151,7 +213,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
@ -215,21 +277,21 @@ private:
*/
ImageManager * imagem;
/**
* Function to execute the Manager action loop method within a new pthread
* (requires C linkage)
*/
friend void * lcm_action_loop(void *arg);
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(
const string & action,
void * arg);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("LCM",Log::INFO,"Stopping Life-cycle Manager...");
};
void user_action(const ActionRequest& ar);
/**
* Cleans up a VM, canceling any pending or ongoing action and closing
@ -240,115 +302,101 @@ 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);
// -------------------------------------------------------------------------
// 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 poweroff_action(int vid, bool hard, const LCMAction& la);
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_*/

View File

@ -20,6 +20,7 @@
#include "MadManager.h"
#include "ActionManager.h"
#include "MarketPlaceManagerDriver.h"
#include "NebulaLog.h"
extern "C" void * marketplace_action_loop(void *arg);
@ -80,7 +81,7 @@ public:
*/
void finalize()
{
am.trigger(ACTION_FINALIZE,0);
am.finalize();
};
/**
@ -197,13 +198,6 @@ private:
*/
friend void * marketplace_action_loop(void *arg);
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(const std::string& action, void * arg);
/**
* Formats an XML message for the MAD
*
@ -217,10 +211,20 @@ private:
const std::string& app_data,
const std::string& market_data,
const std::string& extra_data);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
/**
* This function is executed periodically to monitor marketplaces..
*/
void timer_action();
void timer_action(const ActionRequest& ar);
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("MKP", Log::INFO, "Stopping Marketplace Manager...");
MadManager::stop();
};
};
#endif /*MARKETPLACE_MANAGER_H*/

View File

@ -78,7 +78,7 @@ public:
*/
void finalize()
{
am.trigger(ACTION_FINALIZE,0);
am.finalize();
};
@ -162,21 +162,34 @@ private:
*/
xmlrpc_c::serverAbyss * AbyssServer;
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(const string & action, void * arg);
/**
* Register the XML-RPC API Calls
*/
void register_xml_methods();
int setup_socket();
};
// ------------------------------------------------------------------------
// ActioListener Interface
// ------------------------------------------------------------------------
virtual void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("ReM",Log::INFO,"Stopping Request Manager...");
pthread_cancel(rm_xml_server_thread);
pthread_join(rm_xml_server_thread,0);
NebulaLog::log("ReM",Log::INFO,"XML-RPC server stopped.");
delete AbyssServer;
if ( socket_fd != -1 )
{
close(socket_fd);
}
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -404,6 +404,9 @@ public:
};
~VirtualRouterDelete(){};
protected:
int drop(PoolObjectSQL * obj, bool resive, RequestAttributes& att);
};
/* ------------------------------------------------------------------------- */

View File

@ -65,7 +65,7 @@ public:
*/
void notify()
{
am.trigger(ActionListener::ACTION_FINALIZE,0);
am.finalize();
};
/**
@ -75,7 +75,7 @@ public:
{
time_out = time(0) + 90;//Requests will expire in 1.5 minutes
am.loop(0,0);
am.loop();
};
protected:
@ -91,11 +91,6 @@ protected:
* The ActionManager that will be notify when the request is ready.
*/
ActionManager am;
/**
* No actions defined for the request, just FINALIZE when done
*/
void do_action(const string &name, void *args){};
};
#endif /*SYNC_REQUEST_H_*/

View File

@ -29,23 +29,12 @@ extern "C" void * tm_action_loop(void *arg);
class VirtualMachineDisk;
class TransferManager : public MadManager, public ActionListener
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class TMAction : public ActionRequest
{
public:
TransferManager(
VirtualMachinePool * _vmpool,
HostPool * _hpool,
vector<const VectorAttribute*>& _mads):
MadManager(_mads),
vmpool(_vmpool),
hpool(_hpool)
{
am.addListener(this);
};
~TransferManager(){};
enum Actions
{
PROLOG,
@ -66,10 +55,53 @@ public:
SNAPSHOT_CREATE,
SNAPSHOT_REVERT,
SNAPSHOT_DELETE,
RESIZE,
FINALIZE
RESIZE
};
TMAction(Actions a, int v):ActionRequest(ActionRequest::USER),
_action(a), _vm_id(v){};
TMAction(const TMAction& o):ActionRequest(o._type), _action(o._action),
_vm_id(o._vm_id){};
Actions action() const
{
return _action;
}
int vm_id() const
{
return _vm_id;
}
ActionRequest * clone() const
{
return new TMAction(*this);
}
private:
Actions _action;
int _vm_id;
};
class TransferManager : public MadManager, public ActionListener
{
public:
TransferManager(
VirtualMachinePool * _vmpool,
HostPool * _hpool,
vector<const VectorAttribute*>& _mads):
MadManager(_mads),
vmpool(_vmpool),
hpool(_hpool)
{
am.addListener(this);
};
~TransferManager(){};
/**
* Triggers specific actions to the Information Manager. This function
* wraps the ActionManager trigger function.
@ -77,9 +109,17 @@ public:
* @param vid VM unique id. This is the argument of the passed to the
* invoked action.
*/
virtual void trigger(
Actions action,
int vid);
void trigger(TMAction::Actions action, int vid)
{
TMAction tm_ar(action, vid);
am.trigger(tm_ar);
}
void finalize()
{
am.finalize();
}
/**
* This functions starts the associated listener thread, and creates a
@ -279,14 +319,17 @@ private:
*/
friend void * tm_action_loop(void *arg);
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
*/
void do_action(
const string & action,
void * arg);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("TM",Log::INFO,"Stopping Transfer Manager...");
MadManager::stop();
};
void user_action(const ActionRequest& ar);
/**
* This function starts the prolog sequence

View File

@ -452,6 +452,16 @@ public:
return (previous_history!=0);
};
bool is_history_open() const
{
return (history != 0) && (history->etime == 0);
}
bool is_previous_history_open() const
{
return (previous_history != 0) && (previous_history->etime == 0);
}
/**
* Returns the VMM driver name for the current host. The hasHistory()
* function MUST be called before this one.
@ -637,15 +647,6 @@ public:
return previous_history->hostname;
};
/**
* Returns the reason that closed the history record in the previous host
* @return the reason to close the history record in the previous host
*/
const History::EndReason get_previous_reason() const
{
return previous_history->reason;
};
/**
* Returns the action that closed the current history record. The hasHistory()
* function MUST be called before this one.
@ -815,40 +816,48 @@ public:
history->epilog_etime=_etime;
};
/**
* Sets the reason that closed the history record
* @param _reason reason to close the history record
*/
void set_reason(History::EndReason _reason)
{
history->reason=_reason;
};
/**
* Sets the reason that closed the history record in the previous host
* @param _reason reason to close the history record in the previous host
*/
void set_previous_reason(History::EndReason _reason)
{
previous_history->reason=_reason;
};
/**
* Sets the action that closed the history record
* @param action that closed the history record
*/
void set_action(History::VMAction action)
void set_action(History::VMAction action, int uid, int gid, int req_id)
{
history->action = action;
history->uid = uid;
history->gid = gid;
history->req_id = req_id;
};
/**
* Sets the action that closed the history record in the previous host
* @param action that closed the history record in the previous host
*/
void set_previous_action(History::VMAction action)
void set_internal_action(History::VMAction action)
{
history->action = action;
history->uid = -1;
history->gid = -1;
history->req_id = -1;
};
void clear_action()
{
history->action = History::NONE_ACTION;
history->uid = -1;
history->gid = -1;
history->req_id = -1;
}
void set_previous_action(History::VMAction action, int uid, int gid,int rid)
{
previous_history->action = action;
previous_history->uid = uid;
previous_history->gid = gid;
previous_history->req_id = rid;
};
// ------------------------------------------------------------------------

View File

@ -29,19 +29,12 @@ using namespace std;
extern "C" void * vmm_action_loop(void *arg);
class VirtualMachineManager : public MadManager, public ActionListener
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class VMMAction : public ActionRequest
{
public:
VirtualMachineManager(
time_t _timer_period,
time_t _poll_period,
bool _do_vm_poll,
int _vm_limit,
vector<const VectorAttribute*>& _mads);
~VirtualMachineManager(){};
enum Actions
{
DEPLOY,
@ -57,9 +50,7 @@ public:
REBOOT,
RESET,
POLL,
TIMER,
DRIVER_CANCEL,
FINALIZE,
ATTACH,
DETACH,
ATTACH_NIC,
@ -71,6 +62,46 @@ public:
DISK_RESIZE
};
VMMAction(Actions a, int v):ActionRequest(ActionRequest::USER),
_action(a), _vm_id(v){};
VMMAction(const VMMAction& o):ActionRequest(o._type), _action(o._action),
_vm_id(o._vm_id){};
Actions action() const
{
return _action;
}
int vm_id() const
{
return _vm_id;
}
ActionRequest * clone() const
{
return new VMMAction(*this);
}
private:
Actions _action;
int _vm_id;
};
class VirtualMachineManager : public MadManager, public ActionListener
{
public:
VirtualMachineManager(
time_t _timer_period,
time_t _poll_period,
bool _do_vm_poll,
int _vm_limit,
vector<const VectorAttribute*>& _mads);
~VirtualMachineManager(){};
/**
* Triggers specific actions to the Virtual Machine Manager. This function
* wraps the ActionManager trigger function.
@ -78,9 +109,17 @@ public:
* @param vid VM unique id. This is the argument of the passed to the
* invoked action.
*/
virtual void trigger(
Actions action,
int vid);
void trigger(VMMAction::Actions action, int vid)
{
VMMAction vmm_ar(action, vid);
am.trigger(vmm_ar);
}
void finalize()
{
am.finalize();
}
/**
* This functions starts the associated listener thread, and creates a
@ -232,14 +271,22 @@ private:
(MadManager::get(0,_name,name));
};
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
/**
* The action function executed when an action is triggered.
* @param action the name of the action
* @param arg arguments for the action function
* This function is executed periodically to poll the running VMs
*/
void do_action(
const string & action,
void * arg);
void timer_action(const ActionRequest& ar);
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("VMM",Log::INFO,"Stopping Virtual Machine Manager...");
MadManager::stop();
};
void user_action(const ActionRequest& ar);
/**
* Function to format a VMM Driver message in the form:
@ -373,10 +420,6 @@ private:
void poll_action(
int vid);
/**
* This function is executed periodically to poll the running VMs
*/
void timer_action();
/**
* Attaches a new disk to a VM. The VM must have a disk with the

View File

@ -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_*/

View File

@ -30,13 +30,6 @@
<xs:element name="ESTIME" type="xs:integer"/>
<xs:element name="EETIME" type="xs:integer"/>
<!-- REASON values:
NONE = 0 History record is not closed yet
ERROR = 1 History record was closed because of an error
USER = 2 History record was closed because of a user action
-->
<xs:element name="REASON" type="xs:integer"/>
<!-- ACTION values:
NONE_ACTION = 0
MIGRATE_ACTION = 1
@ -67,6 +60,22 @@
DISK_SNAPSHOT_DELETE_ACTION = 26
TERMINATE_ACTION = 27
TERMINATE_HARD_ACTION = 28
DISK_RESIZE_ACTION = 29
DEPLOY_ACTION = 30
CHOWN_ACTION = 31
CHMOD_ACTION = 32
UPDATECONF_ACTION = 33
RENAME_ACTION = 34
RESIZE_ACTION = 35
UPDATE_ACTION = 36
SNAPSHOT_CREATE_ACTION = 37
SNAPSHOT_DELETE_ACTION = 38
SNAPSHOT_REVERT_ACTION = 39
DISK_SAVEAS_ACTION = 40
DISK_SNAPSHOT_REVERT_ACTION = 41
RECOVER_ACTION = 42
RETRY_ACTION = 43
MONITOR_ACTION = 44
-->
<xs:element name="ACTION" type="xs:integer"/>

View File

@ -87,13 +87,6 @@
<xs:element name="ESTIME" type="xs:integer"/>
<xs:element name="EETIME" type="xs:integer"/>
<!-- REASON values:
NONE = 0 History record is not closed yet
ERROR = 1 History record was closed because of an error
USER = 2 History record was closed because of a user action
-->
<xs:element name="REASON" type="xs:integer"/>
<!-- ACTION values:
NONE_ACTION = 0
MIGRATE_ACTION = 1
@ -124,6 +117,22 @@
DISK_SNAPSHOT_DELETE_ACTION = 26
TERMINATE_ACTION = 27
TERMINATE_HARD_ACTION = 28
DISK_RESIZE_ACTION = 29
DEPLOY_ACTION = 30
CHOWN_ACTION = 31
CHMOD_ACTION = 32
UPDATECONF_ACTION = 33
RENAME_ACTION = 34
RESIZE_ACTION = 35
UPDATE_ACTION = 36
SNAPSHOT_CREATE_ACTION = 37
SNAPSHOT_DELETE_ACTION = 38
SNAPSHOT_REVERT_ACTION = 39
DISK_SAVEAS_ACTION = 40
DISK_SNAPSHOT_REVERT_ACTION = 41
RECOVER_ACTION = 42
RETRY_ACTION = 43
MONITOR_ACTION = 44
-->
<xs:element name="ACTION" type="xs:integer"/>
</xs:sequence>

View File

@ -17,7 +17,6 @@
#include <climits>
#include "AclManager.h"
#include "NebulaLog.h"
#include "PoolObjectAuth.h"
/* -------------------------------------------------------------------------- */
@ -132,7 +131,7 @@ extern "C" void * acl_action_loop(void *arg)
aclm = static_cast<AclManager *>(arg);
aclm->am.loop(aclm->timer_period,0);
aclm->am.loop(aclm->timer_period);
NebulaLog::log("ACL",Log::INFO,"ACL Manager stopped.");
@ -174,7 +173,7 @@ void AclManager::finalize()
{
if (is_federation_slave)
{
am.trigger(ACTION_FINALIZE,0);
am.finalize();
}
else
{
@ -1262,24 +1261,3 @@ int AclManager::dump(ostringstream& oss)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void AclManager::do_action(const string &action, void * arg)
{
if (action == ACTION_TIMER)
{
select();
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("ACL",Log::INFO,"Stopping ACL Manager...");
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("ACL", Log::ERROR, oss);
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -16,7 +16,6 @@
#include "AuthManager.h"
#include "AuthRequest.h"
#include "NebulaLog.h"
#include "NebulaUtil.h"
#include "PoolObjectAuth.h"
#include "Nebula.h"
@ -124,7 +123,7 @@ extern "C" void * authm_action_loop(void *arg)
NebulaLog::log("AuM",Log::INFO,"Authorization Manager started.");
authm->am.loop(authm->timer_period, 0);
authm->am.loop(authm->timer_period);
NebulaLog::log("AuM",Log::INFO,"Authorization Manager stopped.");
@ -158,64 +157,25 @@ int AuthManager::start()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void AuthManager::trigger(Actions action, AuthRequest * request)
void AuthManager::user_action(const ActionRequest& ar)
{
string aname;
const AMAction& auth_ar = static_cast<const AMAction& >(ar);
AuthRequest * request = auth_ar.request();
switch (action)
if ( request == 0 )
{
case AUTHENTICATE:
aname = "AUTHENTICATE";
break;
case AUTHORIZE:
aname = "AUTHORIZE";
break;
case FINALIZE:
aname = ACTION_FINALIZE;
break;
default:
return;
}
am.trigger(aname,request);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void AuthManager::do_action(const string &action, void * arg)
{
AuthRequest * request;
request = static_cast<AuthRequest *>(arg);
if (action == "AUTHENTICATE" && request != 0)
switch(auth_ar.action())
{
authenticate_action(request);
}
else if (action == "AUTHORIZE" && request != 0)
{
authorize_action(request);
}
else if (action == ACTION_TIMER)
{
check_time_outs_action();
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("AuM",Log::INFO,"Stopping Authorization Manager...");
case AMAction::AUTHENTICATE:
authenticate_action(request);
break;
MadManager::stop();
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("AuM", Log::ERROR, oss);
case AMAction::AUTHORIZE:
authorize_action(request);
break;
}
}

View File

@ -21,11 +21,6 @@
:size: 16
:left: true
:REASON:
:desc: VM state change reason
:size: 4
:left: true
:START_TIME:
:desc: Start time
:size: 14
@ -58,7 +53,6 @@
- :VID
- :HOSTNAME
- :ACTION
- :REASON
- :START_TIME
- :END_TIME
- :MEMORY

View File

@ -135,10 +135,6 @@ class AcctHelper < OpenNebulaHelper::OneHelper
VirtualMachine.get_history_action d["ACTION"]
end
column :REASON, "VM state change reason", :left, :size=>4 do |d|
VirtualMachine.get_reason d["REASON"]
end
column :START_TIME, "Start time", :size=>14 do |d|
OpenNebulaHelper.time_to_str(d['STIME'])
end
@ -187,7 +183,7 @@ class AcctHelper < OpenNebulaHelper::OneHelper
OpenNebulaHelper.unit_to_str(total_disk_size * 1024.0, {})
end
default :VID, :HOSTNAME, :ACTION, :REASON, :START_TIME, :END_TIME, :MEMORY, :CPU, :NETRX, :NETTX, :DISK
default :VID, :HOSTNAME, :ACTION, :START_TIME, :END_TIME, :MEMORY, :CPU, :NETRX, :NETTX, :DISK
end
SHOWBACK_TABLE = CLIHelper::ShowTable.new(self.table_conf("oneshowback.yaml"), nil) do

View File

@ -1023,10 +1023,6 @@ in the frontend machine.
VirtualMachine.get_history_action d["ACTION"]
end
column :REASON, "VM state change reason", :left, :size=>4 do |d|
VirtualMachine.get_reason d["REASON"]
end
column :DS, "System Datastore", :size=>4 do |d|
d["DS_ID"]
end

View File

@ -16,22 +16,12 @@
#include "ActionManager.h"
#include <ctime>
#include <cerrno>
/* ************************************************************************** */
/* NeActionManager constants */
/* ActionManager constructor & destructor */
/* ************************************************************************** */
const string ActionListener::ACTION_TIMER = string("ACTION_TIMER");
const string ActionListener::ACTION_FINALIZE = string("ACTION_FINALIZE");
/* ************************************************************************** */
/* NeActionManager constructor & destructor */
/* ************************************************************************** */
ActionManager::ActionManager():
actions(),
listener(0)
ActionManager::ActionManager(): listener(0)
{
pthread_mutex_init(&mutex,0);
@ -51,15 +41,11 @@ ActionManager::~ActionManager()
/* NeActionManager public interface */
/* ************************************************************************** */
void ActionManager::trigger(
const string &action,
void * arg)
void ActionManager::trigger(const ActionRequest& ar )
{
ActionRequest request(action,arg);
lock();
actions.push(request);
actions.push(ar.clone());
pthread_cond_signal(&cond);
@ -69,16 +55,14 @@ void ActionManager::trigger(
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void ActionManager::loop(
time_t timer,
void * timer_args)
void ActionManager::loop(time_t timer, const ActionRequest& trequest)
{
struct timespec timeout;
int finalize = 0;
int rc;
struct timespec timeout;
ActionRequest action;
ActionRequest trequest(ActionListener::ACTION_TIMER,timer_args);
int finalize = 0;
int rc;
ActionRequest * action;
timeout.tv_sec = time(NULL) + timer;
timeout.tv_nsec = 0;
@ -95,7 +79,7 @@ void ActionManager::loop(
rc = pthread_cond_timedwait(&cond,&mutex, &timeout);
if ( rc == ETIMEDOUT )
actions.push(trequest);
actions.push(trequest.clone());
}
else
pthread_cond_wait(&cond,&mutex);
@ -106,17 +90,24 @@ void ActionManager::loop(
unlock();
listener->do_action(action.name,action.args);
listener->_do_action(*action);
if ( action.name == ActionListener::ACTION_TIMER )
switch(action->type())
{
timeout.tv_sec = time(NULL) + timer;
timeout.tv_nsec = 0;
}
else if ( action.name == ActionListener::ACTION_FINALIZE )
{
finalize = 1;
case ActionRequest::TIMER:
timeout.tv_sec = time(NULL) + timer;
timeout.tv_nsec = 0;
break;
case ActionRequest::FINALIZE:
finalize = 1;
break;
default:
break;
}
delete action;
}
}

View File

@ -34,7 +34,7 @@ extern "C" void * dm_action_loop(void *arg)
NebulaLog::log("DiM",Log::INFO,"Dispatch Manager started.");
dm->am.loop(0,0);
dm->am.loop();
NebulaLog::log("DiM",Log::INFO,"Dispatch Manager stopped.");
@ -53,7 +53,7 @@ int DispatchManager::start()
NebulaLog::log("DiM",Log::INFO,"Starting Dispatch Manager...");
rc = pthread_create(&dm_thread,&pattr,dm_action_loop,(void *) this);
rc = pthread_create(&dm_thread, &pattr, dm_action_loop,(void *) this);
return rc;
}
@ -61,102 +61,36 @@ int DispatchManager::start()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void DispatchManager::trigger(Actions action, int _vid)
void DispatchManager::user_action(const ActionRequest& ar)
{
int * vid;
string aname;
const DMAction& dm_ar = static_cast<const DMAction& >(ar);
int vid = dm_ar.vm_id();
vid = new int(_vid);
switch (action)
switch (dm_ar.action())
{
case SUSPEND_SUCCESS:
aname = "SUSPEND_SUCCESS";
break;
case DMAction::SUSPEND_SUCCESS:
suspend_success_action(vid);
break;
case STOP_SUCCESS:
aname = "STOP_SUCCESS";
break;
case DMAction::STOP_SUCCESS:
stop_success_action(vid);
break;
case UNDEPLOY_SUCCESS:
aname = "UNDEPLOY_SUCCESS";
break;
case DMAction::UNDEPLOY_SUCCESS:
undeploy_success_action(vid);
break;
case POWEROFF_SUCCESS:
aname = "POWEROFF_SUCCESS";
break;
case DMAction::POWEROFF_SUCCESS:
poweroff_success_action(vid);
break;
case DONE:
aname = "DONE";
break;
case DMAction::DONE:
done_action(vid);
break;
case RESUBMIT:
aname = "RESUBMIT";
break;
case FINALIZE:
aname = ACTION_FINALIZE;
break;
default:
delete vid;
return;
}
am.trigger(aname,vid);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void DispatchManager::do_action(const string &action, void * arg)
{
int vid;
ostringstream oss;
if (arg == 0)
{
return;
}
vid = *(static_cast<int *>(arg));
delete static_cast<int *>(arg);
if (action == "SUSPEND_SUCCESS")
{
suspend_success_action(vid);
}
else if (action == "STOP_SUCCESS")
{
stop_success_action(vid);
}
else if (action == "UNDEPLOY_SUCCESS")
{
undeploy_success_action(vid);
}
else if (action == "POWEROFF_SUCCESS")
{
poweroff_success_action(vid);
}
else if (action == "DONE")
{
done_action(vid);
}
else if (action == "RESUBMIT")
{
resubmit_action(vid);
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("DiM",Log::INFO,"Stopping Dispatch Manager...");
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("DiM", Log::ERROR, oss);
case DMAction::RESUBMIT:
resubmit_action(vid);
break;
}
}

View File

@ -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(LifeCycleManager::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(LifeCycleManager::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(LifeCycleManager::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(LifeCycleManager::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(LifeCycleManager::CANCEL,vid);
lcm->trigger(LCMAction::CANCEL, vid, ra);
}
else
{
lcm->trigger(LifeCycleManager::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(LifeCycleManager::UNDEPLOY_HARD,vid);
lcm->trigger(LCMAction::UNDEPLOY_HARD, vid, ra);
}
else
{
lcm->trigger(LifeCycleManager::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(LifeCycleManager::POWEROFF_HARD,vid);
lcm->trigger(LCMAction::POWEROFF_HARD, vid, ra);
}
else
{
lcm->trigger(LifeCycleManager::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(LifeCycleManager::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(LifeCycleManager::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(LifeCycleManager::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(LifeCycleManager::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(VirtualMachineManager::RESET,vid);
vmm->trigger(VMMAction::RESET, vid);
}
else
{
vmm->trigger(VirtualMachineManager::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(LifeCycleManager::DISK_LOCK_SUCCESS,vm->get_oid());
lcm->trigger(LCMAction::DISK_LOCK_SUCCESS, vid, ra);
}
else
{
lcm->trigger(LifeCycleManager::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;
@ -1008,11 +994,11 @@ int DispatchManager::delete_vm(VirtualMachine * vm, string& error)
if (is_public_host)
{
vmm->trigger(VirtualMachineManager::CLEANUP, vid);
vmm->trigger(VMMAction::CLEANUP, vid);
}
else
{
tm->trigger(TransferManager::EPILOG_DELETE, vid);
tm->trigger(TMAction::EPILOG_DELETE, vid);
}
free_vm_resources(vm);
@ -1022,11 +1008,11 @@ int DispatchManager::delete_vm(VirtualMachine * vm, string& error)
case VirtualMachine::UNDEPLOYED:
if (is_public_host)
{
vmm->trigger(VirtualMachineManager::CLEANUP, vid);
vmm->trigger(VMMAction::CLEANUP, vid);
}
else
{
tm->trigger(TransferManager::EPILOG_DELETE, vid);
tm->trigger(TMAction::EPILOG_DELETE, vid);
}
free_vm_resources(vm);
@ -1041,7 +1027,7 @@ int DispatchManager::delete_vm(VirtualMachine * vm, string& error)
break;
case VirtualMachine::ACTIVE:
lcm->trigger(LifeCycleManager::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;
@ -1103,7 +1090,8 @@ int DispatchManager::delete_recreate(VirtualMachine * vm, string& error)
case VirtualMachine::HOLD:
if (vm->hasHistory())
{
vm->set_action(History::DELETE_RECREATE_ACTION);
vm->set_action(History::DELETE_RECREATE_ACTION, ra.uid, ra.gid,
ra.req_id);
vmpool->update_history(vm);
}
@ -1116,7 +1104,7 @@ int DispatchManager::delete_recreate(VirtualMachine * vm, string& error)
break;
case VirtualMachine::ACTIVE: //Cleanup VM resources before PENDING
lcm->trigger(LifeCycleManager::DELETE_RECREATE, vm->get_oid());
lcm->trigger(LCMAction::DELETE_RECREATE, vm->get_oid(), ra);
break;
case VirtualMachine::DONE:
@ -1158,7 +1146,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;
@ -1229,8 +1218,7 @@ int DispatchManager::attach(int vid, VirtualMachineTemplate * tmpl, string & err
vm->set_etime(the_time);
vm->set_action(History::DISK_ATTACH_ACTION);
vm->set_reason(History::USER);
vm->set_action(History::DISK_ATTACH_ACTION, ra.uid, ra.gid, ra.req_id);
vmpool->update_history(vm);
@ -1246,11 +1234,11 @@ int DispatchManager::attach(int vid, VirtualMachineTemplate * tmpl, string & err
//-----------------------------------------------
vmm->trigger(VirtualMachineManager::ATTACH,vid);
vmm->trigger(VMMAction::ATTACH, vid);
}
else
{
tm->trigger(TransferManager::PROLOG_ATTACH, vid);
tm->trigger(TMAction::PROLOG_ATTACH, vid);
}
vmpool->update(vm);
@ -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;
@ -1322,8 +1308,7 @@ int DispatchManager::detach(
vm->set_etime(the_time);
vm->set_action(History::DISK_DETACH_ACTION);
vm->set_reason(History::USER);
vm->set_action(History::DISK_DETACH_ACTION, ra.uid, ra.gid, ra.req_id);
vmpool->update_history(vm);
@ -1341,14 +1326,14 @@ int DispatchManager::detach(
vm->set_state(VirtualMachine::HOTPLUG);
vmm->trigger(VirtualMachineManager::DETACH,vid);
vmm->trigger(VMMAction::DETACH, vid);
}
else
{
vm->set_state(VirtualMachine::ACTIVE);
vm->set_state(VirtualMachine::HOTPLUG_EPILOG_POWEROFF);
tm->trigger(TransferManager::EPILOG_DETACH, vid);
tm->trigger(TMAction::EPILOG_DETACH, vid);
}
vmpool->update(vm);
@ -1361,11 +1346,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 +1387,7 @@ int DispatchManager::snapshot_create(
vm->unlock();
vmm->trigger(VirtualMachineManager::SNAPSHOT_CREATE,vid);
vmm->trigger(VMMAction::SNAPSHOT_CREATE, vid);
return 0;
}
@ -1413,10 +1395,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 +1451,7 @@ int DispatchManager::snapshot_revert(
vm->unlock();
vmm->trigger(VirtualMachineManager::SNAPSHOT_REVERT,vid);
vmm->trigger(VMMAction::SNAPSHOT_REVERT, vid);
return 0;
}
@ -1479,10 +1459,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 +1514,7 @@ int DispatchManager::snapshot_delete(
vm->unlock();
vmm->trigger(VirtualMachineManager::SNAPSHOT_DELETE,vid);
vmm->trigger(VMMAction::SNAPSHOT_DELETE, vid);
return 0;
}
@ -1544,10 +1522,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;
@ -1612,8 +1588,7 @@ int DispatchManager::attach_nic(
vm->set_etime(the_time);
vm->set_action(History::NIC_ATTACH_ACTION);
vm->set_reason(History::USER);
vm->set_action(History::NIC_ATTACH_ACTION, ra.uid, ra.gid, ra.req_id);
vmpool->update_history(vm);
@ -1629,7 +1604,7 @@ int DispatchManager::attach_nic(
//-----------------------------------------------
vmm->trigger(VirtualMachineManager::ATTACH_NIC,vid);
vmm->trigger(VMMAction::ATTACH_NIC, vid);
}
else
{
@ -1648,10 +1623,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;
@ -1706,8 +1679,7 @@ int DispatchManager::detach_nic(
vm->set_etime(the_time);
vm->set_action(History::NIC_DETACH_ACTION);
vm->set_reason(History::USER);
vm->set_action(History::NIC_DETACH_ACTION, ra.uid, ra.gid, ra.req_id);
vmpool->update_history(vm);
@ -1731,7 +1703,7 @@ int DispatchManager::detach_nic(
//---------------------------------------------------
vmm->trigger(VirtualMachineManager::DETACH_NIC,vid);
vmm->trigger(VMMAction::DETACH_NIC, vid);
}
else
{
@ -1750,12 +1722,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 +1798,7 @@ int DispatchManager::disk_snapshot_create(
{
case VirtualMachine::POWEROFF:
case VirtualMachine::SUSPENDED:
tm->trigger(TransferManager::SNAPSHOT_CREATE,vid);
tm->trigger(TMAction::SNAPSHOT_CREATE, vid);
break;
case VirtualMachine::ACTIVE:
@ -1842,8 +1810,8 @@ int DispatchManager::disk_snapshot_create(
vm->set_etime(the_time);
vm->set_action(History::DISK_SNAPSHOT_CREATE_ACTION);
vm->set_reason(History::USER);
vm->set_action(History::DISK_SNAPSHOT_CREATE_ACTION, ra.uid, ra.gid,
ra.req_id);
vmpool->update_history(vm);
@ -1857,7 +1825,7 @@ int DispatchManager::disk_snapshot_create(
vmpool->update_history(vm);
vmm->trigger(VirtualMachineManager::DISK_SNAPSHOT_CREATE, vid);
vmm->trigger(VMMAction::DISK_SNAPSHOT_CREATE, vid);
break;
default: break;
@ -1869,11 +1837,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;
@ -1939,7 +1904,7 @@ int DispatchManager::disk_snapshot_revert(
vm->unlock();
tm->trigger(TransferManager::SNAPSHOT_REVERT, vid);
tm->trigger(TMAction::SNAPSHOT_REVERT, vid);
return 0;
}
@ -1947,11 +1912,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;
@ -2044,8 +2006,8 @@ int DispatchManager::disk_snapshot_delete(
vm->set_etime(the_time);
vm->set_action(History::DISK_SNAPSHOT_DELETE_ACTION);
vm->set_reason(History::USER);
vm->set_action(History::DISK_SNAPSHOT_DELETE_ACTION, ra.uid, ra.gid,
ra.req_id);
vmpool->update_history(vm);
@ -2061,7 +2023,7 @@ int DispatchManager::disk_snapshot_delete(
case VirtualMachine::POWEROFF:
case VirtualMachine::SUSPENDED:
tm->trigger(TransferManager::SNAPSHOT_DELETE, vid);
tm->trigger(TMAction::SNAPSHOT_DELETE, vid);
break;
default: break;
@ -2073,11 +2035,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;
@ -2150,7 +2109,7 @@ int DispatchManager::disk_resize(
{
case VirtualMachine::POWEROFF:
case VirtualMachine::UNDEPLOYED:
tm->trigger(TransferManager::RESIZE, vid);
tm->trigger(TMAction::RESIZE, vid);
break;
case VirtualMachine::ACTIVE:
@ -2162,8 +2121,8 @@ int DispatchManager::disk_resize(
vm->set_etime(the_time);
vm->set_action(History::DISK_RESIZE_ACTION);
vm->set_reason(History::USER);
vm->set_action(History::DISK_RESIZE_ACTION, ra.uid, ra.gid,
ra.req_id);
vmpool->update_history(vm);
@ -2177,7 +2136,7 @@ int DispatchManager::disk_resize(
vmpool->update_history(vm);
vmm->trigger(VirtualMachineManager::DISK_RESIZE, vid);
vmm->trigger(VMMAction::DISK_RESIZE, vid);
break;
default: break;

View File

@ -83,7 +83,7 @@ void DispatchManager::stop_success_action(int vid)
//Set history action field to perform the right TM command on resume
if (vm->get_action() == History::NONE_ACTION)
{
vm->set_action(History::STOP_ACTION);
vm->set_internal_action(History::STOP_ACTION);
vmpool->update_history(vm);
}
@ -130,7 +130,7 @@ void DispatchManager::undeploy_success_action(int vid)
//Set history action field to perform the right TM command on resume
if (vm->get_action() == History::NONE_ACTION)
{
vm->set_action(History::UNDEPLOY_ACTION);
vm->set_internal_action(History::UNDEPLOY_ACTION);
vmpool->update_history(vm);
}

View File

@ -35,7 +35,7 @@ extern "C" void * hm_action_loop(void *arg)
hm = static_cast<HookManager *>(arg);
hm->am.loop(0,0);
hm->am.loop();
NebulaLog::log("HKM",Log::INFO,"Hook Manager stopped.");
@ -112,23 +112,3 @@ int HookManager::start()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void HookManager::do_action(const string &action, void * arg)
{
if (action == ACTION_FINALIZE)
{
NebulaLog::log("HKM",Log::INFO,"Stopping Hook Manager...");
MadManager::stop();
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("HKM", Log::ERROR, oss);
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -15,7 +15,6 @@
/* -------------------------------------------------------------------------- */
#include "InformationManager.h"
#include "NebulaLog.h"
#include "Cluster.h"
#include "Nebula.h"
@ -42,7 +41,7 @@ extern "C" void * im_action_loop(void *arg)
im = static_cast<InformationManager *>(arg);
im->am.loop(im->timer_period,0);
im->am.loop(im->timer_period);
NebulaLog::log("InM",Log::INFO,"Information Manager stopped.");
@ -116,29 +115,6 @@ int InformationManager::start()
return rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void InformationManager::do_action(const string &action, void * arg)
{
if (action == ACTION_TIMER)
{
timer_action();
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("InM",Log::INFO,"Stopping Information Manager...");
MadManager::stop();
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("InM", Log::ERROR, oss);
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -179,7 +155,7 @@ int InformationManager::start_monitor(Host * host, bool update_remotes)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void InformationManager::timer_action()
void InformationManager::timer_action(const ActionRequest& ar)
{
static int mark = 0;

View File

@ -106,7 +106,7 @@ void MonitorThread::do_message()
for (set<int>::iterator it = vm_ids.begin(); it != vm_ids.end(); it++)
{
lcm->trigger(LifeCycleManager::MONITOR_DONE, *it);
lcm->trigger(LCMAction::MONITOR_DONE, *it);
}
delete hinfo;
@ -245,7 +245,7 @@ void MonitorThread::do_message()
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY))
{
lcm->trigger(LifeCycleManager::MONITOR_POWEROFF, *its);
lcm->trigger(LCMAction::MONITOR_POWEROFF, *its);
}
// If the guest is shut down before the poll reports it at least
// once, the VM gets stuck in running. An individual poll action
@ -255,7 +255,7 @@ void MonitorThread::do_message()
vm->get_lcm_state() == VirtualMachine::RUNNING &&
(time(0) - vm->get_running_stime() > 300))
{
vmm->trigger(VirtualMachineManager::POLL,vm->get_oid());
vmm->trigger(VMMAction::POLL,vm->get_oid());
}
vm->unlock();

View File

@ -805,7 +805,7 @@ void Image::set_state(ImageState _state)
for(set<int>::iterator i = vms.begin(); i != vms.end(); i++)
{
lcm->trigger(LifeCycleManager::DISK_LOCK_FAILURE, *i);
lcm->trigger(LCMAction::DISK_LOCK_FAILURE, *i);
}
}
@ -866,7 +866,7 @@ void Image::set_state_unlock()
for(set<int>::iterator i = vms.begin(); i != vms.end(); i++)
{
lcm->trigger(LifeCycleManager::DISK_LOCK_SUCCESS, *i);
lcm->trigger(LCMAction::DISK_LOCK_SUCCESS, *i);
}
}
}

View File

@ -15,7 +15,6 @@
/* -------------------------------------------------------------------------- */
#include "ImageManager.h"
#include "NebulaLog.h"
#include "ImagePool.h"
#include "Nebula.h"
@ -37,7 +36,7 @@ extern "C" void * image_action_loop(void *arg)
im = static_cast<ImageManager *>(arg);
im->am.loop(im->timer_period, 0);
im->am.loop(im->timer_period);
NebulaLog::log("ImM",Log::INFO,"Image Manager stopped.");
@ -114,31 +113,7 @@ int ImageManager::start()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void ImageManager::do_action(const string &action, void * arg)
{
if (action == ACTION_TIMER)
{
timer_action();
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("ImM",Log::INFO,"Stopping Image Manager...");
MadManager::stop();
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("ImM", Log::ERROR, oss);
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void ImageManager::timer_action()
void ImageManager::timer_action(const ActionRequest& ar)
{
static int mark = 0;
static int tics = monitor_period;

View File

@ -469,7 +469,7 @@ static int mkfs_action(istringstream& is,
goto error_save_state;
}
tm->trigger(TransferManager::SAVEAS_HOT, vm_id);
tm->trigger(TMAction::SAVEAS_HOT, vm_id);
vmpool->update(vm);

View File

@ -16,7 +16,6 @@
#include "IPAMManager.h"
#include "IPAMRequest.h"
#include "NebulaLog.h"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -39,7 +38,7 @@ extern "C" void * ipamm_action_loop(void *arg)
NebulaLog::log("IPM",Log::INFO,"IPAM Manager started.");
ipamm->am.loop(ipamm->timer_period, 0);
ipamm->am.loop(ipamm->timer_period);
NebulaLog::log("IPM",Log::INFO,"IPAM Manager stopped.");
@ -73,78 +72,34 @@ int IPAMManager::start()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void IPAMManager::trigger(Actions action, IPAMRequest * request)
void IPAMManager::user_action(const ActionRequest& ar)
{
string aname;
const IPMAction& ipam_ar = static_cast<const IPMAction&>(ar);
switch (action)
IPAMRequest * request = ipam_ar.request();
if ( request == 0 )
{
case REGISTER_ADDRESS_RANGE:
aname = "REGISTER_ADDRESS_RANGE";
break;
case ALLOCATE_ADDRESS:
aname = "ALLOCATE_ADDRESS";
break;
case GET_ADDRESS:
aname = "GET_ADDRESS";
break;
case FREE_ADDRESS:
aname = "FREE_ADDRESS";
break;
case FINALIZE:
aname = ACTION_FINALIZE;
break;
default:
return;
}
am.trigger(aname,request);
}
switch(ipam_ar.action())
{
case IPMAction::REGISTER_ADDRESS_RANGE:
register_address_range_action(request);
break;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
case IPMAction::ALLOCATE_ADDRESS:
allocate_address_action(request);
break;
void IPAMManager::do_action(const string &action, void * arg)
{
IPAMRequest * request = static_cast<IPAMRequest *>(arg);
case IPMAction::GET_ADDRESS:
get_address_action(request);
break;
if (action == "REGISTER_ADDRESS_RANGE" && request != 0)
{
register_address_range_action(request);
}
else if (action == "ALLOCATE_ADDRESS" && request != 0)
{
allocate_address_action(request);
}
else if (action == "GET_ADDRESS" && request != 0)
{
get_address_action(request);
}
else if (action == "FREE_ADDRESS" && request != 0)
{
free_address_action(request);
}
else if (action == ACTION_TIMER)
{
check_time_outs_action();
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("IPM",Log::INFO,"Stopping IPAM Manager...");
MadManager::stop();
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("IPM", Log::ERROR, oss);
case IPMAction::FREE_ADDRESS:
free_address_action(request);
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@
#include "LifeCycleManager.h"
#include "Nebula.h"
#include "NebulaLog.h"
#include "Request.h"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -34,7 +35,7 @@ extern "C" void * lcm_action_loop(void *arg)
NebulaLog::log("LCM",Log::INFO,"Life-cycle Manager started.");
lcm->am.loop(0,0);
lcm->am.loop();
NebulaLog::log("LCM",Log::INFO,"Life-cycle Manager stopped.");
@ -80,502 +81,207 @@ void LifeCycleManager::init_managers()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void LifeCycleManager::trigger(Actions action, int _vid)
void LifeCycleManager::trigger(LCMAction::Actions action, int vid,
const RequestAttributes& ra)
{
int * vid;
string aname;
LCMAction lcm_ar(action, vid, ra.uid, ra.gid, ra.req_id);
vid = new int(_vid);
am.trigger(lcm_ar);
}
switch (action)
{
case SAVE_SUCCESS:
aname = "SAVE_SUCCESS";
break;
void LifeCycleManager::trigger(LCMAction::Actions action, int vid)
{
LCMAction lcm_ar(action, vid, -1, -1, -1);
case SAVE_FAILURE:
aname = "SAVE_FAILURE";
break;
case DEPLOY_SUCCESS:
aname = "DEPLOY_SUCCESS";
break;
case DEPLOY_FAILURE:
aname = "DEPLOY_FAILURE";
break;
case SHUTDOWN_SUCCESS:
aname = "SHUTDOWN_SUCCESS";
break;
case SHUTDOWN_FAILURE:
aname = "SHUTDOWN_FAILURE";
break;
case CANCEL_SUCCESS:
aname = "CANCEL_SUCCESS";
break;
case CANCEL_FAILURE:
aname = "CANCEL_FAILURE";
break;
case MONITOR_SUSPEND:
aname = "MONITOR_SUSPEND";
break;
case MONITOR_DONE:
aname = "MONITOR_DONE";
break;
case MONITOR_POWEROFF:
aname = "MONITOR_POWEROFF";
break;
case MONITOR_POWERON:
aname = "MONITOR_POWERON";
break;
case PROLOG_SUCCESS:
aname = "PROLOG_SUCCESS";
break;
case PROLOG_FAILURE:
aname = "PROLOG_FAILURE";
break;
case EPILOG_SUCCESS:
aname = "EPILOG_SUCCESS";
break;
case EPILOG_FAILURE:
aname = "EPILOG_FAILURE";
break;
case ATTACH_SUCCESS:
aname = "ATTACH_SUCCESS";
break;
case ATTACH_FAILURE:
aname = "ATTACH_FAILURE";
break;
case DETACH_SUCCESS:
aname = "DETACH_SUCCESS";
break;
case DETACH_FAILURE:
aname = "DETACH_FAILURE";
break;
case SAVEAS_SUCCESS:
aname = "SAVEAS_SUCCESS";
break;
case SAVEAS_FAILURE:
aname = "SAVEAS_FAILURE";
break;
case ATTACH_NIC_SUCCESS:
aname = "ATTACH_NIC_SUCCESS";
break;
case ATTACH_NIC_FAILURE:
aname = "ATTACH_NIC_FAILURE";
break;
case DETACH_NIC_SUCCESS:
aname = "DETACH_NIC_SUCCESS";
break;
case DETACH_NIC_FAILURE:
aname = "DETACH_NIC_FAILURE";
break;
case CLEANUP_SUCCESS:
aname = "CLEANUP_SUCCESS";
break;
case CLEANUP_FAILURE:
aname = "CLEANUP_FAILURE";
break;
case SNAPSHOT_CREATE_SUCCESS:
aname = "SNAPSHOT_CREATE_SUCCESS";
break;
case SNAPSHOT_CREATE_FAILURE:
aname = "SNAPSHOT_CREATE_FAILURE";
break;
case SNAPSHOT_REVERT_SUCCESS:
aname = "SNAPSHOT_REVERT_SUCCESS";
break;
case SNAPSHOT_REVERT_FAILURE:
aname = "SNAPSHOT_REVERT_FAILURE";
break;
case SNAPSHOT_DELETE_SUCCESS:
aname = "SNAPSHOT_DELETE_SUCCESS";
break;
case SNAPSHOT_DELETE_FAILURE:
aname = "SNAPSHOT_DELETE_FAILURE";
break;
case DISK_SNAPSHOT_SUCCESS:
aname = "DISK_SNAPSHOT_SUCCESS";
break;
case DISK_SNAPSHOT_FAILURE:
aname = "DISK_SNAPSHOT_FAILURE";
break;
case DISK_LOCK_SUCCESS:
aname = "DISK_LOCK_SUCCESS";
break;
case DISK_LOCK_FAILURE:
aname = "DISK_LOCK_FAILURE";
break;
case DISK_RESIZE_SUCCESS:
aname = "DISK_RESIZE_SUCCESS";
break;
case DISK_RESIZE_FAILURE:
aname = "DISK_RESIZE_FAILURE";
break;
case DEPLOY:
aname = "DEPLOY";
break;
case SUSPEND:
aname = "SUSPEND";
break;
case RESTORE:
aname = "RESTORE";
break;
case STOP:
aname = "STOP";
break;
case CANCEL:
aname = "CANCEL";
break;
case MIGRATE:
aname = "MIGRATE";
break;
case LIVE_MIGRATE:
aname = "LIVE_MIGRATE";
break;
case SHUTDOWN:
aname = "SHUTDOWN";
break;
case UNDEPLOY:
aname = "UNDEPLOY";
break;
case UNDEPLOY_HARD:
aname = "UNDEPLOY_HARD";
break;
case RESTART:
aname = "RESTART";
break;
case DELETE:
aname = "DELETE";
break;
case DELETE_RECREATE:
aname = "DELETE_RECREATE";
break;
case FINALIZE:
aname = ACTION_FINALIZE;
break;
case POWEROFF:
aname = "POWEROFF";
break;
case POWEROFF_HARD:
aname = "POWEROFF_HARD";
break;
case UPDATESG:
aname = "UPDATESG";
break;
default:
delete vid;
return;
}
am.trigger(aname,vid);
am.trigger(lcm_ar);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void LifeCycleManager::do_action(const string &action, void * arg)
void LifeCycleManager::user_action(const ActionRequest& ar)
{
int vid;
ostringstream oss;
const LCMAction& la = static_cast<const LCMAction& >(ar);
int vid = la.vm_id();
if (arg == 0)
{
return;
}
vid = *(static_cast<int *>(arg));
delete static_cast<int *>(arg);
if (action == "SAVE_SUCCESS")
switch (la.action())
{
// -------------------------------------------------------------------------
// Internal Actions, triggered by OpenNebula components & drivers
// -------------------------------------------------------------------------
case LCMAction::SAVE_SUCCESS:
save_success_action(vid);
}
else if (action == "SAVE_FAILURE")
{
break;
case LCMAction::SAVE_FAILURE:
save_failure_action(vid);
}
else if (action == "DEPLOY_SUCCESS")
{
break;
case LCMAction::DEPLOY_SUCCESS:
deploy_success_action(vid);
}
else if (action == "DEPLOY_FAILURE")
{
break;
case LCMAction::DEPLOY_FAILURE:
deploy_failure_action(vid);
}
else if (action == "SHUTDOWN_SUCCESS")
{
break;
case LCMAction::SHUTDOWN_SUCCESS:
shutdown_success_action(vid);
}
else if (action == "SHUTDOWN_FAILURE")
{
break;
case LCMAction::SHUTDOWN_FAILURE:
shutdown_failure_action(vid);
}
else if (action == "CANCEL_SUCCESS")
{
break;
case LCMAction::CANCEL_SUCCESS:
shutdown_success_action(vid);
}
else if (action == "CANCEL_FAILURE")
{
break;
case LCMAction::CANCEL_FAILURE:
shutdown_failure_action(vid);
}
else if (action == "MONITOR_SUSPEND")
{
break;
case LCMAction::MONITOR_SUSPEND:
monitor_suspend_action(vid);
}
else if (action == "MONITOR_DONE")
{
break;
case LCMAction::MONITOR_DONE:
monitor_done_action(vid);
}
else if (action == "MONITOR_POWEROFF")
{
break;
case LCMAction::MONITOR_POWEROFF:
monitor_poweroff_action(vid);
}
else if (action == "MONITOR_POWERON")
{
break;
case LCMAction::MONITOR_POWERON:
monitor_poweron_action(vid);
}
else if (action == "PROLOG_SUCCESS")
{
break;
case LCMAction::PROLOG_SUCCESS:
prolog_success_action(vid);
}
else if (action == "PROLOG_FAILURE")
{
break;
case LCMAction::PROLOG_FAILURE:
prolog_failure_action(vid);
}
else if (action == "EPILOG_SUCCESS")
{
break;
case LCMAction::EPILOG_SUCCESS:
epilog_success_action(vid);
}
else if (action == "EPILOG_FAILURE")
{
break;
case LCMAction::EPILOG_FAILURE:
epilog_failure_action(vid);
}
else if (action == "ATTACH_SUCCESS")
{
break;
case LCMAction::ATTACH_SUCCESS:
attach_success_action(vid);
}
else if (action == "ATTACH_FAILURE")
{
break;
case LCMAction::ATTACH_FAILURE:
attach_failure_action(vid);
}
else if (action == "DETACH_SUCCESS")
{
break;
case LCMAction::DETACH_SUCCESS:
detach_success_action(vid);
}
else if (action == "DETACH_FAILURE")
{
break;
case LCMAction::DETACH_FAILURE:
detach_failure_action(vid);
}
else if (action == "SAVEAS_SUCCESS")
{
break;
case LCMAction::SAVEAS_SUCCESS:
saveas_success_action(vid);
}
else if (action == "SAVEAS_FAILURE")
{
break;
case LCMAction::SAVEAS_FAILURE:
saveas_failure_action(vid);
}
else if (action == "ATTACH_NIC_SUCCESS")
{
break;
case LCMAction::ATTACH_NIC_SUCCESS:
attach_nic_success_action(vid);
}
else if (action == "ATTACH_NIC_FAILURE")
{
break;
case LCMAction::ATTACH_NIC_FAILURE:
attach_nic_failure_action(vid);
}
else if (action == "DETACH_NIC_SUCCESS")
{
break;
case LCMAction::DETACH_NIC_SUCCESS:
detach_nic_success_action(vid);
}
else if (action == "DETACH_NIC_FAILURE")
{
break;
case LCMAction::DETACH_NIC_FAILURE:
detach_nic_failure_action(vid);
}
else if (action == "CLEANUP_SUCCESS")
{
break;
case LCMAction::CLEANUP_SUCCESS:
cleanup_callback_action(vid);
}
else if (action == "CLEANUP_FAILURE")
{
break;
case LCMAction::CLEANUP_FAILURE:
cleanup_callback_action(vid);
}
else if (action == "SNAPSHOT_CREATE_SUCCESS")
{
break;
case LCMAction::SNAPSHOT_CREATE_SUCCESS:
snapshot_create_success(vid);
}
else if (action == "SNAPSHOT_CREATE_FAILURE")
{
break;
case LCMAction::SNAPSHOT_CREATE_FAILURE:
snapshot_create_failure(vid);
}
else if (action == "SNAPSHOT_REVERT_SUCCESS")
{
break;
case LCMAction::SNAPSHOT_REVERT_SUCCESS:
snapshot_revert_success(vid);
}
else if (action == "SNAPSHOT_REVERT_FAILURE")
{
break;
case LCMAction::SNAPSHOT_REVERT_FAILURE:
snapshot_revert_failure(vid);
}
else if (action == "SNAPSHOT_DELETE_SUCCESS")
{
break;
case LCMAction::SNAPSHOT_DELETE_SUCCESS:
snapshot_delete_success(vid);
}
else if (action == "SNAPSHOT_DELETE_FAILURE")
{
break;
case LCMAction::SNAPSHOT_DELETE_FAILURE:
snapshot_delete_failure(vid);
}
else if (action == "DISK_SNAPSHOT_SUCCESS")
{
break;
case LCMAction::DISK_SNAPSHOT_SUCCESS:
disk_snapshot_success(vid);
}
else if (action == "DISK_SNAPSHOT_FAILURE")
{
break;
case LCMAction::DISK_SNAPSHOT_FAILURE:
disk_snapshot_failure(vid);
}
else if (action == "DISK_LOCK_SUCCESS")
{
break;
case LCMAction::DISK_LOCK_SUCCESS:
disk_lock_success(vid);
}
else if (action == "DISK_LOCK_FAILURE")
{
break;
case LCMAction::DISK_LOCK_FAILURE:
disk_lock_failure(vid);
}
else if (action == "DISK_RESIZE_SUCCESS")
{
break;
case LCMAction::DISK_RESIZE_SUCCESS:
disk_resize_success(vid);
}
else if (action == "DISK_RESIZE_FAILURE")
{
break;
case LCMAction::DISK_RESIZE_FAILURE:
disk_resize_failure(vid);
}
else if (action == "DEPLOY")
{
deploy_action(vid);
}
else if (action == "SUSPEND")
{
suspend_action(vid);
}
else if (action == "RESTORE")
{
restore_action(vid);
}
else if (action == "STOP")
{
stop_action(vid);
}
else if (action == "CANCEL")
{
shutdown_action(vid, true);
}
else if (action == "MIGRATE")
{
migrate_action(vid);
}
else if (action == "LIVE_MIGRATE")
{
live_migrate_action(vid);
}
else if (action == "SHUTDOWN")
{
shutdown_action(vid, false);
}
else if (action == "UNDEPLOY")
{
undeploy_action(vid, false);
}
else if (action == "UNDEPLOY_HARD")
{
undeploy_action(vid, true);
}
else if (action == "RESTART")
{
restart_action(vid);
}
else if (action == "DELETE")
{
delete_action(vid);
}
else if (action == "DELETE_RECREATE")
{
delete_recreate_action(vid);
}
else if (action == "POWEROFF")
{
poweroff_action(vid);
}
else if (action == "POWEROFF_HARD")
{
poweroff_hard_action(vid);
}
else if (action == "UPDATESG")
{
updatesg_action(vid);
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("LCM",Log::INFO,"Stopping Life-cycle Manager...");
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("LCM", Log::ERROR, oss);
break;
// -------------------------------------------------------------------------
// External Actions, triggered by user requests
// -------------------------------------------------------------------------
case LCMAction::DEPLOY:
deploy_action(la);
break;
case LCMAction::SUSPEND:
suspend_action(la);
break;
case LCMAction::RESTORE:
restore_action(la);
break;
case LCMAction::STOP:
stop_action(la);
break;
case LCMAction::CANCEL:
shutdown_action(la, true);
break;
case LCMAction::MIGRATE:
migrate_action(la);
break;
case LCMAction::LIVE_MIGRATE:
live_migrate_action(la);
break;
case LCMAction::SHUTDOWN:
shutdown_action(la, false);
break;
case LCMAction::UNDEPLOY:
undeploy_action(la, false);
break;
case LCMAction::UNDEPLOY_HARD:
undeploy_action(la, true);
break;
case LCMAction::RESTART:
restart_action(la);
break;
case LCMAction::DELETE:
delete_action(la);
break;
case LCMAction::DELETE_RECREATE:
delete_recreate_action(la);
break;
case LCMAction::POWEROFF:
poweroff_action(la);
break;
case LCMAction::POWEROFF_HARD:
poweroff_hard_action(la);
break;
case LCMAction::UPDATESG:
updatesg_action(la);
break;
case LCMAction::NONE:
break;
}
}

View File

@ -63,8 +63,6 @@ void LifeCycleManager::save_success_action(int vid)
vm->set_previous_running_etime(the_time);
vm->set_previous_reason(History::USER);
vmpool->update_previous_history(vm);
vm->set_prolog_stime(the_time);
@ -77,7 +75,7 @@ void LifeCycleManager::save_success_action(int vid)
//----------------------------------------------------
tm->trigger(TransferManager::PROLOG_MIGR,vid);
tm->trigger(TMAction::PROLOG_MIGR,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::SAVE_SUSPEND)
{
@ -102,13 +100,11 @@ void LifeCycleManager::save_success_action(int vid)
vm->set_vm_info();
vm->set_reason(History::USER);
vmpool->update_history(vm);
//----------------------------------------------------
dm->trigger(DispatchManager::SUSPEND_SUCCESS,vid);
dm->trigger(DMAction::SUSPEND_SUCCESS,vid);
}
else if ( vm->get_lcm_state() == VirtualMachine::SAVE_STOP)
{
@ -133,13 +129,11 @@ void LifeCycleManager::save_success_action(int vid)
vm->set_running_etime(the_time);
vm->set_reason(History::USER);
vmpool->update_history(vm);
//----------------------------------------------------
tm->trigger(TransferManager::EPILOG_STOP,vid);
tm->trigger(TMAction::EPILOG_STOP,vid);
}
else
{
@ -180,8 +174,6 @@ void LifeCycleManager::save_failure_action(int vid)
vm->set_vm_info();
vm->set_reason(History::ERROR);
vmpool->update_history(vm);
vm->get_requirements(cpu, mem, disk, pci);
@ -194,8 +186,6 @@ void LifeCycleManager::save_failure_action(int vid)
vm->set_previous_running_etime(the_time);
vm->set_previous_reason(History::USER);
vmpool->update_previous_history(vm);
// --- Add new record by copying the previous one
@ -217,7 +207,7 @@ void LifeCycleManager::save_failure_action(int vid)
//----------------------------------------------------
vmm->trigger(VirtualMachineManager::POLL,vid);
vmm->trigger(VMMAction::POLL,vid);
}
else if ( vm->get_lcm_state() == VirtualMachine::SAVE_SUSPEND ||
vm->get_lcm_state() == VirtualMachine::SAVE_STOP )
@ -230,7 +220,7 @@ void LifeCycleManager::save_failure_action(int vid)
vmpool->update(vm);
vm->set_action(History::NONE_ACTION);
vm->clear_action();
vmpool->update_history(vm);
@ -239,7 +229,7 @@ void LifeCycleManager::save_failure_action(int vid)
//----------------------------------------------------
vmm->trigger(VirtualMachineManager::POLL,vid);
vmm->trigger(VMMAction::POLL,vid);
}
else
{
@ -286,8 +276,6 @@ void LifeCycleManager::deploy_success_action(int vid)
vm->set_previous_running_etime(the_time);
vm->set_previous_reason(History::USER);
vmpool->update_previous_history(vm);
vm->get_requirements(cpu, mem, disk, pci);
@ -317,6 +305,10 @@ void LifeCycleManager::deploy_success_action(int vid)
{
vm->set_state(VirtualMachine::RUNNING);
vm->clear_action();
vmpool->update_history(vm);
vmpool->update(vm);
}
else
@ -363,8 +355,6 @@ void LifeCycleManager::deploy_failure_action(int vid)
vm->set_vm_info();
vm->set_reason(History::ERROR);
vmpool->update_history(vm);
vm->set_previous_etime(the_time);
@ -373,8 +363,6 @@ void LifeCycleManager::deploy_failure_action(int vid)
vm->set_previous_running_etime(the_time);
vm->set_previous_reason(History::USER);
vmpool->update_previous_history(vm);
vm->get_requirements(cpu, mem, disk, pci);
@ -400,7 +388,7 @@ void LifeCycleManager::deploy_failure_action(int vid)
//----------------------------------------------------
vmm->trigger(VirtualMachineManager::POLL,vid);
vmm->trigger(VMMAction::POLL,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::BOOT)
{
@ -425,9 +413,6 @@ void LifeCycleManager::deploy_failure_action(int vid)
vm->set_etime(the_time);
vm->set_running_etime(the_time);
vm->set_reason(History::ERROR);
vm->set_action(History::RESUME_ACTION);
vm->set_state(VirtualMachine::POWEROFF);
vm->set_state(VirtualMachine::LCM_INIT);
@ -439,9 +424,6 @@ void LifeCycleManager::deploy_failure_action(int vid)
vm->set_etime(the_time);
vm->set_running_etime(the_time);
vm->set_reason(History::ERROR);
vm->set_action(History::RESUME_ACTION);
vm->set_state(VirtualMachine::SUSPENDED);
vm->set_state(VirtualMachine::LCM_INIT);
@ -508,13 +490,11 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->set_running_etime(the_time);
vm->set_reason(History::USER);
vmpool->update_history(vm);
//----------------------------------------------------
tm->trigger(TransferManager::EPILOG,vid);
tm->trigger(TMAction::EPILOG,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF)
{
@ -537,13 +517,11 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->set_vm_info();
vm->set_reason(History::USER);
vmpool->update_history(vm);
//----------------------------------------------------
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY)
{
@ -566,13 +544,11 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->set_running_etime(the_time);
vm->set_reason(History::USER);
vmpool->update_history(vm);
//----------------------------------------------------
tm->trigger(TransferManager::EPILOG_STOP,vid);
tm->trigger(TMAction::EPILOG_STOP,vid);
}
else
{
@ -608,7 +584,7 @@ void LifeCycleManager::shutdown_failure_action(int vid)
vmpool->update(vm);
vm->set_action(History::NONE_ACTION);
vm->clear_action();
vmpool->update_history(vm);
@ -617,7 +593,7 @@ void LifeCycleManager::shutdown_failure_action(int vid)
//----------------------------------------------------
vmm->trigger(VirtualMachineManager::POLL,vid);
vmm->trigger(VMMAction::POLL,vid);
}
else
{
@ -636,7 +612,7 @@ void LifeCycleManager::prolog_success_action(int vid)
time_t the_time = time(0);
ostringstream os;
VirtualMachineManager::Actions action;
VMMAction::Actions action;
vm = vmpool->get(vid, true);
@ -666,19 +642,19 @@ void LifeCycleManager::prolog_success_action(int vid)
{
case VirtualMachine::PROLOG_RESUME:
case VirtualMachine::PROLOG_RESUME_FAILURE:
action = VirtualMachineManager::RESTORE;
action = VMMAction::RESTORE;
vm->set_state(VirtualMachine::BOOT_STOPPED);
break;
case VirtualMachine::PROLOG_UNDEPLOY:
case VirtualMachine::PROLOG_UNDEPLOY_FAILURE:
action = VirtualMachineManager::DEPLOY;
action = VMMAction::DEPLOY;
vm->set_state(VirtualMachine::BOOT_UNDEPLOY);
break;
case VirtualMachine::PROLOG_MIGRATE:
case VirtualMachine::PROLOG_MIGRATE_FAILURE: //recover success
action = VirtualMachineManager::RESTORE;
action = VMMAction::RESTORE;
vm->set_state(VirtualMachine::BOOT_MIGRATE);
break;
@ -686,7 +662,7 @@ void LifeCycleManager::prolog_success_action(int vid)
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
case VirtualMachine::PROLOG:
case VirtualMachine::PROLOG_FAILURE: //recover success
action = VirtualMachineManager::DEPLOY;
action = VMMAction::DEPLOY;
vm->set_state(VirtualMachine::BOOT);
break;
@ -731,20 +707,16 @@ void LifeCycleManager::prolog_success_action(int vid)
vm->set_vm_info();
vm->set_reason(History::USER);
vm->set_action(History::MIGRATE_ACTION);
vmpool->update_history(vm);
if (lcm_state == VirtualMachine::PROLOG_MIGRATE_POWEROFF||
lcm_state == VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE)
{
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
}
else //PROLOG_MIGRATE_SUSPEND, PROLOG_MIGRATE_SUSPEND_FAILURE
{
dm->trigger(DispatchManager::SUSPEND_SUCCESS,vid);
dm->trigger(DMAction::SUSPEND_SUCCESS,vid);
}
break;
@ -821,8 +793,6 @@ void LifeCycleManager::prolog_failure_action(int vid)
// Close current history record
vm->set_prolog_etime(t);
vm->set_etime(t);
vm->set_reason(History::ERROR);
vm->set_action(History::MIGRATE_ACTION);
vm->set_vm_info();
@ -862,7 +832,7 @@ void LifeCycleManager::prolog_failure_action(int vid)
hpool->add_capacity(vm->get_hid(), vm->get_oid(), cpu,mem,disk,pci);
trigger(LifeCycleManager::PROLOG_SUCCESS, vm->get_oid());
trigger(LCMAction::PROLOG_SUCCESS, vm->get_oid());
break;
case VirtualMachine::PROLOG_RESUME_FAILURE:
@ -893,7 +863,7 @@ void LifeCycleManager::epilog_success_action(int vid)
unsigned int port;
VirtualMachine::LcmState state;
DispatchManager::Actions action;
DMAction::Actions action;
vm = vmpool->get(vid,true);
@ -925,19 +895,19 @@ void LifeCycleManager::epilog_success_action(int vid)
if ( state == VirtualMachine::EPILOG_STOP )
{
action = DispatchManager::STOP_SUCCESS;
action = DMAction::STOP_SUCCESS;
}
else if ( state == VirtualMachine::EPILOG_UNDEPLOY )
{
action = DispatchManager::UNDEPLOY_SUCCESS;
action = DMAction::UNDEPLOY_SUCCESS;
}
else if ( state == VirtualMachine::EPILOG )
{
action = DispatchManager::DONE;
action = DMAction::DONE;
}
else if ( state == VirtualMachine::CLEANUP_RESUBMIT )
{
dm->trigger(DispatchManager::RESUBMIT, vid);
dm->trigger(DMAction::RESUBMIT, vid);
vm->unlock();
@ -999,7 +969,7 @@ void LifeCycleManager::cleanup_callback_action(int vid)
if ( state == VirtualMachine::CLEANUP_RESUBMIT )
{
dm->trigger(DispatchManager::RESUBMIT, vid);
dm->trigger(DMAction::RESUBMIT, vid);
}
else
@ -1032,7 +1002,7 @@ void LifeCycleManager::epilog_failure_action(int vid)
if ( state == VirtualMachine::CLEANUP_RESUBMIT )
{
dm->trigger(DispatchManager::RESUBMIT, vid);
dm->trigger(DMAction::RESUBMIT, vid);
}
else if ( state == VirtualMachine::EPILOG )
{
@ -1106,13 +1076,13 @@ void LifeCycleManager::monitor_suspend_action(int vid)
vm->set_vm_info();
vm->set_reason(History::ERROR);
vm->set_internal_action(History::MONITOR_ACTION);
vmpool->update_history(vm);
//----------------------------------------------------
dm->trigger(DispatchManager::SUSPEND_SUCCESS,vid);
dm->trigger(DMAction::SUSPEND_SUCCESS,vid);
}
else
{
@ -1198,13 +1168,13 @@ void LifeCycleManager::monitor_poweroff_action(int vid)
vm->set_vm_info();
vm->set_reason(History::USER);
vm->set_internal_action(History::MONITOR_ACTION);
vmpool->update_history(vm);
//----------------------------------------------------
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
} else if ( vm->get_lcm_state() == VirtualMachine::SHUTDOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF ||
@ -1212,7 +1182,7 @@ void LifeCycleManager::monitor_poweroff_action(int vid)
{
vm->log("LCM", Log::INFO, "VM reported SHUTDOWN by the drivers");
trigger(LifeCycleManager::SHUTDOWN_SUCCESS, vid);
trigger(LCMAction::SHUTDOWN_SUCCESS, vid);
}
vm->unlock();
@ -1277,7 +1247,7 @@ void LifeCycleManager::monitor_poweron_action(int vid)
case VirtualMachine::BOOT_FAILURE:
vm->log("LCM", Log::INFO, "VM reported RUNNING by the drivers");
trigger(LifeCycleManager::DEPLOY_SUCCESS, vid);
trigger(LCMAction::DEPLOY_SUCCESS, vid);
break;
default:
@ -1317,7 +1287,7 @@ void LifeCycleManager::attach_success_action(int vid)
vm->clear_attach_disk();
vmpool->update(vm);
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
}
else
{
@ -1363,7 +1333,7 @@ void LifeCycleManager::attach_failure_action(int vid)
{
vm->log("LCM", Log::INFO, "VM Disk attach failure.");
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
}
vmpool->update(vm);
@ -1413,7 +1383,7 @@ void LifeCycleManager::detach_success_action(int vid)
{
vm->log("LCM", Log::INFO, "VM Disk successfully detached.");
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
}
vmpool->update(vm);
@ -1456,7 +1426,7 @@ void LifeCycleManager::detach_failure_action(int vid)
vm->clear_attach_disk();
vmpool->update(vm);
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
dm->trigger(DMAction::POWEROFF_SUCCESS,vid);
}
else
{
@ -2004,13 +1974,13 @@ void LifeCycleManager::disk_snapshot_success(int vid)
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
dm->trigger(DMAction::POWEROFF_SUCCESS, vid);
break;
case VirtualMachine::DISK_SNAPSHOT_SUSPENDED:
case VirtualMachine::DISK_SNAPSHOT_REVERT_SUSPENDED:
case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED:
dm->trigger(DispatchManager::SUSPEND_SUCCESS, vid);
dm->trigger(DMAction::SUSPEND_SUCCESS, vid);
break;
default:
@ -2140,13 +2110,13 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_REVERT_POWEROFF:
case VirtualMachine::DISK_SNAPSHOT_DELETE_POWEROFF:
dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
dm->trigger(DMAction::POWEROFF_SUCCESS, vid);
break;
case VirtualMachine::DISK_SNAPSHOT_SUSPENDED:
case VirtualMachine::DISK_SNAPSHOT_REVERT_SUSPENDED:
case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED:
dm->trigger(DispatchManager::SUSPEND_SUCCESS, vid);
dm->trigger(DMAction::SUSPEND_SUCCESS, vid);
break;
default:
@ -2331,11 +2301,11 @@ void LifeCycleManager::disk_resize_success(int vid)
switch (state)
{
case VirtualMachine::DISK_RESIZE_POWEROFF:
dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
dm->trigger(DMAction::POWEROFF_SUCCESS, vid);
break;
case VirtualMachine::DISK_RESIZE_UNDEPLOYED:
dm->trigger(DispatchManager::UNDEPLOY_SUCCESS, vid);
dm->trigger(DMAction::UNDEPLOY_SUCCESS, vid);
break;
default:
@ -2427,11 +2397,11 @@ void LifeCycleManager::disk_resize_failure(int vid)
switch (state)
{
case VirtualMachine::DISK_RESIZE_POWEROFF:
dm->trigger(DispatchManager::POWEROFF_SUCCESS, vid);
dm->trigger(DMAction::POWEROFF_SUCCESS, vid);
break;
case VirtualMachine::DISK_RESIZE_UNDEPLOYED:
dm->trigger(DispatchManager::UNDEPLOY_SUCCESS, vid);
dm->trigger(DMAction::UNDEPLOY_SUCCESS, vid);
break;
default:

View File

@ -19,7 +19,6 @@
#include "MarketPlaceAppPool.h"
#include "MarketPlaceManagerDriver.h"
#include "NebulaLog.h"
#include "Nebula.h"
const char * MarketPlaceManager::market_driver_name = "market_exe";
@ -40,7 +39,7 @@ extern "C" void * marketplace_action_loop(void *arg)
mpm = static_cast<MarketPlaceManager *>(arg);
mpm->am.loop(mpm->timer_period, 0);
mpm->am.loop(mpm->timer_period);
NebulaLog::log("MKP", Log::INFO, "Marketplace Manager stopped.");
@ -152,29 +151,6 @@ int MarketPlaceManager::start()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void MarketPlaceManager::do_action(const string &action, void * arg)
{
if (action == ACTION_TIMER)
{
timer_action();
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("MKP", Log::INFO, "Stopping Marketplace Manager...");
MadManager::stop();
}
else
{
std::ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("MKP", Log::ERROR, oss);
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
string * MarketPlaceManager::format_message(
const string& app_data,
const string& market_data,
@ -194,7 +170,7 @@ string * MarketPlaceManager::format_message(
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void MarketPlaceManager::timer_action()
void MarketPlaceManager::timer_action(const ActionRequest& ar)
{
static int mark = 0;
static int tics = monitor_period;

View File

@ -992,11 +992,11 @@ void Nebula::start(bool bootstrap_only)
// Stop the managers & free resources
// -----------------------------------------------------------
vmm->trigger(VirtualMachineManager::FINALIZE,0);
lcm->trigger(LifeCycleManager::FINALIZE,0);
vmm->finalize();
lcm->finalize();
tm->trigger(TransferManager::FINALIZE,0);
dm->trigger(DispatchManager::FINALIZE,0);
tm->finalize();
dm->finalize();
im->finalize();
rm->finalize();

View File

@ -203,14 +203,6 @@ module OpenNebula
"DISK_RESIZE_UNDEPLOYED" => "drsz"
}
MIGRATE_REASON=%w{NONE ERROR USER}
SHORT_MIGRATE_REASON={
"NONE" => "none",
"ERROR" => "erro",
"USER" => "user"
}
HISTORY_ACTION=%w{none migrate live-migrate shutdown shutdown-hard
undeploy undeploy-hard hold release stop suspend resume boot delete
delete-recreate reboot reboot-hard resched unresched poweroff
@ -218,7 +210,7 @@ module OpenNebula
disk-snapshot-create disk-snapshot-delete terminate terminate-hard
disk-resize deploy chown chmod updateconf rename resize update
snapshot-resize snapshot-delete snapshot-revert disk-saveas
disk-snapshot-revert recover retry}
disk-snapshot-revert recover retry monitor}
EXTERNAL_IP_ATTRS = [
'GUEST_IP',
@ -266,13 +258,6 @@ module OpenNebula
XMLElement.build_xml(vm_xml, 'VM')
end
def VirtualMachine.get_reason(reason)
reason=MIGRATE_REASON[reason.to_i]
reason_str=SHORT_MIGRATE_REASON[reason]
reason_str
end
def VirtualMachine.get_history_action(action)
return HISTORY_ACTION[action.to_i]
end

View File

@ -107,7 +107,7 @@ extern "C" void * rm_action_loop(void *arg)
rm = static_cast<RequestManager *>(arg);
rm->am.loop(0,0);
rm->am.loop();
NebulaLog::log("ReM",Log::INFO,"Request Manager stopped.");
@ -279,39 +279,6 @@ int RequestManager::start()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void RequestManager::do_action(
const string & action,
void * arg)
{
if (action == ACTION_FINALIZE)
{
NebulaLog::log("ReM",Log::INFO,"Stopping Request Manager...");
pthread_cancel(rm_xml_server_thread);
pthread_join(rm_xml_server_thread,0);
NebulaLog::log("ReM",Log::INFO,"XML-RPC server stopped.");
delete AbyssServer;
if ( socket_fd != -1 )
{
close(socket_fd);
}
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("ReM", Log::ERROR, oss);
}
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void RequestManager::register_xml_methods()
{
Nebula& nebula = Nebula::instance();

View File

@ -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)
{

View File

@ -50,7 +50,7 @@ void SecurityGroupCommit::request_execute(xmlrpc_c::paramList const& paramList,
sg->unlock();
lcm->trigger(LifeCycleManager::UPDATESG, oid);
lcm->trigger(LCMAction::UPDATESG, oid, att);
success_response(oid, att);

View File

@ -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();
@ -1056,7 +1056,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
return;
}
if((vm->hasPreviousHistory() && vm->get_previous_reason()== History::NONE)||
if( vm->is_previous_history_open() ||
(vm->get_state() != VirtualMachine::POWEROFF &&
vm->get_state() != VirtualMachine::SUSPENDED &&
(vm->get_state() != VirtualMachine::ACTIVE ||
@ -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 )
{

View File

@ -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);
}
}

View File

@ -200,7 +200,15 @@ private:
pthread_t sched_thread;
ActionManager am;
void do_action(const string &name, void *args);
// -------------------------------------------------------------------------
// Action Listener interface
// -------------------------------------------------------------------------
void timer_action(const ActionRequest& ar);
void finalize_action(const ActionRequest& ar)
{
NebulaLog::log("SCHED",Log::INFO,"Stopping the scheduler...");
};
};
#endif /*SCHEDULER_H_*/

View File

@ -90,7 +90,7 @@ extern "C" void * scheduler_action_loop(void *arg)
NebulaLog::log("SCHED",Log::INFO,"Scheduler loop started.");
sched->am.loop(sched->timer,0);
sched->am.loop(sched->timer);
NebulaLog::log("SCHED",Log::INFO,"Scheduler loop stopped.");
@ -392,7 +392,7 @@ void Scheduler::start()
sigwait(&mask, &signal);
am.trigger(ActionListener::ACTION_FINALIZE,0); //Cancel sched loop
am.finalize();
pthread_join(sched_thread,0);
@ -1488,44 +1488,37 @@ void Scheduler::do_vm_groups()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void Scheduler::do_action(const string &name, void *args)
void Scheduler::timer_action(const ActionRequest& ar)
{
int rc;
if (name == ACTION_TIMER)
profile(true);
rc = vmapool->set_up();
profile(false,"Getting scheduled actions information.");
if ( rc == 0 )
{
profile(true);
rc = vmapool->set_up();
profile(false,"Getting scheduled actions information.");
if ( rc == 0 )
{
profile(true);
do_scheduled_actions();
profile(false,"Executing scheduled actions.");
}
profile(true);
rc = set_up_pools();
profile(false,"Getting VM and Host information.");
if ( rc != 0 )
{
return;
}
profile(true);
do_vm_groups();
profile(false,"Setting VM groups placement constraints.");
match_schedule();
profile(true);
dispatch();
profile(false,"Dispatching VMs to hosts.");
do_scheduled_actions();
profile(false,"Executing scheduled actions.");
}
else if (name == ACTION_FINALIZE)
profile(true);
rc = set_up_pools();
profile(false,"Getting VM and Host information.");
if ( rc != 0 )
{
NebulaLog::log("SCHED",Log::INFO,"Stopping the scheduler...");
return;
}
profile(true);
do_vm_groups();
profile(false,"Setting VM groups placement constraints.");
match_schedule();
profile(true);
dispatch();
profile(false,"Dispatching VMs to hosts.");
}

View File

@ -453,7 +453,7 @@ int SecurityGroup::post_update_template(string& error)
commit(false);
Nebula::instance().get_lcm()->trigger(LifeCycleManager::UPDATESG, oid);
Nebula::instance().get_lcm()->trigger(LCMAction::UPDATESG, oid);
return 0;
}

View File

@ -42,7 +42,7 @@ extern "C" void * tm_action_loop(void *arg)
NebulaLog::log("TrM",Log::INFO,"Transfer Manager started.");
tm->am.loop(0,0);
tm->am.loop();
NebulaLog::log("TrM",Log::INFO,"Transfer Manager stopped.");
@ -76,136 +76,17 @@ int TransferManager::start()
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void TransferManager::trigger(Actions action, int _vid)
void TransferManager::user_action(const ActionRequest& ar)
{
int * vid;
string aname;
const TMAction& tm_ar = static_cast<const TMAction& >(ar);
int vid = tm_ar.vm_id();
vid = new int(_vid);
switch (action)
{
case PROLOG:
aname = "PROLOG";
break;
case PROLOG_MIGR:
aname = "PROLOG_MIGR";
break;
case PROLOG_RESUME:
aname = "PROLOG_RESUME";
break;
case PROLOG_ATTACH:
aname = "PROLOG_ATTACH";
break;
case EPILOG:
aname = "EPILOG";
break;
case EPILOG_STOP:
aname = "EPILOG_STOP";
break;
case EPILOG_DELETE:
aname = "EPILOG_DELETE";
break;
case EPILOG_LOCAL:
aname = "EPILOG_LOCAL";
break;
case EPILOG_DELETE_STOP:
aname = "EPILOG_DELETE_STOP";
break;
case EPILOG_DELETE_PREVIOUS:
aname = "EPILOG_DELETE_PREVIOUS";
break;
case EPILOG_DELETE_BOTH:
aname = "EPILOG_DELETE_BOTH";
break;
case EPILOG_DETACH:
aname = "EPILOG_DETACH";
break;
case CHECKPOINT:
aname = "CHECKPOINT";
break;
case SAVEAS_HOT:
aname = "SAVEAS_HOT";
break;
case DRIVER_CANCEL:
aname = "DRIVER_CANCEL";
break;
case SNAPSHOT_CREATE:
aname = "SNAPSHOT_CREATE";
break;
case SNAPSHOT_REVERT:
aname = "SNAPSHOT_REVERT";
break;
case SNAPSHOT_DELETE:
aname = "SNAPSHOT_DELETE";
break;
case RESIZE:
aname = "RESIZE";
break;
case FINALIZE:
aname = ACTION_FINALIZE;
break;
default:
delete vid;
return;
}
am.trigger(aname,vid);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void TransferManager::do_action(const string &action, void * arg)
{
VirtualMachine * vm;
int vid;
bool host_is_cloud = false;
bool vm_no_history = false;
Nebula& nd = Nebula::instance();
if (arg == 0)
{
return;
}
vid = *(static_cast<int *>(arg));
delete static_cast<int *>(arg);
if (action == ACTION_FINALIZE)
{
NebulaLog::log("TrM",Log::INFO,"Stopping Transfer Manager...");
MadManager::stop();
return;
}
vm = vmpool->get(vid,true);
VirtualMachine * vm = vmpool->get(vid,true);
if (vm == 0)
{
@ -223,220 +104,215 @@ void TransferManager::do_action(const string &action, void * arg)
vm->unlock();
if (action == "PROLOG")
switch(tm_ar.action())
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_FAILURE,vid);
}
else
{
prolog_action(vid);
}
}
else if (action == "PROLOG_MIGR")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_FAILURE,vid);
}
else
{
prolog_migr_action(vid);
}
}
else if (action == "PROLOG_RESUME")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_FAILURE,vid);
}
else
{
prolog_resume_action(vid);
}
}
else if (action == "PROLOG_ATTACH")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::ATTACH_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::ATTACH_FAILURE,vid);
}
else
{
prolog_attach_action(vid);
}
}
else if (action == "EPILOG")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
}
else
{
epilog_action(false, vid);
}
}
else if (action == "EPILOG_LOCAL")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
}
else
{
epilog_action(true, vid);
}
}
else if (action == "EPILOG_STOP")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
}
else
{
epilog_stop_action(vid);
}
}
else if (action == "EPILOG_DELETE")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
}
else
{
epilog_delete_action(vid);
}
}
else if (action == "EPILOG_DELETE_STOP")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
}
else
{
epilog_delete_stop_action(vid);
}
}
else if (action == "EPILOG_DELETE_PREVIOUS")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
}
else
{
epilog_delete_previous_action(vid);
}
}
else if (action == "EPILOG_DELETE_BOTH")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
}
else
{
epilog_delete_both_action(vid);
}
}
else if (action == "EPILOG_DETACH")
{
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LifeCycleManager::DETACH_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LifeCycleManager::DETACH_FAILURE,vid);
}
else
{
epilog_detach_action(vid);
}
}
else if (action == "CHECKPOINT")
{
checkpoint_action(vid);
}
else if (action == "SAVEAS_HOT")
{
saveas_hot_action(vid);
}
else if (action == "DRIVER_CANCEL")
{
driver_cancel_action(vid);
}
else if (action == "SNAPSHOT_CREATE")
{
snapshot_create_action(vid);
}
else if (action == "SNAPSHOT_REVERT")
{
snapshot_revert_action(vid);
}
else if (action == "SNAPSHOT_DELETE")
{
snapshot_delete_action(vid);
}
else if (action == "RESIZE")
{
resize_action(vid);
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
case TMAction::PROLOG:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::PROLOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::PROLOG_FAILURE,vid);
}
else
{
prolog_action(vid);
}
break;
NebulaLog::log("TrM", Log::ERROR, oss);
case TMAction::PROLOG_MIGR:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::PROLOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::PROLOG_FAILURE,vid);
}
else
{
prolog_migr_action(vid);
}
break;
case TMAction::PROLOG_RESUME:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::PROLOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::PROLOG_FAILURE,vid);
}
else
{
prolog_resume_action(vid);
}
break;
case TMAction::PROLOG_ATTACH:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::ATTACH_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::ATTACH_FAILURE,vid);
}
else
{
prolog_attach_action(vid);
}
break;
case TMAction::EPILOG:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
}
else
{
epilog_action(false, vid);
}
break;
case TMAction::EPILOG_LOCAL:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
}
else
{
epilog_action(true, vid);
}
break;
case TMAction::EPILOG_STOP:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
}
else
{
epilog_stop_action(vid);
}
break;
case TMAction::EPILOG_DELETE:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
}
else
{
epilog_delete_action(vid);
}
break;
case TMAction::EPILOG_DELETE_STOP:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
}
else
{
epilog_delete_stop_action(vid);
}
break;
case TMAction::EPILOG_DELETE_PREVIOUS:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
}
else
{
epilog_delete_previous_action(vid);
}
break;
case TMAction::EPILOG_DELETE_BOTH:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
}
else
{
epilog_delete_both_action(vid);
}
break;
case TMAction::EPILOG_DETACH:
if (host_is_cloud)
{
(nd.get_lcm())->trigger(LCMAction::DETACH_SUCCESS,vid);
}
else if (vm_no_history)
{
(nd.get_lcm())->trigger(LCMAction::DETACH_FAILURE,vid);
}
else
{
epilog_detach_action(vid);
}
break;
case TMAction::CHECKPOINT:
checkpoint_action(vid);
break;
case TMAction::SAVEAS_HOT:
saveas_hot_action(vid);
break;
case TMAction::DRIVER_CANCEL:
driver_cancel_action(vid);
break;
case TMAction::SNAPSHOT_CREATE:
snapshot_create_action(vid);
break;
case TMAction::SNAPSHOT_REVERT:
snapshot_revert_action(vid);
break;
case TMAction::SNAPSHOT_DELETE:
snapshot_delete_action(vid);
break;
case TMAction::RESIZE:
resize_action(vid);
break;
}
}
@ -834,7 +710,7 @@ error_attributes:
goto error_common;
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_FAILURE,vid);
(nd.get_lcm())->trigger(LCMAction::PROLOG_FAILURE,vid);
vm->log("TM", Log::ERROR, os);
vm->unlock();
@ -964,7 +840,7 @@ error_file:
goto error_common;
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_FAILURE,vid);
(nd.get_lcm())->trigger(LCMAction::PROLOG_FAILURE,vid);
vm->log("TM", Log::ERROR, os);
vm->unlock();
@ -1111,7 +987,7 @@ error_file:
goto error_common;
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_FAILURE,vid);
(nd.get_lcm())->trigger(LCMAction::PROLOG_FAILURE,vid);
vm->log("TM", Log::ERROR, os);
@ -1227,7 +1103,7 @@ error_attributes:
goto error_common;
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::PROLOG_FAILURE,vid);
(nd.get_lcm())->trigger(LCMAction::PROLOG_FAILURE,vid);
vm->log("TM", Log::ERROR, os);
vm->unlock();
@ -1404,7 +1280,7 @@ error_file:
goto error_common;
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
vm->log("TM", Log::ERROR, os);
vm->unlock();
@ -1532,7 +1408,7 @@ error_file:
goto error_common;
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
vm->log("TM", Log::ERROR, os);
vm->unlock();
@ -1732,7 +1608,7 @@ error_file:
error_common:
vm->log("TM", Log::ERROR, os);
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE, vid);
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE, vid);
vm->unlock();
return;
@ -1805,7 +1681,7 @@ error_file:
error_common:
vm->log("TM", Log::ERROR, os);
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE, vid);
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE, vid);
vm->unlock();
return;
@ -1879,7 +1755,7 @@ error_file:
error_common:
vm->log("TM", Log::ERROR, os);
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE, vid);
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE, vid);
vm->unlock();
return;
@ -1975,7 +1851,7 @@ error_disk:
goto error_common;
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::EPILOG_FAILURE,vid);
(nd.get_lcm())->trigger(LCMAction::EPILOG_FAILURE,vid);
vm->log("TM", Log::ERROR, os);
vm->unlock();
@ -2126,7 +2002,7 @@ error_file:
error_common:
vm->log("TM", Log::ERROR, os);
(nd.get_lcm())->trigger(LifeCycleManager::SAVEAS_FAILURE, vid);
(nd.get_lcm())->trigger(LCMAction::SAVEAS_FAILURE, vid);
vm->unlock();
return;
@ -2256,7 +2132,7 @@ error_file:
error_common:
vm->log("TM", Log::ERROR, os);
(nd.get_lcm())->trigger(LifeCycleManager::DISK_SNAPSHOT_FAILURE, vid);
(nd.get_lcm())->trigger(LCMAction::DISK_SNAPSHOT_FAILURE, vid);
vm->unlock();
return;
@ -2386,7 +2262,7 @@ error_disk:
error_common:
vm->log("TM", Log::ERROR, os);
(nd.get_lcm())->trigger(LifeCycleManager::DISK_RESIZE_FAILURE, vid);
(nd.get_lcm())->trigger(LCMAction::DISK_RESIZE_FAILURE, vid);
vm->unlock();
return;

View File

@ -111,7 +111,7 @@ void TransferManagerDriver::protocol(const string& message) const
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
LifeCycleManager::Actions lcm_action;
LCMAction::Actions lcm_action;
if (result == "SUCCESS")
{
@ -124,28 +124,28 @@ void TransferManagerDriver::protocol(const string& message) const
case VirtualMachine::PROLOG_MIGRATE_POWEROFF:
case VirtualMachine::PROLOG_MIGRATE_SUSPEND:
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN:
lcm_action = LifeCycleManager::PROLOG_SUCCESS;
lcm_action = LCMAction::PROLOG_SUCCESS;
break;
case VirtualMachine::EPILOG:
case VirtualMachine::EPILOG_STOP:
case VirtualMachine::EPILOG_UNDEPLOY:
case VirtualMachine::CLEANUP_RESUBMIT:
lcm_action = LifeCycleManager::EPILOG_SUCCESS;
lcm_action = LCMAction::EPILOG_SUCCESS;
break;
case VirtualMachine::HOTPLUG_SAVEAS:
case VirtualMachine::HOTPLUG_SAVEAS_POWEROFF:
case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED:
lcm_action = LifeCycleManager::SAVEAS_SUCCESS;
lcm_action = LCMAction::SAVEAS_SUCCESS;
break;
case VirtualMachine::HOTPLUG_PROLOG_POWEROFF:
lcm_action = LifeCycleManager::ATTACH_SUCCESS;
lcm_action = LCMAction::ATTACH_SUCCESS;
break;
case VirtualMachine::HOTPLUG_EPILOG_POWEROFF:
lcm_action = LifeCycleManager::DETACH_SUCCESS;
lcm_action = LCMAction::DETACH_SUCCESS;
break;
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
@ -155,12 +155,12 @@ void TransferManagerDriver::protocol(const string& message) const
case VirtualMachine::DISK_SNAPSHOT_REVERT_SUSPENDED:
case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED:
case VirtualMachine::DISK_SNAPSHOT_DELETE:
lcm_action = LifeCycleManager::DISK_SNAPSHOT_SUCCESS;
lcm_action = LCMAction::DISK_SNAPSHOT_SUCCESS;
break;
case VirtualMachine::DISK_RESIZE_POWEROFF:
case VirtualMachine::DISK_RESIZE_UNDEPLOYED:
lcm_action = LifeCycleManager::DISK_RESIZE_SUCCESS;
lcm_action = LCMAction::DISK_RESIZE_SUCCESS;
break;
default:
@ -195,28 +195,28 @@ void TransferManagerDriver::protocol(const string& message) const
case VirtualMachine::PROLOG_MIGRATE_POWEROFF:
case VirtualMachine::PROLOG_MIGRATE_SUSPEND:
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN:
lcm_action = LifeCycleManager::PROLOG_FAILURE;
lcm_action = LCMAction::PROLOG_FAILURE;
break;
case VirtualMachine::EPILOG:
case VirtualMachine::EPILOG_STOP:
case VirtualMachine::EPILOG_UNDEPLOY:
case VirtualMachine::CLEANUP_RESUBMIT:
lcm_action = LifeCycleManager::EPILOG_FAILURE;
lcm_action = LCMAction::EPILOG_FAILURE;
break;
case VirtualMachine::HOTPLUG_SAVEAS:
case VirtualMachine::HOTPLUG_SAVEAS_POWEROFF:
case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED:
lcm_action = LifeCycleManager::SAVEAS_FAILURE;
lcm_action = LCMAction::SAVEAS_FAILURE;
break;
case VirtualMachine::HOTPLUG_PROLOG_POWEROFF:
lcm_action = LifeCycleManager::ATTACH_FAILURE;
lcm_action = LCMAction::ATTACH_FAILURE;
break;
case VirtualMachine::HOTPLUG_EPILOG_POWEROFF:
lcm_action = LifeCycleManager::DETACH_FAILURE;
lcm_action = LCMAction::DETACH_FAILURE;
break;
case VirtualMachine::DISK_SNAPSHOT_POWEROFF:
@ -226,12 +226,12 @@ void TransferManagerDriver::protocol(const string& message) const
case VirtualMachine::DISK_SNAPSHOT_REVERT_SUSPENDED:
case VirtualMachine::DISK_SNAPSHOT_DELETE_SUSPENDED:
case VirtualMachine::DISK_SNAPSHOT_DELETE:
lcm_action = LifeCycleManager::DISK_SNAPSHOT_FAILURE;
lcm_action = LCMAction::DISK_SNAPSHOT_FAILURE;
break;
case VirtualMachine::DISK_RESIZE_POWEROFF:
case VirtualMachine::DISK_RESIZE_UNDEPLOYED:
lcm_action = LifeCycleManager::DISK_RESIZE_FAILURE;
lcm_action = LCMAction::DISK_RESIZE_FAILURE;
break;
default:

View File

@ -707,7 +707,7 @@ bool UserPool::authenticate_internal(User * user,
{
ar.add_authenticate(auth_driver,username,password,token);
authm->trigger(AuthManager::AUTHENTICATE,&ar);
authm->trigger(AMAction::AUTHENTICATE,&ar);
ar.wait();
@ -959,7 +959,7 @@ bool UserPool::authenticate_server(User * user,
server_password,
second_token);
authm->trigger(AuthManager::AUTHENTICATE,&ar);
authm->trigger(AMAction::AUTHENTICATE,&ar);
ar.wait();
if (ar.result!=true) //User was not authenticated
@ -1063,7 +1063,7 @@ bool UserPool::authenticate_external(const string& username,
ar.add_authenticate(default_auth, username,"-",token);
authm->trigger(AuthManager::AUTHENTICATE, &ar);
authm->trigger(AMAction::AUTHENTICATE, &ar);
ar.wait();
if (ar.result != true) //User was not authenticated
@ -1232,7 +1232,7 @@ int UserPool::authorize(AuthRequest& ar)
}
else
{
authm->trigger(AuthManager::AUTHORIZE,&ar);
authm->trigger(AMAction::AUTHORIZE,&ar);
ar.wait();
if (ar.result==true)

View File

@ -54,7 +54,6 @@ History::History(
running_etime(0),
epilog_stime(0),
epilog_etime(0),
reason(NONE),
action(NONE_ACTION),
vm_info("<VM/>"){};
@ -86,7 +85,6 @@ History::History(
running_etime(0),
epilog_stime(0),
epilog_etime(0),
reason(NONE),
action(NONE_ACTION),
vm_info(_vm_info)
{
@ -311,8 +309,10 @@ string& History::to_xml(string& xml, bool database) const
"<RETIME>" << running_etime << "</RETIME>"<<
"<ESTIME>" << epilog_stime << "</ESTIME>"<<
"<EETIME>" << epilog_etime << "</EETIME>"<<
"<REASON>" << reason << "</REASON>"<<
"<ACTION>" << action << "</ACTION>";
"<ACTION>" << action << "</ACTION>"<<
"<UID>" << uid << "</UID>"<<
"<GID>" << gid << "</GID>"<<
"<REQUEST_ID>" << req_id << "</REQUEST_ID>";
if ( database )
{
@ -332,28 +332,36 @@ string& History::to_xml(string& xml, bool database) const
int History::rebuild_attributes()
{
int int_reason, int_action;
int int_action;
int rc = 0;
rc += xpath(seq , "/HISTORY/SEQ", -1);
rc += xpath(hostname , "/HISTORY/HOSTNAME", "not_found");
rc += xpath(hid , "/HISTORY/HID", -1);
rc += xpath(cid , "/HISTORY/CID", -1);
rc += xpath<time_t>(stime , "/HISTORY/STIME", 0);
rc += xpath<time_t>(etime , "/HISTORY/ETIME", 0);
rc += xpath(vmm_mad_name , "/HISTORY/VM_MAD", "not_found");
rc += xpath(tm_mad_name , "/HISTORY/TM_MAD", "not_found");
rc += xpath(ds_id , "/HISTORY/DS_ID", 0);
rc += xpath<time_t>(prolog_stime , "/HISTORY/PSTIME", 0);
rc += xpath<time_t>(prolog_etime , "/HISTORY/PETIME", 0);
rc += xpath<time_t>(running_stime, "/HISTORY/RSTIME", 0);
rc += xpath<time_t>(running_etime, "/HISTORY/RETIME", 0);
rc += xpath<time_t>(epilog_stime , "/HISTORY/ESTIME", 0);
rc += xpath<time_t>(epilog_etime , "/HISTORY/EETIME", 0);
rc += xpath(int_reason , "/HISTORY/REASON", 0);
rc += xpath(int_action , "/HISTORY/ACTION", 0);
rc += xpath(seq, "/HISTORY/SEQ", -1);
rc += xpath(hid, "/HISTORY/HID", -1);
rc += xpath(cid, "/HISTORY/CID", -1);
rc += xpath(ds_id, "/HISTORY/DS_ID", 0);
rc += xpath(hostname, "/HISTORY/HOSTNAME", "not_found");
rc += xpath<time_t>(stime , "/HISTORY/STIME", 0);
rc += xpath<time_t>(etime , "/HISTORY/ETIME", 0);
rc += xpath(vmm_mad_name, "/HISTORY/VM_MAD", "not_found");
rc += xpath(tm_mad_name , "/HISTORY/TM_MAD", "not_found");
rc += xpath<time_t>(prolog_stime , "/HISTORY/PSTIME", 0);
rc += xpath<time_t>(prolog_etime , "/HISTORY/PETIME", 0);
rc += xpath<time_t>(running_stime, "/HISTORY/RSTIME", 0);
rc += xpath<time_t>(running_etime, "/HISTORY/RETIME", 0);
rc += xpath<time_t>(epilog_stime , "/HISTORY/ESTIME", 0);
rc += xpath<time_t>(epilog_etime , "/HISTORY/EETIME", 0);
rc += xpath(int_action , "/HISTORY/ACTION", 0);
rc += xpath(uid, "/HISTORY/UID", -1);
rc += xpath(gid, "/HISTORY/GID", -1);
rc += xpath(req_id, "/HISTORY/REQUEST_ID", -1);
reason = static_cast<EndReason>(int_reason);
action = static_cast<VMAction>(int_action);
non_persistent_data();
@ -495,6 +503,9 @@ string History::action_to_str(VMAction action)
case RETRY_ACTION:
st = "retry";
break;
case MONITOR_ACTION:
st = "monitor";
break;
case NONE_ACTION:
st = "none";
break;
@ -665,6 +676,10 @@ int History::action_from_str(const string& st, VMAction& action)
{
action = RETRY_ACTION;
}
else if ( st == "monitor")
{
action = MONITOR_ACTION;
}
else
{
action = NONE_ACTION;

View File

@ -67,7 +67,7 @@ extern "C" void * vmm_action_loop(void *arg)
NebulaLog::log("VMM",Log::INFO,"Virtual Machine Manager started.");
vmm->am.loop(vmm->timer_period, 0);
vmm->am.loop(vmm->timer_period);
NebulaLog::log("VMM",Log::INFO,"Virtual Machine Manager stopped.");
@ -102,250 +102,82 @@ int VirtualMachineManager::start()
/* Manager Action Interface */
/* ************************************************************************** */
void VirtualMachineManager::trigger(Actions action, int _vid)
void VirtualMachineManager::user_action(const ActionRequest& ar)
{
int * vid;
string aname;
const VMMAction& vmm_ar = static_cast<const VMMAction& >(ar);
int vid = vmm_ar.vm_id();
vid = new int(_vid);
switch (action)
switch (vmm_ar.action())
{
case DEPLOY:
aname = "DEPLOY";
case VMMAction::DEPLOY:
deploy_action(vid);
break;
case SAVE:
aname = "SAVE";
case VMMAction::SAVE:
save_action(vid);
break;
case RESTORE:
aname = "RESTORE";
case VMMAction::RESTORE:
restore_action(vid);
break;
case REBOOT:
aname = "REBOOT";
case VMMAction::REBOOT:
reboot_action(vid);
break;
case RESET:
aname = "RESET";
case VMMAction::RESET:
reset_action(vid);
break;
case SHUTDOWN:
aname = "SHUTDOWN";
case VMMAction::SHUTDOWN:
shutdown_action(vid);
break;
case CANCEL:
aname = "CANCEL";
case VMMAction::CANCEL:
cancel_action(vid);
break;
case CANCEL_PREVIOUS:
aname = "CANCEL_PREVIOUS";
case VMMAction::CANCEL_PREVIOUS:
cancel_previous_action(vid);
break;
case CLEANUP:
aname = "CLEANUP";
case VMMAction::CLEANUP:
cleanup_action(vid, false);
break;
case CLEANUP_BOTH:
aname = "CLEANUP_BOTH";
case VMMAction::CLEANUP_BOTH:
cleanup_action(vid, true);
break;
case CLEANUP_PREVIOUS:
aname = "CLEANUP_PREVIOUS";
case VMMAction::CLEANUP_PREVIOUS:
cleanup_previous_action(vid);
break;
case MIGRATE:
aname = "MIGRATE";
case VMMAction::MIGRATE:
migrate_action(vid);
break;
case POLL:
aname = "POLL";
case VMMAction::POLL:
poll_action(vid);
break;
case DRIVER_CANCEL:
aname = "DRIVER_CANCEL";
case VMMAction::DRIVER_CANCEL:
driver_cancel_action(vid);
break;
case FINALIZE:
aname = ACTION_FINALIZE;
case VMMAction::ATTACH:
attach_action(vid);
break;
case ATTACH:
aname = "ATTACH";
case VMMAction::DETACH:
detach_action(vid);
break;
case DETACH:
aname = "DETACH";
case VMMAction::ATTACH_NIC:
attach_nic_action(vid);
break;
case ATTACH_NIC:
aname = "ATTACH_NIC";
case VMMAction::DETACH_NIC:
detach_nic_action(vid);
break;
case DETACH_NIC:
aname = "DETACH_NIC";
case VMMAction::SNAPSHOT_CREATE:
snapshot_create_action(vid);
break;
case SNAPSHOT_CREATE:
aname = "SNAPSHOT_CREATE";
case VMMAction::SNAPSHOT_REVERT:
snapshot_revert_action(vid);
break;
case SNAPSHOT_REVERT:
aname = "SNAPSHOT_REVERT";
case VMMAction::SNAPSHOT_DELETE:
snapshot_delete_action(vid);
break;
case SNAPSHOT_DELETE:
aname = "SNAPSHOT_DELETE";
case VMMAction::DISK_SNAPSHOT_CREATE:
disk_snapshot_create_action(vid);
break;
case DISK_SNAPSHOT_CREATE:
aname = "DISK_SNAPSHOT_CREATE";
case VMMAction::DISK_RESIZE:
disk_resize_action(vid);
break;
case DISK_RESIZE:
aname = "DISK_RESIZE";
break;
default:
delete vid;
return;
}
am.trigger(aname,vid);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManager::do_action(const string &action, void * arg)
{
int vid;
if ( arg == 0)
{
if ( action != ACTION_TIMER && action != ACTION_FINALIZE )
{
return;
}
vid = -1;
}
else
{
vid = *(static_cast<int *>(arg));
delete static_cast<int *>(arg);
}
if (action == "DEPLOY")
{
deploy_action(vid);
}
else if (action == "SAVE")
{
save_action(vid);
}
else if (action == "RESTORE")
{
restore_action(vid);
}
else if (action == "REBOOT")
{
reboot_action(vid);
}
else if (action == "RESET")
{
reset_action(vid);
}
else if (action == "SHUTDOWN")
{
shutdown_action(vid);
}
else if (action == "CANCEL")
{
cancel_action(vid);
}
else if (action == "CANCEL_PREVIOUS")
{
cancel_previous_action(vid);
}
else if (action == "CLEANUP")
{
cleanup_action(vid, false);
}
else if (action == "CLEANUP_BOTH")
{
cleanup_action(vid, true);
}
else if (action == "CLEANUP_PREVIOUS")
{
cleanup_previous_action(vid);
}
else if (action == "MIGRATE")
{
migrate_action(vid);
}
else if (action == "POLL")
{
poll_action(vid);
}
else if (action == "DRIVER_CANCEL")
{
driver_cancel_action(vid);
}
else if (action == "ATTACH")
{
attach_action(vid);
}
else if (action == "DETACH")
{
detach_action(vid);
}
else if (action == "ATTACH_NIC")
{
attach_nic_action(vid);
}
else if (action == "DETACH_NIC")
{
detach_nic_action(vid);
}
else if (action == "SNAPSHOT_CREATE")
{
snapshot_create_action(vid);
}
else if (action == "SNAPSHOT_REVERT")
{
snapshot_revert_action(vid);
}
else if (action == "SNAPSHOT_DELETE")
{
snapshot_delete_action(vid);
}
else if (action == "DISK_SNAPSHOT_CREATE")
{
disk_snapshot_create_action(vid);
}
else if (action == "DISK_RESIZE")
{
disk_resize_action(vid);
}
else if (action == ACTION_TIMER)
{
timer_action();
}
else if (action == ACTION_FINALIZE)
{
NebulaLog::log("VMM",Log::INFO,"Stopping Virtual Machine Manager...");
MadManager::stop();
}
else
{
ostringstream oss;
oss << "Unknown action name: " << action;
NebulaLog::log("VMM", Log::ERROR, oss);
}
}
@ -615,7 +447,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::DEPLOY_FAILURE, vid);
lcm->trigger(LCMAction::DEPLOY_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -716,7 +548,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::SAVE_FAILURE, vid);
lcm->trigger(LCMAction::SAVE_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -791,7 +623,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::SHUTDOWN_FAILURE, vid);
lcm->trigger(LCMAction::SHUTDOWN_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -1003,11 +835,11 @@ error_history:
error_driver:
os << "cancel_action, error getting driver " << vm->get_vmm_mad();
error_common://LifeCycleManager::cancel_failure_action will check state
error_common://LCMAction::cancel_failure_action will check state
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::CANCEL_FAILURE, vid);
lcm->trigger(LCMAction::CANCEL_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -1175,7 +1007,7 @@ error_epligo_command:
os << "cleanup_action canceled";
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::CLEANUP_FAILURE, vid);
(nd.get_lcm())->trigger(LCMAction::CLEANUP_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -1261,7 +1093,7 @@ error_epilog_command:
os << "cleanup_action canceled";
error_common:
(nd.get_lcm())->trigger(LifeCycleManager::CLEANUP_FAILURE, vid);
(nd.get_lcm())->trigger(LCMAction::CLEANUP_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -1347,7 +1179,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::DEPLOY_FAILURE, vid);
lcm->trigger(LCMAction::DEPLOY_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -1454,7 +1286,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::DEPLOY_FAILURE, vid);
lcm->trigger(LCMAction::DEPLOY_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -1586,7 +1418,7 @@ error_common:
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VirtualMachineManager::timer_action()
void VirtualMachineManager::timer_action(const ActionRequest& ar)
{
static int mark = 0;
static int timer_start = time(0);
@ -1832,7 +1664,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::ATTACH_FAILURE, vid);
lcm->trigger(LCMAction::ATTACH_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -1948,7 +1780,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::DETACH_FAILURE, vid);
lcm->trigger(LCMAction::DETACH_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -2025,7 +1857,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::SNAPSHOT_CREATE_FAILURE, vid);
lcm->trigger(LCMAction::SNAPSHOT_CREATE_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -2103,7 +1935,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::SNAPSHOT_REVERT_FAILURE, vid);
lcm->trigger(LCMAction::SNAPSHOT_REVERT_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -2181,7 +2013,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::SNAPSHOT_DELETE_FAILURE, vid);
lcm->trigger(LCMAction::SNAPSHOT_DELETE_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -2296,7 +2128,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::DISK_SNAPSHOT_FAILURE, vid);
lcm->trigger(LCMAction::DISK_SNAPSHOT_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -2408,7 +2240,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::DISK_SNAPSHOT_FAILURE, vid);
lcm->trigger(LCMAction::DISK_SNAPSHOT_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -2518,7 +2350,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::ATTACH_NIC_FAILURE, vid);
lcm->trigger(LCMAction::ATTACH_NIC_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();
@ -2597,7 +2429,7 @@ error_common:
Nebula &ne = Nebula::instance();
LifeCycleManager * lcm = ne.get_lcm();
lcm->trigger(LifeCycleManager::DETACH_NIC_FAILURE, vid);
lcm->trigger(LCMAction::DETACH_NIC_FAILURE, vid);
vm->log("VMM", Log::ERROR, os);
vm->unlock();

View File

@ -322,7 +322,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
vm->unlock();
}
lcm->trigger(LifeCycleManager::UPDATESG, sgid);
lcm->trigger(LCMAction::UPDATESG, sgid);
return;
}
@ -348,7 +348,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
if ( action == "DEPLOY" )
{
LifeCycleManager::Actions action = LifeCycleManager::DEPLOY_SUCCESS;
LCMAction::Actions action = LCMAction::DEPLOY_SUCCESS;
if (result == "SUCCESS")
{
@ -362,13 +362,13 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
}
else
{
action = LifeCycleManager::DEPLOY_FAILURE;
action = LCMAction::DEPLOY_FAILURE;
log_error(vm,os,is,"Empty deploy ID for virtual machine");
}
}
else
{
action = LifeCycleManager::DEPLOY_FAILURE;
action = LCMAction::DEPLOY_FAILURE;
log_error(vm,os,is,"Error deploying virtual machine");
}
@ -380,70 +380,70 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
if (result == "SUCCESS")
{
lcm->trigger(LifeCycleManager::SHUTDOWN_SUCCESS, id);
lcm->trigger(LCMAction::SHUTDOWN_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error shutting down VM");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::SHUTDOWN_FAILURE, id);
lcm->trigger(LCMAction::SHUTDOWN_FAILURE, id);
}
}
else if ( action == "CANCEL" )
{
if (result == "SUCCESS")
{
lcm->trigger(LifeCycleManager::CANCEL_SUCCESS, id);
lcm->trigger(LCMAction::CANCEL_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error canceling VM");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::CANCEL_FAILURE, id);
lcm->trigger(LCMAction::CANCEL_FAILURE, id);
}
}
else if ( action == "SAVE" )
{
if (result == "SUCCESS")
{
lcm->trigger(LifeCycleManager::SAVE_SUCCESS, id);
lcm->trigger(LCMAction::SAVE_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error saving VM state");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::SAVE_FAILURE, id);
lcm->trigger(LCMAction::SAVE_FAILURE, id);
}
}
else if ( action == "RESTORE" )
{
if (result == "SUCCESS")
{
lcm->trigger(LifeCycleManager::DEPLOY_SUCCESS, id);
lcm->trigger(LCMAction::DEPLOY_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error restoring VM");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DEPLOY_FAILURE, id);
lcm->trigger(LCMAction::DEPLOY_FAILURE, id);
}
}
else if ( action == "MIGRATE" )
{
if (result == "SUCCESS")
{
lcm->trigger(LifeCycleManager::DEPLOY_SUCCESS, id);
lcm->trigger(LCMAction::DEPLOY_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error live migrating VM");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DEPLOY_FAILURE, id);
lcm->trigger(LCMAction::DEPLOY_FAILURE, id);
}
}
else if ( action == "REBOOT" )
@ -476,14 +476,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM", Log::INFO, "VM Disk successfully attached.");
lcm->trigger(LifeCycleManager::ATTACH_SUCCESS, id);
lcm->trigger(LCMAction::ATTACH_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error attaching new VM Disk");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::ATTACH_FAILURE, id);
lcm->trigger(LCMAction::ATTACH_FAILURE, id);
}
}
else if ( action == "DETACHDISK" )
@ -492,14 +492,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM",Log::INFO,"VM Disk successfully detached.");
lcm->trigger(LifeCycleManager::DETACH_SUCCESS, id);
lcm->trigger(LCMAction::DETACH_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error detaching VM Disk");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DETACH_FAILURE, id);
lcm->trigger(LCMAction::DETACH_FAILURE, id);
}
}
else if ( action == "ATTACHNIC" )
@ -508,14 +508,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM", Log::INFO, "VM NIC Successfully attached.");
lcm->trigger(LifeCycleManager::ATTACH_NIC_SUCCESS, id);
lcm->trigger(LCMAction::ATTACH_NIC_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error attaching new VM NIC");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::ATTACH_NIC_FAILURE, id);
lcm->trigger(LCMAction::ATTACH_NIC_FAILURE, id);
}
}
else if ( action == "DETACHNIC" )
@ -524,14 +524,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM",Log::INFO, "VM NIC Successfully detached.");
lcm->trigger(LifeCycleManager::DETACH_NIC_SUCCESS, id);
lcm->trigger(LCMAction::DETACH_NIC_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error detaching VM NIC");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DETACH_NIC_FAILURE, id);
lcm->trigger(LCMAction::DETACH_NIC_FAILURE, id);
}
}
else if ( action == "SNAPSHOTCREATE" )
@ -548,14 +548,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
vm->log("VMM", Log::INFO, "VM Snapshot successfully created.");
lcm->trigger(LifeCycleManager::SNAPSHOT_CREATE_SUCCESS, id);
lcm->trigger(LCMAction::SNAPSHOT_CREATE_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error creating new VM Snapshot");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::SNAPSHOT_CREATE_FAILURE, id);
lcm->trigger(LCMAction::SNAPSHOT_CREATE_FAILURE, id);
}
}
else if ( action == "SNAPSHOTREVERT" )
@ -564,14 +564,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM",Log::INFO,"VM Snapshot successfully reverted.");
lcm->trigger(LifeCycleManager::SNAPSHOT_REVERT_SUCCESS, id);
lcm->trigger(LCMAction::SNAPSHOT_REVERT_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error reverting VM Snapshot");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::SNAPSHOT_REVERT_FAILURE, id);
lcm->trigger(LCMAction::SNAPSHOT_REVERT_FAILURE, id);
}
}
else if ( action == "SNAPSHOTDELETE" )
@ -580,14 +580,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM",Log::INFO,"VM Snapshot successfully deleted.");
lcm->trigger(LifeCycleManager::SNAPSHOT_DELETE_SUCCESS, id);
lcm->trigger(LCMAction::SNAPSHOT_DELETE_SUCCESS, id);
}
else
{
log_error(vm,os,is,"Error deleting VM Snapshot");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::SNAPSHOT_DELETE_FAILURE, id);
lcm->trigger(LCMAction::SNAPSHOT_DELETE_FAILURE, id);
}
}
else if ( action == "DISKSNAPSHOTCREATE" )
@ -596,14 +596,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM", Log::INFO, "VM disk snapshot successfully created.");
lcm->trigger(LifeCycleManager::DISK_SNAPSHOT_SUCCESS, id);
lcm->trigger(LCMAction::DISK_SNAPSHOT_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error creating new disk snapshot");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DISK_SNAPSHOT_FAILURE, id);
lcm->trigger(LCMAction::DISK_SNAPSHOT_FAILURE, id);
}
}
else if ( action == "DISKSNAPSHOTREVERT" )
@ -612,14 +612,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM", Log::INFO, "VM disk state reverted.");
lcm->trigger(LifeCycleManager::DISK_SNAPSHOT_SUCCESS, id);
lcm->trigger(LCMAction::DISK_SNAPSHOT_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error reverting disk snapshot");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DISK_SNAPSHOT_FAILURE, id);
lcm->trigger(LCMAction::DISK_SNAPSHOT_FAILURE, id);
}
}
else if ( action == "RESIZEDISK" )
@ -628,14 +628,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM", Log::INFO, "VM disk successfully resized");
lcm->trigger(LifeCycleManager::DISK_RESIZE_SUCCESS, id);
lcm->trigger(LCMAction::DISK_RESIZE_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error resizing disk");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::DISK_RESIZE_FAILURE, id);
lcm->trigger(LCMAction::DISK_RESIZE_FAILURE, id);
}
}
else if ( action == "CLEANUP" )
@ -644,14 +644,14 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
vm->log("VMM", Log::INFO, "Host successfully cleaned.");
lcm->trigger(LifeCycleManager::CLEANUP_SUCCESS, id);
lcm->trigger(LCMAction::CLEANUP_SUCCESS, id);
}
else
{
log_error(vm, os, is, "Error cleaning Host");
vmpool->update(vm);
lcm->trigger(LifeCycleManager::CLEANUP_FAILURE, id);
lcm->trigger(LCMAction::CLEANUP_FAILURE, id);
}
}
else if ( action == "POLL" )
@ -667,7 +667,7 @@ void VirtualMachineManagerDriver::protocol(const string& message) const
{
log_monitor_error(vm, os, is, "Error monitoring VM");
lcm->trigger(LifeCycleManager::MONITOR_DONE, vm->get_oid());
lcm->trigger(LCMAction::MONITOR_DONE, vm->get_oid());
}
}
else if (action == "LOG")
@ -784,7 +784,7 @@ void VirtualMachineManagerDriver::process_poll(
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY_FAILURE ||
vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE )))
{
lcm->trigger(LifeCycleManager::MONITOR_POWERON, vm->get_oid());
lcm->trigger(LCMAction::MONITOR_POWERON, vm->get_oid());
}
break;
@ -796,7 +796,7 @@ void VirtualMachineManagerDriver::process_poll(
{
vm->log("VMM",Log::INFO, "VM running but monitor state is PAUSED.");
lcm->trigger(LifeCycleManager::MONITOR_SUSPEND, vm->get_oid());
lcm->trigger(LCMAction::MONITOR_SUSPEND, vm->get_oid());
}
break;
@ -806,7 +806,7 @@ void VirtualMachineManagerDriver::process_poll(
{
vm->log("VMM",Log::INFO,"VM running but monitor state is ERROR.");
lcm->trigger(LifeCycleManager::MONITOR_DONE, vm->get_oid());
lcm->trigger(LCMAction::MONITOR_DONE, vm->get_oid());
}
break;
@ -817,7 +817,7 @@ void VirtualMachineManagerDriver::process_poll(
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY ))
{
lcm->trigger(LifeCycleManager::MONITOR_POWEROFF, vm->get_oid());
lcm->trigger(LCMAction::MONITOR_POWEROFF, vm->get_oid());
}
break;
}

View File

@ -34,7 +34,7 @@ int AddressRangeIPAM::from_vattr(VectorAttribute * attr, std::string& error_msg)
free(ar_xml);
ipamm->trigger(IPAMManager::REGISTER_ADDRESS_RANGE, &ir);
ipamm->trigger(IPMAction::REGISTER_ADDRESS_RANGE, &ir);
ir.wait();
@ -76,7 +76,7 @@ int AddressRangeIPAM::allocate_addr(unsigned int index, unsigned int rsize,
IPAMRequest ir(ar_xml, address_xml);
ipamm->trigger(IPAMManager::ALLOCATE_ADDRESS, &ir);
ipamm->trigger(IPMAction::ALLOCATE_ADDRESS, &ir);
ir.wait();
@ -113,7 +113,7 @@ int AddressRangeIPAM::get_addr(unsigned int& index, unsigned int rsize,
IPAMRequest ir(ar_xml, address_xml);
ipamm->trigger(IPAMManager::GET_ADDRESS, &ir);
ipamm->trigger(IPMAction::GET_ADDRESS, &ir);
ir.wait();
@ -173,7 +173,7 @@ int AddressRangeIPAM::free_addr(unsigned int index, std::string& error_msg)
IPAMRequest ir(ar_xml, address_xml);
ipamm->trigger(IPAMManager::FREE_ADDRESS, &ir);
ipamm->trigger(IPMAction::FREE_ADDRESS, &ir);
ir.wait();

View File

@ -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);
}
}
}