Search in sources :

Example 1 with IscsiBond

use of org.ovirt.engine.core.common.businessentities.IscsiBond in project ovirt-engine by oVirt.

the class IscsiBondValidatorTest method successfullyAddedStorageConnections.

@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));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) Test(org.junit.Test)

Example 2 with IscsiBond

use of org.ovirt.engine.core.common.businessentities.IscsiBond in project ovirt-engine by oVirt.

the class IscsiBondValidatorTest method addedLogicalNetworkBelongToAnotherDatacenter.

@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);
    assertThat(res, failsWith(EngineMessage.NETWORKS_DONT_EXIST_IN_DATA_CENTER));
    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));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 3 with IscsiBond

use of org.ovirt.engine.core.common.businessentities.IscsiBond in project ovirt-engine by oVirt.

the class IscsiBondValidatorTest method someAddedStorageConnectionsAreNotAnIscsi.

@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);
    assertThat(res, failsWith(EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTIONS_CANNOT_BE_ADDED_TO_ISCSI_BOND));
    assertEquals(1, res.getVariableReplacements().size());
    assertEquals("$connectionIds " + iscsiBond.getStorageConnectionIds().get(1).toString(), res.getVariableReplacements().get(0));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 4 with IscsiBond

use of org.ovirt.engine.core.common.businessentities.IscsiBond in project ovirt-engine by oVirt.

the class IscsiBondValidatorTest method addedRequiredLogicalNetworks.

@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());
    ValidationResult res = validator.validateAddedLogicalNetworks(iscsiBond);
    assertThat(res, failsWith(EngineMessage.ACTION_TYPE_FAILED_ISCSI_BOND_NETWORK_CANNOT_BE_REQUIRED));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 5 with IscsiBond

use of org.ovirt.engine.core.common.businessentities.IscsiBond in project ovirt-engine by oVirt.

the class IscsiBondValidatorTest method addedLogicalNetworkBelongToSameDatacenter.

@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());
    assertEquals(ValidationResult.VALID, validator.validateAddedLogicalNetworks(iscsiBond));
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) Test(org.junit.Test)

Aggregations

IscsiBond (org.ovirt.engine.core.common.businessentities.IscsiBond)36 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)12 Guid (org.ovirt.engine.core.compat.Guid)9 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)5 EditIscsiBondParameters (org.ovirt.engine.core.common.action.EditIscsiBondParameters)5 AbstractQueryTest (org.ovirt.engine.core.bll.AbstractQueryTest)4 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)2 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 RemoveIscsiBondParameters (org.ovirt.engine.core.common.action.RemoveIscsiBondParameters)1 StorageServerConnectionQueryParametersBase (org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1