mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-04 22:21:36 +09:00
* Remove vm_import table from DB * Remove imported vms actions * Fix fsck for image and network * onedb fsck fix running_vms only for non-backup images
This commit is contained in:
1 parent
f4616d0c1f
commit
fa73142e7d
40 files changed
+68
-1300
No files matched your search
@@ -76,56 +76,8 @@ int VirtualMachinePool::update(PoolObjectSQL * objsql)
|
||||
return vm->update(db);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachinePool::insert_index(const string& deploy_id, int vmid,
|
||||
bool replace)
|
||||
{
|
||||
ostringstream oss;
|
||||
char * deploy_name = db->escape_str(deploy_id);
|
||||
|
||||
if (deploy_name == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (replace)
|
||||
{
|
||||
oss << "REPLACE ";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << "INSERT ";
|
||||
}
|
||||
|
||||
oss << "INTO " << one_db::vm_import_table
|
||||
<< " (" << one_db::vm_import_db_names << ") "
|
||||
<< " VALUES ('" << deploy_name << "'," << vmid << ")";
|
||||
|
||||
db->free_str(deploy_name);
|
||||
|
||||
return db->exec_wr(oss);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachinePool::drop_index(const string& deploy_id)
|
||||
{
|
||||
ostringstream oss;
|
||||
char * deploy_name = db->escape_str(deploy_id);
|
||||
|
||||
if (deploy_name == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
oss << "DELETE FROM " << one_db::vm_import_table << " WHERE deploy_id='"
|
||||
<< deploy_name << "'";
|
||||
|
||||
db->exec_wr(oss);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachinePool::allocate(
|
||||
@@ -157,20 +109,6 @@ int VirtualMachinePool::allocate(
|
||||
|
||||
vm.prev_state = vm.state;
|
||||
|
||||
string deploy_id;
|
||||
vm.user_obj_template->get("DEPLOY_ID", deploy_id);
|
||||
|
||||
if (!deploy_id.empty())
|
||||
{
|
||||
vm.state = VirtualMachine::HOLD;
|
||||
|
||||
if (insert_index(deploy_id, -1, false) == -1) //Set import in progress
|
||||
{
|
||||
error_str = "Virtual Machine " + deploy_id + " already imported.";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Insert the Object in the pool
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -181,18 +119,6 @@ int VirtualMachinePool::allocate(
|
||||
// Insert the deploy_id - vmid index for imported VMs
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!deploy_id.empty())
|
||||
{
|
||||
if (*oid >= 0)
|
||||
{
|
||||
insert_index(deploy_id, *oid, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
drop_index(deploy_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (*oid >= 0)
|
||||
{
|
||||
if (auto vm2 = get_ro(*oid))
|
||||
@@ -487,38 +413,6 @@ VirtualMachineMonitorInfo VirtualMachinePool::get_monitoring(int vmid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachinePool::get_vmid(const string& deploy_id)
|
||||
{
|
||||
int rc;
|
||||
int vmid = -1;
|
||||
ostringstream oss;
|
||||
|
||||
auto sql_id = db->escape_str(deploy_id);
|
||||
|
||||
single_cb<int> cb;
|
||||
|
||||
cb.set_callback(&vmid);
|
||||
|
||||
oss << "SELECT vmid FROM " << one_db::vm_import_table
|
||||
<< " WHERE deploy_id = '" << sql_id << "'";
|
||||
|
||||
rc = db->exec_rd(oss, &cb);
|
||||
|
||||
cb.unset_callback();
|
||||
|
||||
db->free_str(sql_id);
|
||||
|
||||
if (rc != 0 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return vmid;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SBDEBUG
|
||||
#include <chrono>
|
||||
|
||||
|
||||
Reference in new issue
Block a user