use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class BrocadeNetworkSMIS method createZoneSet.
@SuppressWarnings("rawtypes")
public CIMObjectPath createZoneSet(WBEMClient client, CIMInstance zoneServiceIns, String zoneSetName) throws WBEMException {
CIMArgument[] inargs = new CIMArgument[1];
inargs[0] = _cimArgumentFactory.string(_ZoneSetName, zoneSetName);
CIMArgument[] outargs = new CIMArgument[1];
UnsignedInteger32 result = (UnsignedInteger32) client.invokeMethod(zoneServiceIns.getObjectPath(), _CreateZoneSet, inargs, outargs);
if (result.intValue() == 0 && outargs.length > 0) {
return (CIMObjectPath) outargs[0].getValue();
}
return null;
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class BrocadeNetworkSMIS method zonesetHasMore.
/**
* Checks to see if the zoneset has a number of zones that is greater than the count parameter.
* This function is used when deleting zones to check if the zoneset will become
* empty.
*
* @param client and instance of client
* @param zonesetPath the cim path to the zoneset
* @param removeCount the count of zones that will be removed
* @return true if the zoneset will have remaining zones after the number of zones is removed.
* @throws WBEMException
*/
public boolean zonesetHasMore(WBEMClient client, CIMObjectPath zonesetPath, int removeCount) throws WBEMException {
CloseableIterator<CIMObjectPath> zoneItr = null;
int count = 0;
try {
zoneItr = client.associatorNames(zonesetPath, _Brocade_ZoneInZoneSet, _Brocade_Zone, null, null);
while (zoneItr.hasNext()) {
if (zoneItr.next() != null) {
count++;
}
if (count > removeCount) {
return true;
}
}
} finally {
if (zoneItr != null) {
zoneItr.close();
}
}
return false;
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class BrocadeNetworkSMIS method getFCEndpointsByFabric.
/**
* Get FCEndpoints instances by getting TopologyView instances by fabric. This method
* of getting TopologyView instances can be slow in some environments thus the need
* for the alternate function {@link #getFCEndpointsByFabric(WBEMClient, Map, Map, Map, Map)} which is faster but requires more
* memory. The user can select the function best suitable
* using config item controller_ns_brocade_discovery_by_fabric_association
*
* @param client
* WBEMClient
* @param routedConnections
* IN/OUT - A map where routed endpoints will be stored
* @param fabricsByIds
* a map of fabric name to fabric WWN
* @param deviceNameCache
* a map to cache switch names
* @param logicalToPhysicalSwitchMap
* a map to cache logical switches and their container physical switch
* @return a map of endpoint Wwn to its FCEndpoint instance
* @throws WBEMException
*/
private Map<String, FCEndpoint> getFCEndpointsByFabric(WBEMClient client, Map<String, Set<String>> routedConnections, Map<String, String> fabricsByIds, Map<String, String> deviceNameCache, Map<String, String> logicalToPhysicalSwitchMap) throws WBEMException {
long start = System.currentTimeMillis();
_log.info("Getting topology by fabric");
Map<String, FCEndpoint> portConnections = new HashMap<String, FCEndpoint>();
CIMObjectPath path = CimObjectPathCreator.createInstance(_fabric_path, _namespace);
CloseableIterator<CIMInstance> it = null;
try {
it = client.enumerateInstances(path, false, true, true, null);
while (it.hasNext()) {
CIMInstance ins = it.next();
String fabricWwn = formatWWN(cimStringProperty(ins, _name));
String fabricName = cimStringProperty(ins, _element_name);
_log.info("Fabric: " + fabricName + " (" + fabricWwn + ")");
CloseableIterator<CIMInstance> topit = client.associatorInstances(ins.getObjectPath(), _Brocade_TopologyViewInFabric, _Brocade_TopologyView, null, null, false, null);
try {
CIMInstance topins = null;
while (topit.hasNext()) {
topins = topit.next();
_log.debug(topins.toString());
processTopologyViewInstance(client, topins, portConnections, routedConnections, fabricsByIds.get(fabricWwn), fabricWwn, deviceNameCache, logicalToPhysicalSwitchMap);
}
} finally {
if (topit != null) {
topit.close();
}
}
}
} finally {
if (it != null) {
it.close();
}
}
_log.info("Getting topology by fabric took " + (System.currentTimeMillis() - start));
return portConnections;
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class BrocadeNetworkSMIS method getLogicalToPhysicalSwitcheMap.
/**
* get Logical switches to physical switch map
* @param client an instance of WBEMClient
* @return a map of logical to physical switch name
* @throws WBEMException
*/
public HashMap<String, String> getLogicalToPhysicalSwitcheMap(WBEMClient client) throws WBEMException {
HashMap<String, String> switchMap = new HashMap<>();
CIMObjectPath path = new CIMObjectPath(null, null, null, _namespace, _Brocade_SwitchPCS, null);
CloseableIterator<CIMInstance> it = null;
try {
it = client.enumerateInstances(path, false, true, true, null);
while (it.hasNext()) {
CIMInstance ins = it.next();
String parentName = cimStringProperty(ins, _Parent);
String childName = cimStringProperty(ins, _Child);
_log.debug("Brocade Switch: Parent : {} - Child : {} )", parentName, childName);
CIMProperty[] props = ins.getProperties();
for (int i = 0; i < props.length; i++) {
_log.debug("Switch property : " + props[i].getName() + ": value : " + props[i].getValue());
}
CIMInstance parentObject = client.getInstance(new CIMObjectPath(parentName), true, true, null);
CIMInstance childObject = client.getInstance(new CIMObjectPath(childName), true, true, null);
parentName = cimStringProperty(parentObject, _element_name);
childName = cimStringProperty(childObject, _element_name);
switchMap.put(childName, parentName);
_log.info("Brocade Switch: Logical Switch : " + childName + " In (" + parentName + ")");
}
} finally {
if (it != null) {
it.close();
}
}
return switchMap;
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class BrocadeNetworkSystemDevice method createZone.
/**
* Creates the zone in the fabric's active zoneset
*
* @param client an instance of the SMI client
* @param zoneServiceIns the instance of SMI zoneServices
* @param fabricId the fabric id where the zone should created
* @param fabricWwn the fabric WWN where the zone should created
* @param zonesetPath the SMI path of the active zoneset for the fabric
* @param zone the zone to be created
* @return a boolean to indicated if a zone was created or not.
* @throws WBEMException
*/
private boolean createZone(WBEMClient client, CIMInstance zoneServiceIns, String fabricId, String fabricWwn, CIMObjectPath zonesetPath, Zone zone) throws WBEMException {
_log.info("Creating a new zone " + zone.getName());
CIMObjectPath zonePath = _smisHelper.addZone(client, zoneServiceIns, zonesetPath, zone.getName(), fabricId, fabricWwn);
if (zonePath != null) {
boolean success = false;
String name = null;
for (ZoneMember member : zone.getMembers()) {
name = member.getAlias() == null ? member.getAddress() : member.getAlias();
_log.info("Creating zone member: " + name + " zone: " + zone.getName());
success = _smisHelper.addZoneOrAliasMember(client, zoneServiceIns, fabricWwn, zonePath, name);
if (!success) {
_log.info("Failed to create memeber " + name + " for zone : " + zone.getName());
throw NetworkDeviceControllerException.exceptions.addZonesMemberFailedPath(zone.getName(), name);
}
}
} else {
_log.info("Failed to create zone : " + zone.getName());
throw NetworkDeviceControllerException.exceptions.addZonesStrategyFailedPath();
}
return true;
}
Aggregations