Search in sources :

Example 16 with NetworkRestRep

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

the class Networks method endpointsJson.

/**
 * Creates and renders JSON datatable source for endpoints for the given network.
 *
 * @param networkId
 *            the network ID.
 */
public static void endpointsJson(String networkId) {
    NetworkRestRep network = NetworkUtils.getNetwork(networkId);
    if (network == null) {
        error(MessagesUtils.get(UNKNOWN, networkId));
    }
    List<EndpointInfo> items = Lists.newArrayList();
    // All known endpoints, remove endpoints from storage systems and hosts to get manual endpoints
    Set<String> endpoints = Sets.newTreeSet(new Comparator<String>() {

        @Override
        public int compare(String s1, String s2) {
            return s1.compareToIgnoreCase(s2);
        }
    });
    endpoints.addAll(network.getEndpoints());
    // Add ports from storage systems
    CachedResources<StorageSystemRestRep> storageSystems = StorageSystemUtils.createCache();
    for (StoragePortRestRep storagePort : StoragePortUtils.getStoragePortsByNetwork(network.getId())) {
        items.add(new EndpointInfo(storagePort, storageSystems));
        for (String endpoint : NetworkUtils.getEndPoints(storagePort)) {
            endpoints.remove(endpoint);
        }
    }
    // Add ports from hosts
    CachedResources<HostRestRep> hosts = HostUtils.createCache();
    for (InitiatorRestRep initiator : NetworkUtils.getInitiators(network.getId())) {
        if (initiator.getHost() != null) {
            items.add(new EndpointInfo(initiator, hosts));
            endpoints.remove(NetworkUtils.getEndPoint(initiator));
        }
    }
    for (IpInterfaceRestRep ipInterface : NetworkUtils.getIpInterfaces(network.getId())) {
        if (ipInterface.getHost() != null) {
            items.add(new EndpointInfo(ipInterface, hosts));
            endpoints.remove(NetworkUtils.getEndPoint(ipInterface));
        }
    }
    // Add any remaining endpoints as 'manual'
    for (String endpoint : endpoints) {
        items.add(new EndpointInfo(endpoint));
    }
    setEndpointAttrs(network, items);
    renderJSON(DataTablesSupport.createJSON(items, params));
}
Also used : StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) InitiatorRestRep(com.emc.storageos.model.host.InitiatorRestRep) IpInterfaceRestRep(com.emc.storageos.model.host.IpInterfaceRestRep) EndpointInfo(models.datatable.NetworkEndpointDataTable.EndpointInfo) HostRestRep(com.emc.storageos.model.host.HostRestRep) 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