diff --git a/include/MarketPlace.h b/include/MarketPlace.h index a004aeeb88..485f067f68 100644 --- a/include/MarketPlace.h +++ b/include/MarketPlace.h @@ -18,8 +18,11 @@ #define MARKETPLACE_H_ #include "PoolSQL.h" +#include "ActionSet.h" #include "ObjectCollection.h" #include "MarketPlaceTemplate.h" +#include "MarketPlaceApp.h" +#include "ActionSet.h" /** * The MarketPlace class. It represents an abstract container for OpenNebula @@ -86,6 +89,16 @@ public: */ void update_monitor(const Template& data); + /** + * Check if action is supported for the apps + * @param action + * @return true if it is supported + */ + bool is_action_supported(MarketPlaceApp::Action action) const + { + return supported_actions.is_set(action); + } + private: friend class MarketPlacePool; @@ -93,7 +106,6 @@ private: // ************************************************************************* // MarketPlace Attributes // ************************************************************************* - /** * Name of the marketplace driver used to import apps */ @@ -114,6 +126,11 @@ private: */ long long used_mb; + /** + * Supported actions on MarketPlaceApps + */ + ActionSet supported_actions; + // ************************************************************************* // Constructor // ************************************************************************* diff --git a/include/MarketPlaceApp.h b/include/MarketPlaceApp.h index 0edb83e23b..a109f6a8e4 100644 --- a/include/MarketPlaceApp.h +++ b/include/MarketPlaceApp.h @@ -28,10 +28,44 @@ class MarketPlaceApp : public PoolObjectSQL { public: + /** + * MarketPlaceApp actions + */ + enum Action + { + NONE = 0, + CREATE = 1, + DELETE = 2, + MONITOR = 3 + }; + + static int action_from_str(string& st, Action& action) + { + if (st == "create") + { + action = CREATE; + } + else if (st == "delete") + { + action = DELETE; + } + else if (st == "monitor") + { + action = MONITOR; + } + else + { + action = NONE; + return -1; + } + + return 0; + }; + /** * MarketPlaceApp states */ - enum MarketPlaceAppState + enum State { INIT = 0, /** < Initialization state */ READY = 1, /** < Ready to use */ @@ -45,7 +79,7 @@ public: * @param state The state * @return the string representation */ - static string state_to_str(MarketPlaceAppState state) + static string state_to_str(State state) { switch(state) { @@ -61,7 +95,7 @@ public: /** * MarketPlaceApp container types */ - enum MarketPlaceAppType + enum Type { UNKNOWN = 0, /** < Unknown types */ IMAGE = 1, /** < Image MarketPlace App*/ @@ -74,7 +108,7 @@ public: * @param ob the type * @return the string */ - static string type_to_str(MarketPlaceAppType ob) + static string type_to_str(Type ob) { switch (ob) { @@ -91,7 +125,7 @@ public: * @param str_type string representing the type * @return the MarketPlaceType */ - static MarketPlaceAppType str_to_type(string& str_type); + static Type str_to_type(string& str_type); /** * Function to print the MarketPlaceApp object into a string in XML format @@ -161,7 +195,7 @@ public: * Returns the marketplace app type * @return marketplace app type */ - MarketPlaceAppType get_type() const + Type get_type() const { return type; }; @@ -196,7 +230,7 @@ public: } - MarketPlaceAppState get_state() const + State get_state() const { return state; } @@ -204,7 +238,7 @@ public: //-------------------------------------------------------------------------- // Set Marketplace app attributes //-------------------------------------------------------------------------- - void set_state(MarketPlaceAppState _state) + void set_state(State _state) { state = _state; }; @@ -294,12 +328,12 @@ private: /** * Marketplace App state */ - MarketPlaceAppState state; + State state; /** * The marketplace type */ - MarketPlaceAppType type; + Type type; /** * Origin of this App diff --git a/include/Nebula.h b/include/Nebula.h index 09df54c2c2..4790abb08c 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -408,38 +408,35 @@ public: nebula_configuration->get(name, value); }; - /** - * Gets a configuration attribute for oned, bool version - */ - void get_configuration_attribute( - const char * name, - bool& value) const - { - string _name(name); - - nebula_configuration->Template::get(_name, value); - }; - /** * Gets a DS configuration attribute */ int get_ds_conf_attribute( const std::string& ds_name, - const VectorAttribute* &value) const; + const VectorAttribute* &value) const + { + return get_conf_attribute("DS_MAD_CONF", ds_name, value); + }; /** * Gets a TM configuration attribute */ int get_tm_conf_attribute( const string& tm_name, - const VectorAttribute* &value) const; + const VectorAttribute* &value) const + { + return get_conf_attribute("TM_MAD_CONF", tm_name, value); + }; /** * Gets a Market configuration attribute */ int get_market_conf_attribute( - const string& tm_name, - const VectorAttribute* &value) const; + const string& mk_name, + const VectorAttribute* &value) const + { + return get_conf_attribute("MARKET_MAD_CONF", mk_name, value); + }; /** * Gets an XML document with all of the configuration attributes diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 6962d602e4..c02e4192d4 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1326,12 +1326,6 @@ public: */ bool is_vrouter(); - /** - * Checks if the given action is supported for Virtual Router VMs - * @param action VM action to check - * @return true if the action is supported for Virtual Router VMs - */ - static bool is_vrouter_action_supported(History::VMAction action); // ------------------------------------------------------------------------ // Context related functions diff --git a/include/VirtualMachineManagerDriver.h b/include/VirtualMachineManagerDriver.h index 50bb69ce99..6a3ef1ef3c 100644 --- a/include/VirtualMachineManagerDriver.h +++ b/include/VirtualMachineManagerDriver.h @@ -22,6 +22,7 @@ #include #include "Mad.h" +#include "ActionSet.h" #include "VirtualMachinePool.h" #include "History.h" @@ -91,7 +92,7 @@ public: */ bool is_imported_action_supported(History::VMAction action) const { - return (imported_vm_actions && (1 << static_cast(action))) != 0; + return imported_actions.is_set(action); } protected: @@ -101,13 +102,10 @@ protected: * @param name of config attribute * @param value of the attribute */ - void get_default( - const char * name, - string& value) const + template + void get_default(const string& name, T& value) const { - string sn = name; - - driver_conf.get(sn,value); + driver_conf.get(name, value); } /** @@ -117,26 +115,25 @@ protected: * @param vname of the attribute * @param value of the attribute */ - void get_default( - const char * name, - const char * vname, - string& value) const; + template + int get_default(const char* name, const char* vname, T& value) const + { + const VectorAttribute * vattr = driver_conf.get(name); - /** - * Gets a configuration attr from driver configuration file (vector - * version) - * @param name of config vector attribute for the domain - * @param vname of the attribute - * @param value of the attribute - * - * @return true if the attribute was found - */ - bool get_default( - const char * name, - const char * vname, - bool& value) const; + if (vattr != 0) + { + return -1; + } + + return vattr->vector_value(vname, value); + } private: + friend class VirtualMachineManager; + + static const string imported_actions_default; + static const string imported_actions_default_public; + /** * Configuration file for the driver */ @@ -146,15 +143,13 @@ private: * List of available actions for imported VMs. Each bit is an action * as defined in History.h, 1=supported and 0=not supported */ - long long imported_vm_actions; + ActionSet imported_actions; /** * Pointer to the Virtual Machine Pool, to access VMs */ VirtualMachinePool * vmpool; - friend class VirtualMachineManager; - /** * Sends a deploy request to the MAD: "DEPLOY ID XML_DRV_MSG" * @param oid the virtual machine id. @@ -287,7 +282,6 @@ private: const string& drv_msg) const { write_drv("POLL", oid, drv_msg); - } /** diff --git a/include/VirtualRouter.h b/include/VirtualRouter.h index 2a31cbdaf5..377f3465ca 100644 --- a/include/VirtualRouter.h +++ b/include/VirtualRouter.h @@ -22,6 +22,8 @@ #include "ObjectCollection.h" #include "VirtualMachineTemplate.h" #include "AuthRequest.h" +#include "History.h" +#include "ActionSet.h" /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -131,18 +133,27 @@ public: AuthRequest& ar, Template *tmpl); + /** + * Checks if the given action is supported for Virtual Router VMs + * @param action VM action to check + * @return true if the action is supported for Virtual Router VMs + */ + static bool is_action_supported(History::VMAction action) + { + return SUPPORTED_ACTIONS.is_set(action); + } + private: // ------------------------------------------------------------------------- // Friends // ------------------------------------------------------------------------- - friend class VirtualRouterPool; + static const ActionSet SUPPORTED_ACTIONS; // ************************************************************************* // Attributes // ************************************************************************* - ObjectCollection vms; // ************************************************************************* diff --git a/share/etc/oned.conf b/share/etc/oned.conf index ac6a35c44a..ead8cac620 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -1078,19 +1078,26 @@ DS_MAD_CONF = [ # name : name of the market driver # required_attrs : comma separated list of required attributes in the Market # template +# app_actions: List of actions allowed for a MarketPlaceApp +# - monitor The apps of the marketplace will be monitored +# - import, the app into an OpenNebula datastore +# - delete, the app from the marketplace #******************************************************************************* MARKET_MAD_CONF = [ NAME = "one", - REQUIRED_ATTRS = "" + REQUIRED_ATTRS = "", + APP_ACTIONS = "import, monitor" ] MARKET_MAD_CONF = [ NAME = "http", REQUIRED_ATTRS = "BASE_URL,PUBLIC_DIR" + APP_ACTIONS = "import, delete, monitor", ] MARKET_MAD_CONF = [ NAME = "s3", - REQUIRED_ATTRS = "ACCESS_KEY_ID,SECRET_ACCESS_KEY,REGION,BUCKET" + REQUIRED_ATTRS = "ACCESS_KEY_ID,SECRET_ACCESS_KEY,REGION,BUCKET", + APP_ACTIONS = "import, delete, monitor" ] diff --git a/src/market/MarketPlace.cc b/src/market/MarketPlace.cc index dd0d7204fc..c806bede89 100644 --- a/src/market/MarketPlace.cc +++ b/src/market/MarketPlace.cc @@ -290,6 +290,31 @@ std::string& MarketPlace::to_xml(std::string& xml) const /* --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- */ +static void set_supported_actions(ActionSet& as, + const string& astr) +{ + std::vector actions; + std::vector::iterator vit; + + std::string action; + MarketPlaceApp::Action id; + + actions = one_util::split(astr, ','); + + for (vit = actions.begin() ; vit != actions.end() ; ++vit) + { + action = one_util::trim(*vit); + + if ( MarketPlaceApp::action_from_str(action, id) != 0 ) + { + NebulaLog::log("VMM", Log::ERROR, "Wrong action: " + action); + continue; + } + + as.set(id); + } +} + int MarketPlace::from_xml(const std::string &xml_str) { int rc = 0; @@ -346,6 +371,29 @@ int MarketPlace::from_xml(const std::string &xml_str) return -1; } + // ------ SUPPORTED ACTIONS, regenerated from oned.conf ------ + const VectorAttribute* vatt; + string actions; + + if (Nebula::instance().get_market_conf_attribute(market_mad, vatt) == 0) + { + actions = vatt->vector_value("APP_ACTIONS"); + } + + if (actions.empty()) + { + if (market_mad == "http" || market_mad == "s3") + { + actions = "create, monitor, delete"; + } + else if ( market_mad == "one" ) + { + actions = "create, monitor"; + } + } + + set_supported_actions(supported_actions, actions); + return 0; } diff --git a/src/market/MarketPlaceApp.cc b/src/market/MarketPlaceApp.cc index d896bf12f4..bfebe976c5 100644 --- a/src/market/MarketPlaceApp.cc +++ b/src/market/MarketPlaceApp.cc @@ -305,8 +305,8 @@ int MarketPlaceApp::from_xml(const std::string &xml_str) rc += xpath(market_name, "/MARKETPLACEAPP/MARKETPLACE", "not_found"); rc += xpath(market_id, "/MARKETPLACEAPP/MARKETPLACE_ID", -1); - state = static_cast(istate); - type = static_cast(itype); + state = static_cast(istate); + type = static_cast(itype); // ----- Permissions ----- rc += perms_from_xml(); @@ -360,7 +360,7 @@ int MarketPlaceApp::post_update_template(string& error) /* --------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------- */ -MarketPlaceApp::MarketPlaceAppType MarketPlaceApp::str_to_type(string& str_type) +MarketPlaceApp::Type MarketPlaceApp::str_to_type(string& str_type) { one_util::toupper(str_type); diff --git a/src/market/MarketPlaceManager.cc b/src/market/MarketPlaceManager.cc index 93a26b2f89..4655fbd5ac 100644 --- a/src/market/MarketPlaceManager.cc +++ b/src/market/MarketPlaceManager.cc @@ -263,10 +263,20 @@ void MarketPlaceManager::monitor_market(int mp_id) return; } - mp->to_xml(mp_data); - mp_name = mp->get_name(); + if ( !mp->is_action_supported(MarketPlaceApp::MONITOR) ) + { + NebulaLog::log("MKP", Log::DEBUG, "Monitoring disabled for market: " + + mp_name); + + mp->unlock(); + + return; + } + + mp->to_xml(mp_data); + mp->unlock(); drv_msg = MarketPlaceManager::format_message("", mp_data, ""); diff --git a/src/market/MarketPlaceManagerActions.cc b/src/market/MarketPlaceManagerActions.cc index 2ec1cfb768..25e6714803 100644 --- a/src/market/MarketPlaceManagerActions.cc +++ b/src/market/MarketPlaceManagerActions.cc @@ -61,7 +61,7 @@ int MarketPlaceManager::import_app( app->to_xml(app_data); - MarketPlaceApp::MarketPlaceAppType type = app->get_type(); + MarketPlaceApp::Type type = app->get_type(); int app_id = app->get_oid(); int origin_id = app->get_origin_id(); @@ -131,7 +131,7 @@ void MarketPlaceManager::release_app_resources(int appid) return; } - MarketPlaceApp::MarketPlaceAppType type = app->get_type(); + MarketPlaceApp::Type type = app->get_type(); int iid = app->get_origin_id(); @@ -180,8 +180,8 @@ int MarketPlaceManager::delete_app(int appid, const std::string& market_data, app->to_xml(app_data); - MarketPlaceApp::MarketPlaceAppType type = app->get_type(); - MarketPlaceApp::MarketPlaceAppState state = app->get_state(); + MarketPlaceApp::Type type = app->get_type(); + MarketPlaceApp::State state = app->get_state(); int market_id = app->get_market_id(); diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index d560626d05..01410a467f 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -1107,23 +1107,3 @@ int Nebula::get_conf_attribute( return -1; }; -int Nebula::get_ds_conf_attribute( - const std::string& name, - const VectorAttribute* &value) const -{ - return get_conf_attribute("DS_MAD_CONF", name, value); -}; - -int Nebula::get_tm_conf_attribute( - const std::string& name, - const VectorAttribute* &value) const -{ - return get_conf_attribute("TM_MAD_CONF", name, value); -}; - -int Nebula::get_market_conf_attribute( - const std::string& name, - const VectorAttribute* &value) const -{ - return get_conf_attribute("MARKET_MAD_CONF", name, value); -}; diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index 257d7c2cfe..30d12eb1c6 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -912,6 +912,14 @@ int MarketPlaceAppAllocate::pool_allocate( std::string mp_name = mp->get_name(); std::string mp_data; + if ( !mp->is_action_supported(MarketPlaceApp::CREATE) ) + { + att.resp_msg = "Create disabled for market: " + mp_name; + mp->unlock(); + + return -1; + } + mp->to_xml(mp_data); mp->unlock(); diff --git a/src/rm/RequestManagerDelete.cc b/src/rm/RequestManagerDelete.cc index 3e5deef351..a79f6e7f92 100644 --- a/src/rm/RequestManagerDelete.cc +++ b/src/rm/RequestManagerDelete.cc @@ -388,6 +388,14 @@ int MarketPlaceAppDelete::drop(int oid, PoolObjectSQL * object, string& emsg) std::string mp_name = mp->get_name(); std::string mp_data; + if ( !mp->is_action_supported(MarketPlaceApp::DELETE) ) + { + emsg = "Delete disabled for market: " + mp_name; + mp->unlock(); + + return -1; + } + mp->to_xml(mp_data); mp->unlock(); diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index d90a231a14..a7fb8234c3 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -544,7 +544,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList, return; } - if (vm->is_vrouter() && !vm->is_vrouter_action_supported(action)) + if (vm->is_vrouter() && !VirtualRouter::is_action_supported(action)) { bool failure = true; @@ -1029,7 +1029,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList return; } - if (vm->is_vrouter() && !vm->is_vrouter_action_supported(action)) + if (vm->is_vrouter() && !VirtualRouter::is_action_supported(action)) { att.resp_msg = "Migration is not supported for virtual router VMs"; failure_response(ACTION, att); @@ -1580,7 +1580,7 @@ void VirtualMachineAttach::request_execute(xmlrpc_c::paramList const& paramList, volatile_disk = vm->volatile_disk_extended_info(&tmpl); - if (vm->is_vrouter() && !vm->is_vrouter_action_supported(History::DISK_ATTACH_ACTION)) + if (vm->is_vrouter() && !VirtualRouter::is_action_supported(History::DISK_ATTACH_ACTION)) { att.resp_msg = "Action is not supported for virtual router VMs"; failure_response(ACTION, att); @@ -1663,7 +1663,7 @@ void VirtualMachineDetach::request_execute(xmlrpc_c::paramList const& paramList, return; } - if (vm->is_vrouter() && !vm->is_vrouter_action_supported(History::NIC_DETACH_ACTION)) + if (vm->is_vrouter() && !VirtualRouter::is_action_supported(History::NIC_DETACH_ACTION)) { att.resp_msg = "Action is not supported for virtual router VMs"; failure_response(ACTION, att); @@ -2115,7 +2115,7 @@ void VirtualMachineAttachNic::request_execute( return; } - if (vm->is_vrouter() && !vm->is_vrouter_action_supported(History::NIC_ATTACH_ACTION)) + if (vm->is_vrouter() && !VirtualRouter::is_action_supported(History::NIC_ATTACH_ACTION)) { att.resp_msg = "Action is not supported for virtual router VMs"; failure_response(Request::ACTION, att); @@ -2252,7 +2252,7 @@ void VirtualMachineDetachNic::request_execute( return; } - if (vm->is_vrouter() && !vm->is_vrouter_action_supported(History::NIC_DETACH_ACTION)) + if (vm->is_vrouter() && !VirtualRouter::is_action_supported(History::NIC_DETACH_ACTION)) { att.resp_msg = "Action is not supported for virtual router VMs"; failure_response(Request::ACTION, att); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 18c7e17627..57a92647f8 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -3204,24 +3204,6 @@ bool VirtualMachine::is_vrouter() /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -bool VirtualMachine::is_vrouter_action_supported(History::VMAction action) -{ - return (action == History::MIGRATE_ACTION || - action == History::LIVE_MIGRATE_ACTION || - action == History::HOLD_ACTION || - action == History::RELEASE_ACTION || - action == History::RESUME_ACTION || - action == History::BOOT_ACTION || - action == History::REBOOT_ACTION || - action == History::REBOOT_HARD_ACTION || - action == History::RESCHED_ACTION || - action == History::UNRESCHED_ACTION || - action == History::DISK_SNAPSHOT_CREATE_ACTION || - action == History::DISK_SNAPSHOT_DELETE_ACTION); -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ int VirtualMachine::generate_context(string &files, int &disk_id, const string& token_password) diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index d59fbc9a89..af9f96cc2b 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -206,8 +206,8 @@ int LibVirtDriver::deployment_description_kvm( string hyperv_options = ""; vector raw; - string default_raw; - string data; + string default_raw = ""; + string data = ""; // ------------------------------------------------------------------------ @@ -928,7 +928,7 @@ int LibVirtDriver::deployment_description_kvm( { get_default("SPICE_OPTIONS", spice_options); - if ( spice_options != "" ) + if (spice_options.empty()) { file << "\t\t" << spice_options << endl; } diff --git a/src/vmm/VirtualMachineManagerDriver.cc b/src/vmm/VirtualMachineManagerDriver.cc index 0a68b3516a..ae4b5c59d1 100644 --- a/src/vmm/VirtualMachineManagerDriver.cc +++ b/src/vmm/VirtualMachineManagerDriver.cc @@ -22,19 +22,30 @@ #include "NebulaUtil.h" #include + +const string VirtualMachineManagerDriver::imported_actions_default = + "shutdown, shutdown-hard, hold, release, suspend, resume, delete, reboot, " + "reboot-hard, resched, unresched, disk-attach, disk-detach, nic-attach, " + "nic-detach, snap-create, snap-delete"; + +const string VirtualMachineManagerDriver::imported_actions_default_public = + "shutdown, shutdown-hard, hold, release, suspend, resume, delete, reboot, " + "reboot-hard, resched, unresched, disk-attach, disk-detach, nic-attach, " + "nic-detach, snap-create, snap-delete, poweroff, poweroff-hard"; + VirtualMachineManagerDriver::VirtualMachineManagerDriver( int userid, const map& attrs, bool sudo, VirtualMachinePool * pool): - Mad(userid,attrs,sudo), driver_conf(true), imported_vm_actions(0), - vmpool(pool) + Mad(userid,attrs,sudo), driver_conf(true), vmpool(pool) { map::const_iterator it; char * error_msg = 0; const char * cfile; string file; int rc; + string action_defaults; it = attrs.find("DEFAULT"); @@ -78,26 +89,7 @@ VirtualMachineManagerDriver::VirtualMachineManagerDriver( if (it != attrs.end()) { - vector actions; - vector::iterator vit; - - string action; - History::VMAction id; - - actions = one_util::split(it->second, ','); - - for (vit = actions.begin() ; vit != actions.end() ; ++vit) - { - action = one_util::trim(*vit); - - if ( History::action_from_str(action, id) != 0 ) - { - NebulaLog::log("VMM", Log::ERROR, "Wrong action: " + action); - continue; - } - - imported_vm_actions += 1 << static_cast(id); - } + action_defaults = it->second; } else { @@ -107,85 +99,39 @@ VirtualMachineManagerDriver::VirtualMachineManagerDriver( if (it != attrs.end()) { - if ( it->second == "kvm" ) + if ( it->second == "kvm" || it->second == "xen3" || + it->second == "xen" || it->second == "vmware" ) { - imported_vm_actions = 132623768; + action_defaults = imported_actions_default; } - else if ( it->second == "xen3" ) + else if ( it->second == "sl" || it->second == "ec2" || + it->second == "az" || it->second == "vcenter" ) { - imported_vm_actions = 132623768; - } - else if ( it->second == "xen" ) - { - imported_vm_actions = 132623768; - } - else if ( it->second == "vmware" ) - { - imported_vm_actions = 132623768; - } - else if ( it->second == "vcenter" ) - { - imported_vm_actions = 134196632; - } - else if ( it->second == "ec2" ) - { - imported_vm_actions = 134196632; - } - else if ( it->second == "az" ) - { - imported_vm_actions = 134196632; - } - else if ( it->second == "sl" ) - { - imported_vm_actions = 134196632; + action_defaults = imported_actions_default_public; } } } -} -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ + vector actions; + vector::iterator vit; -void VirtualMachineManagerDriver::get_default( - const char * name, - const char * vname, - string& value) const -{ - const VectorAttribute * vattr = driver_conf.get(name); + string action; + History::VMAction id; - if ( vattr == 0 ) + actions = one_util::split(action_defaults, ','); + + for (vit = actions.begin() ; vit != actions.end() ; ++vit) { - value.clear(); + action = one_util::trim(*vit); + + if ( History::action_from_str(action, id) != 0 ) + { + NebulaLog::log("VMM", Log::ERROR, "Wrong action: " + action); + continue; + } + + imported_actions.set(id); } - else - { - value = vattr->vector_value(vname); - } -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -bool VirtualMachineManagerDriver::get_default( - const char * name, - const char * vname, - bool& value) const -{ - string st; - - get_default(name, vname, st); - - if ( st == "" ) - { - value = false; - return false; - } - - one_util::toupper(st); - - value = ( st == "YES" ); - - return true; } /* ************************************************************************** */ diff --git a/src/vmm/XenDriver.cc b/src/vmm/XenDriver.cc index 124e18e666..feef9026b6 100644 --- a/src/vmm/XenDriver.cc +++ b/src/vmm/XenDriver.cc @@ -35,10 +35,10 @@ int XenDriver::deployment_description( int num; - string credits; - string cpu; - string memory; - string vcpu; + string credits = ""; + string cpu = ""; + string memory = ""; + string vcpu = ""; float base_credit = 1.0; float cpu_units = 1.0; @@ -102,8 +102,8 @@ int XenDriver::deployment_description( int localtime_found = -1; vector raw; - string data; - string default_raw; + string data = ""; + string default_raw = ""; // ------------------------------------------------------------------------ @@ -624,17 +624,17 @@ int XenDriver::deployment_description( } } - if ( pae_found != 0 && get_default("FEATURES", "PAE", pae) ) + if ( pae_found != 0 && get_default("FEATURES", "PAE", pae) == 0 ) { pae_found = 0; } - if ( acpi_found != 0 && get_default("FEATURES", "ACPI", acpi) ) + if ( acpi_found != 0 && get_default("FEATURES", "ACPI", acpi) == 0 ) { acpi_found = 0; } - if ( apic_found != 0 && get_default("FEATURES", "APIC", apic) ) + if ( apic_found != 0 && get_default("FEATURES", "APIC", apic) == 0 ) { apic_found = 0; } @@ -653,22 +653,22 @@ int XenDriver::deployment_description( get_default("FEATURES", "LOCALTIME", localtime); } - if ( pae_found == 0) + if ( pae_found == 0 ) { file << "pae = " << on_off_string(pae) << endl; } - if ( acpi_found == 0) + if ( acpi_found == 0 ) { file << "acpi = " << on_off_string(acpi) << endl; } - if ( apic_found == 0) + if ( apic_found == 0 ) { file << "apic = " << on_off_string(apic) << endl; } - if ( device_model_found == 0) + if ( device_model_found == 0 ) { file << "device_model = '" << device_model << "'" << endl; } diff --git a/src/vrouter/VirtualRouter.cc b/src/vrouter/VirtualRouter.cc index 5a7a9459dc..5b1969b4e0 100644 --- a/src/vrouter/VirtualRouter.cc +++ b/src/vrouter/VirtualRouter.cc @@ -17,6 +17,24 @@ #include "VirtualRouter.h" #include "VirtualNetworkPool.h" #include "Nebula.h" +#include "VirtualMachine.h" + +static const History::VMAction action[12] = { + History::MIGRATE_ACTION, + History::LIVE_MIGRATE_ACTION, + History::HOLD_ACTION, + History::RELEASE_ACTION, + History::RESUME_ACTION, + History::BOOT_ACTION, + History::REBOOT_ACTION, + History::REBOOT_HARD_ACTION, + History::RESCHED_ACTION, + History::UNRESCHED_ACTION, + History::DISK_SNAPSHOT_CREATE_ACTION, + History::DISK_SNAPSHOT_DELETE_ACTION +}; + +const ActionSet VirtualRouter::SUPPORTED_ACTIONS(action, 12); /* ************************************************************************ */ /* VirtualRouter :: Constructor/Destructor */ @@ -728,3 +746,4 @@ void VirtualRouter::set_auth_request(int uid, vnpool->authorize_nic(PoolObjectSQL::VROUTER, *nics_it, uid, &ar); } } +