Search in sources :

Example 21 with IscsiBond

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

the class GetIscsiBondByIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    IscsiBond iscsiBond = iscsiBondDao.get(getParameters().getId());
    if (iscsiBond != null) {
        iscsiBond.getNetworkIds().addAll(iscsiBondDao.getNetworkIdsByIscsiBondId(iscsiBond.getId()));
        iscsiBond.getStorageConnectionIds().addAll(iscsiBondDao.getStorageConnectionIdsByIscsiBondId(iscsiBond.getId()));
        getQueryReturnValue().setReturnValue(iscsiBond);
    }
}
Also used : IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond)

Example 22 with IscsiBond

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

the class GetIscsiBondsByStoragePoolIdQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    List<IscsiBond> iscsiBonds = iscsiBondDao.getAllByStoragePoolId(getParameters().getId());
    for (IscsiBond iscsiBond : iscsiBonds) {
        List<Guid> networkIds = iscsiBondDao.getNetworkIdsByIscsiBondId(iscsiBond.getId());
        iscsiBond.setNetworkIds(networkIds);
        List<String> connectionIds = iscsiBondDao.getStorageConnectionIdsByIscsiBondId(iscsiBond.getId());
        iscsiBond.setStorageConnectionIds(connectionIds);
    }
    getQueryReturnValue().setReturnValue(iscsiBonds);
}
Also used : IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) Guid(org.ovirt.engine.core.compat.Guid)

Example 23 with IscsiBond

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

the class IscsiBondValidatorTest method createIscsiBond.

private IscsiBond createIscsiBond(String name, Guid dataCenterId) {
    IscsiBond iscsiBond = new IscsiBond();
    iscsiBond.setId(Guid.newGuid());
    iscsiBond.setStoragePoolId(dataCenterId);
    iscsiBond.setName(name);
    return iscsiBond;
}
Also used : IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond)

Example 24 with IscsiBond

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

the class IscsiBondValidatorTest method iscsiBondWithTheSameNameExistsInDataCenter.

@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());
    ValidationResult res = validator.iscsiBondWithTheSameNameExistInDataCenter(createIscsiBond("Second", dataCenterId));
    assertThat(res, failsWith(EngineMessage.ISCSI_BOND_WITH_SAME_NAME_EXIST_IN_DATA_CENTER));
}
Also used : ArrayList(java.util.ArrayList) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 25 with IscsiBond

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

the class IscsiBondValidatorTest method iscsiBondWithTheSameNameDoesNotExistInDataCenter.

@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());
    assertEquals(ValidationResult.VALID, validator.iscsiBondWithTheSameNameExistInDataCenter(createIscsiBond("Third", dataCenterId)));
}
Also used : ArrayList(java.util.ArrayList) IscsiBond(org.ovirt.engine.core.common.businessentities.IscsiBond) Guid(org.ovirt.engine.core.compat.Guid) 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