Search in sources :

Example 1 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.

the class ImportVmCommand method validateLunExistsAndInitDeviceData.

private boolean validateLunExistsAndInitDeviceData(LUNs lun, StorageType storageType, Guid vdsId) {
    List<LUNs> lunFromStorage = null;
    try {
        StorageServerConnectionManagementVDSParameters connectParams = new StorageServerConnectionManagementVDSParameters(vdsId, Guid.Empty, storageType, lun.getLunConnections());
        runVdsCommand(VDSCommandType.ConnectStorageServer, connectParams);
        GetDeviceListVDSCommandParameters parameters = new GetDeviceListVDSCommandParameters(vdsId, storageType, false, Collections.singleton(lun.getLUNId()));
        lunFromStorage = (List<LUNs>) runVdsCommand(VDSCommandType.GetDeviceList, parameters).getReturnValue();
    } catch (Exception e) {
        log.debug("Exception while validating LUN disk: '{}'", e);
        return false;
    }
    if (lunFromStorage == null || lunFromStorage.isEmpty()) {
        return false;
    } else {
        LUNs luns = lunFromStorage.get(0);
        lun.setSerial(luns.getSerial());
        lun.setLunMapping(luns.getLunMapping());
        lun.setVendorId(luns.getVendorId());
        lun.setProductId(luns.getProductId());
        lun.setProductId(luns.getProductId());
        lun.setDiscardMaxSize(luns.getDiscardMaxSize());
        lun.setPvSize(luns.getPvSize());
    }
    return true;
}
Also used : StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) GetDeviceListVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 2 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.

the class DisconnectHostFromStoragePoolServersCommand method disconnectStorageByType.

private void disconnectStorageByType(StorageType storageType, List<StorageServerConnections> connections) {
    /*
         * HE SD should only be connected/disconnected by the HE tools, not
         * by the engine.
         */
    Set<String> heIds = storageDomainDao.getHostedEngineStorageDomainIds().stream().map(storageDomainDao::get).map(StorageDomain::getStorageStaticData).map(StorageDomainStatic::getStorage).collect(Collectors.toSet());
    connections = connections.stream().filter(c -> !heIds.contains(c.getId())).collect(Collectors.toList());
    storageHelperDirector.getItem(storageType).prepareDisconnectHostFromStoragePoolServers(getParameters(), connections);
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.DisconnectStorageServer, new StorageServerConnectionManagementVDSParameters(getVds().getId(), getStoragePool().getId(), storageType, connections));
    setSucceeded(vdsReturnValue.getSucceeded());
    if (!vdsReturnValue.getSucceeded()) {
        storageHelperDirector.getItem(storageType).isConnectSucceeded((HashMap<String, String>) vdsReturnValue.getReturnValue(), connections);
    }
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 3 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters 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 4 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters 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)

Example 5 with StorageServerConnectionManagementVDSParameters

use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.

the class RunVmCommandBase method connectLunDisks.

protected boolean connectLunDisks(Guid hostId) {
    if (getVm().getDiskMap().isEmpty()) {
        vmHandler.updateDisksFromDb(getVm());
    }
    List<LunDisk> lunDisks = DisksFilter.filterLunDisks(getVm().getDiskMap().values());
    Map<StorageType, List<StorageServerConnections>> connectionsByType = lunDisks.stream().flatMap(d -> storageServerConnectionDao.getAllForLun(d.getLun().getLUNId()).stream()).distinct().collect(groupingBy(StorageServerConnections::getStorageType, toList()));
    return connectionsByType.entrySet().stream().map(entry -> runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(hostId, getStoragePoolId(), entry.getKey(), entry.getValue()))).noneMatch(vdsReturnValue -> !vdsReturnValue.getSucceeded());
}
Also used : CinderBroker(org.ovirt.engine.core.bll.storage.disk.cinder.CinderBroker) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) ProviderDao(org.ovirt.engine.core.dao.provider.ProviderDao) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LoggerFactory(org.slf4j.LoggerFactory) Provider(org.ovirt.engine.core.common.businessentities.Provider) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) Map(java.util.Map) JobRepository(org.ovirt.engine.core.bll.job.JobRepository) VdsRefreshRate(org.ovirt.engine.core.common.config.ConfigValues.VdsRefreshRate) ThreadPoolUtil(org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) RunVmDelayer(org.ovirt.engine.core.bll.scheduling.RunVmDelayer) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) BlockingQueue(java.util.concurrent.BlockingQueue) List(java.util.List) SchedulingManager(org.ovirt.engine.core.bll.scheduling.SchedulingManager) VnicProfileDao(org.ovirt.engine.core.dao.network.VnicProfileDao) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) ProcessDownVmParameters(org.ovirt.engine.core.common.action.ProcessDownVmParameters) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) ResourceManager(org.ovirt.engine.core.vdsbroker.ResourceManager) Job(org.ovirt.engine.core.common.job.Job) Guid(org.ovirt.engine.core.compat.Guid) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) NetworkDeviceHelper(org.ovirt.engine.core.bll.network.host.NetworkDeviceHelper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ExecutionHandler(org.ovirt.engine.core.bll.job.ExecutionHandler) NetworkHelper(org.ovirt.engine.core.bll.network.cluster.NetworkHelper) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy) StorageServerConnectionDao(org.ovirt.engine.core.dao.StorageServerConnectionDao) Network(org.ovirt.engine.core.common.businessentities.network.Network) IVdsAsyncCommand(org.ovirt.engine.core.common.businessentities.IVdsAsyncCommand) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Pair(org.ovirt.engine.core.common.utils.Pair) HostMonitoring(org.ovirt.engine.core.vdsbroker.monitoring.HostMonitoring) Config(org.ovirt.engine.core.common.config.Config) ProviderProxyFactory(org.ovirt.engine.core.bll.provider.ProviderProxyFactory) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) Logger(org.slf4j.Logger) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) VfScheduler(org.ovirt.engine.core.bll.network.host.VfScheduler) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) ExecutionContext(org.ovirt.engine.core.bll.job.ExecutionContext) TimeUnit(java.util.concurrent.TimeUnit) VdsMonitor(org.ovirt.engine.core.vdsbroker.VdsMonitor) Collectors.toList(java.util.stream.Collectors.toList) VmOperationParameterBase(org.ovirt.engine.core.common.action.VmOperationParameterBase) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) ONLY_PLUGGED(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_PLUGGED) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk)

Aggregations

StorageServerConnectionManagementVDSParameters (org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters)13 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)9 ArrayList (java.util.ArrayList)7 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)5 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)5 Pair (org.ovirt.engine.core.common.utils.Pair)5 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)5 Map (java.util.Map)4 Test (org.junit.Test)4 VM (org.ovirt.engine.core.common.businessentities.VM)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 Guid (org.ovirt.engine.core.compat.Guid)2 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 Callable (java.util.concurrent.Callable)1