Hello Moti Asayag,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/16850

to review the following change.

Change subject: engine: Add agent configuration to provider
......................................................................

engine: Add agent configuration to provider

The Provider entity is being extended with the agent configuration.
The agent configuration represents the specific network agent
configuration and it will be used for installing and configuring the
agent on the installed host.

Change-Id: If93d24404815c080253207f8e9b8f781fac0c7f6
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/OpenstackNetworkProviderProperties.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M packaging/dbscripts/providers_sp.sql
A packaging/dbscripts/upgrade/03_03_0400_add_agent_configuration_to_provider.sql
5 files changed, 193 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/50/16850/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/OpenstackNetworkProviderProperties.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/OpenstackNetworkProviderProperties.java
index 93fa55b..0690a95 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/OpenstackNetworkProviderProperties.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/OpenstackNetworkProviderProperties.java
@@ -1,10 +1,14 @@
 package org.ovirt.engine.core.common.businessentities;
 
+import java.io.Serializable;
+
 public class OpenstackNetworkProviderProperties extends 
TenantProviderProperties {
 
     private static final long serialVersionUID = -7470940167999871534L;
 
     private String pluginType;
+
+    private AgentConfiguration agentConfiguration;
 
     public String getPluginType() {
         return pluginType;
@@ -14,11 +18,20 @@
         this.pluginType = pluginType;
     }
 
+    public AgentConfiguration getAgentConfiguration() {
+        return agentConfiguration;
+    }
+
+    public void setAgentConfiguration(AgentConfiguration agentConfiguration) {
+        this.agentConfiguration = agentConfiguration;
+    }
+
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
         result = prime * result + ((getPluginType() == null) ? 0 : 
getPluginType().hashCode());
+        result = prime * result + ((getAgentConfiguration() == null) ? 0 : 
getAgentConfiguration().hashCode());
         return result;
     }
 
@@ -37,6 +50,13 @@
         if (!getPluginType().equals(other.getPluginType())) {
             return false;
         }
+        if (getAgentConfiguration() == null) {
+            if (other.getAgentConfiguration() != null) {
+                return false;
+            }
+        } else if 
(!getAgentConfiguration().equals(other.getAgentConfiguration())) {
+            return false;
+        }
         return true;
     }
 
@@ -51,4 +71,158 @@
         return builder.toString();
     }
 
+    public static class QpidConfiguration implements Serializable {
+        private static final long serialVersionUID = -8072430559946539586L;
+        private String address;
+        private int port;
+        private String username;
+        private String password;
+
+        public String getAddress() {
+            return address;
+        }
+
+        public void setAddress(String address) {
+            this.address = address;
+        }
+
+
+        public Integer getPort() {
+            return port;
+        }
+
+        public void setPort(Integer port) {
+            this.port = port;
+        }
+
+        public String getUsername() {
+            return username;
+        }
+
+        public void setUsername(String username) {
+            this.username = username;
+        }
+
+        public String getPassword() {
+            return password;
+        }
+
+        public void setPassword(String password) {
+            this.password = password;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((getAddress() == null) ? 0 : 
getAddress().hashCode());
+            result = prime * result + ((getPort() == null) ? 0 : 
getPort().hashCode());
+            result = prime * result + ((getUsername() == null) ? 0 : 
getUsername().hashCode());
+            result = prime * result + ((getPassword() == null) ? 0 : 
getPassword().hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (!(obj instanceof QpidConfiguration)) {
+                return false;
+            }
+            QpidConfiguration other = (QpidConfiguration) obj;
+            if (getAddress() == null) {
+                if (other.getAddress() != null) {
+                    return false;
+                }
+            } else if (!getAddress().equals(other.getAddress())) {
+                return false;
+            }
+            if (getPassword() == null) {
+                if (other.getPassword() != null) {
+                    return false;
+                }
+            } else if (!getPassword().equals(other.getPassword())) {
+                return false;
+            }
+            if (getPort() == null) {
+                if (other.getPort() != null) {
+                    return false;
+                }
+            } else if (!getPort().equals(other.getPort())) {
+                return false;
+            }
+            if (getUsername() == null) {
+                if (other.getUsername() != null) {
+                    return false;
+                }
+            } else if (!getUsername().equals(other.getUsername())) {
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static class AgentConfiguration implements Serializable {
+        private static final long serialVersionUID = -3588687921167640459L;
+        private QpidConfiguration qpidConfiguration;
+        private String networkMappings;
+
+        public QpidConfiguration getQpidConfiguration() {
+            return qpidConfiguration;
+        }
+
+        public void setQpidConfiguration(QpidConfiguration qpidConfiguration) {
+            this.qpidConfiguration = qpidConfiguration;
+        }
+
+        public String getNetworkMappings() {
+            return networkMappings;
+        }
+
+        public void setNetworkMappings(String networkMappings) {
+            this.networkMappings = networkMappings;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((getNetworkMappings() == null) ? 0 : 
getNetworkMappings().hashCode());
+            result = prime * result + ((getQpidConfiguration() == null) ? 0 : 
getQpidConfiguration().hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (!(obj instanceof AgentConfiguration)) {
+                return false;
+            }
+            AgentConfiguration other = (AgentConfiguration) obj;
+            if (getNetworkMappings() == null) {
+                if (other.getNetworkMappings() != null) {
+                    return false;
+                }
+            } else if 
(!getNetworkMappings().equals(other.getNetworkMappings())) {
+                return false;
+            }
+            if (getQpidConfiguration() == null) {
+                if (other.getQpidConfiguration() != null) {
+                    return false;
+                }
+            } else if 
(!getQpidConfiguration().equals(other.getQpidConfiguration())) {
+                return false;
+            }
+            return true;
+        }
+    }
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java
index b29442f..348811e 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/provider/ProviderDaoDbFacadeImpl.java
@@ -6,6 +6,7 @@
 import java.util.List;
 
 import 
org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties;
+import 
org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration;
 import org.ovirt.engine.core.common.businessentities.Provider;
 import 
org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties;
 import org.ovirt.engine.core.common.businessentities.ProviderType;
@@ -28,6 +29,7 @@
         MapSqlParameterSource mapper = 
createBaseProviderParametersMapper(entity);
         String tenantName = null;
         String pluginType = null;
+        AgentConfiguration agentConfiguration = null;
 
         if (entity.getAdditionalProperties() != null) {
             switch (entity.getType()) {
@@ -36,6 +38,7 @@
                         (OpenstackNetworkProviderProperties) 
entity.getAdditionalProperties();
                 tenantName = properties.getTenantName();
                 pluginType = properties.getPluginType();
+                agentConfiguration = properties.getAgentConfiguration();
                 break;
             default:
                 break;
@@ -45,6 +48,7 @@
         // We always add the values since JdbcTeplate expects them to be set, 
otherwise it throws an exception.
         mapper.addValue("tenant_name", tenantName);
         mapper.addValue("plugin_type", pluginType);
+        mapper.addValue("agent_configuration", 
SerializationFactory.getSerializer().serialize(agentConfiguration));
         return mapper;
     }
 
@@ -110,6 +114,8 @@
                 OpenstackNetworkProviderProperties properties = new 
OpenstackNetworkProviderProperties();
                 properties.setTenantName(rs.getString("tenant_name"));
                 properties.setPluginType(rs.getString("plugin_type"));
+                
properties.setAgentConfiguration(SerializationFactory.getDeserializer()
+                        .deserialize(rs.getString("agent_configuration"), 
AgentConfiguration.class));
                 return properties;
             default:
                 return null;
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index bb3d1f3..6538f65 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -732,6 +732,7 @@
         <column>auth_password</column>
         <column>tenant_name</column>
         <column>plugin_type</column>
+        <column>agent_configuration</column>
         <row>
             <value>1115c1c6-cb15-4832-b2a4-023770607111</value>
             <value>provider</value>
@@ -743,6 +744,7 @@
             <null/>
             <value>bubu</value>
             <value>LINUX_BRIDGE</value>
+            <null/>
         </row>
     </table>
 
diff --git a/packaging/dbscripts/providers_sp.sql 
b/packaging/dbscripts/providers_sp.sql
index 13bc4a1..dd089f2 100644
--- a/packaging/dbscripts/providers_sp.sql
+++ b/packaging/dbscripts/providers_sp.sql
@@ -18,7 +18,8 @@
     v_auth_password TEXT,
     v_custom_properties TEXT,
     v_tenant_name VARCHAR DEFAULT NULL,
-    v_plugin_type VARCHAR DEFAULT NULL)
+    v_plugin_type VARCHAR DEFAULT NULL,
+    v_agent_configuration TEXT DEFAULT NULL)
 RETURNS VOID
 AS $procedure$
 BEGIN
@@ -33,7 +34,8 @@
         auth_password,
         custom_properties,
         tenant_name,
-        plugin_type)
+        plugin_type,
+        agent_configuration)
     VALUES(
         v_id,
         v_name,
@@ -45,7 +47,8 @@
         v_auth_password,
         v_custom_properties,
         v_tenant_name,
-        v_plugin_type);
+        v_plugin_type,
+        v_agent_configuration);
 END; $procedure$
 LANGUAGE plpgsql;
 
@@ -64,7 +67,8 @@
     v_auth_password TEXT,
     v_custom_properties TEXT,
     v_tenant_name VARCHAR DEFAULT NULL,
-    v_plugin_type VARCHAR DEFAULT NULL)
+    v_plugin_type VARCHAR DEFAULT NULL,
+    v_agent_configuration TEXT DEFAULT NULL)
 RETURNS VOID
 AS $procedure$
 BEGIN
@@ -79,7 +83,8 @@
            custom_properties = v_custom_properties,
            tenant_name = v_tenant_name,
            plugin_type = v_plugin_type,
-           _update_date = NOW()
+           _update_date = NOW(),
+           agent_configuration = v_agent_configuration
     WHERE  id = v_id;
 END; $procedure$
 LANGUAGE plpgsql;
diff --git 
a/packaging/dbscripts/upgrade/03_03_0400_add_agent_configuration_to_provider.sql
 
b/packaging/dbscripts/upgrade/03_03_0400_add_agent_configuration_to_provider.sql
new file mode 100644
index 0000000..8bc53d1
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_03_0400_add_agent_configuration_to_provider.sql
@@ -0,0 +1 @@
+select fn_db_add_column('providers', 'agent_configuration', 'TEXT');


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If93d24404815c080253207f8e9b8f781fac0c7f6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Mike Kolesnik <mkole...@redhat.com>
Gerrit-Reviewer: Moti Asayag <masa...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to