Eli Mesika has uploaded a new change for review.

Change subject: core[DAO]: Adding external status to host
......................................................................

core[DAO]: Adding external status to host

This patch adds external status handling to the DAOs
I added here also an interface for external status aware DAOs in t6he
same manner it was done for status

Change-Id: Ie4dd9a1bc0aa99604f74a07155a7b596585e3ccf
Signed-off-by: emesika <[email protected]>
---
A 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/ExternalStatusAwareDao.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/VdsDynamicDAO.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
6 files changed, 59 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/94/40994/1

diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/ExternalStatusAwareDao.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/ExternalStatusAwareDao.java
new file mode 100644
index 0000000..577111a
--- /dev/null
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/ExternalStatusAwareDao.java
@@ -0,0 +1,28 @@
+package org.ovirt.engine.core.dao;
+
+import java.io.Serializable;
+
+
+/**
+ * This is a specific type of DAO that is aware of entities having a 
"externalStatus" field, and can update this field.
+ *
+ * @param <ID>
+ *            The type of the entity's id.
+ * @param <S>
+ *            The type of status.
+ * @see GenericDao
+ */
+
+public interface ExternalStatusAwareDao <ID extends Serializable, S extends 
Enum<?>> extends DAO {
+
+    /**
+     * Update the entity's status field only.
+     *
+     * @param id
+     *            The id of the entity for which to update the status field.
+     * @param status
+     *            The external status to update to.
+     */
+    public void updateExternalStatus(ID id, S status);
+
+}
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 0d8b710..7538213 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
@@ -14,6 +14,7 @@
 import javax.inject.Singleton;
 
 import org.ovirt.engine.core.common.businessentities.AutoNumaBalanceStatus;
+import org.ovirt.engine.core.common.businessentities.ExternalStatus;
 import org.ovirt.engine.core.common.businessentities.KdumpStatus;
 import org.ovirt.engine.core.common.businessentities.NonOperationalReason;
 import org.ovirt.engine.core.common.businessentities.VDS;
@@ -266,6 +267,7 @@
             entity.setSshPort(rs.getInt("ssh_port"));
             entity.setSshUsername(rs.getString("ssh_username"));
             entity.setStatus(VDSStatus.forValue(rs.getInt("status")));
+            
entity.setExternalStatus(ExternalStatus.forValue(rs.getInt("external_status")));
             entity.setCpuCores((Integer) rs.getObject("cpu_cores"));
             entity.setCpuThreads((Integer) rs.getObject("cpu_threads"));
             entity.setCpuModel(rs.getString("cpu_model"));
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java
index 60f4dc9..f925b78 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAO.java
@@ -2,6 +2,7 @@
 
 import java.util.List;
 
+import org.ovirt.engine.core.common.businessentities.ExternalStatus;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VdsDynamic;
 import org.ovirt.engine.core.compat.Guid;
@@ -11,7 +12,7 @@
  *
  *
  */
-public interface VdsDynamicDAO extends GenericDao<VdsDynamic, Guid>, 
StatusAwareDao<Guid, VDSStatus>, MassOperationsDao<VdsDynamic, Guid>, 
CheckedUpdate<VdsDynamic> {
+public interface VdsDynamicDAO extends GenericDao<VdsDynamic, Guid>, 
StatusAwareDao<Guid, VDSStatus>, ExternalStatusAwareDao<Guid, ExternalStatus>, 
MassOperationsDao<VdsDynamic, Guid>, CheckedUpdate<VdsDynamic> {
 
    /**
      * Update entity net_config_dirty field
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
index 768fd2d..caeec8f 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
@@ -10,6 +10,7 @@
 
 import org.apache.commons.lang.NotImplementedException;
 import org.ovirt.engine.core.common.businessentities.AutoNumaBalanceStatus;
+import org.ovirt.engine.core.common.businessentities.ExternalStatus;
 import org.ovirt.engine.core.common.businessentities.KdumpStatus;
 import org.ovirt.engine.core.common.businessentities.NonOperationalReason;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
@@ -159,6 +160,15 @@
     }
 
     @Override
+    public void updateExternalStatus(Guid id, ExternalStatus status) {
+        MapSqlParameterSource parameterSource = 
getCustomMapSqlParameterSource()
+                .addValue("vds_guid", id)
+                .addValue("external_status", status);
+
+        
getCallsHandler().executeModification("UpdateVdsDynamiciExternalStatus", 
parameterSource);
+    }
+
+    @Override
     public void updateNetConfigDirty(Guid id, Boolean netConfigDirty) {
         MapSqlParameterSource parameterSource = 
getCustomMapSqlParameterSource()
                 .addValue("vds_guid", id)
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
index 73633f6..1783e83 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsDynamicDAOTest.java
@@ -11,6 +11,7 @@
 import java.util.List;
 
 import org.junit.Test;
+import org.ovirt.engine.core.common.businessentities.ExternalStatus;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VdsDynamic;
 import org.ovirt.engine.core.common.businessentities.VdsProtocol;
@@ -115,6 +116,16 @@
     }
 
     @Test
+    public void testUpdateExternalStatus() {
+        VdsDynamic before = dao.get(existingVds.getId());
+        before.setExternalStatus(ExternalStatus.Error);
+        dao.updateExternalStatus(before.getId(), before.getExternalStatus());
+        VdsDynamic after = dao.get(existingVds.getId());
+        assertEquals(before, after);
+    }
+
+
+    @Test
     public void testUpdateNetConfigDirty() {
         VdsDynamic before = dao.get(existingVds.getId());
         Boolean netConfigDirty = before.getNetConfigDirty();
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index c711066..f9cad22 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -3290,6 +3290,7 @@
     <table name="vds_dynamic">
         <column>vds_id</column>
         <column>status</column>
+        <column>external_status</column>
         <column>cpu_cores</column>
         <column>cpu_model</column>
         <column>cpu_speed_mh</column>
@@ -3348,6 +3349,7 @@
         <row>
             <value>afce7a39-8e8c-4819-ba9c-796d316592e6</value>
             <value>3</value>
+            <value>0</value>
             <value>8</value>
             <value>Intel(R) Xeon(R) CPU           E5420  @ 2.50GHz</value>
             <value>2494</value>
@@ -3407,6 +3409,7 @@
         <row>
             <value>afce7a39-8e8c-4819-ba9c-796d316592e7</value>
             <value>3</value>
+            <value>0</value>
             <value>8</value>
             <value>Intel(R) Xeon(R) CPU           E5420  @ 2.50GHz</value>
             <value>2494</value>
@@ -3466,6 +3469,7 @@
         <row>
             <value>afce7a39-8e8c-4819-ba9c-796d316592e8</value>
             <value>3</value>
+            <value>0</value>
             <value>8</value>
             <value>Intel(R) Xeon(R) CPU           E5420  @ 2.50GHz</value>
             <value>2494</value>
@@ -3525,6 +3529,7 @@
         <row>
             <value>23f6d691-5dfb-472b-86dc-9e1d2d3c18f3</value>
             <value>3</value>
+            <value>0</value>
             <value>8</value>
             <value>Intel(R) Xeon(R) CPU           E5420  @ 2.50GHz</value>
             <value>2494</value>
@@ -3584,6 +3589,7 @@
         <row>
             <value>2001751e-549b-4e7a-aff6-32d36856c125</value>
             <value>3</value>
+            <value>0</value>
             <value>8</value>
             <value>Intel(R) Xeon(R) CPU           E5420  @ 2.50GHz</value>
             <value>2494</value>


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

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

Reply via email to