Search in sources :

Example 1 with NetworkRestRep

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

the class InternalNetworkClient method updateNetworkEndpoints.

/**
 * Method for updating the network's endpoints
 *
 * @param id the URN of a ViPR network
 * @param param The ips to add or remove, and whether to add or remove
 * @return network info
 */
public NetworkRestRep updateNetworkEndpoints(URI id, NetworkEndpointParam param) {
    WebResource rRoot = createRequest(INTERNAL_TRANSPORTZONE_ROOT + id + ENDPOINTS);
    NetworkRestRep resp = addSignature(rRoot).post(NetworkRestRep.class, param);
    return resp;
}
Also used : WebResource(com.sun.jersey.api.client.WebResource) NetworkRestRep(com.emc.storageos.model.varray.NetworkRestRep)

Example 2 with NetworkRestRep

use of com.emc.storageos.model.varray.NetworkRestRep 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 3 with NetworkRestRep

use of com.emc.storageos.model.varray.NetworkRestRep 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)

Example 4 with NetworkRestRep

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

the class Networks method getNetwork.

/**
 * Gets a network by ID, or flashes an error and goes back to the referring page or the list page if no referrer.
 *
 * @param id
 *            the network ID.
 * @return the network.
 */
@Util
public static NetworkRestRep getNetwork(String id) {
    NetworkRestRep network = NetworkUtils.getNetwork(id);
    if (network == null) {
        flash.error(MessagesUtils.get(UNKNOWN, id));
        backToReferrer();
        list();
    }
    return network;
}
Also used : NetworkRestRep(com.emc.storageos.model.varray.NetworkRestRep) Util(play.mvc.Util)

Example 5 with NetworkRestRep

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

the class Networks method availableHostEndpointsJson.

public static void availableHostEndpointsJson(String id) {
    NetworkRestRep network = NetworkUtils.getNetwork(id);
    CachedResources<HostRestRep> hosts = HostUtils.createCache();
    List<EndpointInfo> items = Lists.newArrayList();
    if (TransportProtocols.isIp(network.getTransportType())) {
        // Host IP interfaces not in the network
        for (IpInterfaceRestRep ipInterface : NetworkUtils.getEligibleIpInterfaces(network.getId())) {
            items.add(new EndpointInfo(ipInterface, hosts));
        }
    }
    // Host initiators not in the network
    Set<String> protocols = NetworkUtils.getSupportedProtocols(network);
    for (InitiatorRestRep initiator : NetworkUtils.getEligibleInitiators(network.getId(), protocols)) {
        items.add(new EndpointInfo(initiator, hosts));
    }
    setEndpointAttrs(network, items);
    renderJSON(DataTablesSupport.createJSON(items, params));
}
Also used : EndpointInfo(models.datatable.NetworkEndpointDataTable.EndpointInfo) HostRestRep(com.emc.storageos.model.host.HostRestRep) IpInterfaceRestRep(com.emc.storageos.model.host.IpInterfaceRestRep) InitiatorRestRep(com.emc.storageos.model.host.InitiatorRestRep) NetworkRestRep(com.emc.storageos.model.varray.NetworkRestRep)

Aggregations

NetworkRestRep (com.emc.storageos.model.varray.NetworkRestRep)16 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)4 HashSet (java.util.HashSet)3 EndpointAliasRestRep (com.emc.storageos.model.EndpointAliasRestRep)2 HostRestRep (com.emc.storageos.model.host.HostRestRep)2 InitiatorRestRep (com.emc.storageos.model.host.InitiatorRestRep)2 IpInterfaceRestRep (com.emc.storageos.model.host.IpInterfaceRestRep)2 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)2 EndpointInfo (models.datatable.NetworkEndpointDataTable.EndpointInfo)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 NetworkCreate (com.emc.storageos.model.varray.NetworkCreate)1 NetworkEndpointParam (com.emc.storageos.model.varray.NetworkEndpointParam)1 NetworkUpdate (com.emc.storageos.model.varray.NetworkUpdate)1 WebResource (com.sun.jersey.api.client.WebResource)1 FlashException (controllers.util.FlashException)1 URI (java.net.URI)1