Omer Frenkel has uploaded a new change for review. Change subject: core: add "disabled" feature to template ......................................................................
core: add "disabled" feature to template this is the engine core implementation for disabled templates, if template is disabled, it cannot be used to create vms. Change-Id: Ia9f8b60280d76b73a26f0d5feaf6650c7ef7ce7e Signed-off-by: Omer Frenkel <ofren...@redhat.com> --- M backend/manager/dbscripts/create_views.sql A backend/manager/dbscripts/upgrade/03_02_0230_add_disabled_to_vm_static.sql M backend/manager/dbscripts/vm_templates_sp.sql M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmTemplateHandler.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/dal/VdcBllMessages.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 14 files changed, 43 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/10502/1 diff --git a/backend/manager/dbscripts/create_views.sql b/backend/manager/dbscripts/create_views.sql index 5537481..29b8e09 100644 --- a/backend/manager/dbscripts/create_views.sql +++ b/backend/manager/dbscripts/create_views.sql @@ -371,7 +371,8 @@ quota.quota_name as quota_name, vm_templates.db_generation as db_generation, vm_templates.migration_support, - vm_templates.dedicated_vm_for_vds + vm_templates.dedicated_vm_for_vds, + vm_templates.is_disabled FROM vm_static AS vm_templates INNER JOIN vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id left outer JOIN @@ -406,7 +407,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 + quota.quota_name as quota_name, vm_templates.is_disabled 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 @@ -426,7 +427,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 + quota.quota_name as quota_name, vm_templates_1.is_disabled 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 diff --git a/backend/manager/dbscripts/upgrade/03_02_0230_add_disabled_to_vm_static.sql b/backend/manager/dbscripts/upgrade/03_02_0230_add_disabled_to_vm_static.sql new file mode 100644 index 0000000..6f23a58 --- /dev/null +++ b/backend/manager/dbscripts/upgrade/03_02_0230_add_disabled_to_vm_static.sql @@ -0,0 +1 @@ +select fn_db_add_column('vm_static', 'is_disabled', 'boolean default false'); diff --git a/backend/manager/dbscripts/vm_templates_sp.sql b/backend/manager/dbscripts/vm_templates_sp.sql index 92309fa..b61edae 100644 --- a/backend/manager/dbscripts/vm_templates_sp.sql +++ b/backend/manager/dbscripts/vm_templates_sp.sql @@ -34,6 +34,7 @@ v_is_stateless BOOLEAN, v_is_smartcard_enabled BOOLEAN, v_is_delete_protected BOOLEAN, + v_is_disabled BOOLEAN, v_iso_path VARCHAR(4000) , v_origin INTEGER , v_initrd_url VARCHAR(4000) , @@ -82,6 +83,7 @@ entity_type, quota_id, migration_support, + is_disabled, dedicated_vm_for_vds, is_smartcard_enabled, is_delete_protected) @@ -122,6 +124,7 @@ 'TEMPLATE', v_quota_id, v_migration_support, + v_is_disabled, v_dedicated_vm_for_vds, v_is_smartcard_enabled, v_is_delete_protected); @@ -163,6 +166,7 @@ v_is_stateless BOOLEAN, v_is_smartcard_enabled BOOLEAN, v_is_delete_protected BOOLEAN, + v_is_disabled BOOLEAN, v_iso_path VARCHAR(4000) , v_origin INTEGER , v_initrd_url VARCHAR(4000) , @@ -191,7 +195,7 @@ iso_path = v_iso_path,origin = v_origin,initrd_url = v_initrd_url, kernel_url = v_kernel_url,kernel_params = v_kernel_params, _update_date = CURRENT_TIMESTAMP, quota_id = v_quota_id, migration_support = v_migration_support, dedicated_vm_for_vds = v_dedicated_vm_for_vds, is_smartcard_enabled = v_is_smartcard_enabled, - is_delete_protected = v_is_delete_protected + is_delete_protected = v_is_delete_protected, is_disabled = v_is_disabled WHERE vm_guid = v_vmt_guid AND entity_type = 'TEMPLATE'; END; $procedure$ diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index f6ebbca..2116ae5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -288,6 +288,10 @@ addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); return false; } + if (getVmTemplate().isDisabled()) { + addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED); + return false; + } returnValue = buildAndCheckDestStorageDomains(); if (returnValue) { storageToDisksMap = diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmTemplateHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmTemplateHandler.java index 70e8bca..74195b9 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmTemplateHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmTemplateHandler.java @@ -32,7 +32,7 @@ mUpdateVmTemplate.AddPermittedFields(new String[] { "name", "description", "domain", "os", "osType", "is_auto_suspend", "interfaces", "mem_size_mb", "num_of_sockets", "cpu_per_socket", "vds_group_id", "num_of_monitors", "allowConsoleReconnect", "usb_policy", "time_zone", "diskMap", - "default_boot_sequence", + "default_boot_sequence", "disabled", "iso_path", "diskImageMap", "default_display_type", "priority", "auto_startup", "is_stateless", "initrd_url", "kernel_url", "kernel_params", "images", "interfaces", "quotaId", "quotaName", "quotaEnforcementType", "migrationSupport", "dedicated_vm_for_vds", "smartcardEnabled", "dbGeneration", "deleteProtected" 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 4d3cff0..220c2df 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 @@ -91,6 +91,8 @@ diskTemplateMap = new HashMap<Guid, DiskImage>(); } + private boolean disabled; + public VmTemplate(int child_count, Date creation_date, String description, int mem_size_mb, String name, int num_of_sockets, int cpu_per_socket, VmOsType os, Guid vds_group_id, Guid vmt_guid, String domain, int num_of_monitors, int status, int usb_policy, String time_zone, boolean is_auto_suspend, int nice_level, @@ -269,4 +271,12 @@ public int hashCode() { return getId().hashCode(); } + + public Boolean isDisabled() { + return disabled; + } + + public void setDisabled(Boolean disabled) { + this.disabled = disabled; + } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java index 71dde08..59c4693 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java @@ -132,6 +132,7 @@ ACTION_TYPE_FAILED_CPU_NOT_FOUND, ACTION_TYPE_FAILED_PROBLEM_WITH_CANDIDATE_INFO, ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST, + ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED, ACTION_TYPE_FAILED_IMAGE_ALREADY_EXISTS, ACTION_TYPE_FAILED_TEMPLATE_NAME_ALREADY_EXISTS, ACTION_TYPE_FAILED_TEMPLATE_GUID_ALREADY_EXISTS, 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 633ffd9..fe2bdaa 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 @@ -156,6 +156,7 @@ .addValue("is_stateless", template.getis_stateless()) .addValue("is_smartcard_enabled", template.isSmartcardEnabled()) .addValue("is_delete_protected", template.isDeleteProtected()) + .addValue("is_disabled", template.isDisabled()) .addValue("iso_path", template.getiso_path()) .addValue("origin", template.getorigin()) .addValue("initrd_url", template.getinitrd_url()) @@ -227,6 +228,7 @@ entity.setQuotaEnforcementType(QuotaEnforcementTypeEnum.forValue(rs.getInt("quota_enforcement_type"))); entity.setMigrationSupport(MigrationSupport.forValue(rs.getInt("migration_support"))); entity.setdedicated_vm_for_vds(NGuid.createGuidFromString(rs.getString("dedicated_vm_for_vds"))); + entity.setDisabled(rs.getBoolean("is_disabled")); return entity; } } diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 454db21..416780a 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -188,6 +188,7 @@ ACTION_TYPE_FAILED_PROBLEM_WITH_CANDIDATE_INFO=Cannot ${action} ${type}. Failed to get data for Import operation.\n\ - Check your Import Domain. ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Template doesn't exist. +ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED=Cannot ${action} ${type}. The Template is disabled, please try to enable the template first and try again. ACTION_TYPE_FAILED_IMAGE_ALREADY_EXISTS=Cannot ${action} ${type}. One of the Template Images already exists. ACTION_TYPE_FAILED_TEMPLATE_NAME_ALREADY_EXISTS=Cannot ${action} ${type}. A Template with the same name already exists. ACTION_TYPE_FAILED_TEMPLATE_GUID_ALREADY_EXISTS=Cannot ${action} ${type}. A Template with the same identifier already exists. diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java index bc9def2..434d09c 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateReader.java @@ -165,5 +165,11 @@ _vmTemplate.setdefault_display_type(DisplayType.forValue(Integer.parseInt(node.InnerText))); } } + node = content.SelectSingleNode("IsDisabled"); + if (node != null) { + if (!StringUtils.isEmpty(node.InnerText)) { + _vmTemplate.setDisabled(Boolean.parseBoolean(node.InnerText)); + } + } } } diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java index a523da9..e903a13 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfTemplateWriter.java @@ -34,6 +34,9 @@ _writer.WriteStartElement("default_display_type"); _writer.WriteRaw(String.valueOf(_vmTemplate.getdefault_display_type().getValue())); _writer.WriteEndElement(); + _writer.WriteStartElement("IsDisabled"); + _writer.WriteRaw(String.valueOf(_vmTemplate.isDisabled())); + _writer.WriteEndElement(); } @Override diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index b73e083..828f0c2 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -479,6 +479,9 @@ @DefaultStringValue("Cannot ${action} ${type}. The relevant Template doesn't exist.") String ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST(); + @DefaultStringValue("Cannot ${action} ${type}. The Template is disabled, please try to enable the template first and try again.") + String ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED(); + @DefaultStringValue("Cannot ${action} ${type}. One of the Template Images already exists.") String ACTION_TYPE_FAILED_IMAGE_ALREADY_EXISTS(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index b4779fa..d002831 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -187,6 +187,7 @@ ACTION_TYPE_FAILED_PROBLEM_WITH_CANDIDATE_INFO=Cannot ${action} ${type}. Failed to get data for Import operation.\n\ - Check your Import Domain. ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Template doesn't exist. +ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED=Cannot ${action} ${type}. The Template is disabled, please try to enable the template first and try again. ACTION_TYPE_FAILED_IMAGE_ALREADY_EXISTS=Cannot ${action} ${type}. One of the Template Images already exists. ACTION_TYPE_FAILED_TEMPLATE_NAME_ALREADY_EXISTS=Cannot ${action} ${type}. A Template with the same name already exists. ACTION_TYPE_FAILED_TEMPLATE_GUID_ALREADY_EXISTS=Cannot ${action} ${type}. A Template with the same identifier already exists. diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index dbba8c9..33ec194 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -185,6 +185,7 @@ ACTION_TYPE_FAILED_PROBLEM_WITH_CANDIDATE_INFO=Cannot ${action} ${type}. Failed to get data for Import operation.\n\ - Check your Import Domain. ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST=Cannot ${action} ${type}. The relevant Template doesn't exist. +ACTION_TYPE_FAILED_TEMPLATE_IS_DISABLED=Cannot ${action} ${type}. The Template is disabled, please try to enable the template first and try again. ACTION_TYPE_FAILED_IMAGE_ALREADY_EXISTS=Cannot ${action} ${type}. One of the Template Images already exists. ACTION_TYPE_FAILED_TEMPLATE_NAME_ALREADY_EXISTS=Cannot ${action} ${type}. A Template with the same name already exists. ACTION_TYPE_FAILED_TEMPLATE_GUID_ALREADY_EXISTS=Cannot ${action} ${type}. A Template with the same identifier already exists. -- To view, visit http://gerrit.ovirt.org/10502 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia9f8b60280d76b73a26f0d5feaf6650c7ef7ce7e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Omer Frenkel <ofren...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches