Yaniv Bronhaim has uploaded a new change for review.

Change subject: Adding ssh_user and ssh_port values to api schema for Host 
mapper
......................................................................

Adding ssh_user and ssh_port values to api schema for Host mapper

Change-Id: I6b8c117d041c29780af2468888a732ee664d283c
Signed-off-by: Yaniv Bronhaim <[email protected]>
---
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostResource.java
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostsResource.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostResourceTest.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostsResourceTest.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendResourceTest.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
8 files changed, 43 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/47/16247/1

diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index 6b51918..7606855 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -897,6 +897,8 @@
         <column>vds_unique_id</column>
         <column>host_name</column>
         <column>port</column>
+        <column>ssh_port</column>
+        <column>ssh_username</column>
         <column>vds_group_id</column>
         <column>server_SSL_enabled</column>
         <column>vds_type</column>
@@ -926,6 +928,8 @@
             <value>farkle</value>
             <value>magenta-vdsc.redhat.com</value>
             <value>54321</value>
+            <value>22</value>
+            <value>root</value>
             <value>b399944a-81ab-4ec5-8266-e19ba7c3c9d1</value>
             <value>1</value>
             <value>1</value>
@@ -956,6 +960,8 @@
             <value>farkle</value>
             <value>purple-vdsc.redhat.com</value>
             <value>54321</value>
+            <value>22</value>
+            <value>root</value>
             <value>b399944a-81ab-4ec5-8266-e19ba7c3c9d2</value>
             <value>1</value>
             <value>0</value>
@@ -986,6 +992,8 @@
             <value>farkle</value>
             <value>localfs-vds.redhat.com</value>
             <value>54321</value>
+            <value>22</value>
+            <value>root</value>
             <value>eba797fb-8e3b-4777-b63c-92e7a5957d7f</value>
             <value>1</value>
             <value>1</value>
@@ -1016,6 +1024,8 @@
             <value>farkle</value>
             <value>gluster1-vdsc.redhat.com</value>
             <value>54321</value>
+            <value>22</value>
+            <value>root</value>
             <value>ae956031-6be2-43d6-bb8f-5191c9253314</value>
             <value>1</value>
             <value>1</value>
@@ -1046,6 +1056,8 @@
             <value>farkle</value>
             <value>gluster2-vdsc.redhat.com</value>
             <value>54321</value>
+            <value>22</value>
+            <value>root</value>
             <value>ae956031-6be2-43d6-bb8f-5191c9253314</value>
             <value>1</value>
             <value>1</value>
diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
index 0df3464..1cc5b8a 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
@@ -140,8 +140,10 @@
       <xs:element name="host" type="Host" minOccurs="0"/>
       <!-- for host NIC attach action -->
       <xs:element name="network" type="Network" minOccurs="0"/>
-      <!-- when installing a host, a root password is required -->
-      <xs:element name="root_password" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
+      <!-- when installing a host, ssh user name is required -->
+      <xs:element name="ssh_username" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
+      <!-- when installing a host, user password is required -->
+      <xs:element name="password" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
       <!-- when installing a rhev-h host, an ISO image file is required -->
       <xs:element name="image" type="xs:string" minOccurs="0" maxOccurs="1"/>
       <!-- for host fence action -->
@@ -1256,6 +1258,8 @@
           <!-- unsigned to avoid issues with port values greater than 32767,
                e.g. the standard VDSM port 54321 -->
           <xs:element name="port" type="xs:unsignedShort" minOccurs="0"/>
+          <xs:element name="ssh_port" type="xs:unsignedShort" minOccurs="0"/>
+          <xs:element name="ssh_username" type="xs:string" minOccurs="0"/>
           <xs:element name="type" type="xs:string" minOccurs="0"/>
           <xs:element name="storage_manager" type="StorageManager" 
minOccurs="0"/>
           <xs:element name="version" type="Version" minOccurs="0"/>
@@ -1264,9 +1268,9 @@
           <xs:element ref="ksm" minOccurs="0"/>
           <xs:element ref="transparent_hugepages" minOccurs="0"/>
           <xs:element name="iscsi" type="IscsiDetails" minOccurs="0"/>
-          <!-- when creating a new host, a root password is required, but
+          <!-- when creating a new host, a password is required, but
                this is not subsequently included in the representation -->
-          <xs:element name="root_password" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
+          <xs:element name="password" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
           <xs:element name="statistics" type="Statistics" minOccurs="0" 
maxOccurs="1"/>
           <xs:element ref="cpu" minOccurs="0" maxOccurs="1"/>
           <xs:element name="memory" type="xs:long" minOccurs="0"/>
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostResource.java
index 9918efa..35fdf5c 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostResource.java
@@ -98,14 +98,14 @@
     public Response install(Action action) {
         // REVISIT fencing options
         VDS vds = getEntity();
-        UpdateVdsActionParameters params = new 
UpdateVdsActionParameters(vds.getStaticData(), action.getRootPassword(), true);
+        UpdateVdsActionParameters params = new 
UpdateVdsActionParameters(vds.getStaticData(), action.getPassword(), true);
         if (vds.getVdsType()==VDSType.oVirtNode) {
             params.setIsReinstallOrUpgrade(true);
             if (action.isSetImage()) {
                 params.setoVirtIsoFile(action.getImage());
             }
         } else {
-            validateParameters(action, "rootPassword");
+            validateParameters(action, "Password");
         }
         return doAction(VdcActionType.UpdateVds,
                         params,
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostsResource.java
index 0310821..d0717b0 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostsResource.java
@@ -86,10 +86,10 @@
     @Override
     public Response add(Host host) {
         validateEnums(Host.class, host);
-        validateParameters(host, "name", "address", "rootPassword");
+        validateParameters(host, "name", "address", "password");
         VdsStatic staticHost = getMapper(Host.class, 
VdsStatic.class).map(host, null);
         staticHost.setVdsGroupId(getClusterId(host));
-        AddVdsActionParameters addParams = new 
AddVdsActionParameters(staticHost, host.getRootPassword());
+        AddVdsActionParameters addParams = new 
AddVdsActionParameters(staticHost, host.getPassword());
         if (host.isSetOverrideIptables()) {
             addParams.setOverrideFirewall(host.isOverrideIptables());
         }
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostResourceTest.java
index 42bc9ef..371abee 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostResourceTest.java
@@ -451,7 +451,7 @@
                                            new Object[] { NAMES[2] }));
 
         Action action = new Action();
-        action.setRootPassword(NAMES[2]);
+        action.setPassword(NAMES[2]);
         verifyActionResponse(resource.install(action));
     }
 
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostsResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostsResourceTest.java
index a35b69b..5f02e9a 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostsResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostsResourceTest.java
@@ -341,7 +341,7 @@
         Host model = new Host();
         model.setName(NAMES[index]);
         model.setAddress(ADDRESSES[index]);
-        model.setRootPassword(ROOT_PASSWORD);
+        model.setPassword(ROOT_PASSWORD);
         return model;
     }
 
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendResourceTest.java
index 28de390..7606aff 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendResourceTest.java
@@ -70,7 +70,7 @@
                                            true,
                                            true)));
         Action action = new Action();
-        action.setRootPassword(NAMES[2]);
+        action.setPassword(NAMES[2]);
         resource.install(action);
     }
 
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
index 3711f47..76ffd15 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
@@ -48,6 +48,8 @@
     public final static Long BYTES_IN_MEGABYTE = 1024L * 1024L;
     // REVISIT retrieve from configuration
     private static final int DEFAULT_VDSM_PORT = 54321;
+    private static final int DEFAULT_SSH_PORT = 22;
+    private static final String DEFAULT_ROOT_USERNAME = "root";
     private static final String MD5_FILE_SIGNATURE = "md5";
     private static final String MD5_SECURITY_ALGORITHM = "MD5";
 
@@ -72,6 +74,16 @@
             entity.setPort(model.getPort());
         } else {
             entity.setPort(DEFAULT_VDSM_PORT);
+        }
+        if (model.isSetSshPort() && model.getSshPort() > 0) {
+            entity.setSSHPort(model.getSshPort());
+        } else {
+            entity.setSSHPort(DEFAULT_SSH_PORT);
+        }
+        if (model.isSetSshUsername()) {
+            entity.setSSHUsername(model.getSshUsername());
+        } else {
+            entity.setSSHUsername(DEFAULT_ROOT_USERNAME);
         }
         if (model.isSetPowerManagement()) {
             entity = map(model.getPowerManagement(), entity);
@@ -227,6 +239,10 @@
         if (entity.getPort() > 0) {
             model.setPort(entity.getPort());
         }
+        if (entity.getSSHPort() > 0) {
+            model.setSshPort(entity.getSSHPort());
+        }
+        model.setSshUsername(entity.getSSHUsername());
         HostStatus status = map(entity.getStatus(), null);
         model.setStatus(StatusUtils.create(status));
         if (status==HostStatus.NON_OPERATIONAL) {


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

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

Reply via email to