Maor Lipchuk has uploaded a new change for review.

Change subject: restapi: Validate if the host is connected to the storage id.
......................................................................

restapi: Validate if the host is connected to the storage id.

Adding a validation to check if the Host is connected to the iSCSI storage
domain before importing it.

The import process should be after the Host has been connected to the
targets and can see the Storage Domain with the id which has been
configured in the request.

Change-Id: I6a6376a358c0c3d02960efe12b3a8b79cd62aeb1
Signed-off-by: Maor Lipchuk <[email protected]>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainsResource.java
1 file changed, 9 insertions(+), 0 deletions(-)


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

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainsResource.java
index b7c9ff3..cc78822 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainsResource.java
@@ -34,6 +34,7 @@
 import org.ovirt.engine.core.common.businessentities.StorageDomainType;
 import org.ovirt.engine.core.common.businessentities.StorageServerConnections;
 import org.ovirt.engine.core.common.businessentities.StorageType;
+import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VdsStatic;
 import org.ovirt.engine.core.common.interfaces.SearchType;
 import org.ovirt.engine.core.common.queries.GetDeviceListQueryParameters;
@@ -132,6 +133,10 @@
     }
 
     private Response addExistingSAN(StorageDomain model, StorageType 
storageType, Guid hostId) {
+        getEntity(VDS.class,
+                VdcQueryType.GetVdsByVdsId,
+                new IdQueryParameters(hostId),
+                "Host: id=" + hostId);
         List<LUNs> existingLuns = getDeviceList(hostId, storageType);
         List<StorageServerConnections> existingStorageServerConnections =
                 getLunsWithInitializedStorageType(existingLuns, storageType);
@@ -143,6 +148,10 @@
 
         StorageDomainStatic storageDomainToImport =
                 getMatchingStorageDomain(asGuid(model.getId()), 
existingStorageDomains);
+        if (storageDomainToImport == null) {
+            throw new WebFaultException(new WebApplicationException(), 
"Storage Domain id " + model.getId()
+                    + " Does not exists", Status.NOT_FOUND);
+        }
         StorageDomainManagementParameter parameters =
                 new StorageDomainManagementParameter(storageDomainToImport);
         parameters.setVdsId(hostId);


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

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

Reply via email to