1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-10 01:17:40 +03:00

F #1709: Add index to state in VM pool

This commit is contained in:
Ruben S. Montero 2018-02-02 17:03:45 +01:00
parent 37ce0d2a8f
commit 37e14b23f5
3 changed files with 34 additions and 16 deletions

View File

@ -1750,22 +1750,7 @@ private:
* Bootstraps the database table(s) associated to the VirtualMachine
* @return 0 on success
*/
static int bootstrap(SqlDB * db)
{
int rc;
ostringstream oss_vm(VirtualMachine::db_bootstrap);
ostringstream oss_monit(VirtualMachine::monit_db_bootstrap);
ostringstream oss_hist(History::db_bootstrap);
ostringstream oss_showback(VirtualMachine::showback_db_bootstrap);
rc = db->exec_local_wr(oss_vm);
rc += db->exec_local_wr(oss_monit);
rc += db->exec_local_wr(oss_hist);
rc += db->exec_local_wr(oss_showback);
return rc;
};
static int bootstrap(SqlDB * db);
/**
* Callback function to unmarshall a VirtualMachine object

View File

@ -33,6 +33,8 @@ module Migrator
feature_5189()
feature_1709()
log_time()
return true
@ -55,6 +57,14 @@ module Migrator
end
end
def feature_1709()
indexes = @db.indexes(:vm_pool)
@db.alter_table(:vm_pool) do
add_index :state, name: :state_idx if !indexes[:state_idx]
end
end
def feature_5189()
az_driver_conf = "#{ETC_LOCATION}/az_driver.conf.old"
token = File.read(VAR_LOCATION+'/.one/one_key')

View File

@ -482,6 +482,29 @@ const char * VirtualMachine::showback_db_bootstrap =
"(vmid INTEGER, year INTEGER, month INTEGER, body MEDIUMTEXT, "
"PRIMARY KEY(vmid, year, month))";
/* -------------------------------------------------------------------------- */
int VirtualMachine::bootstrap(SqlDB * db)
{
int rc;
ostringstream oss_vm(VirtualMachine::db_bootstrap);
ostringstream oss_monit(VirtualMachine::monit_db_bootstrap);
ostringstream oss_hist(History::db_bootstrap);
ostringstream oss_showback(VirtualMachine::showback_db_bootstrap);
ostringstream oss_index("CREATE INDEX state_idx on vm_pool (state);");
rc = db->exec_local_wr(oss_vm);
rc += db->exec_local_wr(oss_index);
rc += db->exec_local_wr(oss_monit);
rc += db->exec_local_wr(oss_hist);
rc += db->exec_local_wr(oss_showback);
return rc;
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */