mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
schema,framework/db,server: fix user_vm_details usage (#11292)
* schema,framework/db,server: fix user_vm_details usage Continuation of #10736 * python files Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
13892e2ff0
commit
407072ffd4
@ -204,9 +204,9 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
||||
"(CASE WHEN ISNULL(service_offering.speed) THEN custom_speed.value ELSE service_offering.speed end) AS speed, " +
|
||||
"(CASE WHEN ISNULL(service_offering.ram_size) THEN custom_ram_size.value ELSE service_offering.ram_size end) AS ram_size " +
|
||||
"FROM vm_instance vi LEFT JOIN service_offering ON(((vi.service_offering_id = service_offering.id))) " +
|
||||
"LEFT JOIN user_vm_details custom_cpu ON(((custom_cpu.vm_id = vi.id) AND (custom_cpu.name = 'CpuNumber'))) " +
|
||||
"LEFT JOIN user_vm_details custom_speed ON(((custom_speed.vm_id = vi.id) AND (custom_speed.name = 'CpuSpeed'))) " +
|
||||
"LEFT JOIN user_vm_details custom_ram_size ON(((custom_ram_size.vm_id = vi.id) AND (custom_ram_size.name = 'memory'))) ";
|
||||
"LEFT JOIN vm_instance_details custom_cpu ON(((custom_cpu.vm_id = vi.id) AND (custom_cpu.name = 'CpuNumber'))) " +
|
||||
"LEFT JOIN vm_instance_details custom_speed ON(((custom_speed.vm_id = vi.id) AND (custom_speed.name = 'CpuSpeed'))) " +
|
||||
"LEFT JOIN vm_instance_details custom_ram_size ON(((custom_ram_size.vm_id = vi.id) AND (custom_ram_size.name = 'memory'))) ";
|
||||
|
||||
private static final String WHERE_STATE_IS_NOT_DESTRUCTIVE =
|
||||
"WHERE ISNULL(vi.removed) AND vi.state NOT IN ('Destroyed', 'Error', 'Expunging')";
|
||||
|
||||
@ -336,7 +336,7 @@ public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long>
|
||||
+ " END)) as total "
|
||||
+ " from vm_instance vm "
|
||||
+ " join service_offering so on so.id = vm.service_offering_id "
|
||||
+ " left join user_vm_details vmd on vmd.vm_id = vm.id and vmd.name = '%s' "
|
||||
+ " left join vm_instance_details vmd on vmd.vm_id = vm.id and vmd.name = '%s' "
|
||||
+ " where vm.type = 'User' and state not in ('Destroyed', 'Error', 'Expunging') and display_vm = true and account_id = ? ";
|
||||
|
||||
@Override
|
||||
|
||||
@ -124,8 +124,8 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
||||
+ "left join security_group on security_group_vm_map.security_group_id=security_group.id " + "left join nics on vm_instance.id=nics.instance_id "
|
||||
+ "left join networks on nics.network_id=networks.id " + "left join user_ip_address on user_ip_address.vm_id=vm_instance.id " + "where vm_instance.id in (";
|
||||
|
||||
private static final String VMS_DETAIL_BY_NAME = "select vm_instance.instance_name, vm_instance.vm_type, vm_instance.id , user_vm_details.value, user_vm_details.name from vm_instance "
|
||||
+ "left join user_vm_details on vm_instance.id = user_vm_details.vm_id where (user_vm_details.name is null or user_vm_details.name = ? ) and vm_instance.instance_name in (";
|
||||
private static final String VMS_DETAIL_BY_NAME = "select vm_instance.instance_name, vm_instance.vm_type, vm_instance.id , vm_instance_details.value, vm_instance_details.name from vm_instance "
|
||||
+ "left join vm_instance_details on vm_instance.id = vm_instance_details.vm_id where (vm_instance_details.name is null or vm_instance_details.name = ? ) and vm_instance.instance_name in (";
|
||||
|
||||
private static final int VM_DETAILS_BATCH_SIZE = 100;
|
||||
|
||||
@ -755,7 +755,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
|
||||
while (rs.next()) {
|
||||
vmsDetailByNames.add(new Pair<Pair<String, VirtualMachine.Type>, Pair<Long, String>>(new Pair<String, VirtualMachine.Type>(
|
||||
rs.getString("vm_instance.instance_name"), VirtualMachine.Type.valueOf(rs.getString("vm_type"))),
|
||||
new Pair<Long, String>(rs.getLong("vm_instance.id"), rs.getString("user_vm_details.value"))));
|
||||
new Pair<Long, String>(rs.getLong("vm_instance.id"), rs.getString("vm_instance_details.value"))));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
@ -632,7 +632,7 @@ public class EncryptionSecretKeyChanger {
|
||||
|
||||
private void migrateUserVmDetails(Connection conn) {
|
||||
System.out.println("Begin migrate user vm details");
|
||||
migrateDetails(conn, "user_vm_details", PASSWORD);
|
||||
migrateDetails(conn, "vm_instance_details", PASSWORD);
|
||||
System.out.println("End migrate user vm details");
|
||||
}
|
||||
|
||||
|
||||
@ -3203,7 +3203,7 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies vm vram size if it was set to a different size to the one provided in svga.vramSize (user_vm_details or template_vm_details) on {@code vmConfigSpec}
|
||||
* Modifies vm vram size if it was set to a different size to the one provided in svga.vramSize (vm_instance_details or template_vm_details) on {@code vmConfigSpec}
|
||||
*
|
||||
* @param videoCard vm's video card device
|
||||
* @param vmMo virtual machine mo
|
||||
|
||||
@ -6324,7 +6324,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
}
|
||||
}
|
||||
|
||||
// Add extraConfig to user_vm_details table
|
||||
// Add extraConfig to vm_instance_details table
|
||||
String extraConfig = cmd.getExtraConfig();
|
||||
if (StringUtils.isNotBlank(extraConfig)) {
|
||||
if (EnableAdditionalVmConfig.valueIn(callerId)) {
|
||||
@ -6482,7 +6482,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist extra configuration data in the user_vm_details table as key/value pair
|
||||
* Persist extra configuration data in the vm_instance_details table as key/value pair
|
||||
* @param decodedUrl String consisting of the extra config data to appended onto the vmx file for VMware instances
|
||||
*/
|
||||
protected void persistExtraConfigVmware(String decodedUrl, UserVm vm) {
|
||||
@ -6506,7 +6506,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to persist extra configuration settings in user_vm_details table for the XenServer hypervisor
|
||||
* Used to persist extra configuration settings in vm_instance_details table for the XenServer hypervisor
|
||||
* persists config as key/value pair e.g key = extraconfig-1 , value="PV-bootloader=pygrub" and so on to extraconfig-N where
|
||||
* N denotes the number of extra configuration settings passed by user
|
||||
*
|
||||
@ -6587,9 +6587,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
|
||||
/**
|
||||
* Persist extra configuration data on KVM
|
||||
* persisted in the user_vm_details DB as extraconfig-1, and so on depending on the number of configurations
|
||||
* persisted in the vm_instance_details DB as extraconfig-1, and so on depending on the number of configurations
|
||||
* For KVM, extra config is passed as XML
|
||||
* @param decodedUrl string containing xml configuration to be persisted into user_vm_details table
|
||||
* @param decodedUrl string containing xml configuration to be persisted into vm_instance_details table
|
||||
* @param vm
|
||||
*/
|
||||
protected void persistExtraConfigKvm(String decodedUrl, UserVm vm) {
|
||||
|
||||
@ -308,7 +308,7 @@ class TestResizeVolume(cloudstackTestCase):
|
||||
vmid = int(qresultvmuuid[0][0])
|
||||
qresult = self.dbclient.execute(
|
||||
"select rootDiskController from"
|
||||
" user_vm_details where id = '%s';" % vmid
|
||||
" vm_instance_details where id = '%s';" % vmid
|
||||
)
|
||||
self.debug("Query result: %s" % qresult)
|
||||
diskcontroller = qresult[0][0]
|
||||
|
||||
@ -186,7 +186,7 @@ class TestUpdateVirtualMachine(cloudstackTestCase):
|
||||
vm_db_id = dbresult[0][0]
|
||||
self.debug("VM has database id %d" % vm_db_id)
|
||||
|
||||
self.dbclient.execute("insert into user_vm_details (vm_id, name, value, display) values (%d,'%s','HOST', 0)" % (vm_db_id, hidden_detail_name))
|
||||
self.dbclient.execute("insert into vm_instance_details (vm_id, name, value, display) values (%d,'%s','HOST', 0)" % (vm_db_id, hidden_detail_name))
|
||||
|
||||
vm = self.listVmById(self.virtual_machine.id)
|
||||
self.debug("VirtualMachine fetched with details: %s of type %s" % (vm.details, type(vm.details)))
|
||||
@ -227,7 +227,7 @@ class TestUpdateVirtualMachine(cloudstackTestCase):
|
||||
|
||||
|
||||
def detailInDatabase(self, vm_id, detail_name):
|
||||
dbresult = self.dbclient.execute("select id from user_vm_details where vm_id=%s and name='%s'" % (vm_id, detail_name))
|
||||
dbresult = self.dbclient.execute("select id from vm_instance_details where vm_id=%s and name='%s'" % (vm_id, detail_name))
|
||||
self.debug("Detail %s for VM %s: %s" % (detail_name, vm_id, dbresult))
|
||||
if validateList(dbresult)[0] == PASS:
|
||||
return True
|
||||
|
||||
@ -319,7 +319,7 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
|
||||
|
||||
qresultset = self.dbclient.execute("select id from vm_instance where uuid = '%s';" % self.virtual_machine.id)
|
||||
vm_id = qresultset[0]
|
||||
qresultset = self.dbclient.execute("select name, value from user_vm_details where vm_id = '%d';" % vm_id)
|
||||
qresultset = self.dbclient.execute("select name, value from vm_instance_details where vm_id = '%d';" % vm_id)
|
||||
detailKeys = [x[0] for x in qresultset]
|
||||
|
||||
self.assertTrue('mks.enable3d' in detailKeys and 'mks.use3dRenderer' in detailKeys and 'svga.autodetect' in detailKeys and 'svga.vramSize' in detailKeys, "VM details do not contain 3D GPU details")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user