Search in sources :

Example 61 with StorageServerConnections

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

the class UpdateStorageServerConnectionCommandTest method updateConnectionOfDomainsAndLunDisks.

@Test
public void updateConnectionOfDomainsAndLunDisks() {
    StorageServerConnections iscsiConnection = createISCSIConnection("10.35.16.25", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "3260", "user1", "mypassword123");
    LUNs lun1 = new LUNs();
    lun1.setLUNId("3600144f09dbd05000000517e730b1212");
    lun1.setVolumeGroupId("");
    lun1.setDiskAlias("disk1");
    Guid diskId1 = Guid.newGuid();
    lun1.setDiskId(diskId1);
    LUNs lun2 = new LUNs();
    lun2.setLUNId("3600144f09dbd05000000517e730b1212");
    lun2.setVolumeGroupId("");
    lun2.setDiskAlias("disk2");
    Guid diskId2 = Guid.newGuid();
    lun2.setDiskId(diskId2);
    LUNs lun3 = new LUNs();
    lun3.setLUNId("3600144f09dbd05000000517e730b1212");
    lun3.setStorageDomainName("storagedomain4");
    Guid storageDomainId = Guid.newGuid();
    lun3.setStorageDomainId(storageDomainId);
    lun3.setVolumeGroupId(Guid.newGuid().toString());
    List<LUNs> luns = Arrays.asList(lun1, lun2, 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 = Arrays.asList(vm1, vm2);
    List<VM> unPluggedVms = Collections.singletonList(vm3);
    vmsMap.put(Boolean.FALSE, unPluggedVms);
    vmsMap.put(Boolean.TRUE, pluggedVms);
    when(vmDao.getForDisk(diskId1, true)).thenReturn(vmsMap);
    parameters.setStorageServerConnection(iscsiConnection);
    when(storageConnDao.get(iscsiConnection.getId())).thenReturn(iscsiConnection);
    doReturn(luns).when(command).getLuns();
    StorageDomain domain1 = new StorageDomain();
    domain1.setStorage(iscsiConnection.getConnection());
    domain1.setStatus(StorageDomainStatus.Active);
    domain1.setStorageDomainSharedStatus(StorageDomainSharedStatus.Active);
    domain1.setId(storageDomainId);
    domain1.setStorageName("storagedomain4");
    when(storageDomainDao.get(storageDomainId)).thenReturn(domain1);
    when(storagePoolIsoMapDao.getAllForStorage(storageDomainId)).thenReturn(Collections.singletonList(new StoragePoolIsoMap(storageDomainId, Guid.newGuid(), StorageDomainStatus.Active)));
    List<String> messages = ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_STATUS);
    assertTrue(messages.contains("$vmNames vm1"));
    assertTrue(messages.contains("$domainNames storagedomain4"));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VM(org.ovirt.engine.core.common.businessentities.VM) List(java.util.List) Test(org.junit.Test)

Example 62 with StorageServerConnections

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

the class UpdateStorageServerConnectionCommandTest method failUpdateConnectToStorage.

@Test
public void failUpdateConnectToStorage() {
    StorageServerConnections newNFSConnection = createNFSConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data2", StorageType.NFS, NfsVersion.V4, 300, 0);
    parameters.setStorageServerConnection(newNFSConnection);
    doReturn(false).when(command).connectToStorage();
    VDSReturnValue returnValueUpdate = new VDSReturnValue();
    returnValueUpdate.setSucceeded(true);
    StorageDomainDynamic domainDynamic = new StorageDomainDynamic();
    StorageDomain domain = createDomain();
    initDomainListForConnection(newNFSConnection.getId(), domain);
    StoragePoolIsoMap map = new StoragePoolIsoMap();
    doReturn(Collections.singletonList(map)).when(command).getStoragePoolIsoMap(domain);
    command.executeCommand();
    CommandAssertUtils.checkSucceeded(command, true);
    verify(storageDomainDynamicDao, never()).update(domainDynamic);
    verify(command, never()).disconnectFromStorage();
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) StorageDomainDynamic(org.ovirt.engine.core.common.businessentities.StorageDomainDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Test(org.junit.Test)

Example 63 with StorageServerConnections

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

the class UpdateStorageServerConnectionCommandTest method updateSeveralConnectionsWithSamePath.

@Test
public void updateSeveralConnectionsWithSamePath() {
    StorageServerConnections newNFSConnection = createNFSConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data2", StorageType.NFS, NfsVersion.V4, 300, 0);
    parameters.setStorageServerConnection(newNFSConnection);
    StorageServerConnections conn1 = new StorageServerConnections();
    conn1.setConnection(newNFSConnection.getConnection());
    conn1.setId(newNFSConnection.getId());
    StorageServerConnections conn2 = new StorageServerConnections();
    conn2.setConnection(newNFSConnection.getConnection());
    conn2.setId(Guid.newGuid().toString());
    when(storageConnDao.get(newNFSConnection.getId())).thenReturn(oldNFSConnection);
    doReturn(true).when(command).isConnWithSameDetailsExists(newNFSConnection, null);
    ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_ALREADY_EXISTS);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Test(org.junit.Test)

Example 64 with StorageServerConnections

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

the class UpdateStorageServerConnectionCommandTest method updateConnectionOfActiveDomain.

@Test
public void updateConnectionOfActiveDomain() {
    StorageServerConnections newNFSConnection = createNFSConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data2", StorageType.NFS, NfsVersion.V4, 300, 0);
    StorageDomain domain1 = new StorageDomain();
    domain1.setStorage(newNFSConnection.getConnection());
    domain1.setStatus(StorageDomainStatus.Active);
    domain1.setStorageDomainSharedStatus(StorageDomainSharedStatus.Active);
    initDomainListForConnection(newNFSConnection.getId(), domain1);
    parameters.setStorageServerConnection(newNFSConnection);
    when(storageConnDao.get(newNFSConnection.getId())).thenReturn(oldNFSConnection);
    doReturn(false).when(command).isConnWithSameDetailsExists(newNFSConnection, null);
    ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_UNSUPPORTED_ACTION_DOMAIN_MUST_BE_IN_MAINTENANCE_OR_UNATTACHED);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Test(org.junit.Test)

Example 65 with StorageServerConnections

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

the class UpdateStorageServerConnectionCommandTest method isConnWithSameDetailsExistSameConnection.

@Test
public void isConnWithSameDetailsExistSameConnection() {
    StorageServerConnections newNFSConnection = createNFSConnection("multipass.my.domain.tlv.company.com:/export/allstorage/data2", StorageType.NFS, NfsVersion.V4, 300, 0);
    List<StorageServerConnections> connections = Collections.singletonList(newNFSConnection);
    when(storageConnDao.getAllForStorage(newNFSConnection.getConnection())).thenReturn(connections);
    boolean isExists = command.isConnWithSameDetailsExists(newNFSConnection, null);
    assertFalse(isExists);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Test(org.junit.Test)

Aggregations

StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)181 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)43 Guid (org.ovirt.engine.core.compat.Guid)39 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)33 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)32 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)19 List (java.util.List)18 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)15 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)14 HashSet (java.util.HashSet)13 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)11 ActionType (org.ovirt.engine.core.common.action.ActionType)11 Set (java.util.Set)10 StorageConnection (org.ovirt.engine.api.model.StorageConnection)10 StorageDomainType (org.ovirt.engine.core.common.businessentities.StorageDomainType)10 QueryType (org.ovirt.engine.core.common.queries.QueryType)10