Hello Sergey Gotliv,

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

    http://gerrit.ovirt.org/28605

to review the following change.

Change subject: engine: Improve iSCSI Bond CDA validation
......................................................................

engine: Improve iSCSI Bond CDA validation

Add following CDA validations due to adding iSCSI Multipathing support
through the REST API:

1. Validate that datacenter version is at least 3.4.
2. Validate that added logical networks belong to the same datacenter as
the specified iSCSI Bond and that none of them is "required" network.
3. Validate that added storage targets are indeed iSCSI targets, they
are "connectable" and they belong to the storage domain from the same
datacenter as the specified iSCSI Bond.

Change-Id: I1d0ac7e6af6cb87b500740d679af2f13e63dbeb5
Bug-Url: https://bugzilla.redhat.com/1108174
Signed-off-by: Sergey Gotliv <[email protected]>
Signed-off-by: Tal Nisan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddIscsiBondCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/IscsiBondValidator.java
A 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/IscsiBondValidatorTest.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, 433 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/05/28605/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddIscsiBondCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddIscsiBondCommand.java
index 8b7da3d..2e26558 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddIscsiBondCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/AddIscsiBondCommand.java
@@ -5,6 +5,7 @@
 import org.ovirt.engine.core.bll.NonTransactiveCommandAttribute;
 import org.ovirt.engine.core.bll.validator.IscsiBondValidator;
 import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.FeatureSupported;
 import org.ovirt.engine.core.common.action.AddIscsiBondParameters;
 import org.ovirt.engine.core.common.businessentities.IscsiBond;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
@@ -26,8 +27,14 @@
 
     @Override
     protected boolean canDoAction() {
+        if 
(!FeatureSupported.isIscsiMultipathingSupported(getStoragePool().getcompatibility_version()))
 {
+            return failCanDoAction(VdcBllMessages.ISCSI_BOND_NOT_SUPPORTED);
+        }
+
         IscsiBondValidator validator = new IscsiBondValidator();
-        return 
validate(validator.iscsiBondWithTheSameNameExistInDataCenter(getIscsiBond()));
+        return 
validate(validator.iscsiBondWithTheSameNameExistInDataCenter(getIscsiBond())) &&
+                
validate(validator.validateAddedLogicalNetworks(getIscsiBond())) &&
+                
validate(validator.validateAddedStorageConnections(getIscsiBond()));
     }
 
     @Override
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
index e1e65cb..a1089b1 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/EditIscsiBondCommand.java
@@ -45,7 +45,8 @@
             return false;
         }
 
-        return true;
+        return validate(validator.validateAddedLogicalNetworks(getIscsiBond(), 
getExistingIscsiBond())) &&
+                
validate(validator.validateAddedStorageConnections(getIscsiBond(), 
getExistingIscsiBond()));
     }
 
     @Override
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/IscsiBondValidator.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/IscsiBondValidator.java
index 279387e..f444ceb 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/IscsiBondValidator.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/IscsiBondValidator.java
@@ -1,16 +1,28 @@
 package org.ovirt.engine.core.bll.validator;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Set;
 
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.ValidationResult;
 import org.ovirt.engine.core.common.businessentities.IscsiBond;
+import org.ovirt.engine.core.common.businessentities.StorageServerConnections;
+import org.ovirt.engine.core.common.businessentities.StorageType;
+import org.ovirt.engine.core.common.businessentities.network.Network;
+import org.ovirt.engine.core.common.businessentities.network.NetworkCluster;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 
 public class IscsiBondValidator {
 
     public ValidationResult 
iscsiBondWithTheSameNameExistInDataCenter(IscsiBond iscsiBond) {
-        List<IscsiBond> iscsiBonds = 
DbFacade.getInstance().getIscsiBondDao().getAllByStoragePoolId(iscsiBond.getStoragePoolId());
+        List<IscsiBond> iscsiBonds = 
getDBFacade().getIscsiBondDao().getAllByStoragePoolId(iscsiBond.getStoragePoolId());
 
         for (IscsiBond bond : iscsiBonds) {
             if (bond.getName().equals(iscsiBond.getName()) && 
!bond.getId().equals(iscsiBond.getId())) {
@@ -25,4 +37,131 @@
         return (iscsiBond == null) ?
                 new ValidationResult(VdcBllMessages.ISCSI_BOND_NOT_EXIST) : 
ValidationResult.VALID;
     }
+
+    public ValidationResult validateAddedLogicalNetworks(IscsiBond iscsiBond) {
+        return validateAddedLogicalNetworks(iscsiBond.getNetworkIds(), 
iscsiBond.getStoragePoolId());
+    }
+
+    public ValidationResult validateAddedLogicalNetworks(IscsiBond after, 
IscsiBond before) {
+        Collection<Guid> addedLogicalNetworks = 
CollectionUtils.subtract(after.getNetworkIds(), before.getNetworkIds());
+        return validateAddedLogicalNetworks(addedLogicalNetworks, 
after.getStoragePoolId());
+    }
+
+    public ValidationResult validateAddedStorageConnections(IscsiBond 
iscsiBond) {
+        return 
validateAddedStorageConnections(iscsiBond.getStorageConnectionIds(), 
iscsiBond.getStoragePoolId());
+    }
+
+    public ValidationResult validateAddedStorageConnections(IscsiBond after, 
IscsiBond before) {
+        Collection<String> addedStorageConnections =
+                CollectionUtils.subtract(after.getStorageConnectionIds(), 
before.getStorageConnectionIds());
+        return validateAddedStorageConnections(addedStorageConnections, 
after.getStoragePoolId());
+    }
+
+    private ValidationResult validateAddedLogicalNetworks(Collection<Guid> 
addedLogicalNetworks, Guid dataCenterId) {
+        if (!addedLogicalNetworks.isEmpty()) {
+            List<Guid> existingNetworks = 
getDataCenterLogicalNetworks(dataCenterId);
+            Collection<Guid> missingNetworks = 
CollectionUtils.subtract(addedLogicalNetworks, existingNetworks);
+
+            if (!missingNetworks.isEmpty()) {
+                return new 
ValidationResult(VdcBllMessages.NETWORKS_DONT_EXIST_IN_DATA_CENTER,
+                        String.format("$networkIds %s", 
StringUtils.join(missingNetworks, ",")),
+                        String.format("$dataCenterId %s", dataCenterId));
+            }
+
+            Collection<Guid> requiredNetworks = 
getRequiredNetworks(addedLogicalNetworks);
+            if (!requiredNetworks.isEmpty()) {
+                return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED);
+            }
+        }
+
+        return ValidationResult.VALID;
+    }
+
+    private List<Guid> getDataCenterLogicalNetworks(Guid dataCenterId) {
+        List<Guid> res = new LinkedList<>();
+
+        List<Network> dcLogicalNetworks = 
getDBFacade().getNetworkDao().getAllForDataCenter(dataCenterId);
+        for (Network network : dcLogicalNetworks) {
+            res.add(network.getId());
+        }
+
+        return res;
+    }
+
+    private List<Guid> getRequiredNetworks(Collection<Guid> 
addedLogicalNetworks) {
+        List<Guid> res = new ArrayList<>();
+
+        for (Guid networkId : addedLogicalNetworks) {
+            if (isRequiredNetwork(networkId)) {
+                res.add(networkId);
+            }
+        }
+
+        return res;
+    }
+
+    private boolean isRequiredNetwork(Guid networkId) {
+        List<NetworkCluster> clusters = 
getDBFacade().getNetworkClusterDao().getAllForNetwork(networkId);
+
+        for (NetworkCluster cluster : clusters) {
+            if (cluster.isRequired()) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private List<Guid> getNetworksMissingInDataCenter(Collection<Guid> 
networks, Guid dataCenterId) {
+        Set<Guid> existingNetworkIds = new HashSet<>();
+        List<Guid> res = new LinkedList<>();
+
+        List<Network> dcLogicalNetworks = 
getDBFacade().getNetworkDao().getAllForDataCenter(dataCenterId);
+        for (Network network : dcLogicalNetworks) {
+            existingNetworkIds.add(network.getId());
+        }
+
+        for (Guid id : networks) {
+            if (!existingNetworkIds.contains(id)) {
+                res.add(id);
+            }
+        }
+
+        return res;
+    }
+
+    private ValidationResult 
validateAddedStorageConnections(Collection<String> addedStorageConnections, 
Guid dataCenterId) {
+        if (!addedStorageConnections.isEmpty()) {
+            List<String> connectionsNotInDataCenter = 
getStorageConnectionsMissingInDataCenter(addedStorageConnections, dataCenterId);
+            if (!connectionsNotInDataCenter.isEmpty()) {
+                return new 
ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND,
+                        String.format("$connectionIds %s", 
StringUtils.join(connectionsNotInDataCenter, ",")));
+            }
+        }
+
+        return ValidationResult.VALID;
+    }
+
+    private List<String> 
getStorageConnectionsMissingInDataCenter(Collection<String> storageConnections, 
Guid dataCenterId) {
+        Set<String> existingConnIds = new HashSet<>();
+        List<String> res = new LinkedList<>();
+
+        List<StorageServerConnections> dcStorageConnections =
+                
getDBFacade().getStorageServerConnectionDao().getConnectableStorageConnectionsByStorageType(dataCenterId,
 StorageType.ISCSI);
+        for (StorageServerConnections conn : dcStorageConnections) {
+            existingConnIds.add(conn.getid());
+        }
+
+        for (String id : storageConnections) {
+            if (!existingConnIds.contains(id)) {
+                res.add(id);
+            }
+        }
+
+        return res;
+    }
+
+    protected DbFacade getDBFacade() {
+        return DbFacade.getInstance();
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/IscsiBondValidatorTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/IscsiBondValidatorTest.java
new file mode 100644
index 0000000..4265e9a
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/IscsiBondValidatorTest.java
@@ -0,0 +1,236 @@
+package org.ovirt.engine.core.bll.validator;
+
+import static org.junit.Assert.assertEquals;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.ovirt.engine.core.bll.ValidationResult;
+import org.ovirt.engine.core.common.businessentities.IscsiBond;
+import org.ovirt.engine.core.common.businessentities.StorageServerConnections;
+import org.ovirt.engine.core.common.businessentities.StorageType;
+import org.ovirt.engine.core.common.businessentities.network.Network;
+import org.ovirt.engine.core.common.businessentities.network.NetworkCluster;
+import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+import org.ovirt.engine.core.dao.IscsiBondDao;
+import org.ovirt.engine.core.dao.StorageServerConnectionDAO;
+import org.ovirt.engine.core.dao.network.NetworkClusterDao;
+import org.ovirt.engine.core.dao.network.NetworkDao;
+
+@RunWith(MockitoJUnitRunner.class)
+public class IscsiBondValidatorTest {
+    @Mock
+    private DbFacade dbFacade;
+    @Mock
+    private IscsiBondDao iscsiBondDao;
+    @Mock
+    private NetworkDao networkDao;
+    @Mock
+    private NetworkClusterDao networkClusterDao;
+    @Mock
+    private StorageServerConnectionDAO storageServerConnectionDAO;
+
+    private IscsiBondValidator validator;
+
+    @Before
+    public void setUp() {
+        validator = Mockito.spy(new IscsiBondValidator());
+
+        doReturn(dbFacade).when(validator).getDBFacade();
+        doReturn(iscsiBondDao).when(dbFacade).getIscsiBondDao();
+        doReturn(networkDao).when(dbFacade).getNetworkDao();
+        doReturn(networkClusterDao).when(dbFacade).getNetworkClusterDao();
+        
doReturn(storageServerConnectionDAO).when(dbFacade).getStorageServerConnectionDao();
+    }
+
+    @Test
+    public void iscsiBondExists() {
+        assertEquals(ValidationResult.VALID, validator.isIscsiBondExist(new 
IscsiBond()));
+    }
+
+    @Test
+    public void iscsiBondDoesNotExist() {
+        ValidationResult res = validator.isIscsiBondExist(null);
+        assertEquals(VdcBllMessages.ISCSI_BOND_NOT_EXIST, res.getMessage());
+    }
+
+    @Test
+    public void iscsiBondWithTheSameNameExistsInDataCenter() {
+        List<IscsiBond> iscsiBonds = new ArrayList<>();
+        Guid dataCenterId = Guid.newGuid();
+
+        iscsiBonds.add(createIscsiBond("First", dataCenterId));
+        iscsiBonds.add(createIscsiBond("Second", dataCenterId));
+        
doReturn(iscsiBonds).when(iscsiBondDao).getAllByStoragePoolId(any(Guid.class));
+
+        ValidationResult res = 
validator.iscsiBondWithTheSameNameExistInDataCenter(createIscsiBond("Second", 
dataCenterId));
+        
assertEquals(VdcBllMessages.ISCSI_BOND_WITH_SAME_NAME_EXIST_IN_DATA_CENTER, 
res.getMessage());
+    }
+
+    @Test
+    public void iscsiBondWithTheSameNameDoesNotExistInDataCenter() {
+        List<IscsiBond> iscsiBonds = new ArrayList<>();
+        Guid dataCenterId = Guid.newGuid();
+
+        iscsiBonds.add(createIscsiBond("First", dataCenterId));
+        iscsiBonds.add(createIscsiBond("Second", dataCenterId));
+        
doReturn(iscsiBonds).when(iscsiBondDao).getAllByStoragePoolId(any(Guid.class));
+
+        assertEquals(ValidationResult.VALID,
+                
validator.iscsiBondWithTheSameNameExistInDataCenter(createIscsiBond("Third", 
dataCenterId)));
+    }
+
+    @Test
+    public void addedLogicalNetworkBelongToAnotherDatacenter() {
+        IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
+
+        List<Network> networks = new ArrayList<>();
+        networks.add(createNetwork(iscsiBond.getStoragePoolId()));
+        
doReturn(networks).when(networkDao).getAllForDataCenter(iscsiBond.getStoragePoolId());
+
+        iscsiBond.getNetworkIds().add(networks.get(0).getId());
+        iscsiBond.getNetworkIds().add(Guid.newGuid());
+
+        ValidationResult res = 
validator.validateAddedLogicalNetworks(iscsiBond);
+
+        assertEquals(VdcBllMessages.NETWORKS_DONT_EXIST_IN_DATA_CENTER, 
res.getMessage());
+        assertEquals(2, res.getVariableReplacements().size());
+        assertEquals("$networkIds " + 
iscsiBond.getNetworkIds().get(1).toString(), 
res.getVariableReplacements().get(0));
+        assertEquals("$dataCenterId " + 
iscsiBond.getStoragePoolId().toString(), res.getVariableReplacements().get(1));
+    }
+
+    @Test
+    public void addedLogicalNetworkBelongToAnotherDatacenter2() {
+        Guid dataCenterId = Guid.newGuid();
+        IscsiBond before = createIscsiBond("Before", dataCenterId);
+        IscsiBond after = createIscsiBond("After", dataCenterId);
+
+        List<Network> networks = new ArrayList<>();
+        networks.add(createNetwork(dataCenterId));
+        doReturn(networks).when(networkDao).getAllForDataCenter(dataCenterId);
+
+        before.getNetworkIds().add(networks.get(0).getId());
+        after.getNetworkIds().add(networks.get(0).getId());
+        after.getNetworkIds().add(Guid.newGuid());
+
+        ValidationResult res = validator.validateAddedLogicalNetworks(after, 
before);
+
+        assertEquals(VdcBllMessages.NETWORKS_DONT_EXIST_IN_DATA_CENTER, 
res.getMessage());
+        assertEquals(2, res.getVariableReplacements().size());
+        assertEquals("$networkIds " + after.getNetworkIds().get(1).toString(), 
res.getVariableReplacements().get(0));
+        assertEquals("$dataCenterId " + after.getStoragePoolId().toString(), 
res.getVariableReplacements().get(1));
+    }
+
+    @Test
+    public void addedLogicalNetworkBelongToSameDatacenter() {
+        IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
+
+        List<Network> networks = new ArrayList<>();
+        networks.add(createNetwork(iscsiBond.getStoragePoolId()));
+        networks.add(createNetwork(iscsiBond.getStoragePoolId()));
+        
doReturn(networks).when(networkDao).getAllForDataCenter(iscsiBond.getStoragePoolId());
+
+        for (Network network : networks) {
+            iscsiBond.getNetworkIds().add(network.getId());
+        }
+
+        List<NetworkCluster> networkClusters = new ArrayList<>();
+        networkClusters.add(createNetworkCluster(false));
+        
doReturn(networkClusters).when(networkClusterDao).getAllForNetwork(any(Guid.class));
+
+        assertEquals(ValidationResult.VALID, 
validator.validateAddedLogicalNetworks(iscsiBond));
+    }
+
+    @Test
+    public void addedRequiredLogicalNetworks() {
+        IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
+
+        List<Network> networks = new ArrayList<>();
+        networks.add(createNetwork(iscsiBond.getStoragePoolId()));
+        networks.add(createNetwork(iscsiBond.getStoragePoolId()));
+        
doReturn(networks).when(networkDao).getAllForDataCenter(iscsiBond.getStoragePoolId());
+
+        for (Network network : networks) {
+            iscsiBond.getNetworkIds().add(network.getId());
+        }
+
+        List<NetworkCluster> networkClusters = new ArrayList<>();
+        networkClusters.add(createNetworkCluster(true));
+        
doReturn(networkClusters).when(networkClusterDao).getAllForNetwork(any(Guid.class));
+
+        ValidationResult res = 
validator.validateAddedLogicalNetworks(iscsiBond);
+
+        
assertEquals(VdcBllMessages.ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED,
 res.getMessage());
+    }
+
+    @Test
+    public void successfullyAddedStorageConnections() {
+        IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
+
+        List<StorageServerConnections> conns = new ArrayList<>();
+        conns.add(createStorageConnection());
+        conns.add(createStorageConnection());
+        
doReturn(conns).when(storageServerConnectionDAO).getConnectableStorageConnectionsByStorageType(iscsiBond.getStoragePoolId(),
 StorageType.ISCSI);
+
+        iscsiBond.getStorageConnectionIds().add(conns.get(0).getid());
+        iscsiBond.getStorageConnectionIds().add(conns.get(1).getid());
+
+        assertEquals(ValidationResult.VALID, 
validator.validateAddedStorageConnections(iscsiBond));
+    }
+
+    @Test
+    public void someAddedStorageConnectionsAreNotAnIscsi() {
+        IscsiBond iscsiBond = createIscsiBond("First", Guid.newGuid());
+
+        List<StorageServerConnections> conns = new ArrayList<>();
+        conns.add(createStorageConnection());
+        
doReturn(conns).when(storageServerConnectionDAO).getConnectableStorageConnectionsByStorageType(iscsiBond.getStoragePoolId(),
 StorageType.ISCSI);
+
+        iscsiBond.getStorageConnectionIds().add(conns.get(0).getid());
+        iscsiBond.getStorageConnectionIds().add(Guid.newGuid().toString());
+
+        ValidationResult res = 
validator.validateAddedStorageConnections(iscsiBond);
+
+        
assertEquals(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND,
 res.getMessage());
+        assertEquals(1, res.getVariableReplacements().size());
+        assertEquals("$connectionIds " + 
iscsiBond.getStorageConnectionIds().get(1).toString(), 
res.getVariableReplacements().get(0));
+    }
+
+    private IscsiBond createIscsiBond(String name, Guid dataCenterId) {
+        IscsiBond iscsiBond = new IscsiBond();
+        iscsiBond.setId(Guid.newGuid());
+        iscsiBond.setStoragePoolId(dataCenterId);
+        iscsiBond.setName(name);
+        return iscsiBond;
+    }
+
+    private Network createNetwork(Guid dataCenterId) {
+        Network network = new Network();
+        network.setId(Guid.newGuid());
+        network.setDataCenterId(dataCenterId);
+        return network;
+    }
+
+    private NetworkCluster createNetworkCluster(boolean isRequired) {
+        NetworkCluster networkCluster = new NetworkCluster();
+        networkCluster.setRequired(isRequired);
+        return networkCluster;
+    }
+
+    private StorageServerConnections createStorageConnection() {
+        StorageServerConnections conn = new StorageServerConnections();
+        conn.setid(Guid.newGuid().toString());
+        return conn;
+    }
+}
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 fc42dc8..e910efc 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
@@ -495,6 +495,7 @@
     NETWORKS_ALREADY_ATTACHED_TO_IFACES(ErrorType.CONFLICT),
     NETWORK_INTERFACES_DONT_EXIST(ErrorType.BAD_PARAMETERS),
     NETWORKS_DONT_EXIST_IN_CLUSTER(ErrorType.CONFLICT),
+    NETWORKS_DONT_EXIST_IN_DATA_CENTER(ErrorType.CONFLICT),
     NETWORK_BONDS_INVALID_SLAVE_COUNT(ErrorType.BAD_PARAMETERS),
     NETWORK_INTERFACES_NOT_EXCLUSIVELY_USED_BY_NETWORK(ErrorType.CONFLICT),
     NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS(ErrorType.CONFLICT),
@@ -528,6 +529,7 @@
     ACTION_TYPE_FAILED_EXTERNAL_NETWORK_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_DISPLAY(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REQUIRED(ErrorType.NOT_SUPPORTED),
+    
ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED(ErrorType.NOT_SUPPORTED),
     ACTION_TYPE_FAILED_PROVIDER_NETWORKS_USED(ErrorType.CONFLICT),
     
ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED(ErrorType.NOT_SUPPORTED),
     
ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED(ErrorType.NOT_SUPPORTED),
@@ -551,6 +553,7 @@
     
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),
     
ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_CHANGE_STORAGE_TYPE(ErrorType.BAD_PARAMETERS),
+    
ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_STORAGE_DOMAIN_STATUS_ILLEGAL2(ErrorType.CONFLICT),
     
STORAGE_POOL_REINITIALIZE_WITH_MORE_THAN_ONE_DATA_DOMAIN(ErrorType.CONFLICT),
@@ -952,6 +955,7 @@
 
     // Iscsi bonds
     ISCSI_BOND_WITH_SAME_NAME_EXIST_IN_DATA_CENTER(ErrorType.CONFLICT),
+    ISCSI_BOND_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED),
     ISCSI_BOND_NOT_EXIST(ErrorType.BAD_PARAMETERS);
 
     private ErrorType messageType;
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 c53cf6e..a1304d5 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -564,6 +564,7 @@
 NETWORK_INTERFACES_DONT_EXIST=Cannot ${action} ${type}. The following Network 
Interfaces don't exist on the Host: ${NETWORK_INTERFACES_DONT_EXIST_LIST}.
 NETWORKS_DONT_EXIST_IN_CLUSTER=Cannot ${action} ${type}. The following Logical 
Networks don't exist in the Host's Cluster: 
${NETWORKS_DONT_EXIST_IN_CLUSTER_LIST}.
 NETWORK_BONDS_INVALID_SLAVE_COUNT=Cannot ${action} ${type}. The following 
Bonds consist of less than two Network Interfaces: 
${NETWORK_BONDS_INVALID_SLAVE_COUNT_LIST}.
+NETWORKS_DONT_EXIST_IN_DATA_CENTER=Cannot ${action} ${type}. The following 
Logical Networks: ${networkIds} do not exist in the Data Center: 
${dataCenterId}.
 NETWORK_INTERFACES_NOT_EXCLUSIVELY_USED_BY_NETWORK=Cannot ${action} ${type}. 
The following Network Interfaces can have only a single VM Logical Network, or 
at most one non-VM Logical Network and/or several VLAN Logical Networks: 
${NETWORK_INTERFACES_NOT_EXCLUSIVELY_USED_BY_NETWORK_LIST}.
 NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS=Cannot ${action} ${type}. The 
following VMs are actively using the Logical Network: 
${NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS_LIST}. Please stop the VMs and try 
again.
 NON_VM_NETWORK_CANNOT_SUPPORT_STP=Cannot ${action} ${type}. STP can only be 
enabled on VM Networks.
@@ -1163,6 +1164,13 @@
 
 ISCSI_BOND_NOT_EXIST=Cannot ${action} ${type}. The specified iSCSI bond 
doesn't exist.
 ISCSI_BOND_WITH_SAME_NAME_EXIST_IN_DATA_CENTER=Cannot ${action} ${type}. iSCSI 
bond with the same name already exists in the Data Center.
+ISCSI_BOND_NOT_SUPPORTED=Cannot ${action} ${type}. iSCSI Bond is only 
supported on Data Center compatibility versions 3.4 and higher.
+ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND=Cannot 
${action} ${type}. The following storage connections ${connectionIds} cannot be 
added to the specified iSCSI bond. \n\
+Possible reasons:\n\
+    - They are not of type iSCSI.\n\
+    - Their status is not one of the following: Unknown, Active. Inactive.\n\
+    - They do not belong to the same Data Center as the specified iSCSI bond.
+ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} 
${type}. Required network cannot be a part of an iSCSI bond.
 
 ACTION_TYPE_FAILED_IDE_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR=Cannot 
${action} ${type}. An IDE disk can't be read-only.
 
ACTION_TYPE_FAILED_VIRT_IO_SCSI_INTERFACE_FOR_LUN_DISKS_DOES_NOT_SUPPORT_READ_ONLY_ATTR=Cannot
 ${action} ${type}. A VirtIO-SCSI LUN disk can't be read-only.
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 61e7a88..b7a8f15 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
@@ -3105,9 +3105,28 @@
     @DefaultStringValue("Cannot ${action} ${type}. The specified iSCSI bond 
doesn't exist.")
     String ISCSI_BOND_NOT_EXIST();
 
+    @DefaultStringValue("Cannot ${action} ${type}. iSCSI Bond is only 
supported on Data Center compatibility versions 3.4 and higher.")
+    String ISCSI_BOND_NOT_SUPPORTED();
+
     @DefaultStringValue("Cannot ${action} ${type}. An IDE disk can't be 
read-only.")
     String ACTION_TYPE_FAILED_IDE_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR();
 
     @DefaultStringValue("Cannot ${action} ${type}. A VirtIO-SCSI LUN disk 
can't be read-only.")
     String 
ACTION_TYPE_FAILED_VIRT_IO_SCSI_INTERFACE_FOR_LUN_DISKS_DOES_NOT_SUPPORT_READ_ONLY_ATTR();
+    
+    @DefaultStringValue("Cannot ${action} ${type}. Custom serial number must 
be non-empty when \"Custom\" serial number policy is specified.")
+    String ACTION_TYPE_FAILED_INVALID_SERIAL_NUMBER();
+
+    @DefaultStringValue("Cannot ${action} ${type}. The following storage 
connections ${connectionIds} cannot be added to the specified iSCSI bond.\n" +
+            "Possible reasons:\n" +
+            "- They are not of type iSCSI.\n" +
+            "- Their status is not one of the following: Unknown, Active. 
Inactive.\n" +
+            "- They do not belong to the same Data Center as the specified 
iSCSI bond.\n")
+    String 
ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND();
+
+    @DefaultStringValue("Cannot ${action} ${type}. Required network cannot be 
a part of an iSCSI bond.")
+    String ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED();
+
+    @DefaultStringValue("Cannot ${action} ${type}. ${interface} disks can't be 
read-only.")
+    String ACTION_TYPE_FAILED_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR();
 }
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 0e8dcde..1ab63d6 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
@@ -544,6 +544,7 @@
 NETWORK_INTERFACES_DONT_EXIST=Cannot ${action} ${type}. VM network interface 
profiles cannot be added to a non-VM network. Please make sure the network is a 
VM network.
 NETWORKS_DONT_EXIST_IN_CLUSTER=Cannot ${action} ${type}. The following Logical 
Networks don't exist in the Host's Cluster: 
${NETWORKS_DONT_EXIST_IN_CLUSTER_LIST}.
 NETWORK_BONDS_INVALID_SLAVE_COUNT=Cannot ${action} ${type}. The following 
Bonds consist of less than two Network Interfaces: 
${NETWORK_BONDS_INVALID_SLAVE_COUNT_LIST}.
+NETWORKS_DONT_EXIST_IN_DATA_CENTER=Cannot ${action} ${type}. The following 
Logical Networks: ${networkIds} do not exist in the Data Center: 
${dataCenterId}.
 NETWORK_INTERFACES_NOT_EXCLUSIVELY_USED_BY_NETWORK=Cannot ${action} ${type}. 
The following Network Interfaces can have only a single VM Logical Network, or 
at most one non-VM Logical Network and/or several VLAN Logical Networks: 
${NETWORK_INTERFACES_NOT_EXCLUSIVELY_USED_BY_NETWORK_LIST}.
 NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS=Cannot ${action} ${type}. The 
following VMs are actively using the Logical Network: 
${NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS_LIST}. Please stop the VMs and try 
again.
 NON_VM_NETWORK_CANNOT_SUPPORT_STP=Cannot ${action} ${type}. STP can only be 
enabled on VM Networks.
@@ -995,6 +996,13 @@
 
 ISCSI_BOND_NOT_EXIST=Cannot ${action} ${type}. The specified iSCSI bond 
doesn't exist.
 ISCSI_BOND_WITH_SAME_NAME_EXIST_IN_DATA_CENTER=Cannot ${action} ${type}. iSCSI 
bond with the same name already exists in the Data Center.
+ISCSI_BOND_NOT_SUPPORTED=Cannot ${action} ${type}. iSCSI Bond is only 
supported on Data Center compatibility versions 3.4 and higher.
+ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND=Cannot 
${action} ${type}. The following storage connections ${connectionIds} cannot be 
added to the specified iSCSI bond. \n\
+Possible reasons:\n\
+    - They are not of type iSCSI.\n\
+    - Their status is not one of the following: Unknown, Active. Inactive.\n\
+    - They do not belong to the same Data Center as the specified iSCSI bond.
+ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} 
${type}. Required network cannot be a part of an iSCSI bond.
 
 ACTION_TYPE_FAILED_IDE_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR=Cannot 
${action} ${type}. An IDE disk can't be read-only.
 
ACTION_TYPE_FAILED_VIRT_IO_SCSI_INTERFACE_FOR_LUN_DISKS_DOES_NOT_SUPPORT_READ_ONLY_ATTR=Cannot
 ${action} ${type}. A VirtIO-SCSI LUN disk can't be read-only.
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 c0d65ce..4cedaaf 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
@@ -568,6 +568,7 @@
 NETWORK_INTERFACES_DONT_EXIST=Cannot ${action} ${type}. The following Network 
Interfaces don't exist on the Host: ${NETWORK_INTERFACES_DONT_EXIST_LIST}.
 NETWORKS_DONT_EXIST_IN_CLUSTER=Cannot ${action} ${type}. The following Logical 
Networks don't exist in the Host's Cluster: 
${NETWORKS_DONT_EXIST_IN_CLUSTER_LIST}.
 NETWORK_BONDS_INVALID_SLAVE_COUNT=Cannot ${action} ${type}. The following 
Bonds consist of less than two Network Interfaces: 
${NETWORK_BONDS_INVALID_SLAVE_COUNT_LIST}.
+NETWORKS_DONT_EXIST_IN_DATA_CENTER=Cannot ${action} ${type}. The following 
Logical Networks: ${networkIds} do not exist in the Data Center: 
${dataCenterId}.
 NETWORK_INTERFACES_NOT_EXCLUSIVELY_USED_BY_NETWORK=Cannot ${action} ${type}. 
The following Network Interfaces can have only a single VM Logical Network, or 
at most one non-VM Logical Network and/or several VLAN Logical Networks: 
${NETWORK_INTERFACES_NOT_EXCLUSIVELY_USED_BY_NETWORK_LIST}.
 NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS=Cannot ${action} ${type}. The 
following VMs are actively using the Logical Network: 
${NETWORK_CANNOT_DETACH_NETWORK_USED_BY_VMS_LIST}. Please stop the VMs and try 
again.
 NON_VM_NETWORK_CANNOT_SUPPORT_STP=Cannot ${action} ${type}. STP can only be 
enabled on VM Networks.
@@ -1135,6 +1136,13 @@
 
 ISCSI_BOND_NOT_EXIST=Cannot ${action} ${type}. The specified iSCSI bond 
doesn't exist.
 ISCSI_BOND_WITH_SAME_NAME_EXIST_IN_DATA_CENTER=Cannot ${action} ${type}. iSCSI 
bond with the same name already exists in the Data Center.
+ISCSI_BOND_NOT_SUPPORTED=Cannot ${action} ${type}. iSCSI Bond is only 
supported on Data Center compatibility versions 3.4 and higher.
+ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND=Cannot 
${action} ${type}. The following storage connections ${connectionIds} cannot be 
added to the specified iSCSI bond. \n\
+Possible reasons:\n\
+    - They are not of type iSCSI.\n\
+    - Their status is not one of the following: Unknown, Active. Inactive.\n\
+    - They do not belong to the same Data Center as the specified iSCSI bond.
+ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED=Cannot ${action} 
${type}. Required network cannot be a part of an iSCSI bond.
 
 ACTION_TYPE_FAILED_IDE_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR=Cannot 
${action} ${type}. An IDE disk can't be read-only.
 
ACTION_TYPE_FAILED_VIRT_IO_SCSI_INTERFACE_FOR_LUN_DISKS_DOES_NOT_SUPPORT_READ_ONLY_ATTR=Cannot
 ${action} ${type}. A VirtIO-SCSI LUN disk can't be read-only.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d0ac7e6af6cb87b500740d679af2f13e63dbeb5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Tal Nisan <[email protected]>
Gerrit-Reviewer: Sergey Gotliv <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to