Search in sources :

Example 16 with BlockObjectRestRep

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

the class ExportVMwareVolumeService method setVmfsDatastoreTag.

private void setVmfsDatastoreTag(List<String> volumeIds, URI hostId) {
    for (String volumeId : volumeIds) {
        BlockObjectRestRep volume = BlockStorageUtils.getVolume(uri(volumeId));
        Set<String> datastoreNames = VMwareDatastoreTagger.getDatastoreNames(volume);
        for (String datastoreName : datastoreNames) {
            vmware.addVmfsDatastoreTag(volume, hostId, datastoreName);
        }
    }
}
Also used : BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 17 with BlockObjectRestRep

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

the class RemoveBlockVolumeService method execute.

@Override
public void execute() {
    for (BlockObjectRestRep volume : volumes) {
        String datastoreName = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
        if (!StringUtils.isEmpty(datastoreName)) {
            Datastore datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
            if (datastore != null) {
                vmware.unmountVmfsDatastore(host, cluster, datastore);
            }
        }
    }
    for (BlockObjectRestRep volume : volumes) {
        vmware.detachLuns(host, cluster, volume);
    }
    vmware.disconnect();
    BlockStorageUtils.removeBlockResources(uris(volumeIds), deletionType);
    connectAndInitializeHost();
    vmware.refreshStorage(host, cluster);
    // form is always passing hostId, never clusterId - need to figure out which it is.
    String hostOrClusterId = BlockStorageUtils.getHostOrClusterId(hostId);
    if (hostOrClusterId != null) {
        ExecutionUtils.addAffectedResource(hostOrClusterId.toString());
    }
}
Also used : Datastore(com.vmware.vim25.mo.Datastore) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 18 with BlockObjectRestRep

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

the class UnexportVMwareVolumeService method precheck.

@Override
public void precheck() throws Exception {
    super.precheck();
    List<Host> hosts = Lists.newArrayList();
    if (BlockStorageUtils.isCluster(hostId)) {
        clusterInstance = BlockStorageUtils.getCluster(hostId);
        exports = BlockStorageUtils.findExportsContainingCluster(hostId, null, null);
        hosts = getModelClient().hosts().findByCluster(hostId);
    } else {
        hostInstance = BlockStorageUtils.getHost(hostId);
        exports = BlockStorageUtils.findExportsContainingHost(hostId, null, null);
        hosts = Arrays.asList(hostInstance);
    }
    filteredExportGroups = BlockStorageUtils.filterExportsByType(exports, hostId);
    String hostOrClusterLabel = clusterInstance == null ? hostInstance.getLabel() : clusterInstance.getLabel();
    if (filteredExportGroups.isEmpty()) {
        ExecutionUtils.fail("failTask.UnexportHostService.export", args(), args(hostOrClusterLabel));
    }
    volumes = BlockStorageUtils.getBlockResources(uris(volumeIds));
    if (volumes.isEmpty()) {
        ExecutionUtils.fail("failTask.UnexportHostService.volumes", args(), args());
    }
    if (volumes.size() < volumeIds.size()) {
        logWarn("unexport.host.service.not.found", volumeIds.size(), volumes.size());
    }
    for (BlockObjectRestRep volume : volumes) {
        String datastoreName = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
        if (!StringUtils.isEmpty(datastoreName)) {
            Datastore datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
            if (datastore != null) {
                vmware.verifyDatastoreForRemoval(datastore, datacenter.getLabel(), hosts);
            }
        }
    }
}
Also used : Datastore(com.vmware.vim25.mo.Datastore) Host(com.emc.storageos.db.client.model.Host) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 19 with BlockObjectRestRep

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

the class CreateVolumeAndExtendVmfsDatastoreService method execute.

@Override
public void execute() throws Exception {
    List<BlockObjectRestRep> volumes = createBlockVolumeHelper.createAndExportVolumes();
    if (volumes.isEmpty()) {
        ExecutionUtils.fail("CreateVolumeAndExtendVmfsDatastoreService.illegalState.noVolumesCreated", args(), args());
    }
    BlockObjectRestRep volume = volumes.get(0);
    connectAndInitializeHost();
    datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
    artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_VMWARE_EXTEND_DATASTORE);
    vmware.extendVmfsDatastore(host, cluster, hostId, volume, datastore);
    vmware.setMultipathPolicy(host, cluster, multipathPolicy, volume);
}
Also used : BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 20 with BlockObjectRestRep

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

the class TestBlockStorageUtils method newGetBlockResources.

static final List<BlockObjectRestRep> newGetBlockResources(ViPRCoreClient client, Collection<URI> uris) {
    List<BlockObjectRestRep> blockResources = Lists.newArrayList();
    List<URI> blockVolumes = new ArrayList<URI>();
    List<URI> blockSnapshots = new ArrayList<URI>();
    for (URI resourceId : uris) {
        ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
        switch(volumeType) {
            case VOLUME:
                blockVolumes.add(resourceId);
                break;
            case BLOCK_SNAPSHOT:
                blockSnapshots.add(resourceId);
                break;
            default:
                break;
        }
    }
    blockResources.addAll(client.blockVolumes().getByIds(blockVolumes));
    blockResources.addAll(client.blockSnapshots().getByIds(blockSnapshots));
    return blockResources;
}
Also used : ArrayList(java.util.ArrayList) ResourceType(com.emc.sa.util.ResourceType) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Aggregations

BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)60 URI (java.net.URI)30 Host (com.emc.storageos.db.client.model.Host)8 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)8 ArrayList (java.util.ArrayList)8 DiskDrive (com.iwave.ext.windows.model.wmi.DiskDrive)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 HostRestRep (com.emc.storageos.model.host.HostRestRep)3 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