Omer Frenkel has uploaded a new change for review. Change subject: core: add support for instance type ......................................................................
core: add support for instance type Change-Id: I110e74c6fc8906e3d257c7cf31d2af2b1b800218 Signed-off-by: Omer Frenkel <[email protected]> --- M backend/manager/dbscripts/create_views.sql A backend/manager/dbscripts/upgrade/03_02_0470_add_instance_type_to_vm.sql M backend/manager/dbscripts/vm_templates_sp.sql M backend/manager/dbscripts/vms_sp.sql M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/TemplateType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/resources/fixtures.xml M frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml M frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties 15 files changed, 155 insertions(+), 30 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/78/12278/1 diff --git a/backend/manager/dbscripts/create_views.sql b/backend/manager/dbscripts/create_views.sql index ec9d080..e9fbd63 100644 --- a/backend/manager/dbscripts/create_views.sql +++ b/backend/manager/dbscripts/create_views.sql @@ -376,14 +376,15 @@ vm_templates.dedicated_vm_for_vds, vm_templates.is_disabled, vm_templates.tunnel_migration, - vm_templates.vnc_keyboard_layout as vnc_keyboard_layout + vm_templates.vnc_keyboard_layout as vnc_keyboard_layout, + vm_templates.entity_type FROM vm_static AS vm_templates INNER JOIN vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id left outer JOIN storage_pool ON storage_pool.id = vds_groups.storage_pool_id left outer JOIN quota ON vm_templates.quota_id = quota.id -WHERE entity_type = 'TEMPLATE'; +WHERE entity_type = 'TEMPLATE' OR entity_type = 'INSTANCE_TYPE' OR entity_type = 'IMAGE_TYPE'; @@ -411,7 +412,7 @@ vm_templates.default_boot_sequence, vm_templates.default_display_type, vm_templates.priority, vm_templates.auto_startup, vm_templates.is_stateless, vm_templates.iso_path, vm_templates.origin, vm_templates.initrd_url, vm_templates.kernel_url, vm_templates.kernel_params, image_storage_domain_map.storage_domain_id AS storage_id, - quota.quota_name as quota_name, vm_templates.is_disabled + quota.quota_name as quota_name, vm_templates.is_disabled, vm_templates.entity_type FROM vm_static AS vm_templates INNER JOIN vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id LEFT OUTER JOIN storage_pool ON storage_pool.id = vds_groups.storage_pool_id INNER JOIN @@ -419,7 +420,7 @@ images ON images.image_group_id = vm_device.device_id LEFT JOIN image_storage_domain_map ON image_storage_domain_map.image_id = images.image_guid LEFT OUTER JOIN quota quota on quota.id = vm_templates.quota_id -WHERE entity_type = 'TEMPLATE' +WHERE entity_type = 'TEMPLATE' OR entity_type = 'INSTANCE_TYPE' OR entity_type = 'IMAGE_TYPE' UNION SELECT vm_templates_1.vm_guid AS vmt_guid, vm_templates_1.vm_name AS name, vm_templates_1.mem_size_mb, vm_templates_1.os, vm_templates_1.creation_date, vm_templates_1.child_count, vm_templates_1.num_of_sockets, vm_templates_1.cpu_per_socket, @@ -431,7 +432,7 @@ vm_templates_1.priority, vm_templates_1.auto_startup, vm_templates_1.is_stateless, vm_templates_1.iso_path, vm_templates_1.origin, vm_templates_1.initrd_url, vm_templates_1.kernel_url, vm_templates_1.kernel_params, image_storage_domain_map.storage_domain_id AS storage_id, - quota.quota_name as quota_name, vm_templates_1.is_disabled + quota.quota_name as quota_name, vm_templates_1.is_disabled, vm_templates_1.entity_type FROM vm_static AS vm_templates_1 INNER JOIN vds_groups AS vds_groups_1 ON vm_templates_1.vds_group_id = vds_groups_1.vds_group_id LEFT OUTER JOIN storage_pool AS storage_pool_1 ON storage_pool_1.id = vds_groups_1.storage_pool_id INNER JOIN @@ -439,7 +440,7 @@ images AS images_1 ON images_1.image_group_id = vm_device_1.device_id INNER JOIN image_storage_domain_map ON image_storage_domain_map.image_id = images_1.image_guid LEFT OUTER JOIN quota quota on quota.id = vm_templates_1.quota_id -WHERE entity_type = 'TEMPLATE'; +WHERE entity_type = 'TEMPLATE' OR entity_type = 'INSTANCE_TYPE' OR entity_type = 'IMAGE_TYPE'; CREATE OR REPLACE VIEW vm_pool_map_view @@ -550,7 +551,8 @@ vm_statistics.usage_mem_percent as usage_mem_percent, vm_statistics.usage_cpu_percent as usage_cpu_percent, vds_static.vds_name as run_on_vds_name, vds_groups.cpu_name as vds_group_cpu_name, vm_static.default_display_type as default_display_type, vm_static.priority as priority,vm_static.iso_path as iso_path, vm_static.origin as origin, vds_groups.compatibility_version as vds_group_compatibility_version, vm_static.initrd_url as initrd_url, vm_static.kernel_url as kernel_url, vm_static.kernel_params as kernel_params, vm_dynamic.pause_status as pause_status, vm_dynamic.exit_message as exit_message, vm_dynamic.exit_status as exit_status,vm_static.migration_support as migration_support,vm_static.predefined_properties as predefined_properties,vm_static.userdefined_properties as userdefined_properties,vm_static.min_allocated_mem as min_allocated_mem, vm_dynamic.hash as hash, vm_static.cpu_pinning as cpu_pinning, vm_static.db_generation as db_generation, vm_static.host_cpu_flags as host_cpu_flags, - vm_static.tunnel_migration as tunnel_migration, vm_static.vnc_keyboard_layout as vnc_keyboard_layout + vm_static.tunnel_migration as tunnel_migration, vm_static.vnc_keyboard_layout as vnc_keyboard_layout, + vm_static.instance_type_id as instance_type_id, vm_static.image_type_id as image_type_id FROM vm_static INNER JOIN vm_dynamic ON vm_static.vm_guid = vm_dynamic.vm_guid INNER JOIN vm_static AS vm_templates ON vm_static.vmt_guid = vm_templates.vm_guid INNER JOIN @@ -587,7 +589,7 @@ vms.vds_group_compatibility_version, vms.initrd_url, vms.kernel_url, vms.kernel_params, vms.pause_status, vms.exit_status, vms.exit_message, vms.min_allocated_mem, storage_domain_static.id AS storage_id, vms.quota_id as quota_id, vms.quota_name as quota_name, vms.tunnel_migration as tunnel_migration, - vms.vnc_keyboard_layout as vnc_keyboard_layout + vms.vnc_keyboard_layout as vnc_keyboard_layout, vms.instance_type_id as instance_type_id, vms.image_type_id as image_type_id FROM vms LEFT OUTER JOIN tags_vm_map_view ON vms.vm_guid = tags_vm_map_view.vm_id LEFT OUTER JOIN vm_device ON vm_device.vm_id = vms.vm_guid LEFT OUTER JOIN @@ -1338,7 +1340,9 @@ SELECT vm_guid, ad_element_id FROM internal_permissions_view CROSS JOIN vm_static -WHERE object_type_id = 1 AND allows_viewing_children AND role_type = 2 AND vm_static.entity_type::text = 'TEMPLATE'::text; +WHERE object_type_id = 1 AND allows_viewing_children AND role_type = 2 AND +(vm_static.entity_type::text = 'TEMPLATE'::text OR vm_static.entity_type::text = 'INSTANCE_TYPE'::text + OR vm_static.entity_type::text = 'IMAGE_TYPE'::text); CREATE OR REPLACE VIEW user_vm_template_permissions_view (entity_id, user_id) AS diff --git a/backend/manager/dbscripts/upgrade/03_02_0470_add_instance_type_to_vm.sql b/backend/manager/dbscripts/upgrade/03_02_0470_add_instance_type_to_vm.sql new file mode 100644 index 0000000..95f1ab4 --- /dev/null +++ b/backend/manager/dbscripts/upgrade/03_02_0470_add_instance_type_to_vm.sql @@ -0,0 +1,3 @@ +select fn_db_add_column('vm_static', 'instance_type_id', 'uuid default null'); +select fn_db_add_column('vm_static', 'image_type_id', 'uuid default null'); + diff --git a/backend/manager/dbscripts/vm_templates_sp.sql b/backend/manager/dbscripts/vm_templates_sp.sql index 05442af..3f12dd7 100644 --- a/backend/manager/dbscripts/vm_templates_sp.sql +++ b/backend/manager/dbscripts/vm_templates_sp.sql @@ -44,7 +44,8 @@ v_migration_support integer, v_dedicated_vm_for_vds UUID, v_tunnel_migration BOOLEAN, - v_vnc_keyboard_layout VARCHAR(16)) + v_vnc_keyboard_layout VARCHAR(16), + v_template_type VARCHAR(40)) RETURNS VOID AS $procedure$ @@ -125,7 +126,7 @@ v_initrd_url, v_kernel_url, v_kernel_params, - 'TEMPLATE', + v_template_type, v_quota_id, v_migration_support, v_is_disabled, @@ -184,7 +185,8 @@ v_migration_support integer, v_dedicated_vm_for_vds uuid, v_tunnel_migration BOOLEAN, - v_vnc_keyboard_layout VARCHAR(16)) + v_vnc_keyboard_layout VARCHAR(16), + v_template_type VARCHAR(40)) RETURNS VOID --The [vm_templates] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated @@ -208,14 +210,15 @@ is_delete_protected = v_is_delete_protected, is_disabled = v_is_disabled, tunnel_migration = v_tunnel_migration, vnc_keyboard_layout = v_vnc_keyboard_layout WHERE vm_guid = v_vmt_guid - AND entity_type = 'TEMPLATE'; + AND entity_type = v_template_type; END; $procedure$ LANGUAGE plpgsql; Create or replace FUNCTION UpdateVmTemplateStatus( v_vmt_guid UUID, - v_status INTEGER) + v_status INTEGER, + v_template_type VARCHAR(40)) RETURNS VOID AS $procedure$ @@ -223,14 +226,14 @@ UPDATE vm_static SET template_status = v_status WHERE vm_guid = v_vmt_guid - AND entity_type = 'TEMPLATE'; + AND entity_type = v_template_type; END; $procedure$ LANGUAGE plpgsql; -Create or replace FUNCTION DeleteVmTemplates(v_vmt_guid UUID) +Create or replace FUNCTION DeleteVmTemplates(v_vmt_guid UUID, v_template_type VARCHAR(40)) RETURNS VOID AS $procedure$ DECLARE @@ -238,10 +241,10 @@ BEGIN -- Get (and keep) a shared lock with "right to upgrade to exclusive" -- in order to force locking parent before children - select vm_guid INTO v_val FROM vm_static WHERE vm_guid = v_vmt_guid AND entity_type = 'TEMPLATE' FOR UPDATE; + select vm_guid INTO v_val FROM vm_static WHERE vm_guid = v_vmt_guid AND entity_type = v_template_type FOR UPDATE; DELETE FROM vm_static WHERE vm_guid = v_vmt_guid - AND entity_type = 'TEMPLATE'; + AND entity_type = v_template_type; -- delete Template permissions -- DELETE FROM permissions where object_id = v_vmt_guid; END; $procedure$ diff --git a/backend/manager/dbscripts/vms_sp.sql b/backend/manager/dbscripts/vms_sp.sql index feb629b..08baeb7 100644 --- a/backend/manager/dbscripts/vms_sp.sql +++ b/backend/manager/dbscripts/vms_sp.sql @@ -430,12 +430,14 @@ v_cpu_pinning VARCHAR(4000), v_host_cpu_flags BOOLEAN, v_tunnel_migration BOOLEAN, - v_vnc_keyboard_layout VARCHAR(16)) + v_vnc_keyboard_layout VARCHAR(16), + v_instance_type_id UUID, + v_image_type_id UUID) RETURNS VOID AS $procedure$ BEGIN -INSERT INTO vm_static(description, mem_size_mb, os, vds_group_id, vm_guid, VM_NAME, vmt_guid,domain,creation_date,num_of_monitors,allow_console_reconnect,is_initialized,is_auto_suspend,num_of_sockets,cpu_per_socket,usb_policy, time_zone,auto_startup,is_stateless,dedicated_vm_for_vds, fail_back, default_boot_sequence, vm_type, nice_level, default_display_type, priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem, entity_type, quota_id, cpu_pinning, is_smartcard_enabled,is_delete_protected,host_cpu_flags, tunnel_migration, vnc_keyboard_layout) - VALUES(v_description, v_mem_size_mb, v_os, v_vds_group_id, v_vm_guid, v_vm_name, v_vmt_guid, v_domain, v_creation_date, v_num_of_monitors, v_allow_console_reconnect, v_is_initialized, v_is_auto_suspend, v_num_of_sockets, v_cpu_per_socket, v_usb_policy, v_time_zone, v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back, v_default_boot_sequence, v_vm_type, v_nice_level, v_default_display_type, v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem, 'VM', v_quota_id, v_cpu_pinning, v_is_smartcard_enabled,v_is_delete_protected,v_host_cpu_flags, v_tunnel_migration, v_vnc_keyboard_layout); +INSERT INTO vm_static(description, mem_size_mb, os, vds_group_id, vm_guid, VM_NAME, vmt_guid,domain,creation_date,num_of_monitors,allow_console_reconnect,is_initialized,is_auto_suspend,num_of_sockets,cpu_per_socket,usb_policy, time_zone,auto_startup,is_stateless,dedicated_vm_for_vds, fail_back, default_boot_sequence, vm_type, nice_level, default_display_type, priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem, entity_type, quota_id, cpu_pinning, is_smartcard_enabled,is_delete_protected,host_cpu_flags, tunnel_migration, vnc_keyboard_layout, instance_type_id, image_type_id) + VALUES(v_description, v_mem_size_mb, v_os, v_vds_group_id, v_vm_guid, v_vm_name, v_vmt_guid, v_domain, v_creation_date, v_num_of_monitors, v_allow_console_reconnect, v_is_initialized, v_is_auto_suspend, v_num_of_sockets, v_cpu_per_socket, v_usb_policy, v_time_zone, v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back, v_default_boot_sequence, v_vm_type, v_nice_level, v_default_display_type, v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem, 'VM', v_quota_id, v_cpu_pinning, v_is_smartcard_enabled,v_is_delete_protected,v_host_cpu_flags, v_tunnel_migration, v_vnc_keyboard_layout, v_instance_type_id, v_image_type_id); -- perform deletion from vm_ovf_generations to ensure that no record exists when performing insert to avoid PK violation. DELETE FROM vm_ovf_generations gen WHERE gen.vm_guid = v_vm_guid; INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id) VALUES (v_vm_guid, (SELECT storage_pool_id FROM vds_groups vg WHERE vg.vds_group_id = v_vds_group_id)); @@ -545,7 +547,9 @@ v_cpu_pinning VARCHAR(4000), v_host_cpu_flags BOOLEAN, v_tunnel_migration BOOLEAN, -v_vnc_keyboard_layout VARCHAR(16)) +v_vnc_keyboard_layout VARCHAR(16), +v_instance_type_id UUID, +v_image_type_id UUID) RETURNS VOID --The [vm_static] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated @@ -569,7 +573,7 @@ predefined_properties = v_predefined_properties,userdefined_properties = v_userdefined_properties, min_allocated_mem = v_min_allocated_mem, quota_id = v_quota_id, cpu_pinning = v_cpu_pinning, is_smartcard_enabled = v_is_smartcard_enabled, is_delete_protected = v_is_delete_protected, host_cpu_flags = v_host_cpu_flags, tunnel_migration = v_tunnel_migration, - vnc_keyboard_layout = v_vnc_keyboard_layout + vnc_keyboard_layout = v_vnc_keyboard_layout, instance_type_id = v_instance_type_id, image_type_id = v_image_type_id WHERE vm_guid = v_vm_guid AND entity_type = 'VM'; END; $procedure$ @@ -878,12 +882,14 @@ v_min_allocated_mem INTEGER, v_cpu_pinning varchar(4000), v_host_cpu_flags BOOLEAN, - v_tunnel_migration BOOLEAN) + v_tunnel_migration BOOLEAN, + v_instance_type_id UUID, + v_image_type_id UUID) RETURNS VOID AS $procedure$ BEGIN -INSERT INTO vm_static(description, mem_size_mb, os, vds_group_id, vm_guid, VM_NAME, vmt_guid, num_of_monitors, allow_console_reconnect, is_initialized, is_auto_suspend, num_of_sockets, cpu_per_socket, usb_policy, time_zone,auto_startup,is_stateless,dedicated_vm_for_vds,fail_back,vm_type,nice_level,default_boot_sequence,default_display_type,priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem,cpu_pinning,is_smartcard_enabled,is_delete_protected,host_cpu_flags, tunnel_migration) - VALUES(v_description, v_mem_size_mb, v_os, v_vds_group_id, v_vm_guid, v_vm_name, v_vmt_guid, v_num_of_monitors, v_num_of_monitors, v_is_initialized, v_is_auto_suspend, v_num_of_sockets, v_cpu_per_socket, v_usb_policy, v_time_zone,v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back,v_vm_type,v_nice_level,v_default_boot_sequence,v_default_display_type,v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem,v_cpu_pinning,v_is_smartcard_enabled,v_is_delete_protected,v_host_cpu_flags, v_tunnel_migration); +INSERT INTO vm_static(description, mem_size_mb, os, vds_group_id, vm_guid, VM_NAME, vmt_guid, num_of_monitors, allow_console_reconnect, is_initialized, is_auto_suspend, num_of_sockets, cpu_per_socket, usb_policy, time_zone,auto_startup,is_stateless,dedicated_vm_for_vds,fail_back,vm_type,nice_level,default_boot_sequence,default_display_type,priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem,cpu_pinning,is_smartcard_enabled,is_delete_protected,host_cpu_flags, tunnel_migration, instance_type_id, image_type_id) + VALUES(v_description, v_mem_size_mb, v_os, v_vds_group_id, v_vm_guid, v_vm_name, v_vmt_guid, v_num_of_monitors, v_num_of_monitors, v_is_initialized, v_is_auto_suspend, v_num_of_sockets, v_cpu_per_socket, v_usb_policy, v_time_zone,v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back,v_vm_type,v_nice_level,v_default_boot_sequence,v_default_display_type,v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem,v_cpu_pinning,v_is_smartcard_enabled,v_is_delete_protected,v_host_cpu_flags, v_tunnel_migration, v_instance_type_id, v_image_type_id); INSERT INTO vm_dynamic(vm_guid, status) VALUES(v_vm_guid, 0); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java index 68d996a..efd11c9 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java @@ -99,7 +99,6 @@ inspectedClassNames)) { mUpdateVmsStatic.AddField(Arrays.asList(pair.getFirst().statuses()), pair.getSecond()); } - } public static boolean isUpdateValid(VmStatic source, VmStatic destination, VMStatus status) { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/TemplateType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/TemplateType.java new file mode 100644 index 0000000..3f756e4 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/TemplateType.java @@ -0,0 +1,7 @@ +package org.ovirt.engine.core.common.businessentities; + +public enum TemplateType { + TEMPLATE, + INSTANCE_TYPE, + IMAGE_TYPE; +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java index e769c5b..f592228 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java @@ -1434,4 +1434,20 @@ public void setTunnelMigration(Boolean value) { vmStatic.setTunnelMigration(value); } + + public NGuid getInstanceTypeId() { + return vmStatic.getInstanceTypeId(); + } + + public void setInstanceTypeId(NGuid instanceTypeId) { + vmStatic.setInstanceTypeId(instanceTypeId); + } + + public NGuid getImageTypeId() { + return vmStatic.getImageTypeId(); + } + + public void setImageTypeId(NGuid ImageTypeId) { + vmStatic.setImageTypeId(ImageTypeId); + } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java index 98cc4f3..16e596c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java @@ -9,6 +9,7 @@ import org.ovirt.engine.core.common.validation.group.ImportClonedEntity; import org.ovirt.engine.core.common.validation.group.UpdateEntity; import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.compat.NGuid; public class VmStatic extends VmBase { private static final long serialVersionUID = -2753306386502558044L; @@ -45,6 +46,8 @@ @EditableField private boolean useHostCpuFlags = false; + private NGuid instanceTypeId; + private NGuid imageTypeId; public VmStatic() { setNumOfMonitors(1); @@ -193,6 +196,8 @@ result = prime * result + ((userDefinedProperties == null) ? 0 : userDefinedProperties.hashCode()); result = prime * result + ((vmtGuid == null) ? 0 : vmtGuid.hashCode()); result = prime * result + (useHostCpuFlags ? 0 : 1); + result = prime * result + ((instanceTypeId == null) ? 0 : instanceTypeId.hashCode()); + result = prime * result + ((imageTypeId == null) ? 0 : imageTypeId.hashCode()); return result; } @@ -248,6 +253,20 @@ if(useHostCpuFlags != other.useHostCpuFlags) { return false; } + if (instanceTypeId == null) { + if (other.instanceTypeId != null) { + return false; + } + } else if (!instanceTypeId.equals(other.instanceTypeId)) { + return false; + } + if (imageTypeId == null) { + if (other.imageTypeId != null) { + return false; + } + } else if (!imageTypeId.equals(other.imageTypeId)) { + return false; + } return true; } @@ -259,4 +278,19 @@ this.useHostCpuFlags = useHostCpuFlags; } + public NGuid getInstanceTypeId() { + return instanceTypeId; + } + + public void setInstanceTypeId(NGuid instanceTypeId) { + this.instanceTypeId = instanceTypeId; + } + + public NGuid getImageTypeId() { + return imageTypeId; + } + + public void setImageTypeId(NGuid imageTypeId) { + this.imageTypeId = imageTypeId; + } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java index c9a36c6..9918d27 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java @@ -46,6 +46,8 @@ private double actualDiskSize = 0; + private TemplateType templateType; + public VmTemplate() { setAutoSuspend(false); setNiceLevel(0); @@ -237,4 +239,12 @@ public void setDisabled(boolean disabled) { this.disabled = disabled; } + + public TemplateType getTemplateType() { + return templateType; + } + + public void setTemplateType(TemplateType templateType) { + this.templateType = templateType; + } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java index 009a50e..efd9a70 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java @@ -234,7 +234,9 @@ .addValue("host_cpu_flags", vm.isUseHostCpuFlags()) .addValue("guest_agent_nics_hash", vm.getGuestAgentNicsHash()) .addValue("tunnel_migration", vm.getTunnelMigration()) - .addValue("vnc_keyboard_layout", vm.getVncKeyboardLayout())); + .addValue("vnc_keyboard_layout", vm.getVncKeyboardLayout()) + .addValue("instance_type_id", vm.getInstanceTypeId()) + .addValue("image_type_id", vm.getImageTypeId())); } @Override @@ -389,6 +391,8 @@ entity.setGuestAgentNicsHash(rs.getInt("guest_agent_nics_hash")); entity.setTunnelMigration((Boolean) rs.getObject("tunnel_migration")); entity.setVncKeyboardLayout(rs.getString("vnc_keyboard_layout")); + entity.setInstanceTypeId(NGuid.createGuidFromString(rs.getString("instance_type_id"))); + entity.setImageTypeId(NGuid.createGuidFromString(rs.getString("image_type_id"))); return entity; } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java index de3c511..3087a9d 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java @@ -85,7 +85,9 @@ .addValue("cpu_pinning", vm.getCpuPinning()) .addValue("host_cpu_flags", vm.isUseHostCpuFlags()) .addValue("tunnel_migration", vm.getTunnelMigration()) - .addValue("vnc_keyboard_layout", vm.getVncKeyboardLayout()); + .addValue("vnc_keyboard_layout", vm.getVncKeyboardLayout()) + .addValue("instance_type_id", vm.getInstanceTypeId()) + .addValue("image_type_id", vm.getImageTypeId()); } @Override @@ -203,6 +205,8 @@ entity.setUseHostCpuFlags(rs.getBoolean("host_cpu_flags")); entity.setTunnelMigration((Boolean) rs.getObject("tunnel_migration")); entity.setVncKeyboardLayout(rs.getString("vnc_keyboard_layout")); + entity.setInstanceTypeId(NGuid.createGuidFromString(rs.getString("instance_type_id"))); + entity.setImageTypeId(NGuid.createGuidFromString(rs.getString("image_type_id"))); return entity; } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java index cd157a5..7452857 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java @@ -11,6 +11,7 @@ import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.MigrationSupport; import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum; +import org.ovirt.engine.core.common.businessentities.TemplateType; import org.ovirt.engine.core.common.businessentities.VmOsType; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; @@ -166,7 +167,8 @@ .addValue("migration_support", template.getMigrationSupport().getValue()) .addValue("dedicated_vm_for_vds", template.getDedicatedVmForVds()) .addValue("tunnel_migration", template.getTunnelMigration()) - .addValue("vnc_keyboard_layout", template.getVncKeyboardLayout()); + .addValue("vnc_keyboard_layout", template.getVncKeyboardLayout()) + .addValue("template_type", template.getTemplateType().name()); } @Override @@ -233,6 +235,7 @@ entity.setDisabled(rs.getBoolean("is_disabled")); entity.setTunnelMigration((Boolean) rs.getObject("tunnel_migration")); entity.setVncKeyboardLayout(rs.getString("vnc_keyboard_layout")); + entity.setTemplateType(TemplateType.valueOf(rs.getString("entity_type"))); return entity; } } diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index 97ace3a..1b9490e 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -1025,6 +1025,9 @@ <column>quota_id</column> <column>db_generation</column> <column>tunnel_migration</column> + <column>instance_type_id</column> + <column>image_type_id</column> + <!-- Templates --> <row> <value>00000000-0000-0000-0000-000000000000</value> @@ -1068,6 +1071,8 @@ <null /> <value>88296e00-0cad-4e5a-9291-008a7b7f4399</value> <value>1</value> + <null /> + <null /> <null /> </row> <row> @@ -1113,6 +1118,8 @@ <null /> <value>1</value> <value>false</value> + <null /> + <null /> </row> <row> <value>1b85420c-b84c-4f29-997e-0eb674b40b80</value> @@ -1157,6 +1164,8 @@ <null /> <value>1</value> <value>true</value> + <null /> + <null /> </row> <row> <value>1b85420c-b84c-4f29-997e-0eb674b40b81</value> @@ -1201,6 +1210,8 @@ <null /> <value>1</value> <null /> + <null /> + <null /> </row> <row> <value>1b85420c-b84c-4f29-997e-0eb674b40b82</value> @@ -1244,6 +1255,8 @@ <null /> <null /> <value>1</value> + <null /> + <null /> <null /> </row> @@ -1291,6 +1304,8 @@ <null /> <value>1</value> <null /> + <null /> + <null /> </row> <row> <value>77296e00-0cad-4e5a-9299-008a7b6f4355</value> @@ -1335,6 +1350,9 @@ <value>88296e00-0cad-4e5a-9291-008a7b7f4399</value> <value>1</value> <value>false</value> + <null /> + <null /> + <null /> </row> <row> <value>77296e00-0cad-4e5a-9299-008a7b6f4356</value> @@ -1379,6 +1397,8 @@ <value>88296e00-0cad-4e5a-9291-008a7b7f4399</value> <value>1</value> <value>true</value> + <null /> + <null /> </row> <row> <value>77296e00-0cad-4e5a-9299-008a7b6f4357</value> @@ -1422,6 +1442,8 @@ <null /> <value>88296e00-0cad-4e5a-9291-008a7b7f4399</value> <value>1</value> + <null /> + <null /> <null /> </row> <row> @@ -1467,6 +1489,8 @@ <value>88296e00-0cad-4e5a-9291-008a7b7f4399</value> <value>1</value> <null /> + <null /> + <null /> </row> <row> <value>77296e00-0cad-4e5a-9299-008a7b6f4360</value> @@ -1511,6 +1535,8 @@ <value>88296e00-0cad-4e5a-9291-008a7b7f4399</value> <value>1</value> <null /> + <null /> + <null /> </row> <row> <value>77296e00-0cad-4e5a-9299-008a7b6f5001</value> @@ -1555,6 +1581,8 @@ <value>88296e00-0cad-4e5a-9291-008a7b7f4399</value> <value>1</value> <null /> + <null /> + <null /> </row> </table> diff --git a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml index e7fb71e..a4cba12 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml @@ -157,6 +157,7 @@ <include name="common/businessentities/BusinessEntityComparator.java" /> <include name="common/businessentities/Identifiable.java" /> <include name="common/businessentities/VmGuestAgentInterface.java" /> + <include name="common/businessentities/TemplateType.java" /> <include name="common/job/*.java" /> <!-- Quota --> diff --git a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties index e1ba076..e56ecf6 100644 --- a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties +++ b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/Enums.properties @@ -178,3 +178,6 @@ JobExecutionStatus___FAILED=Failed JobExecutionStatus___ABORTED=Aborted JobExecutionStatus___UNKNOWN=Unknown +TemplateType___TEMPLATE=Template +TemplateType___INSTANCE_TYPE=Instance Type +TemplateType___IMAGE_TYPE=Image Type -- To view, visit http://gerrit.ovirt.org/12278 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I110e74c6fc8906e3d257c7cf31d2af2b1b800218 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Omer Frenkel <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
