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