Tomas Jelinek has uploaded a new change for review.

Change subject: core: made it possible to edit the blank template
......................................................................

core: made it possible to edit the blank template

Detached the blank template from the default cluster and made it possiblt to
edit it

Feature Page: www.ovirt.org/Features/Blank_to_Defaults

Bug-Url: https://bugzilla.redhat.com/1130174
Bug-Url: https://bugzilla.redhat.com/1145002

Change-Id: I76f2267ebb36131feadc44a868f6272babe2453e
Signed-off-by: Tomas Jelinek <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
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
A packaging/dbscripts/upgrade/03_06_0870_decouple_blank_from_cluster.sql
7 files changed, 14 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/37904/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
index a775f11..b8f4925 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
@@ -72,22 +72,20 @@
 
     @Override
     protected boolean canDoAction() {
-        boolean isInstanceType = getVmTemplate().getTemplateType() == 
VmEntityType.INSTANCE_TYPE;
-        if (getVdsGroup() == null && !isInstanceType) {
+        boolean isInstanceType = isInstanceType();
+        boolean isBlankTemplate = isBlankTemplate();
+        if (getVdsGroup() == null && !(isInstanceType || isBlankTemplate)) {
             
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CLUSTER_CAN_NOT_BE_EMPTY);
             return false;
         }
 
-        if 
(VmTemplateHandler.BLANK_VM_TEMPLATE_ID.equals(getVmTemplate().getId())) {
-            return 
failCanDoAction(VdcBllMessages.VMT_CANNOT_EDIT_BLANK_TEMPLATE);
-        }
         boolean returnValue = false;
 
         if (mOldTemplate == null) {
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST);
         }
 
-        if (!isInstanceType) {
+        if (!isInstanceType && !isBlankTemplate) {
             VmTemplateHandler.updateDisksFromDb(mOldTemplate);
         }
 
@@ -112,7 +110,7 @@
             return false;
         }
 
-        if (!isInstanceType && returnValue) {
+        if (!isInstanceType && !isBlankTemplate && returnValue) {
             return doClusterRelatedChecks();
         } else {
             return returnValue;
@@ -220,7 +218,7 @@
 
     @Override
     protected void executeCommand() {
-        if (getVmTemplate().getTemplateType() != VmEntityType.INSTANCE_TYPE) {
+        if (!isInstanceType() && !isBlankTemplate()) {
             VmHandler.warnMemorySizeLegal(getParameters().getVmTemplateData(),
                     getVdsGroup().getCompatibilityVersion());
         }
@@ -240,7 +238,7 @@
      * only in case of InstanceType update, update all vms that are bound to it
      */
     private void updateVmsOfInstanceType() {
-        if (getVmTemplate().getTemplateType() != VmEntityType.INSTANCE_TYPE) {
+        if (!isInstanceType()) {
             return;
         }
 
@@ -345,7 +343,7 @@
     public List<PermissionSubject> getPermissionCheckSubjects() {
         final List<PermissionSubject> permissionList = 
super.getPermissionCheckSubjects();
 
-        if (getVmTemplate() != null && getVmTemplate().getTemplateType() != 
VmEntityType.INSTANCE_TYPE) {
+        if (getVmTemplate() != null && !isInstanceType() && 
!isBlankTemplate()) {
             // host-specific parameters can be changed by administration role 
only
             if (!(getVmTemplate().getDedicatedVmForVds() == null ?
                     getParameters().getVmTemplateData().getDedicatedVmForVds() 
== null :
@@ -363,7 +361,7 @@
 
     @Override
     protected boolean isQuotaDependant() {
-        if (getVmTemplate().getTemplateType() == VmEntityType.INSTANCE_TYPE) {
+        if (isInstanceType() || isBlankTemplate()) {
             return false;
         }
 
@@ -371,10 +369,11 @@
     }
 
     protected boolean setAndValidateCpuProfile() {
-        // cpu profile isn't supported for instance types.
-        if (getVmTemplate().getTemplateType() == VmEntityType.INSTANCE_TYPE) {
+        // cpu profile isn't supported for instance types nor for blank 
template.
+        if (isInstanceType() || isBlankTemplate()) {
             return true;
         }
+
         return 
validate(CpuProfileHelper.setAndValidateCpuProfile(getVmTemplate(),
                 getVdsGroup().getCompatibilityVersion()));
     }
@@ -382,7 +381,7 @@
     private boolean isInstanceType() {
         return getVmTemplate().getTemplateType() == VmEntityType.INSTANCE_TYPE;
     }
-    
+
     private VmPropertiesUtils getVmPropertiesUtils() {
         return VmPropertiesUtils.getInstance();
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index 7e9a979..d1a3d6e 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -430,7 +430,6 @@
     ACTION_TYPE_FAILED_DETECTED_DERIVED_DISKS(ErrorType.CONFLICT),
     VMT_CANNOT_CREATE_TEMPLATE_FROM_DOWN_VM(ErrorType.CONFLICT),
     VMT_CANNOT_REMOVE_BLANK_TEMPLATE(ErrorType.CONFLICT),
-    VMT_CANNOT_EDIT_BLANK_TEMPLATE(ErrorType.CONFLICT),
     VMT_CANNOT_EXPORT_BLANK_TEMPLATE(ErrorType.CONFLICT),
     VMT_CANNOT_UPDATE_ILLEGAL_FIELD(ErrorType.BAD_PARAMETERS),
     VMT_CANNOT_UPDATE_VERSION_NAME(ErrorType.BAD_PARAMETERS),
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 d6980fe..4f8f4ff 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -146,7 +146,6 @@
 VM_INVALID_SERVER_CLUSTER_ID=Invalid Host Cluster id.
 VMT_CANNOT_CREATE_TEMPLATE_FROM_DOWN_VM=Cannot ${action} ${type}. VM is locked 
or still running, try again once VM is in the Down state.
 VMT_CANNOT_REMOVE_BLANK_TEMPLATE=Cannot ${action} ${type}. Removing Blank 
Template is not allowed.
-VMT_CANNOT_EDIT_BLANK_TEMPLATE=Cannot ${action} ${type}. Editing Blank 
Template is not allowed.
 VMT_CANNOT_EXPORT_BLANK_TEMPLATE=Cannot export Blank Template.
 VMT_CANNOT_UPDATE_ILLEGAL_FIELD=Failed updating the properties of the VM 
template.
 VMT_CANNOT_UPDATE_VERSION_NAME=Cannot update the name of Sub-Templates, Only 
the Version name can be updated.
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 df810da..e84e824 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
@@ -379,9 +379,6 @@
     @DefaultStringValue("Cannot ${action} ${type}. Removing Blank Template is 
not allowed.")
     String VMT_CANNOT_REMOVE_BLANK_TEMPLATE();
 
-    @DefaultStringValue("Cannot ${action} ${type}. Editing Blank Template is 
not allowed.")
-    String VMT_CANNOT_EDIT_BLANK_TEMPLATE();
-
     @DefaultStringValue("Cannot export Blank Template.")
     String VMT_CANNOT_EXPORT_BLANK_TEMPLATE();
 
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 3452a0a..2262082 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
@@ -130,7 +130,6 @@
 VM_INVALID_SERVER_CLUSTER_ID=Invalid Host Cluster id.
 VMT_CANNOT_CREATE_TEMPLATE_FROM_DOWN_VM=Cannot ${action} ${type}. VM is locked 
or still running, try again once VM is in the Down state.
 VMT_CANNOT_REMOVE_BLANK_TEMPLATE=Cannot ${action} ${type}. Removing Blank 
Template is not allowed.
-VMT_CANNOT_EDIT_BLANK_TEMPLATE=Cannot ${action} ${type}. Editing Blank 
Template is not allowed.
 VMT_CANNOT_EXPORT_BLANK_TEMPLATE=Cannot export Blank Template.
 VMT_CANNOT_UPDATE_ILLEGAL_FIELD=Failed updating the properties of the VM 
template.
 VMT_CANNOT_UPDATE_VERSION_NAME=Cannot update the name of Sub-Templates, Only 
the Version name can be updated.
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 bc1b606..ee01e9f 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
@@ -145,7 +145,6 @@
 VM_INVALID_SERVER_CLUSTER_ID=Invalid Host Cluster id.
 VMT_CANNOT_CREATE_TEMPLATE_FROM_DOWN_VM=Cannot ${action} ${type}. VM is locked 
or still running, try again once VM is in the Down state.
 VMT_CANNOT_REMOVE_BLANK_TEMPLATE=Cannot ${action} ${type}. Removing Blank 
Template is not allowed.
-VMT_CANNOT_EDIT_BLANK_TEMPLATE=Cannot ${action} ${type}. Editing Blank 
Template is not allowed.
 VMT_CANNOT_EXPORT_BLANK_TEMPLATE=Cannot export Blank Template.
 VMT_CANNOT_UPDATE_ILLEGAL_FIELD=Failed updating the properties of the VM 
template.
 VMT_CANNOT_UPDATE_VERSION_NAME=Cannot update the name of Sub-Templates, Only 
the Version name can be updated.
diff --git 
a/packaging/dbscripts/upgrade/03_06_0870_decouple_blank_from_cluster.sql 
b/packaging/dbscripts/upgrade/03_06_0870_decouple_blank_from_cluster.sql
new file mode 100644
index 0000000..6fc08c7
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_06_0870_decouple_blank_from_cluster.sql
@@ -0,0 +1 @@
+update vm_static set vds_group_id = null where 
vm_guid='00000000-0000-0000-0000-000000000000';


-- 
To view, visit http://gerrit.ovirt.org/37904
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I76f2267ebb36131feadc44a868f6272babe2453e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to