Gilad Chaplik has uploaded a new change for review.

Change subject: engine: add cluster policy name to vds_groups
......................................................................

engine: add cluster policy name to vds_groups

This change is done in order rest-api to support cluster_policy
in cluster BE, without fetching the cluster policies.

Change-Id: I448db08754a7348ff1947882f18fa6e7f43a2eae
Signed-off-by: Gilad Chaplik <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
M packaging/dbscripts/create_views.sql
4 files changed, 28 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/06/16606/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java
index 43a3264..759b551 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsGroupOperationCommandBase.java
@@ -53,8 +53,18 @@
     }
 
     protected boolean validateClusterPolicy() {
-        ClusterPolicy clusterPolicy =
+        ClusterPolicy clusterPolicy = null;
+        if (getVdsGroup().getClusterPolicyId() != null) {
+            clusterPolicy =
                 
SchedulingManager.getInstance().getClusterPolicy(getVdsGroup().getClusterPolicyId());
+        }
+        if (clusterPolicy == null) {
+            clusterPolicy = 
SchedulingManager.getInstance().getClusterPolicy(getVdsGroup().getClusterPolicyName());
+            if (clusterPolicy == null) {
+                return false;
+            }
+            getVdsGroup().setClusterPolicyId(clusterPolicy.getId());
+        }
         List<ValidationError> validationErrors =
                 
SimpleCustomPropertiesUtil.getInstance().validateProperties(SchedulingManager.getInstance()
                         .getCustomPropertiesRegexMap(clusterPolicy),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
index 6ac34c1..b65176f 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDSGroup.java
@@ -75,6 +75,8 @@
 
     private Guid clusterPolicyId;
 
+    private String clusterPolicyName;
+
     private Map<String, String> clusterPolicyProperties;
 
     public VDSGroup() {
@@ -275,6 +277,14 @@
         this.clusterPolicyId = clusterPolicyId;
     }
 
+    public String getClusterPolicyName() {
+        return clusterPolicyName;
+    }
+
+    public void setClusterPolicyName(String clusterPolicyName) {
+        this.clusterPolicyName = clusterPolicyName;
+    }
+
     public Map<String, String> getClusterPolicyProperties() {
         return clusterPolicyProperties;
     }
@@ -309,6 +319,7 @@
         result = prime * result + (emulatedMachine == null ? 0 : 
emulatedMachine.hashCode());
         result = prime * result + (trustedService ? 1231 : 1237);
         result = prime * result + ((clusterPolicyId == null) ? 0 : 
clusterPolicyId.hashCode());
+        result = prime * result + ((clusterPolicyName == null) ? 0 : 
clusterPolicyName.hashCode());
         result = prime * result + (clusterPolicyProperties == null ? 0 : 
clusterPolicyProperties.hashCode());
         return result;
     }
@@ -347,6 +358,7 @@
                 && ObjectUtils.objectsEqual(emulatedMachine, 
other.emulatedMachine)
                 && trustedService == other.trustedService
                 && ObjectUtils.objectsEqual(clusterPolicyId, 
other.clusterPolicyId)
+                && ObjectUtils.objectsEqual(clusterPolicyName, 
other.clusterPolicyName)
                 && ObjectUtils.objectsEqual(clusterPolicyProperties, 
other.clusterPolicyProperties));
     }
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
index b99ee94..99efe87 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsGroupDAODbFacadeImpl.java
@@ -211,6 +211,7 @@
             entity.setEmulatedMachine(rs.getString("emulated_machine"));
             entity.setTrustedService(rs.getBoolean("trusted_service"));
             
entity.setClusterPolicyId(Guid.createGuidFromString(rs.getString("cluster_policy_id")));
+            entity.setClusterPolicyName(rs.getString("cluster_policy_name"));
             
entity.setClusterPolicyProperties(SerializationFactory.getDeserializer()
                     
.deserializeOrCreateNew(rs.getString("cluster_policy_custom_properties"), 
LinkedHashMap.class));
             return entity;
diff --git a/packaging/dbscripts/create_views.sql 
b/packaging/dbscripts/create_views.sql
index e56c362..35848e4 100644
--- a/packaging/dbscripts/create_views.sql
+++ b/packaging/dbscripts/create_views.sql
@@ -921,9 +921,11 @@
 CREATE OR REPLACE VIEW vds_groups_view
 AS
 SELECT vds_groups.*,
-       storage_pool.name AS storage_pool_name
+       storage_pool.name AS storage_pool_name,
+       cluster_policies.name AS cluster_policy_name
 FROM vds_groups
-LEFT JOIN storage_pool ON vds_groups.storage_pool_id = storage_pool.id;
+LEFT JOIN storage_pool ON vds_groups.storage_pool_id = storage_pool.id
+LEFT JOIN cluster_policies ON vds_groups.cluster_policy_id = 
cluster_policies.id;
 
 CREATE OR REPLACE VIEW storage_domains_with_hosts_view
 


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

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

Reply via email to