Search in sources :

Example 6 with WBEMException

use of javax.wbem.WBEMException 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 7 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class DCNMDialog method startSession.

/**
 * @param client
 * @param zonesetService -- Instance of the ZonesetService
 * @return true iff session is started
 * @throws NetworkControllerSessionLockedException
 * @throws WBEMException
 */
@SuppressWarnings("rawtypes")
public boolean startSession(WBEMClient client, CIMInstance zonesetService) throws NetworkControllerSessionLockedException, WBEMException {
    UnsignedInteger32 result = null;
    try {
        int sessionState = cimIntegerProperty(zonesetService, "SessionState");
        int RequestedSessionState = cimIntegerProperty(zonesetService, "RequestedSessionState");
        if (sessionState == _notApplicable) {
            // no session control implemented by this agent
            return true;
        }
        // if (sessionState != _ended || RequestedSessionState != _noChange) {
        // _log.error("Zone session is locked by another user or agent.");
        // throw new NetworkControllerSessionLockedException(
        // "Zone session is locked by another user or agent.");
        // }
        CIMArgument[] inargs = new CIMArgument[] { _cimArgumentFactory.uint16("RequestedSessionState", _started) };
        result = (UnsignedInteger32) client.invokeMethod(zonesetService.getObjectPath(), "SessionControl", inargs, new CIMArgument[1]);
        _log.info("Start session returned code: " + result.intValue());
        return (result.intValue() == 0 || result.intValue() == 32772);
    } catch (WBEMException ex) {
        _log.error("Encountered an exception while trying to start a zone session." + ex.getLocalizedMessage());
        throw ex;
    }
}
Also used : UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMException(javax.wbem.WBEMException) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) CIMArgument(javax.cim.CIMArgument)

Example 8 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class DCNMDialog method getZonesetsInVsan.

/**
 * Returns the zonesets in a VSAN as given by its CIMInstance.
 * This generates the nested objects Zone and ZoneMember in the Zonesets.
 *
 * @param vsanIns CIMInstance of vsan
 * @return List<Zoneset>
 * @throws javax.wbem.WBEMException
 */
private List<Zoneset> getZonesetsInVsan(CIMInstance vsanIns) throws WBEMException {
    List<Zoneset> inactiveZonesets = new ArrayList<Zoneset>();
    Zoneset activeZoneset = null;
    // Iterate through the zonesets.
    CloseableIterator<CIMInstance> zstIt = null;
    try {
        zstIt = _client.associatorInstances(vsanIns.getObjectPath(), "CIM_HostedCollection", "CISCO_Zoneset", null, null, false, null);
        while (zstIt.hasNext()) {
            CIMInstance zsIns = zstIt.next();
            Zoneset zs = makeZoneset(zsIns);
            _log.debug("zoneset: " + zs.name);
            if (zs.active == true) {
                activeZoneset = zs;
            } else {
                inactiveZonesets.add(zs);
            }
        }
    } catch (WBEMException ex) {
    // Problem where iterator isn't returned in associators();
    } finally {
        if (zstIt != null) {
            zstIt.close();
        }
    }
    List<Zoneset> zonesets = new ArrayList<Zoneset>();
    if (activeZoneset != null) {
        zonesets.add(activeZoneset);
    }
    zonesets.addAll(inactiveZonesets);
    return zonesets;
}
Also used : ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 9 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class HDSCommunicationInterface method getCIMClient.

/**
 * Creates a new WEBClient for a given IP, based on AccessProfile
 *
 * @param accessProfile
 *            : AccessProfile for the providers
 * @throws WBEMException
 *             : if WBEMException while creating the WBEMClient
 * @throws SMIPluginException
 * @return WBEMClient : initialized instance of WBEMClientCIMXML
 */
private WBEMClient getCIMClient(AccessProfile accessProfile) throws Exception {
    String protocol = Boolean.valueOf(accessProfile.getSslEnable()) ? CimConstants.SECURE_PROTOCOL : CimConstants.DEFAULT_PROTOCOL;
    CIMObjectPath path = CimObjectPathCreator.createInstance(protocol, accessProfile.getIpAddress(), Integer.toString(accessProfile.getPortNumber()), accessProfile.getInteropNamespace(), null, null);
    try {
        Subject subject = new Subject();
        subject.getPrincipals().add(new UserPrincipal(accessProfile.getUserName()));
        subject.getPrivateCredentials().add(new PasswordCredential(accessProfile.getPassword()));
        wbemClient = WBEMClientFactory.getClient(CimConstants.CIM_CLIENT_PROTOCOL);
        // Operations block by default, so a timeout must be set in case the
        // CIM server becomes unreachable.
        // Commenting out, as timeout had been moved to cimom.properties
        // file
        // _cimClient.setProperty(WBEMClientConstants.PROP_TIMEOUT,
        // CimConstants.CIM_CLIENT_TIMEOUT);
        wbemClient.initialize(path, subject, null);
    } catch (Exception e) {
        _logger.error("Could not establish connection for {}", accessProfile.getIpAddress(), e);
        wbemClient.close();
        throw e;
    }
    return wbemClient;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) PasswordCredential(javax.wbem.client.PasswordCredential) Subject(javax.security.auth.Subject) UserPrincipal(javax.wbem.client.UserPrincipal) HDSCollectionException(com.emc.storageos.volumecontroller.impl.hds.HDSCollectionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) HDSException(com.emc.storageos.hds.HDSException) WBEMException(javax.wbem.WBEMException) IOException(java.io.IOException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 10 with WBEMException

use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.

the class CIMConnectionFactory method checkConnectionliveness.

/**
 * To-Do: check for Connection liveness 1. if null, add a new Connection. 2.
 * if connection present, then check for liveness.
 *
 * @return boolean
 */
public boolean checkConnectionliveness(CimConnection connection) {
    boolean isLive = false;
    if (null == connection) {
        return isLive;
    }
    WBEMClient wbemClient = connection.getCimClient();
    _log.debug("copPath:{}", _cop);
    try {
        // Call the provider to get computer systems.
        wbemClient.enumerateInstanceNames(_cop);
        isLive = true;
    } catch (WBEMException wbemEx) {
        _log.error("Invalid connection found for ipAddress: {}", connection.getHost());
    }
    return isLive;
}
Also used : WBEMClient(javax.wbem.client.WBEMClient) WBEMException(javax.wbem.WBEMException)

Aggregations

WBEMException (javax.wbem.WBEMException)122 CIMObjectPath (javax.cim.CIMObjectPath)90 CIMInstance (javax.cim.CIMInstance)63 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)60 CIMArgument (javax.cim.CIMArgument)52 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)38 ArrayList (java.util.ArrayList)29 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)27 Volume (com.emc.storageos.db.client.model.Volume)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 WBEMClient (javax.wbem.client.WBEMClient)19 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)16 HashSet (java.util.HashSet)15 URI (java.net.URI)13 HashMap (java.util.HashMap)13 BlockObject (com.emc.storageos.db.client.model.BlockObject)10 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)9 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)8