Search in sources :

Example 11 with CIMObjectPath

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);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) PasswordCredential(javax.wbem.client.PasswordCredential) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) Subject(javax.security.auth.Subject) UserPrincipal(javax.wbem.client.UserPrincipal)

Example 12 with CIMObjectPath

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;
}
Also used : NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Example 13 with CIMObjectPath

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;
}
Also used : CIMProperty(javax.cim.CIMProperty) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) HashSet(java.util.HashSet)

Example 14 with CIMObjectPath

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;
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) PasswordCredential(javax.wbem.client.PasswordCredential) WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException) Subject(javax.security.auth.Subject) UserPrincipal(javax.wbem.client.UserPrincipal)

Example 15 with CIMObjectPath

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;
}
Also used : ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) CIMInstance(javax.cim.CIMInstance)

Aggregations

CIMObjectPath (javax.cim.CIMObjectPath)582 CIMInstance (javax.cim.CIMInstance)254 WBEMException (javax.wbem.WBEMException)236 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)208 CIMArgument (javax.cim.CIMArgument)190 ArrayList (java.util.ArrayList)139 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)118 Volume (com.emc.storageos.db.client.model.Volume)108 URI (java.net.URI)108 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)82 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)76 WBEMClient (javax.wbem.client.WBEMClient)75 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)72 HashSet (java.util.HashSet)68 HashMap (java.util.HashMap)63 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)57 CIMProperty (javax.cim.CIMProperty)57 IOException (java.io.IOException)55 BlockObject (com.emc.storageos.db.client.model.BlockObject)52 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)52