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