Search in sources :

Example 46 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class TestBlockStorageUtils method originalGetBlockResources.

static final List<BlockObjectRestRep> originalGetBlockResources(ViPRCoreClient client, Collection<URI> uris) {
    List<BlockObjectRestRep> returnList = new ArrayList<>();
    for (URI uri : uris) {
        BlockObjectRestRep s = getSingle(client, uri);
        if (s != null) {
            returnList.add(s);
        }
        returnList.add(getSingle(client, uri));
    }
    return returnList;
}
Also used : ArrayList(java.util.ArrayList) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 47 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class TestBlockStorageUtils method testGetBlockResources.

@Test
public void testGetBlockResources() throws URISyntaxException {
    Logger.getRootLogger().setLevel(Level.OFF);
    ViPRCoreClient client = new ViPRCoreClient("host", true).withLogin("root", "password");
    try {
        List<URI> uris = prepare(client);
        StopWatch w = new StopWatch();
        w.start();
        List<BlockObjectRestRep> original = originalGetBlockResources(client, uris);
        w.stop();
        float firstTime = w.getTime();
        System.out.println(String.format("Original query time with %s volumes : %s ms", original.size(), firstTime));
        w.reset();
        w.start();
        List<BlockObjectRestRep> fixed = newGetBlockResources(client, uris);
        w.stop();
        float secondTime = w.getTime();
        System.out.println(String.format("Updated query time with %s volumes : %s ms", fixed.size(), w.getTime()));
        System.out.println(String.format("Improvement : %s %%", firstTime / secondTime * 100.0f));
        Assert.assertTrue(firstTime > secondTime);
    } finally {
        client.auth().logout();
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) StopWatch(org.apache.commons.lang3.time.StopWatch) Test(org.junit.Test)

Example 48 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class CreateVolumeAndVmfsDatastoreService method execute.

@Override
public void execute() throws Exception {
    if (datastoreNames.size() != createBlockVolumeHelpers.size()) {
        throw new IllegalStateException(ExecutionUtils.getMessage("CreateVolumeAndVmfsDatastoreService.datastore.volume.mismatch"));
    }
    Map<String, BlockObjectRestRep> datastoreVolumeMap = Maps.newHashMap();
    List<URI> volumes = BlockStorageUtils.createMultipleVolumes(createBlockVolumeHelpers);
    if (volumes.isEmpty()) {
        ExecutionUtils.fail("CreateVolumeAndVmfsDatastoreService.illegalState.noVolumesCreated", args(), args());
    }
    // use one of the helpers to export all volumes to the host or cluster
    createBlockVolumeHelpers.get(0).exportVolumes(volumes);
    int index = 0;
    for (String datastoreName : datastoreNames) {
        BlockObjectRestRep volume = BlockStorageUtils.getBlockResource(volumes.get(index));
        datastoreVolumeMap.put(datastoreName, volume);
        index++;
    }
    connectAndInitializeHost();
    vmware.refreshStorage(host, cluster);
    for (Entry<String, BlockObjectRestRep> entry : datastoreVolumeMap.entrySet()) {
        Datastore datastore = vmware.createVmfsDatastore(host, cluster, hostId, entry.getValue(), entry.getKey());
        vmware.setMultipathPolicy(host, cluster, multipathPolicy, entry.getValue());
        vmware.setStorageIOControl(datastore, storageIOControl, true);
    }
    vmware.disconnect();
}
Also used : Datastore(com.vmware.vim25.mo.Datastore) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 49 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class ExpandVmfsDatastoreService method execute.

@Override
public void execute() throws Exception {
    BlockObjectRestRep volume = BlockStorageUtils.getVolume(volumeId);
    // Skip the expand if the current volume capacity is larger than the requested expand size
    if (BlockStorageUtils.isVolumeExpanded(volume, sizeInGb)) {
        logWarn("expand.vmfs.datastore.skip", volumeId, BlockStorageUtils.getCapacity(volume));
    } else {
        BlockStorageUtils.expandVolume(volumeId, sizeInGb);
    }
    connectAndInitializeHost();
    datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
    vmware.refreshStorage(host, cluster);
    artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_VMWARE_EXPAND_DATASTORE);
    vmware.expandVmfsDatastore(host, cluster, hostId, volume, datastore);
    if (hostId != null) {
        ExecutionUtils.addAffectedResource(hostId.toString());
    }
}
Also used : BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 50 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class UnexportVMwareVolumeService method execute.

@Override
public void execute() throws Exception {
    for (BlockObjectRestRep volume : volumes) {
        String datastoreName = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
        if (!StringUtils.isEmpty(datastoreName)) {
            Datastore datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
            if (datastore != null) {
                boolean storageIOControlEnabled = datastore.getIormConfiguration() != null ? datastore.getIormConfiguration().isEnabled() : false;
                vmware.unmountVmfsDatastore(host, cluster, datastore);
                datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
                if (storageIOControlEnabled && datastore != null && datastore.getSummary() != null && datastore.getSummary().isAccessible()) {
                    vmware.setStorageIOControl(datastore, true);
                }
            }
        }
    }
    for (BlockObjectRestRep volume : volumes) {
        vmware.detachLuns(host, cluster, volume);
    }
    vmware.disconnect();
    ExecutionUtils.clearRollback();
    for (BlockObjectRestRep volume : volumes) {
        if (volume.getTags() != null) {
            vmware.removeVmfsDatastoreTag(volume, hostId);
        }
    }
    for (ExportGroupRestRep export : filteredExportGroups) {
        URI exportId = ResourceUtils.id(export);
        String exportName = ResourceUtils.name(export);
        // Check each volume to see if it is in this export
        Set<URI> exportedVolumeIds = Sets.newHashSet();
        for (BlockObjectRestRep volume : volumes) {
            URI volumeId = ResourceUtils.id(volume);
            String volumeName = ResourceUtils.name(volume);
            if (BlockStorageUtils.isVolumeInExportGroup(export, volumeId)) {
                logInfo("unexport.host.service.volume.in.export", volumeName, exportName);
                exportedVolumeIds.add(volumeId);
            }
        }
        if (!exportedVolumeIds.isEmpty()) {
            logInfo("unexport.host.service.volume.remove", exportedVolumeIds.size(), exportName);
            BlockStorageUtils.removeBlockResourcesFromExport(exportedVolumeIds, exportId);
        } else {
            logDebug("unexport.host.service.volume.skip", exportName);
        }
        String hostOrClusterId = BlockStorageUtils.getHostOrClusterId(hostId);
        if (hostOrClusterId != null) {
            ExecutionUtils.addAffectedResource(hostOrClusterId.toString());
        }
    }
    connectAndInitializeHost();
    vmware.refreshStorage(host, cluster);
}
Also used : Datastore(com.vmware.vim25.mo.Datastore) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Aggregations

BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)59 URI (java.net.URI)29 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)8 Host (com.emc.storageos.db.client.model.Host)7 DiskDrive (com.iwave.ext.windows.model.wmi.DiskDrive)7 ArrayList (java.util.ArrayList)7 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 Datastore (com.vmware.vim25.mo.Datastore)5 Map (java.util.Map)5 ExecutionException (com.emc.sa.engine.ExecutionException)4 DeactivateHost (com.emc.sa.service.vipr.compute.tasks.DeactivateHost)4 DiscoverHost (com.emc.sa.service.vipr.compute.tasks.DiscoverHost)4 GetHost (com.emc.sa.service.vipr.tasks.GetHost)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)3 TimeoutException (com.emc.vipr.client.exceptions.TimeoutException)3 ViPRException (com.emc.vipr.client.exceptions.ViPRException)3 Disk (com.iwave.ext.windows.model.Disk)3 ResourceType (com.emc.sa.util.ResourceType)2