Search in sources :

Example 1 with StringHashMapEntry

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

the class VirtualArrayMapper method map.

public static NetworkRestRep map(Network from) {
    if (from == null) {
        return null;
    }
    NetworkRestRep to = new NetworkRestRep();
    mapDiscoveredDataObjectFields(from, to);
    StringSet assignedVirtualArrays = from.getAssignedVirtualArrays();
    if ((assignedVirtualArrays != null) && (assignedVirtualArrays.size() == 1)) {
        to.setVirtualArray(toRelatedResource(ResourceTypeEnum.VARRAY, URI.create(assignedVirtualArrays.iterator().next())));
    }
    to.setTransportType(from.getTransportType());
    to.setEndpoints(from.retrieveEndpoints());
    List<StringHashMapEntry> endpointsMap = new StringMapAdapter().marshal(from.getEndpointsMap());
    /*
         * Translated network endpoint to its corresponded EndpointAliasRestRep. At this point, only
         * "name" and "value" attribute are filled. "alias" attribute will filled by the caller.
         */
    to.setEndpointsDiscovered(new ArrayList<EndpointAliasRestRep>());
    for (StringHashMapEntry endpointEntry : endpointsMap) {
        to.getEndpointsDiscovered().add(new EndpointAliasRestRep(endpointEntry.getName(), endpointEntry.getValue()));
    }
    to.setFabricId(from.getNativeId());
    to.setDiscovered(from.getDiscovered());
    to.setNetworkSystems(from.getNetworkSystems());
    to.setRegistrationStatus(from.getRegistrationStatus());
    to.setAssignedVirtualArrays(assignedVirtualArrays);
    to.setConnectedVirtualArrays(from.getConnectedVirtualArrays());
    to.setRoutedNetworks(from.getRoutedNetworks());
    return to;
}
Also used : EndpointAliasRestRep(com.emc.storageos.model.EndpointAliasRestRep) StringSet(com.emc.storageos.db.client.model.StringSet) StringMapAdapter(com.emc.storageos.model.adapters.StringMapAdapter) NetworkRestRep(com.emc.storageos.model.varray.NetworkRestRep) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry)

Example 2 with StringHashMapEntry

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

the class StringMapAdapter method marshal.

@Override
public List<StringHashMapEntry> marshal(Map<String, String> map) {
    if (map == null) {
        return (ArrayList<StringHashMapEntry>) null;
    }
    List<StringHashMapEntry> list = new ArrayList<StringHashMapEntry>();
    if (map != null) {
        for (Entry<String, String> entry : map.entrySet()) {
            StringHashMapEntry listEnt = new StringHashMapEntry(entry.getKey(), entry.getValue());
            list.add(listEnt);
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry)

Example 3 with StringHashMapEntry

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

the class BlockProvider method getExportPathVirtualArray.

@Asset("exportPathVirtualArray")
@AssetDependencies({ "exportPathExport", "exportPathStorageSystem" })
public List<AssetOption> getExportPathVirtualArray(AssetOptionsContext ctx, URI exportId, URI storageSystemId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    ExportGroupRestRep export = client.blockExports().get(exportId);
    List<URI> vArrayIds = new ArrayList<URI>();
    vArrayIds.add(export.getVirtualArray().getId());
    List<StringHashMapEntry> altArrays = export.getAltVirtualArrays() != null ? export.getAltVirtualArrays() : new ArrayList<StringHashMapEntry>();
    for (StringHashMapEntry altArray : altArrays) {
        if (altArray.getName().equalsIgnoreCase(storageSystemId.toString())) {
            vArrayIds.add(URI.create(altArray.getValue()));
        }
    }
    List<VirtualArrayRestRep> vArrays = client.varrays().getByIds(vArrayIds);
    for (VirtualArrayRestRep vArray : vArrays) {
        options.add(new AssetOption(vArray.getId(), vArray.getName()));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) ArrayList(java.util.ArrayList) URI(java.net.URI) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with StringHashMapEntry

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

the class BlockProvider method createVpoolChangeOptions.

protected List<AssetOption> createVpoolChangeOptions(String vpoolChangeOperation, List<VirtualPoolChangeRep> vpoolChanges) {
    List<AssetOption> options = Lists.newArrayList();
    List<AssetOption> available = Lists.newArrayList();
    List<AssetOption> wrongOperation = Lists.newArrayList();
    List<AssetOption> notAllowed = Lists.newArrayList();
    for (VirtualPoolChangeRep vpoolChange : vpoolChanges) {
        if (vpoolChange.getAllowed() && vpoolChange.getAllowedChangeOperations() != null) {
            for (StringHashMapEntry allowedChangeOperation : vpoolChange.getAllowedChangeOperations()) {
                String operation = allowedChangeOperation.getName();
                boolean isCorrectOperation = StringUtils.isNotBlank(operation) && operation.equalsIgnoreCase(vpoolChangeOperation);
                if (isCorrectOperation) {
                    available.add(new AssetOption(vpoolChange.getId(), vpoolChange.getName()));
                } else {
                    wrongOperation.add(new AssetOption(EMPTY_STRING, getMessage("block.virtualPool.vpoolChangeOperation", vpoolChange.getName(), getAllowedChangeOperationNames(vpoolChange.getAllowedChangeOperations()))));
                }
            }
        } else {
            notAllowed.add(new AssetOption(EMPTY_STRING, getMessage("block.virtualPool.vpoolChangeReason", vpoolChange.getName(), vpoolChange.getNotAllowedReason())));
        }
    }
    options.addAll(available);
    options.addAll(wrongOperation);
    options.addAll(notAllowed);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualPoolChangeRep(com.emc.storageos.model.vpool.VirtualPoolChangeRep) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry)

Example 5 with StringHashMapEntry

use of com.emc.storageos.model.StringHashMapEntry 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

StringHashMapEntry (com.emc.storageos.model.StringHashMapEntry)5 ArrayList (java.util.ArrayList)3 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)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 StringSet (com.emc.storageos.db.client.model.StringSet)1 EndpointAliasRestRep (com.emc.storageos.model.EndpointAliasRestRep)1 StringMapAdapter (com.emc.storageos.model.adapters.StringMapAdapter)1 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)1 ExportPathParametersRep (com.emc.storageos.model.block.export.ExportPathParametersRep)1 NetworkRestRep (com.emc.storageos.model.varray.NetworkRestRep)1 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)1 VirtualPoolChangeRep (com.emc.storageos.model.vpool.VirtualPoolChangeRep)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1