Search in sources :

Example 1 with EndpointAliasRestRep

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

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;
}
Also used : HashMap(java.util.HashMap) EndpointAliasRestRep(com.emc.storageos.model.EndpointAliasRestRep) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) NetworkRestRep(com.emc.storageos.model.varray.NetworkRestRep) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Aggregations

EndpointAliasRestRep (com.emc.storageos.model.EndpointAliasRestRep)2 NetworkRestRep (com.emc.storageos.model.varray.NetworkRestRep)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 FCEndpoint (com.emc.storageos.db.client.model.FCEndpoint)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 StringHashMapEntry (com.emc.storageos.model.StringHashMapEntry)1 StringMapAdapter (com.emc.storageos.model.adapters.StringMapAdapter)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1