use of com.emc.storageos.model.EndpointAliasRestRep 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.EndpointAliasRestRep in project coprhd-controller by CoprHD.
the class MapNetwork method toNetworkRestRep.
/**
* Map <code>Network</code> to <code>NetworkRestRep</code> object. Since <code>remote_port_alias</code> is not readily available, it
* must be read from corresponded <code>FCEndpoint</code>.
*
* @param network
* @param dbClient
* @return
*/
public static NetworkRestRep toNetworkRestRep(Network network, DbClient dbClient) {
NetworkRestRep networkRestRep = MapNetwork.getInstance().apply(network);
List<EndpointAliasRestRep> endpoints = networkRestRep.getEndpointsDiscovered();
if (endpoints.isEmpty() || !network.getDiscovered() || !network.getTransportType().equalsIgnoreCase(TransportType.FC.name())) {
return networkRestRep;
}
try {
String fabricWwn = NetworkUtil.getNetworkWwn(network);
if (fabricWwn != null && !fabricWwn.isEmpty()) {
Map<String, EndpointAliasRestRep> aliasMap = new HashMap<String, EndpointAliasRestRep>();
for (EndpointAliasRestRep endpointAliasRestRep : endpoints) {
aliasMap.put(endpointAliasRestRep.getName(), endpointAliasRestRep);
}
URIQueryResultList uriList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFCEndpointByFabricWwnConstraint(NetworkUtil.getNetworkWwn(network)), uriList);
Set<String> fields = new HashSet<String>();
fields.add(REMOTE_PORT_NAME);
fields.add(REMOTE_PORT_ALIAS);
Iterator<FCEndpoint> iterator = dbClient.queryIterativeObjectFields(FCEndpoint.class, fields, uriList);
while (iterator.hasNext()) {
FCEndpoint fc = iterator.next();
if (fc != null && !StringUtils.isEmpty(fc.getRemotePortAlias())) {
String portWWN = fc.getRemotePortName();
EndpointAliasRestRep restRep = aliasMap.get(portWWN);
if (restRep != null) {
logger.debug("Found alias {} for WWN {} in network {}", new Object[] { fc.getRemotePortAlias(), portWWN, networkRestRep.getId() });
restRep.setAlias(fc.getRemotePortAlias());
}
}
}
}
} catch (Exception ex) {
logger.error("Unable to display alias information because an error encountered while getting" + " alias information for network " + networkRestRep.getId(), ex);
}
return networkRestRep;
}
Aggregations