use of com.emc.storageos.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.
the class DCNMDialog method getPortConnection.
List<FCEndpoint> getPortConnection() throws Exception {
List<FCEndpoint> connections = new ArrayList<FCEndpoint>();
CIMObjectPath path = CimObjectPathCreator.createInstance("CISCO_LogicalComputerSystem", _namespace);
CloseableIterator<CIMInstance> lcsIt = null;
CloseableIterator<CIMInstance> lportIt = null;
CloseableIterator<CIMInstance> pepIt = null;
try {
lcsIt = _client.enumerateInstances(path, false, true, true, null);
while (lcsIt.hasNext()) {
CIMInstance lcsIns = lcsIt.next();
// Get the VSAN of this Logical COmputer System
String fabricId = null;
String[] identifyingDescriptions = (String[]) lcsIns.getProperty("IdentifyingDescriptions").getValue();
String[] otherIdentifyingInfo = (String[]) lcsIns.getProperty("OtherIdentifyingInfo").getValue();
if (identifyingDescriptions.length >= 2 && identifyingDescriptions[1].equals("VsanId") && otherIdentifyingInfo.length >= 2) {
fabricId = otherIdentifyingInfo[1];
}
// Find the associated CISCO_LogicalFCPort structures
lportIt = _client.associatorInstances(lcsIns.getObjectPath(), "CISCO_FCPortsInLogicalComputerSystem", "CISCO_LogicalFCPort", null, null, false, null);
// Iterate through all the ports in this Vsan, finding connections.
while (lportIt.hasNext()) {
CIMInstance lportIns = lportIt.next();
_log.debug("logical port: " + cimStringProperty(lportIns, "Name") + " wwpn " + cimStringProperty(lportIns, "PermanentAddress"));
String systemName = getSystemNameFromLogicalPort(lportIns);
pepIt = _client.associatorInstances(lportIns.getObjectPath(), "CISCO_FCPortSAPImplementation", "CISCO_ProtocolEndPoint", null, null, false, null);
while (pepIt.hasNext()) {
CIMInstance pepIns = pepIt.next();
_log.debug("endpoint: " + cimStringProperty(pepIns, "Name"));
FCProtocolEndpoint pep = new FCProtocolEndpoint(pepIns);
pep.findConnections(_client, _namespace);
for (String key : pep.connections.keySet()) {
_log.debug("connection: " + key);
FCProtocolEndpoint cep = pep.connections.get(key);
FCEndpoint conn = new FCEndpoint();
// conn.setFabricId(fabricId)
conn.setRemotePortName(formatWWN(cep.wwpn));
conn.setLabel(conn.getRemotePortName());
conn.setRemoteNodeName(formatWWN(cep.wwnn));
conn.setSwitchPortName(formatWWN(cimStringProperty(lportIns, "PermanentAddress")));
conn.setSwitchInterface(cimStringProperty(lportIns, "Name"));
conn.setFabricId(fabricId);
conn.setSwitchName(systemName);
connections.add(conn);
}
}
pepIt.close();
pepIt = null;
}
lportIt.close();
lportIt = null;
}
} finally {
if (lcsIt != null) {
lcsIt.close();
}
if (lportIt != null) {
lportIt.close();
}
if (pepIt != null) {
pepIt.close();
}
}
return connections;
}
use of com.emc.storageos.db.client.model.FCEndpoint 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.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.
the class MDSDialogTest method testNonIvr.
static void testNonIvr(MDSDialog dialog) throws Exception {
Map<Integer, String> vsanToWwns = dialog.getVsanWwns(null);
for (Integer vsan : vsanToWwns.keySet()) {
String wwn = vsanToWwns.get(vsan);
_log.info("Vsan {} WWN {}", vsan, wwn);
}
boolean isSessionInProgress = dialog.isSessionInProgress(3178);
isSessionInProgress = dialog.isSessionInProgress(new Integer(vsanId));
if (isSessionInProgress) {
throw new Exception("Session in progress vsan: " + vsanId);
}
// dialog.showInterface();
// dialog.showFlogiDatabase();
List<FCEndpoint> connections = dialog.showFcnsDatabase(null);
for (FCEndpoint cn : connections) {
String msg = MessageFormat.format("connection: {0} {1}:{2} {3} remote {4} {5} fabric {6}", cn.getFabricId(), cn.getSwitchName(), cn.getSwitchInterface(), cn.getSwitchPortName(), cn.getRemotePortName(), cn.getRemotePortName(), cn.getFabricWwn());
_log.info(msg);
}
dialog.showVsan(true);
// Print vsans, zonesets, zones, zone members
for (String key : Vsan.vsanIdToVsan.keySet()) {
Vsan v = Vsan.vsanIdToVsan.get(key);
System.out.println("VSAN: " + v.vsanName);
v.print();
}
testZoning(dialog, new Integer(vsanId));
}
use of com.emc.storageos.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.
the class MdsNetworkSystemDevice method getRoutedEndpoints.
@Override
public Set<String> getRoutedEndpoints(NetworkSystem networkSystem, String fabricId, String fabricWwn) throws Exception {
MDSDialog dialog = null;
Set<String> routedEndpoints = Sets.newHashSet();
try {
dialog = setUpDialog(networkSystem);
List<FCEndpoint> fcEndpoints = dialog.showFcnsDatabase(Integer.valueOf(fabricId));
if (fcEndpoints != null) {
for (FCEndpoint fcEndpoint : fcEndpoints) {
if (MDS_ROUTED_INDICATOR.equalsIgnoreCase(fcEndpoint.getSwitchInterface())) {
routedEndpoints.add(fcEndpoint.getRemotePortName());
}
}
}
} finally {
if (dialog != null) {
disconnect(dialog);
}
}
return routedEndpoints;
}
use of com.emc.storageos.db.client.model.FCEndpoint in project coprhd-controller by CoprHD.
the class MdsNetworkSystemDevice method getPortConnections.
@Override
public List<FCEndpoint> getPortConnections(NetworkSystem network, Map<String, Set<String>> routedEndpoints) throws Exception {
MDSDialog dialog = null;
try {
dialog = setUpDialog(network);
List<FCEndpoint> connections = dialog.showFcnsDatabase(null);
// removing all the endpoints that are associated by routing
Iterator<FCEndpoint> itr = connections.iterator();
FCEndpoint ep = null;
while (itr.hasNext()) {
ep = itr.next();
if (MDS_ROUTED_INDICATOR.equalsIgnoreCase(ep.getSwitchInterface()) && ep.getFabricWwn() != null) {
Set<String> netRoutedEndpoints = routedEndpoints.get(ep.getFabricWwn());
if (netRoutedEndpoints == null) {
netRoutedEndpoints = new HashSet<String>();
routedEndpoints.put(ep.getFabricWwn(), netRoutedEndpoints);
}
netRoutedEndpoints.add(ep.getRemotePortName());
itr.remove();
}
}
dialog.populateConnectionByIvrZone(routedEndpoints);
return connections;
} catch (Exception ex) {
_log.error("Cannot read FCNS database from device: " + network.getLabel() + ": " + ex.getLocalizedMessage());
throw ex;
} finally {
disconnect(dialog);
}
}
Aggregations