Search in sources :

Example 6 with ExportBlockParam

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

the class BlockExportGroupSnapshotsDataTable method fetch.

public static List<ExportBlockSnapshot> fetch(URI exportGroupId) {
    if (exportGroupId == null) {
        return Collections.emptyList();
    }
    ViPRCoreClient client = BourneUtil.getViprClient();
    ExportGroupRestRep exportGroup = client.blockExports().get(exportGroupId);
    List<ExportBlockSnapshot> snapshots = Lists.newArrayList();
    for (ExportBlockParam exportBlockParam : exportGroup.getVolumes()) {
        if (ResourceType.isType(BLOCK_SNAPSHOT, exportBlockParam.getId())) {
            BlockSnapshotRestRep snapshot = client.blockSnapshots().get(exportBlockParam.getId());
            VolumeRestRep volume = client.blockVolumes().get(snapshot.getParent().getId());
            snapshots.add(new ExportBlockSnapshot(snapshot, volume.getName()));
        }
    }
    return snapshots;
}
Also used : ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep)

Example 7 with ExportBlockParam

use of com.emc.storageos.model.block.export.ExportBlockParam 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

ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)7 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)7 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)6 URI (java.net.URI)4 Asset (com.emc.sa.asset.annotation.Asset)3 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)3 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)3 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)2 ArrayList (java.util.ArrayList)2 ResourceType (com.emc.sa.util.ResourceType)1 Cluster (com.emc.storageos.db.client.model.Cluster)1 ExportPathParams (com.emc.storageos.db.client.model.ExportPathParams)1 Host (com.emc.storageos.db.client.model.Host)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 StringHashMapEntry (com.emc.storageos.model.StringHashMapEntry)1 BlockMirrorRestRep (com.emc.storageos.model.block.BlockMirrorRestRep)1 ExportPathParametersRep (com.emc.storageos.model.block.export.ExportPathParametersRep)1 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1