Dhandapani Gopal has uploaded a new change for review.

Change subject: engine: Added new column 'fingerprint' in the vds_static table
......................................................................

engine: Added new column 'fingerprint' in the vds_static table

This fingerprint can be used to verify the server identity during add host.

Done the following changes
- Updated the stored procedure in vds_sp
- Updated the DAO test cases
- Introduced the new member fingerprint in the VdsStatic entity

Change-Id: I7abe03b62dc15bb135fa02e0a43b763abd8872af
Signed-off-by: Dhandapani <dgo...@redhat.com>
---
A 
backend/manager/dbscripts/upgrade/03_01_1360_add_fingerprint_column_to_vds_static.sql
M backend/manager/dbscripts/vds_sp.sql
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/VdsStaticDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
6 files changed, 38 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/71/7171/1

diff --git 
a/backend/manager/dbscripts/upgrade/03_01_1360_add_fingerprint_column_to_vds_static.sql
 
b/backend/manager/dbscripts/upgrade/03_01_1360_add_fingerprint_column_to_vds_static.sql
new file mode 100644
index 0000000..4cb6b01
--- /dev/null
+++ 
b/backend/manager/dbscripts/upgrade/03_01_1360_add_fingerprint_column_to_vds_static.sql
@@ -0,0 +1,2 @@
+--Add fingerprint field into vds_static
+SELECT fn_db_add_column('vds_static', 'fingerprint', 'character varying(128)');
diff --git a/backend/manager/dbscripts/vds_sp.sql 
b/backend/manager/dbscripts/vds_sp.sql
index f2c1a8e..2a73bc6 100644
--- a/backend/manager/dbscripts/vds_sp.sql
+++ b/backend/manager/dbscripts/vds_sp.sql
@@ -332,14 +332,15 @@
     v_pm_port INTEGER ,
     v_pm_options VARCHAR(4000) ,
     v_pm_enabled BOOLEAN,
-    v_vds_spm_priority INTEGER)
+    v_vds_spm_priority INTEGER,
+    v_fingerprint VARCHAR(128))
    AS $procedure$
 BEGIN
    IF v_vds_unique_id IS NULL OR NOT EXISTS(SELECT vds_name FROM vds_static 
WHERE vds_unique_id = v_vds_unique_id) then
       BEGIN
          v_vds_id := uuid_generate_v1();
-         INSERT INTO vds_static(vds_id,host_name, ip, vds_unique_id, port, 
vds_group_id, vds_name, 
server_SSL_enabled,vds_type,vds_strength,pm_type,pm_user,pm_password,pm_port,pm_options,pm_enabled,
 vds_spm_priority)
-                       VALUES(v_vds_id,v_host_name, v_ip, v_vds_unique_id, 
v_port, v_vds_group_id, v_vds_name, 
v_server_SSL_enabled,v_vds_type,v_vds_strength,v_pm_type,v_pm_user,v_pm_password,v_pm_port,v_pm_options,v_pm_enabled,
 v_vds_spm_priority);
+         INSERT INTO vds_static(vds_id,host_name, ip, vds_unique_id, port, 
vds_group_id, vds_name, 
server_SSL_enabled,vds_type,vds_strength,pm_type,pm_user,pm_password,pm_port,pm_options,pm_enabled,
 vds_spm_priority, fingerprint)
+                       VALUES(v_vds_id,v_host_name, v_ip, v_vds_unique_id, 
v_port, v_vds_group_id, v_vds_name, 
v_server_SSL_enabled,v_vds_type,v_vds_strength,v_pm_type,v_pm_user,v_pm_password,v_pm_port,v_pm_options,v_pm_enabled,
 v_vds_spm_priority, v_fingerprint);
       END;
    end if;
    RETURN;
@@ -367,7 +368,8 @@
     v_pm_options VARCHAR(4000) ,
     v_pm_enabled BOOLEAN,
     v_otp_validity BIGINT,
-    v_vds_spm_priority INTEGER)
+    v_vds_spm_priority INTEGER,
+    v_fingerprint VARCHAR(128))
 RETURNS VOID
 
        --The [vds_static] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -381,7 +383,7 @@
       vds_type = v_vds_type, 
       _update_date = LOCALTIMESTAMP,vds_strength = v_vds_strength, 
       pm_type = v_pm_type,pm_user = v_pm_user,pm_password = v_pm_password, 
-      pm_port = v_pm_port,pm_options = v_pm_options,pm_enabled = v_pm_enabled, 
otp_validity = v_otp_validity, vds_spm_priority = v_vds_spm_priority
+      pm_port = v_pm_port,pm_options = v_pm_options,pm_enabled = v_pm_enabled, 
otp_validity = v_otp_validity, vds_spm_priority = v_vds_spm_priority, 
fingerprint = v_fingerprint
       WHERE vds_id = v_vds_id;
    END;        
 
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 90ab0df..d5d0419 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
@@ -127,6 +127,9 @@
 
     private boolean autoRecoverable = true;
 
+    @Column(name = "fingerprint")
+    private String fingerprint;
+
     public boolean isAutoRecoverable() {
         return autoRecoverable;
     }
@@ -317,6 +320,14 @@
         this.vdsSpmPriority = value;
     }
 
+    public String getFingerprint() {
+        return fingerprint;
+    }
+
+    public void setFingerprint(String fingerprint) {
+        this.fingerprint = fingerprint;
+    }
+
     /**
      * Converts a PM Options map to string
      *
@@ -477,6 +488,11 @@
             return false;
         if (vdsType != other.vdsType)
             return false;
+        if (fingerprint == null) {
+            if (other.fingerprint != null)
+                return false;
+        } else if (!fingerprint.equals(other.fingerprint))
+            return false;
         return true;
     }
 
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 f6be4d7..c90cf06 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
@@ -98,7 +98,8 @@
                 .addValue("pm_options", vds.getpm_options())
                 .addValue("pm_enabled", vds.getpm_enabled())
                 .addValue("otp_validity", vds.getOtpValidity())
-                .addValue("vds_spm_priority", vds.getVdsSpmPriority());
+                .addValue("vds_spm_priority", vds.getVdsSpmPriority())
+                .addValue("fingerprint", vds.getFingerprint());
     }
 
     @Override
@@ -122,7 +123,7 @@
         String passwd = Config.<String> GetValue(ConfigValues.keystorePass, 
Config.DefaultConfigurationVersion);
         String alias = Config.<String> GetValue(ConfigValues.CertAlias, 
Config.DefaultConfigurationVersion);
         try {
-            return EncryptionUtils.encrypt((String) password, keyFile, passwd, 
alias);
+            return EncryptionUtils.encrypt(password, keyFile, passwd, alias);
         } catch (Exception e) {
             throw new SecurityException(e);
         }
@@ -136,7 +137,7 @@
         String passwd = Config.<String> GetValue(ConfigValues.keystorePass, 
Config.DefaultConfigurationVersion);
         String alias = Config.<String> GetValue(ConfigValues.CertAlias, 
Config.DefaultConfigurationVersion);
         try {
-            return EncryptionUtils.decrypt((String) password, keyFile, passwd, 
alias);
+            return EncryptionUtils.decrypt(password, keyFile, passwd, alias);
         } catch (Exception e) {
             log.debugFormat("Failed to decrypt password, error message: {0}", 
e.getMessage());
             return password;
@@ -170,6 +171,7 @@
             entity.setpm_options(rs.getString("pm_options"));
             entity.setpm_enabled(rs.getBoolean("pm_enabled"));
             entity.setOtpValidity(rs.getLong("otp_validity"));
+            entity.setFingerprint(rs.getString("fingerprint"));
 
             return entity;
         }
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
index b7fd8f3..66c8bcf 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VdsStaticDAOTest.java
@@ -1,11 +1,13 @@
 package org.ovirt.engine.core.dao;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.util.List;
 
 import org.junit.Test;
-
 import org.ovirt.engine.core.common.businessentities.VdsDynamic;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
 import org.ovirt.engine.core.common.businessentities.VdsStatistics;
@@ -32,6 +34,7 @@
         newStaticVds = new VdsStatic();
         newStaticVds.sethost_name("farkle.redhat.com");
         newStaticVds.setvds_group_id(existingVds.getvds_group_id());
+        
newStaticVds.setFingerprint("b5:ad:16:19:06:9f:b3:41:69:eb:1c:42:1d:12:b5:31");
     }
 
     /**
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index 9fcb269..594b4f1 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -736,6 +736,7 @@
         <column>_create_date</column>
         <column>_update_date</column>
         <column>vds_spm_priority</column>
+        <column>fingerprint</column>
         <row>
             <value>afce7a39-8e8c-4819-ba9c-796d316592e6</value>
             <value>magenta-vdsc</value>
@@ -756,7 +757,7 @@
             <value>2010-11-17 17:25:39</value>
             <value>2010-12-01 09:52:57</value>
             <value>8</value>
-            <value>21</value>
+            <value>b5:ad:16:19:06:9f:b3:41:69:eb:1c:42:1d:12:b5:31</value>
         </row>
         <row>
             <value>afce7a39-8e8c-4819-ba9c-796d316592e7</value>
@@ -778,7 +779,7 @@
             <value>2010-11-17 17:25:39</value>
             <value>2010-12-01 09:52:57</value>
             <value>6</value>
-            <value>21</value>
+            <value>b5:ad:16:19:06:9f:b3:41:69:eb:1c:42:1d:12:b5:31</value>
         </row>
     </table>
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7abe03b62dc15bb135fa02e0a43b763abd8872af
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Dhandapani Gopal <dgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to