Martin Peřina has uploaded a new change for review.

Change subject: core: Refactor VdsStatic to use FenceProxySourceType
......................................................................

core: Refactor VdsStatic to use FenceProxySourceType

1. Makes conversions between comma separated string and
   List<FenceProxySourceType> part of DAOs

2. Refactors *PmProxyPreferences() methods to use new
   *FenceProxySources() methods in VDS/VdsStatic

3. Fixes HostMapperTest.testRoundtrip() to not fill in invalid fence
   proxy sources into Host entity as a part of the test.

Change-Id: I584ea587842cb8c4e31fa387d235d42cabea5648
Bug-Url: https://bugzilla.redhat.com/1182510
Signed-off-by: Martin Perina <mper...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java
M 
backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
5 files changed, 45 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/59/39759/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
index 70bac0e..2e9a73b 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
@@ -11,7 +11,9 @@
 
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
+import org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType;
 import org.ovirt.engine.core.common.utils.ObjectUtils;
+import org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.RpmVersion;
 import org.ovirt.engine.core.compat.Version;
@@ -929,12 +931,22 @@
         vdsStatic.setPmEnabled(value);
     }
 
+    // TODO: Remove method when all callers use List<FenceProxySourceType>
     public String getPmProxyPreferences() {
-        return vdsStatic.getPmProxyPreferences();
+        return FenceProxySourceTypeHelper.saveAsString(getFenceProxySources());
     }
 
+    // TODO: Remove method when all callers use List<FenceProxySourceType>
     public void setPmProxyPreferences(String pmProxyPreferences) {
-        vdsStatic.setPmProxyPreferences(pmProxyPreferences);
+        
setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(pmProxyPreferences));
+    }
+
+    public List<FenceProxySourceType> getFenceProxySources() {
+        return vdsStatic.getFenceProxySources();
+    }
+
+    public void setFenceProxySources(List<FenceProxySourceType> 
fenceProxySources) {
+        vdsStatic.setFenceProxySources(fenceProxySources);
     }
 
     public String getHostOs() {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
index 63de7c7..c120c47 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsStatic.java
@@ -1,6 +1,7 @@
 package org.ovirt.engine.core.common.businessentities;
 
 import java.util.HashMap;
+import java.util.List;
 
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
@@ -8,7 +9,9 @@
 import javax.validation.constraints.Size;
 
 import org.hibernate.validator.constraints.Range;
+import org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType;
 import org.ovirt.engine.core.common.utils.ObjectUtils;
+import org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper;
 import org.ovirt.engine.core.common.validation.annotation.HostnameOrIp;
 import org.ovirt.engine.core.common.validation.annotation.ValidNameWithDot;
 import org.ovirt.engine.core.common.validation.group.CreateEntity;
@@ -82,8 +85,7 @@
     private boolean pmEnabled;
 
     @EditableField
-    @Size(max = BusinessEntitiesDefinitions.GENERAL_NAME_SIZE)
-    private String pmProxyPreferences;
+    private List<FenceProxySourceType> fenceProxySources;
 
     @EditableField
     private boolean pmKdumpDetection;
@@ -270,14 +272,6 @@
         pmEnabled = value;
     }
 
-    public String getPmProxyPreferences() {
-        return pmProxyPreferences;
-    }
-
-    public void setPmProxyPreferences(String pmProxyPreferences) {
-        this.pmProxyPreferences = pmProxyPreferences;
-    }
-
     public boolean isPmKdumpDetection() {
         return pmKdumpDetection;
     }
@@ -286,6 +280,24 @@
         this.pmKdumpDetection = pmKdumpDetection;
     }
 
+    // TODO: Remove method when all callers use List<FenceProxySourceType>
+    public String getPmProxyPreferences() {
+        return FenceProxySourceTypeHelper.saveAsString(getFenceProxySources());
+    }
+
+    // TODO: Remove method when all callers use List<FenceProxySourceType>
+    public void setPmProxyPreferences(String pmProxyPreferences) {
+        
setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(pmProxyPreferences));
+    }
+
+    public List<FenceProxySourceType> getFenceProxySources() {
+        return fenceProxySources;
+    }
+
+    public void setFenceProxySources(List<FenceProxySourceType> 
fenceProxySources) {
+        this.fenceProxySources = fenceProxySources;
+    }
+
     public boolean isDisablePowerManagementPolicy() {
         return disablePowerManagementPolicy;
     }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
index f7939be..e36837d 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
@@ -24,6 +24,7 @@
 import org.ovirt.engine.core.common.businessentities.VdsSpmStatus;
 import 
org.ovirt.engine.core.common.businessentities.VdsTransparentHugePagesState;
 import org.ovirt.engine.core.common.businessentities.VmRngDevice;
+import org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.RpmVersion;
 import org.ovirt.engine.core.compat.Version;
@@ -320,7 +321,8 @@
             entity.setNetConfigDirty((Boolean) rs
                     .getObject("net_config_dirty"));
             entity.setPmEnabled(rs.getBoolean("pm_enabled"));
-            entity.setPmProxyPreferences(rs.getString("pm_proxy_preferences"));
+            entity.setFenceProxySources(
+                    
FenceProxySourceTypeHelper.parseFromString(rs.getString("pm_proxy_preferences")));
             entity.setPmKdumpDetection(rs.getBoolean("pm_detect_kdump"));
             entity.setSpmStatus(VdsSpmStatus.forValue(rs
                     .getInt("spm_status")));
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java
index 74c4d9f..6f1a1ed 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsStaticDAODbFacadeImpl.java
@@ -11,6 +11,7 @@
 import org.ovirt.engine.core.common.businessentities.VDSType;
 import org.ovirt.engine.core.common.businessentities.VdsProtocol;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
+import org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper;
 import org.ovirt.engine.core.compat.Guid;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -86,7 +87,7 @@
                 .addValue("vds_type", vds.getVdsType())
                 .addValue("vds_strength", vds.getVdsStrength())
                 .addValue("pm_enabled", vds.isPmEnabled())
-                .addValue("pm_proxy_preferences", vds.getPmProxyPreferences())
+                .addValue("pm_proxy_preferences", 
FenceProxySourceTypeHelper.saveAsString(vds.getFenceProxySources()))
                 .addValue("pm_detect_kdump", vds.isPmKdumpDetection())
                 .addValue("otp_validity", vds.getOtpValidity())
                 .addValue("vds_spm_priority", vds.getVdsSpmPriority())
@@ -137,7 +138,8 @@
             entity.setVdsType(VDSType.forValue(rs.getInt("vds_type")));
             entity.setVdsStrength(rs.getInt("vds_strength"));
             entity.setPmEnabled(rs.getBoolean("pm_enabled"));
-            entity.setPmProxyPreferences(rs.getString("pm_proxy_preferences"));
+            entity.setFenceProxySources(
+                    
FenceProxySourceTypeHelper.parseFromString(rs.getString("pm_proxy_preferences")));
             entity.setPmKdumpDetection(rs.getBoolean("pm_detect_kdump"));
             entity.setOtpValidity(rs.getLong("otp_validity"));
             entity.setSshKeyFingerprint(rs.getString("sshKeyFingerprint"));
diff --git 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
index d1c8ed9..a69d1af 100644
--- 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
+++ 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
@@ -8,6 +8,7 @@
 import org.ovirt.engine.api.model.Host;
 import org.ovirt.engine.api.model.HostProtocol;
 import org.ovirt.engine.api.model.HostedEngine;
+import org.ovirt.engine.api.model.PmProxies;
 import org.ovirt.engine.api.model.PowerManagement;
 import org.ovirt.engine.api.model.SSH;
 import org.ovirt.engine.api.model.User;
@@ -30,6 +31,7 @@
         }
         
from.setProtocol(MappingTestHelper.shuffle(HostProtocol.class).value());
         from.getSpm().setPriority(3);
+        from.getPowerManagement().setPmProxies(new PmProxies());
         return from;
     }
 


-- 
To view, visit https://gerrit.ovirt.org/39759
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I584ea587842cb8c4e31fa387d235d42cabea5648
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <mper...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to