diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 968518ea50..f2bf647fb1 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1113,6 +1113,11 @@ public: */ static bool isVolatile(const Template * tmpl); + /** + * Check if the themplate is for an imported VM + */ + bool isImported() const; + /** * Return the total SIZE of volatile disks */ diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 428fa34222..279b885838 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -640,7 +640,6 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, int id = xmlrpc_c::value_int(paramList.getInt(1)); int hid = xmlrpc_c::value_int(paramList.getInt(2)); bool enforce = false; - bool imported= false; int ds_id = -1; if ( paramList.size() > 3 ) @@ -689,10 +688,6 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, { ds_id = vm->get_ds_id(); } - else if (!vm->get_deploy_id().empty()) //deploy_id && not a Stopped VM - { - imported = true; - } vm->unlock(); @@ -800,13 +795,13 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, return; } - if (!imported) + if (vm->isImported()) { - dm->deploy(vm); + dm->import(vm); } else { - dm->import(vm); + dm->deploy(vm); } vm->unlock(); diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index ae4e6f7ce5..ef41a13855 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -2230,6 +2230,18 @@ bool VirtualMachine::isVolatile(const Template * tmpl) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +bool VirtualMachine::isImported() const +{ + bool is_imported = false; + + get_template_attribute("IMPORTED", is_imported); + + return is_imported; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + long long VirtualMachine::get_volatile_disk_size(Template * tmpl) { long long size = 0;