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

Bug #3622: Return error if trying to import an OpenNebula vm: one-*

This commit is contained in:
Jaime Melis 2015-02-23 14:38:11 +01:00
parent 0c4f02ca75
commit 37b8eeb025

View File

@ -18,6 +18,7 @@
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <regex.h>
#include <unistd.h>
#include <iostream>
@ -443,18 +444,27 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
// -------------------------------------------------------------------------
// Get and set DEPLOY_ID for imported VMs
// -------------------------------------------------------------------------
user_obj_template->get("IMPORT_VM_ID", value);
user_obj_template->erase("IMPORT_VM_ID");
if (!value.empty())
{
deploy_id = value;
obj_template->add("IMPORTED", "YES");
const char * one_vms = "^one-[[:digit:]]+$";
if (one_util::regex_match(one_vms, value.c_str()) == 0)
{
goto error_one_vms;
}
else
{
deploy_id = value;
obj_template->add("IMPORTED", "YES");
}
}
// ------------------------------------------------------------------------
parse_well_known_attributes();
// ------------------------------------------------------------------------
@ -509,6 +519,10 @@ error_memory_cost:
error_str = "MEMORY_COST attribute must be a positive float or integer value.";
goto error_common;
error_one_vms:
error_str = "Trying to import an OpenNebula VM: 'one-*'.";
goto error_common;
error_os:
error_defaults:
error_name: