use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class BrocadeNetworkSystemDevice method getWBEMClient.
private WBEMClient getWBEMClient(String ipaddress, String smisport, String username, String password, boolean useSSL) throws NetworkDeviceControllerException {
try {
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_049);
WBEMClient client = WBEMClientFactory.getClient(WBEMClientConstants.PROTOCOL_CIMXML);
String protocol = useSSL ? CimConstants.SECURE_PROTOCOL : CimConstants.DEFAULT_PROTOCOL;
CIMObjectPath path = CimObjectPathCreator.createInstance(protocol, ipaddress, smisport.toString(), BrocadeNetworkSMIS.getNamespace(), null, null);
final Subject subject = new Subject();
subject.getPrincipals().add(new UserPrincipal(username));
subject.getPrivateCredentials().add(new PasswordCredential(password));
client.initialize(path, subject, new Locale[] { Locale.US });
return client;
} catch (WBEMException ex) {
_log.info("Failed to connect to Brocade at IP: " + ipaddress + " because: " + ex.getLocalizedMessage());
throw NetworkDeviceControllerException.exceptions.getWBEMClientFailed(ipaddress, ex);
}
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class BrocadeNetworkSystemDevice method activateZones.
@Override
public BiosCommandResult activateZones(NetworkSystem networkSystem, String fabricId, String fabricWwn) throws NetworkDeviceControllerException {
BiosCommandResult result = null;
NetworkDeviceControllerException exception = null;
try {
WBEMClient client = getNetworkDeviceClient(networkSystem);
CIMInstance zonesetIns = _smisHelper.getActiveZonesetInstance(client, fabricId, fabricWwn);
if (zonesetIns != null) {
CIMObjectPath shadowZonesetPath = _smisHelper.getShadowZonesetPath(client, fabricId, fabricWwn, zonesetIns);
CIMInstance zoneServiceIns = _smisHelper.getZoneServiceInstance(client, fabricId, fabricWwn);
boolean activate = !_smisHelper.isEmptyZoneset(client, shadowZonesetPath);
if (_smisHelper.activateZoneSet(client, zoneServiceIns, zonesetIns.getObjectPath(), activate)) {
_log.info("The active zoneset for fabric " + fabricId + " was " + (activate ? "re-activated" : "deactivated"));
} else {
_log.error("Failed to re-activate zoneset");
exception = NetworkDeviceControllerException.exceptions.zonesetActivationFailed(fabricId, new Throwable());
}
} else {
exception = NetworkDeviceControllerException.exceptions.noActiveZonesetForFabric(fabricId);
}
result = BiosCommandResult.createSuccessfulResult();
} catch (Exception ex) {
_log.error("Cannot re-activate zoneset: " + ex.getLocalizedMessage());
exception = NetworkDeviceControllerException.exceptions.zonesetActivationFailed(fabricId, ex);
}
if (exception != null) {
throw exception;
}
return result;
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class DCNMDialog method getFabricIds.
/**
* Get the list of Vsan Ids.
*
* @return List<String>
* @throws Exception
*/
public List<String> getFabricIds() throws Exception {
// A set is used because in the case of a disconnected network the same Vsan can
// show up twice. Conerted to list at end.
Set<String> fabricIds = new HashSet<String>();
List<Zoneset> zonesets = new ArrayList<Zoneset>();
CIMObjectPath path = CimObjectPathCreator.createInstance("Cisco_Vsan", _namespace);
CloseableIterator<CIMInstance> vsanIt = null;
try {
vsanIt = _client.enumerateInstances(path, false, true, true, null);
while (vsanIt.hasNext()) {
String vsanId = null;
CIMInstance vsanIns = vsanIt.next();
CIMProperty prop = vsanIns.getProperty("OtherIdentifyingInfo");
String[] idinfoValue = (String[]) prop.getValue();
if (idinfoValue.length == 2 && idinfoValue[0].equals("Fabric")) {
vsanId = idinfoValue[1];
}
if (vsanId != null) {
fabricIds.add(vsanId);
}
}
} finally {
if (vsanIt != null) {
vsanIt.close();
}
}
List<String> alist = new ArrayList<String>();
alist.addAll(fabricIds);
return alist;
}
use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.
the class DCNMDialog method getClient.
/**
* Initialize the client interface.
*
* @param ipaddress
* @param username
* @param password
* @param smisport
* @return WBEMClient
*/
public WBEMClient getClient(String ipaddress, String username, String password, Integer smisport) {
try {
WBEMClient client = WBEMClientFactory.getClient(WBEMClientConstants.PROTOCOL_CIMXML);
CIMObjectPath path = CimObjectPathCreator.createInstance("http", ipaddress, smisport.toString(), _namespace, null, null);
final Subject subject = new Subject();
subject.getPrincipals().add(new UserPrincipal(username));
subject.getPrivateCredentials().add(new PasswordCredential(password));
client.initialize(path, subject, new Locale[] { Locale.US });
_client = client;
return client;
} catch (WBEMException ex) {
_log.error("Can't open client: WBEMException: " + ex.getLocalizedMessage());
return null;
}
}
use of javax.cim.CIMObjectPath 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;
}
Aggregations