Alissa Bonas has uploaded a new change for review.

Change subject: core: check no running VMs use storage conn
......................................................................

core: check no running VMs use storage conn

Check during update connection that if the updated
connection is for block storage, if it's used by lun disks,
that the plugged VMs are down.

Change-Id: I11fe22760952e1319654647eed661a7814675f64
Signed-off-by: Alissa Bonas <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageServerConnectionCommandBase.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
9 files changed, 229 insertions(+), 51 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/03/16203/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
index 854e4b4..8388c5a 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/RemoveStorageServerConnectionCommand.java
@@ -17,7 +17,6 @@
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.locks.LockingGroup;
 import org.ovirt.engine.core.common.utils.Pair;
-import org.ovirt.engine.core.dao.LunDAO;
 import org.ovirt.engine.core.dao.StorageServerConnectionDAO;
 
 
@@ -132,10 +131,6 @@
         // Remove the last "," after the last domain
         domainNames.deleteCharAt(domainNames.length() - 1);
         return domainNames.toString();
-    }
-
-    protected LunDAO getLunDao() {
-        return getDbFacade().getLunDao();
     }
 
     @Override
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageServerConnectionCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageServerConnectionCommandBase.java
index d2cb6f8..5bbc144 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageServerConnectionCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageServerConnectionCommandBase.java
@@ -10,6 +10,7 @@
 import org.ovirt.engine.core.common.businessentities.StorageDomain;
 import org.ovirt.engine.core.common.businessentities.StorageServerConnections;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dao.LunDAO;
 import org.ovirt.engine.core.dao.StorageDomainDAO;
 
 public abstract class StorageServerConnectionCommandBase<T extends 
StorageServerConnectionParametersBase> extends
@@ -33,6 +34,10 @@
         return getDbFacade().getStorageDomainDao();
     }
 
+    protected LunDAO getLunDao() {
+        return getDbFacade().getLunDao();
+    }
+
     protected List<StorageDomain> getStorageDomainsByConnId(String 
connectionId) {
         return 
getStorageDomainDao().getAllByConnectionId(Guid.createGuidFromString(connectionId));
     }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
index 0b25aee..e8e9c8d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommand.java
@@ -12,6 +12,7 @@
 import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
 import org.ovirt.engine.core.bll.context.CompensationContext;
 import 
org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase;
+import org.ovirt.engine.core.common.businessentities.LUNs;
 import org.ovirt.engine.core.common.businessentities.StorageDomain;
 import org.ovirt.engine.core.common.businessentities.StorageDomainStatus;
 import org.ovirt.engine.core.common.businessentities.StorageDomainType;
@@ -19,6 +20,8 @@
 import org.ovirt.engine.core.common.businessentities.StoragePoolIsoMapId;
 import org.ovirt.engine.core.common.businessentities.StorageServerConnections;
 import org.ovirt.engine.core.common.businessentities.StorageType;
+import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.errors.VdcFault;
@@ -30,6 +33,7 @@
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.compat.NGuid;
 import org.ovirt.engine.core.dao.StorageDomainDynamicDAO;
 import org.ovirt.engine.core.dao.StoragePoolIsoMapDAO;
 import org.ovirt.engine.core.dao.StorageServerConnectionDAO;
@@ -48,10 +52,10 @@
     @Override
     protected boolean canDoAction() {
         StorageServerConnections newConnectionDetails = 
getParameters().getStorageServerConnection();
-
-        if (!newConnectionDetails.getstorage_type().isFileDomain()
-                || 
newConnectionDetails.getstorage_type().equals(StorageType.GLUSTERFS)) {
-            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE);
+        StorageType storageType = newConnectionDetails.getstorage_type();
+        if ((!storageType.isFileDomain() && 
!storageType.equals(StorageType.ISCSI))
+                || storageType.equals(StorageType.GLUSTERFS)) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE);
         }
 
         // Check if the NFS path has a valid format
@@ -96,21 +100,18 @@
             }
         }
 
-        if (domains == null) {
-            domains = getStorageDomainsByConnId(newConnectionDetails.getid());
-        }
-        if (doDomainsUseConnection()) {
+        if (doDomainsUseConnection(newConnectionDetails) || 
doLunsUseConnection(newConnectionDetails)) {
             if (domains.size() == 1) {
                 setStorageDomain(domains.get(0));
             }
-            else {
+            else if(storageType.isFileDomain() &&  domains.size() >0 ) {
                 String domainNames = createDomainNamesList(domains);
                 addCanDoActionMessage(String.format("$domainNames %1$s", 
domainNames));
                 return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS);
             }
             // Check that the storage domain is in proper state to be edited
-            if (!isConnectionEditable(getStorageDomain())) {
-                return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE);
+            if (!isConnectionEditable(newConnectionDetails)) {
+                return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE);
             }
         }
         return super.canDoAction();
@@ -128,7 +129,70 @@
         return domainNames.toString();
     }
 
-    protected boolean isConnectionEditable(StorageDomain storageDomain) {
+    protected boolean isConnectionEditable(StorageServerConnections 
connection) {
+         if (connection.getstorage_type().isFileDomain())  {
+            boolean isConnectionEditable = 
isDomainInEditState(getStorageDomain()) ;
+            if (!isConnectionEditable) {
+                addCanDoActionMessage(String.format("$domainNames %1$s", 
getStorageDomain().getStorageName()));
+                
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_DOMAINS_MAINTENANCE);
+            }
+            return isConnectionEditable;
+         }
+         else {
+            List<LUNs> luns = 
getLunDao().getAllForStorageServerConnection(connection.getid());
+            if (!luns.isEmpty()) {
+                List<String> vmNames = new ArrayList();
+                List<String> domainNames = new ArrayList();
+                for (LUNs lun : luns) {
+                    NGuid diskId = lun.getDiskId();
+                    if (diskId != null) {
+                      Map<Boolean, List<VM>> vmsMap = 
getVmDAO().getForDisk(diskId.getValue());
+                      List<VM> pluggedVms = vmsMap.get(Boolean.TRUE);
+                      if (pluggedVms != null && !pluggedVms.isEmpty()) {
+                          for (VM vm : pluggedVms) {
+                              if(!vm.getStatus().equals(VMStatus.Down)) {
+                                  vmNames.add(vm.getName());
+                              }
+                          }
+                      }
+                    }
+                    NGuid storageDomainId = lun.getStorageDomainId();
+                    if(storageDomainId!=null) {
+                        StorageDomain domain = 
getStorageDomainDao().get(storageDomainId.getValue());
+                        
if(!domain.getStatus().equals(StorageDomainStatus.Maintenance)) {
+                              String domainName = domain.getStorageName();
+                              domainNames.add(domainName);
+                        }
+                    }
+                }
+                if (!vmNames.isEmpty()) {
+                    if (domainNames.isEmpty()) {
+                         addCanDoActionMessage(String.format("vmNames %1$s", 
prepareEntityNamesForMessage(vmNames)));
+                         
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS);
+                    }
+                    else {
+                         addCanDoActionMessage(String.format("vmNames %1$s", 
prepareEntityNamesForMessage(vmNames)));
+                         addCanDoActionMessage(String.format("domainNames 
%1$s", prepareEntityNamesForMessage(domainNames)));
+                         
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_MAINTENANCE);
+                    }
+                    return false;
+                }
+
+                if (!domainNames.isEmpty()) {
+                    addCanDoActionMessage(String.format("domainNames %1$s", 
prepareEntityNamesForMessage(domainNames)));
+                    
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_DOMAINS_MAINTENANCE);
+                   return false;
+                }
+            }
+            return true;
+         }
+    }
+
+    private String prepareEntityNamesForMessage(List<String> entityNames) {
+        return StringUtils.join(entityNames, ",");
+    }
+
+    protected boolean isDomainInEditState(StorageDomain storageDomain) {
         boolean isEditable =
                 (storageDomain.getStorageDomainType() == 
StorageDomainType.Data || storageDomain.getStorageDomainType() == 
StorageDomainType.Master)
                         && storageDomain.getStatus() == 
StorageDomainStatus.Maintenance;
@@ -137,7 +201,7 @@
 
     @Override
     protected void executeCommand() {
-        boolean isDomainUpdateRequired = doDomainsUseConnection();
+        boolean isDomainUpdateRequired = 
doDomainsUseConnection(getConnection());
         StoragePoolIsoMap map = getStoragePoolIsoMap();
         if (isDomainUpdateRequired) {
             changeStorageDomainStatusInTransaction(map, 
StorageDomainStatus.Locked);
@@ -184,10 +248,18 @@
         setSucceeded(setSucceeded);
     }
 
-    protected boolean doDomainsUseConnection() {
+    protected boolean doDomainsUseConnection(StorageServerConnections 
connection) {
+        if (domains == null) {
+            domains = getStorageDomainsByConnId(connection.getid());
+        }
         return domains != null && !domains.isEmpty();
     }
 
+    protected boolean doLunsUseConnection(StorageServerConnections connection) 
{
+        List<LUNs> luns = 
getLunDao().getAllForStorageServerConnection(connection.getid());
+        return !luns.isEmpty();
+    }
+
     protected StoragePoolIsoMap getStoragePoolIsoMap() {
         StoragePoolIsoMapId mapId = new 
StoragePoolIsoMapId(getStorageDomain().getId(),
                 getParameters().getStoragePoolId());
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
index fcc22c3..73a0c2c 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/UpdateStorageServerConnectionCommandTest.java
@@ -9,7 +9,9 @@
 import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -20,6 +22,7 @@
 import org.ovirt.engine.core.bll.CanDoActionTestUtils;
 import org.ovirt.engine.core.bll.CommandAssertUtils;
 import 
org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase;
+import org.ovirt.engine.core.common.businessentities.LUNs;
 import org.ovirt.engine.core.common.businessentities.NfsVersion;
 import org.ovirt.engine.core.common.businessentities.StorageDomain;
 import org.ovirt.engine.core.common.businessentities.StorageDomainDynamic;
@@ -27,12 +30,17 @@
 import org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap;
 import org.ovirt.engine.core.common.businessentities.StorageServerConnections;
 import org.ovirt.engine.core.common.businessentities.StorageType;
+import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
 import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dao.LunDAO;
+import org.ovirt.engine.core.dao.StorageDomainDAO;
 import org.ovirt.engine.core.dao.StorageDomainDynamicDAO;
 import org.ovirt.engine.core.dao.StoragePoolIsoMapDAO;
 import org.ovirt.engine.core.dao.StorageServerConnectionDAO;
+import org.ovirt.engine.core.dao.VmDAO;
 import org.ovirt.engine.core.utils.MockEJBStrategyRule;
 
 @RunWith(MockitoJUnitRunner.class)
@@ -54,6 +62,15 @@
 
     @Mock
     private StoragePoolIsoMapDAO storagePoolIsoMapDAO;
+
+    @Mock
+    private LunDAO lunDAO;
+
+    @Mock
+    private VmDAO vmDAO;
+
+    @Mock
+    private StorageDomainDAO storageDomainDAO;
 
     private StorageServerConnectionParametersBase parameters;
 
@@ -87,7 +104,9 @@
        doReturn(storageConnDao).when(command).getStorageConnDao();
        
doReturn(storageDomainDynamicDao).when(command).getStorageDomainDynamicDao();
        doReturn(storagePoolIsoMapDAO).when(command).getStoragePoolIsoMapDao();
-
+       doReturn(lunDAO).when(command).getLunDao();
+       doReturn(vmDAO).when(command).getVmDAO();
+       doReturn(storageDomainDAO).when(command).getStorageDomainDao();
     }
 
     private StorageServerConnections createNFSConnection(String connection,
@@ -108,6 +127,15 @@
         StorageServerConnections connectionDetails = 
populateBasicConnectionDetails(id, connection, type);
         connectionDetails.setVfsType(vfsType);
         connectionDetails.setMountOptions(mountOptions);
+        return connectionDetails;
+    }
+
+    private StorageServerConnections createISCSIConnection(String connection, 
StorageType type, String iqn, String user, String password) {
+        Guid id = Guid.NewGuid();
+        StorageServerConnections connectionDetails = 
populateBasicConnectionDetails(id, connection, type);
+        connectionDetails.setiqn(iqn);
+        connectionDetails.setuser_name(user);
+        connectionDetails.setpassword(password);
         return connectionDetails;
     }
 
@@ -149,28 +177,17 @@
 
     @Test
     public void updateIScsiConnection() {
-          StorageServerConnections  newNFSConnection = createNFSConnection(
-                        
"multipass.my.domain.tlv.company.com:/export/allstorage/data2",
-                        StorageType.ISCSI,
-                        NfsVersion.V4,
-                        300,
-                        0);
-        parameters.setStorageServerConnection(newNFSConnection);
+        StorageServerConnections  dummyFCPConn = 
createISCSIConnection("10.35.16.25", StorageType.FCP, "", "user1", 
"mypassword123");
+        parameters.setStorageServerConnection(dummyFCPConn);
         CanDoActionTestUtils.runAndAssertCanDoActionFailure(command,
-                
VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE);
+                
VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE);
     }
 
     @Test
     public void updateChangeConnectionType() {
-        StorageServerConnections  newNFSConnection = createNFSConnection(
-                        
"multipass.my.domain.tlv.company.com:/export/allstorage/data2",
-                        StorageType.NFS,
-                        NfsVersion.V4,
-                        300,
-                        0);
-        parameters.setStorageServerConnection(newNFSConnection);
-        oldNFSConnection.setstorage_type(StorageType.ISCSI);
-        
when(storageConnDao.get(newNFSConnection.getid())).thenReturn(oldNFSConnection);
+        StorageServerConnections  iscsiConnection = 
createISCSIConnection("10.35.16.25", 
StorageType.ISCSI,"","user1","mypassword123");
+        parameters.setStorageServerConnection(iscsiConnection);
+        
when(storageConnDao.get(iscsiConnection.getid())).thenReturn(oldNFSConnection);
         CanDoActionTestUtils.runAndAssertCanDoActionFailure(command,
                 
VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE);
     }
@@ -280,7 +297,65 @@
         
when(storageConnDao.get(newNFSConnection.getid())).thenReturn(oldNFSConnection);
         
doReturn(domains).when(command).getStorageDomainsByConnId(newNFSConnection.getid());
         CanDoActionTestUtils.runAndAssertCanDoActionFailure(command,
-                
VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE);
+                
VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_DOMAINS_MAINTENANCE);
+    }
+
+    @Test
+    public void updateConnectionOfDomainsAndLunDisks() {
+        StorageServerConnections iscsiConnection = 
createISCSIConnection("10.35.16.25", StorageType.ISCSI, "", "user1", 
"mypassword123");
+        List<LUNs> luns = new ArrayList();
+        LUNs lun1 = new LUNs();
+        lun1.setLUN_id("3600144f09dbd05000000517e730b1212");
+        lun1.setvolume_group_id("");
+        lun1.setDiskAlias("disk1");
+        Guid diskId1 = Guid.NewGuid();
+        lun1.setDiskId(diskId1);
+        luns.add(lun1);
+        LUNs lun2 = new LUNs();
+        lun2.setLUN_id("3600144f09dbd05000000517e730b1212");
+        lun2.setvolume_group_id("");
+        lun2.setDiskAlias("disk2");
+        Guid diskId2 = Guid.NewGuid();
+        lun2.setDiskId(diskId2);
+        luns.add(lun2);
+        LUNs lun3 = new LUNs();
+        lun3.setLUN_id("3600144f09dbd05000000517e730b1212");
+        lun3.setStorageDomainName("storagedomain4");
+        Guid storageDomainId = Guid.NewGuid();
+        lun3.setStorageDomainId(storageDomainId);
+        lun3.setvolume_group_id(Guid.NewGuid().toString());
+        luns.add(lun3);
+        Map<Boolean, List<VM>> vmsMap = new HashMap();
+        VM vm1 = new VM();
+        vm1.setName("vm1");
+        vm1.setStatus(VMStatus.Up);
+        VM vm2 = new VM();
+        vm2.setName("vm2");
+        vm2.setStatus(VMStatus.Down);
+        VM vm3 = new VM();
+        vm3.setName("vm3");
+        vm3.setStatus(VMStatus.Up);
+        List<VM> pluggedVms = new ArrayList();
+        pluggedVms.add(vm1);
+        pluggedVms.add(vm2);
+        List<VM> unPluggedVms = new ArrayList();
+        unPluggedVms.add(vm3);
+        vmsMap.put(Boolean.FALSE, unPluggedVms);
+        vmsMap.put(Boolean.TRUE, pluggedVms);
+        when(vmDAO.getForDisk(diskId1)).thenReturn(vmsMap);
+        parameters.setStorageServerConnection(iscsiConnection);
+        
when(storageConnDao.get(iscsiConnection.getid())).thenReturn(iscsiConnection);
+        
when(lunDAO.getAllForStorageServerConnection(iscsiConnection.getid())).thenReturn(luns);
+        List<StorageDomain> domains = new ArrayList();
+        
doReturn(domains).when(command).getStorageDomainsByConnId(iscsiConnection.getid());
+        StorageDomain domain1 = new StorageDomain();
+        domain1.setStorage(iscsiConnection.getconnection());
+        domain1.setStatus(StorageDomainStatus.Active);
+        domain1.setId(storageDomainId);
+        domains.add(domain1);
+        when(storageDomainDAO.get(storageDomainId)).thenReturn(domain1);
+        CanDoActionTestUtils.runAndAssertCanDoActionFailure(command,
+                
VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_MAINTENANCE);
     }
 
     @Test
@@ -340,11 +415,13 @@
                         NfsVersion.V4,
                         300,
                         0);
+        parameters.setStorageServerConnection(newNFSConnection);
         VDSReturnValue returnValueConnectSuccess = new VDSReturnValue();
         StoragePoolIsoMap map = new StoragePoolIsoMap();
         doReturn(map).when(command).getStoragePoolIsoMap();
         returnValueConnectSuccess.setSucceeded(true);
         StorageDomain domain = new StorageDomain();
+        domain.setStorageName("mydomain");
         StorageDomainDynamic domainDynamic = new StorageDomainDynamic();
         domain.setStorageDynamicData(domainDynamic);
         returnValueConnectSuccess.setReturnValue(domain);
@@ -352,6 +429,9 @@
         doReturn(true).when(command).connectToStorage();
         doNothing().when(storageConnDao).update(newNFSConnection);
         doNothing().when(storageDomainDynamicDao).update(domainDynamic);
+        List<StorageDomain> domains = new ArrayList();
+        domains.add(domain);
+        
doReturn(domains).when(command).getStorageDomainsByConnId(newNFSConnection.getid());
         doNothing().when(command).changeStorageDomainStatusInTransaction(map, 
StorageDomainStatus.Locked);
         doNothing().when(command).changeStorageDomainStatusInTransaction(map, 
StorageDomainStatus.Maintenance);
         doNothing().when(command).disconnectFromStorage();
@@ -367,10 +447,12 @@
                         NfsVersion.V4,
                         300,
                         0);
+        parameters.setStorageServerConnection(newNFSConnection);
         VDSReturnValue returnValueConnectSuccess = new VDSReturnValue();
         StoragePoolIsoMap map = new StoragePoolIsoMap();
         doReturn(map).when(command).getStoragePoolIsoMap();
-        doReturn(false).when(command).doDomainsUseConnection();
+        doReturn(false).when(command).doDomainsUseConnection(newNFSConnection);
+        doReturn(false).when(command).doLunsUseConnection(newNFSConnection);
         returnValueConnectSuccess.setSucceeded(true);
         doReturn(true).when(command).connectToStorage();
         doNothing().when(storageConnDao).update(newNFSConnection);
@@ -387,9 +469,10 @@
                         NfsVersion.V4,
                         300,
                         0);
+        parameters.setStorageServerConnection(newNFSConnection);
         VDSReturnValue returnValueUpdate = new VDSReturnValue();
         returnValueUpdate.setSucceeded(false);
-        doReturn(true).when(command).doDomainsUseConnection();
+        doReturn(true).when(command).doDomainsUseConnection(newNFSConnection);
         StoragePoolIsoMap map = new StoragePoolIsoMap();
         doReturn(map).when(command).getStoragePoolIsoMap();
         doReturn(returnValueUpdate).when(command).getStatsForDomain();
@@ -407,11 +490,12 @@
     @Test
     public void failUpdateConnectToStorage() {
         StorageServerConnections  newNFSConnection = createNFSConnection(
-                       
"multipass.my.domain.tlv.company.com:/export/allstorage/data2",
-                        StorageType.NFS,
-                        NfsVersion.V4,
-                        300,
-                        0);
+                "multipass.my.domain.tlv.company.com:/export/allstorage/data2",
+                StorageType.NFS,
+                NfsVersion.V4,
+                300,
+                0);
+        parameters.setStorageServerConnection(newNFSConnection);
         VDSReturnValue returnValueUpdate = new VDSReturnValue();
         returnValueUpdate.setSucceeded(true);
         StoragePoolIsoMap map = new StoragePoolIsoMap();
@@ -420,6 +504,7 @@
         doReturn(false).when(command).connectToStorage();
         doNothing().when(command).changeStorageDomainStatusInTransaction(map, 
StorageDomainStatus.Locked);
         doNothing().when(command).changeStorageDomainStatusInTransaction(map, 
StorageDomainStatus.Maintenance);
+        doReturn(new 
ArrayList<StorageDomain>()).when(command).getStorageDomainsByConnId(newNFSConnection.getid());
         command.executeCommand();
         CommandAssertUtils.checkSucceeded(command, false);
         StorageDomainDynamic domainDynamic = new StorageDomainDynamic();
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index 4ceef2d..8ad1491 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -418,7 +418,10 @@
     ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_EXIST(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_STORAGE_CONNECTION_NOT_EXIST(ErrorType.BAD_PARAMETERS),
     
ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS(ErrorType.BAD_PARAMETERS),
-    
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE(ErrorType.BAD_PARAMETERS),
+    
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE(ErrorType.NOT_SUPPORTED),
+    
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_DOMAINS_MAINTENANCE(ErrorType.NOT_SUPPORTED),
+    
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_MAINTENANCE(ErrorType.NOT_SUPPORTED),
+    
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS(ErrorType.CONFLICT),
     
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_DISKS(ErrorType.CONFLICT),
     
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS_AND_DISKS(ErrorType.CONFLICT),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 7fdd060..5658100 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -349,7 +349,10 @@
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_EMPTY=Cannot ${action} ${type}. 
Storage connection id is empty.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY=Cannot ${action} ${type}. 
Storage connection id is not empty.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS=Cannot ${action} ${type}. 
Storage connection already exists.
-ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix or local data domains in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE=Cannot
 ${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix, local or iSCSI data domains.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_DOMAINS_MAINTENANCE=Cannot
 ${action} ${type}. The data domains ${domainNames} should be in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_MAINTENANCE=Cannot
 ${action} ${type}. The data domains ${domainNames} should be in maintenance, 
and VMs ${vmNames} should be down..
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS=Cannot
 ${action} ${type}. VMs ${vmNames} should be down.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS=Cannot 
${action} ${type}. Storage connection parameters are used by the following 
storage domains : ${domainNames}.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS_AND_DISKS=Cannot
 ${action} ${type}. Storage connection parameters are used by the following 
storage domains : ${domainNames} and disks: ${diskNames}.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_DISKS=Cannot 
${action} ${type}. Storage connection parameters are used by the following 
disks : ${diskNames}.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 97f40b5..269c1e7 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -982,8 +982,17 @@
     @DefaultStringValue("Cannot ${action} ${type}. Storage connection already 
exists.")
     String ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS();
 
-    @DefaultStringValue("Cannot ${action} ${type}. Storage connection 
parameters can be edited only for NFS, Posix or local data domains in 
maintenance.")
-    String  
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE();
+    @DefaultStringValue("Cannot ${action} ${type}. Storage connection 
parameters can be edited only for NFS, Posix, local or iSCSI data domains.")
+    String 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE();
+
+    @DefaultStringValue("Cannot ${action} ${type}. The data domains 
${domainNames} should be in maintenance,")
+    String 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_DOMAINS_MAINTENANCE();
+
+    @DefaultStringValue("Cannot ${action} ${type}. VMs ${vmNames} should be 
down.")
+    String 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS();
+
+    @DefaultStringValue("Cannot ${action} ${type}. The data domains 
${domainNames} should be in maintenance, and VMs ${vmNames} should be down.")
+    String 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_MAINTENANCE();
 
     @DefaultStringValue("Cannot ${action} ${type}. Storage connection 
parameters are used by the following storage domains : ${domainNames}.")
     String 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS();
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index bfec17b..5ff8aae 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -345,7 +345,10 @@
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_EMPTY=Cannot ${action} ${type}. 
Storage connection id is empty.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY=Cannot ${action} ${type}. 
Storage connection id is not empty.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS=Cannot ${action} ${type}. 
Storage connection already exists.
-ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix or local data domains in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE=Cannot
 ${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix, local or iSCSI data domains.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_DOMAINS_MAINTENANCE=Cannot
 ${action} ${type}. The data domains ${domainNames} should be in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_MAINTENANCE=Cannot
 ${action} ${type}. The data domains ${domainNames} should be in maintenance, 
and VMs ${vmNames} should be down.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS=Cannot
 ${action} ${type}. VMs ${vmNames} should be down.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS=Cannot 
${action} ${type}. Storage connection parameters are used by the following 
storage domains : ${domainNames}.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS_AND_DISKS=Cannot
 ${action} ${type}. Storage connection parameters are used by the following 
storage domains : ${domainNames} and disks: ${diskNames}.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_DISKS=Cannot 
${action} ${type}. Storage connection parameters are used by the following 
disks : ${diskNames}.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 6307cc3..7de7f3a 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -354,7 +354,10 @@
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_EMPTY=Cannot ${action} ${type}. 
Storage connection id is empty.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ID_NOT_EMPTY=Cannot ${action} ${type}. 
Storage connection id is not empty.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS=Cannot ${action} ${type}. 
Storage connection already exists.
-ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE=Cannot 
${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix or local data domains in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_STORAGE_TYPE=Cannot
 ${action} ${type}. Storage connection parameters can be edited only for NFS, 
Posix, local or iSCSI data domains.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_DOMAINS_MAINTENANCE=Cannot
 ${action} ${type}. The data domains ${domainNames} should be in maintenance.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS=Cannot
 ${action} ${type}. VMs ${vmNames} should be down.
+ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_MAINTENANCE=Cannot
 ${action} ${type}. The data domains ${domainNames} should be in maintenance, 
and VMs ${vmNames} should be down.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS=Cannot 
${action} ${type}. Storage connection parameters are used by the following 
storage domains : ${domainNames}.
 
ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_STORAGE_DOMAINS_AND_DISKS=Cannot
 ${action} ${type}. Storage connection parameters are used by the following 
storage domains : ${domainNames} and disks: ${diskNames}.
 ACTION_TYPE_FAILED_STORAGE_CONNECTION_BELONGS_TO_SEVERAL_DISKS=Cannot 
${action} ${type}. Storage connection parameters are used by the following 
disks : ${diskNames}.


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

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

Reply via email to