Ori Liel has uploaded a new change for review.

Change subject: restapi: Fix lun mapping for add lun-disk
......................................................................

restapi: Fix lun mapping for add lun-disk

Change-Id: I8e1299265f4c24b4212b57924eb2c4389411c5a4
Signed-off-by: Ori Liel <[email protected]>
---
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/StorageLogicalUnitMapper.java
1 file changed, 33 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/06/7206/1

diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/StorageLogicalUnitMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/StorageLogicalUnitMapper.java
index 46286aa..16c902a 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/StorageLogicalUnitMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/StorageLogicalUnitMapper.java
@@ -1,5 +1,7 @@
 package org.ovirt.engine.api.restapi.types;
 
+import java.util.ArrayList;
+
 import org.ovirt.engine.api.common.util.SizeConverter;
 import org.ovirt.engine.api.model.LogicalUnit;
 import org.ovirt.engine.api.model.LunStatus;
@@ -65,10 +67,19 @@
         return model;
     }
 
+    /**
+     * This mapping exists for adding a lun-disk, and assumes that 'storage' 
entity contains exactly one lun.
+     */
     @Mapping(from = Storage.class, to = LUNs.class)
     public static LUNs map(Storage model, LUNs template) {
         LUNs entity = template != null ? template : new LUNs();
-        entity.setLUN_id(model.getId());
+        if (model.isSetLogicalUnits()) {
+            LogicalUnit logicalUnit = model.getLogicalUnits().get(0);
+            entity.setLUN_id(logicalUnit.getId());
+            ArrayList<storage_server_connections> connections = new 
ArrayList<storage_server_connections>();
+            connections.add(map(logicalUnit, null));
+            entity.setLunConnections(connections);
+        }
         if (model.isSetType()) {
             StorageType storageType = StorageType.fromValue(model.getType());
             if (storageType != null) {
@@ -78,6 +89,27 @@
         return entity;
     }
 
+    @Mapping(from = LogicalUnit.class, to = storage_server_connections.class)
+    public static storage_server_connections map(LogicalUnit logicalUnit, 
storage_server_connections connection) {
+        storage_server_connections entity = connection != null ? connection : 
new storage_server_connections();
+        if (logicalUnit.isSetAddress()) {
+            entity.setconnection(logicalUnit.getAddress());
+        }
+        if (logicalUnit.isSetTarget()) {
+            entity.setiqn(logicalUnit.getTarget());
+        }
+        if (logicalUnit.isSetPort()) {
+            entity.setport(logicalUnit.getPort().toString());
+        }
+        if (logicalUnit.isSetUsername()) {
+            entity.setuser_name(logicalUnit.getUsername());
+        }
+        if (logicalUnit.isSetPassword()) {
+            entity.setpassword(logicalUnit.getPassword());
+        }
+        return entity;
+    }
+
     @Mapping(from = 
org.ovirt.engine.core.common.businessentities.LunStatus.class, to = 
LunStatus.class)
     public static LunStatus 
map(org.ovirt.engine.core.common.businessentities.LunStatus status, LunStatus 
template) {
         switch (status) {


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

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

Reply via email to