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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations