Search in sources :

Example 1 with StorageServerConnections

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

the class ImportSanStorageModel method getUnregisteredStorageDomains.

protected void getUnregisteredStorageDomains(List<StorageServerConnections> connections) {
    VDS vds = getContainer().getHost().getSelectedItem();
    Frontend.getInstance().runQuery(QueryType.GetUnregisteredBlockStorageDomains, new GetUnregisteredBlockStorageDomainsParameters(vds.getId(), getType(), connections), new AsyncQuery<QueryReturnValue>(returnValue -> {
        Pair<List<StorageDomain>, List<StorageServerConnections>> returnValuePair = returnValue.getReturnValue();
        ArrayList<StorageDomain> storageDomains = (ArrayList<StorageDomain>) returnValuePair.getFirst();
        ArrayList<StorageServerConnections> connections1 = (ArrayList<StorageServerConnections>) returnValuePair.getSecond();
        if (storageDomains != null) {
            addStorageDomains(storageDomains);
        }
        postGetUnregisteredStorageDomains(storageDomains, connections1);
    }));
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Frontend(org.ovirt.engine.ui.frontend.Frontend) List(java.util.List) GetUnregisteredBlockStorageDomainsParameters(org.ovirt.engine.core.common.queries.GetUnregisteredBlockStorageDomainsParameters) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) VDS(org.ovirt.engine.core.common.businessentities.VDS) Pair(org.ovirt.engine.core.common.utils.Pair) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VDS(org.ovirt.engine.core.common.businessentities.VDS) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) GetUnregisteredBlockStorageDomainsParameters(org.ovirt.engine.core.common.queries.GetUnregisteredBlockStorageDomainsParameters) ArrayList(java.util.ArrayList) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 2 with StorageServerConnections

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

the class ConnectHostToStoragePoolServersCommand method connectStorageServer.

private boolean connectStorageServer(Map<StorageType, List<StorageServerConnections>> connectionsByType) {
    boolean connectSucceeded = true;
    for (Map.Entry<StorageType, List<StorageServerConnections>> connectionToType : connectionsByType.entrySet()) {
        StorageType connectionsType = connectionToType.getKey();
        List<StorageServerConnections> connections = connectionToType.getValue();
        connectSucceeded = connectStorageServersByType(connectionsType, connections) && connectSucceeded;
    }
    if (cinderStorageHelper.isActiveCinderDomainAvailable(getStoragePool().getId())) {
        connectSucceeded &= cinderStorageHelper.prepareConnectHostToStoragePoolServers(getContext(), getParameters(), null);
    }
    log.info("Host '{}' storage connection was {} ", getVds().getName(), connectSucceeded ? "succeeded" : "failed");
    return connectSucceeded;
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) List(java.util.List) Map(java.util.Map)

Example 3 with StorageServerConnections

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

the class ImportHostedEngineStorageDomainCommand method addStorageServerConnection.

/**
 * For File based storage only, we need to save the connection in DB. It is implicitly called for SAN domains.
 */
private void addStorageServerConnection() {
    TransactionSupport.executeInNewTransaction(() -> {
        StorageServerConnections connection = heStorageDomain.getStorageStaticData().getConnection();
        connection.setId(Guid.newGuid().toString());
        if (heStorageDomain.getStorageType() == StorageType.GLUSTERFS) {
            // The use of the vfs type is mainly used for posix Storage Domains, usually,
            // adding a posix SD will have a defined vfs type configured by the user,
            // for this specific Gluster Storage Domain the user does not indicate the vfs type,
            // and that is the reason why it is done only for Gluster
            connection.setVfsType(StorageType.GLUSTERFS.name().toLowerCase());
        }
        storageServerConnectionDao.save(connection);
        // make sure the storage domain object is full for the rest of the flow
        heStorageDomain.setStorage(connection.getId());
        setSucceeded(true);
        getCompensationContext().snapshotEntity(connection);
        getCompensationContext().stateChanged();
        return null;
    });
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections)

Example 4 with StorageServerConnections

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

the class RunVmCommandTest method dontConnectFCLuns.

@Test
public void dontConnectFCLuns() {
    // FC luns are connected physically, they don't have StorageServerConnection set.
    // Make sure if we have an FC lun connection we don't try to connect
    // otherwise NPE will be thrown.
    command.setVm(new VM());
    // create 2 FC lun disks
    LunDisk fcLunDisk = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    fcLunDisk.setLun(lun1);
    LunDisk isciDisk = new LunDisk();
    LUNs lun2 = new LUNs();
    lun2.setLUNId("id2");
    isciDisk.setLun(lun2);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), fcLunDisk);
    command.getVm().getDiskMap().put(Guid.newGuid(), isciDisk);
    List<StorageServerConnections> iscsiLunConnections = new ArrayList<>();
    iscsiLunConnections.add(new StorageServerConnections("path/to/iscsi/connection", "id1", null, null, StorageType.ISCSI, null, null, null));
    when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(Collections.emptyList());
    when(storageServerConnectionDao.getAllForLun("id2")).thenReturn(iscsiLunConnections);
    ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
    doReturn(succesfull()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
    boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
    // for different targets, make sure we connect all but not FC.
    verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
    assertThat(captor.getValue().getConnectionList().size(), is(1));
    assertEquals(captor.getValue().getStorageType(), StorageType.ISCSI);
    assertTrue(connectSucceeded);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 5 with StorageServerConnections

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

the class RunVmCommandTest method oneConnectFailed.

@Test
public void oneConnectFailed() {
    command.setVm(new VM());
    // create 2 lun disks
    LunDisk lunDisk1 = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    lunDisk1.setLun(lun1);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk1);
    List<StorageServerConnections> connections = new ArrayList<>();
    // luns have the same backing targets
    connections.add(new StorageServerConnections("/path/to/con1", "id1", null, null, StorageType.ISCSI, null, null, null));
    when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(connections);
    ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
    doReturn(new VDSReturnValue()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
    boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
    // for same targets, connect only once
    verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
    assertThat(captor.getValue().getConnectionList().size(), is(1));
    assertFalse(connectSucceeded);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) 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