Search in sources :

Example 56 with ExportGroupRestRep

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

the class UnexportHostService method execute.

@Override
public void execute() throws Exception {
    for (ExportGroupRestRep export : exports) {
        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());
        }
    }
}
Also used : ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 57 with ExportGroupRestRep

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

the class CreateExportNoWait method executeTask.

@Override
public Task<ExportGroupRestRep> executeTask() throws Exception {
    ExportCreateParam export = new ExportCreateParam();
    export.setName(name);
    export.setVarray(varrayId);
    export.setProject(projectId);
    Integer currentHlu = hlu;
    for (URI volumeId : volumeIds) {
        VolumeParam volume = new VolumeParam(volumeId);
        if (currentHlu != null) {
            volume.setLun(currentHlu);
        }
        if ((currentHlu != null) && (currentHlu > -1)) {
            currentHlu++;
        }
        export.getVolumes().add(volume);
    }
    if (clusterId != null) {
        export.addCluster(clusterId);
        export.setType("Cluster");
    } else {
        export.addHost(hostId);
        export.setType("Host");
    }
    if (!NullColumnValueGetter.isNullURI(portGroup)) {
        ExportPathParameters exportPathParameters = new ExportPathParameters();
        exportPathParameters.setPortGroup(portGroup);
        export.setExportPathParameters(exportPathParameters);
    }
    Task<ExportGroupRestRep> task = getClient().blockExports().create(export);
    addOrderIdTag(task.getTaskResource().getId());
    return task;
}
Also used : ExportCreateParam(com.emc.storageos.model.block.export.ExportCreateParam) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) VolumeParam(com.emc.storageos.model.block.export.VolumeParam) URI(java.net.URI) ExportPathParameters(com.emc.storageos.model.block.export.ExportPathParameters)

Example 58 with ExportGroupRestRep

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

the class GetMobilityGroupVolumesByCluster method getHostExportedVolumes.

private Set<URI> getHostExportedVolumes() {
    Set<URI> volumes = Sets.newHashSet();
    for (NamedRelatedResourceRep cluster : clusters) {
        List<ExportGroupRestRep> exports = getClient().blockExports().findContainingCluster(cluster.getId());
        volumes.addAll(BlockProviderUtils.getExportedResourceIds(exports, ResourceType.VOLUME));
    }
    return volumes;
}
Also used : ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 59 with ExportGroupRestRep

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

the class HostMapper method map.

public static ExportGroupRestRep map(ExportGroup from, List<Initiator> initiators, Map<String, Integer> volumes, List<Host> hosts, List<Cluster> clusters, List<ExportPathParams> exportPathParams) {
    if (from == null) {
        return null;
    }
    ExportGroupRestRep to = new ExportGroupRestRep();
    mapDataObjectFields(from, to);
    if (initiators != null) {
        for (Initiator initiator : initiators) {
            to.getInitiators().add(map(initiator));
        }
    }
    if (volumes != null) {
        for (Map.Entry<String, Integer> entry : volumes.entrySet()) {
            ExportBlockParam volume = new ExportBlockParam();
            volume.setId(URI.create(entry.getKey()));
            Integer lun = entry.getValue();
            if (lun != null && lun != ExportGroup.LUN_UNASSIGNED) {
                volume.setLun(lun);
            }
            to.getVolumes().add(volume);
        }
    }
    if (hosts != null) {
        for (Host host : hosts) {
            to.getHosts().add(map(host));
        }
    }
    if (clusters != null) {
        for (Cluster cluster : clusters) {
            to.getClusters().add(map(cluster));
        }
    }
    if (exportPathParams != null && !exportPathParams.isEmpty()) {
        for (ExportPathParams pathParam : exportPathParams) {
            ExportPathParametersRep pathParamRep = map(pathParam);
            for (Map.Entry<String, String> entry : from.getPathParameters().entrySet()) {
                if (entry.getValue().equals(pathParam.getId().toString())) {
                    pathParamRep.getBlockObjects().add(entry.getKey());
                }
            }
            to.getPathParams().add(pathParamRep);
        }
    }
    if (from.getProject() != null) {
        to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject().getURI()));
    }
    if (from.getTenant() != null) {
        to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, from.getTenant().getURI()));
    }
    to.setVirtualArray(toRelatedResource(ResourceTypeEnum.VARRAY, from.getVirtualArray()));
    if (from.getType() != null) {
        to.setType(from.getType());
    }
    to.setGeneratedName(from.getGeneratedName());
    if (from.getAltVirtualArrays() != null && !from.getAltVirtualArrays().isEmpty()) {
        // The alternate virtual array is a map from Storage System URI to Virtual Array URI
        List<StringHashMapEntry> toVirtualArrays = new ArrayList<StringHashMapEntry>();
        for (Map.Entry<String, String> entry : from.getAltVirtualArrays().entrySet()) {
            StringHashMapEntry toEntry = new StringHashMapEntry();
            toEntry.setName(entry.getKey());
            toEntry.setValue(entry.getValue());
            toVirtualArrays.add(toEntry);
        }
        to.setAltVirtualArrays(toVirtualArrays);
    }
    return to;
}
Also used : ArrayList(java.util.ArrayList) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry) ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) Initiator(com.emc.storageos.db.client.model.Initiator) ExportPathParametersRep(com.emc.storageos.model.block.export.ExportPathParametersRep) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap) ExportPathParams(com.emc.storageos.db.client.model.ExportPathParams)

Aggregations

ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)59 URI (java.net.URI)36 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)24 Asset (com.emc.sa.asset.annotation.Asset)10 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)10 FlashException (controllers.util.FlashException)9 ExportUpdateParam (com.emc.storageos.model.block.export.ExportUpdateParam)8 AssetOption (com.emc.vipr.model.catalog.AssetOption)8 ArrayList (java.util.ArrayList)8 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)7 DeactivateBlockExport (com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport)5 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)5 ITLRestRep (com.emc.storageos.model.block.export.ITLRestRep)5 HostRestRep (com.emc.storageos.model.host.HostRestRep)5 HashSet (java.util.HashSet)5 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)4 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)4