Search in sources :

Example 1 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException 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 2 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class RPInsertion method injectColumnsDetails.

@Override
public void injectColumnsDetails(Stat statObj, DbClient client) throws Exception {
    ProtectionSystem protectionObj = client.queryObject(ProtectionSystem.class, statObj.getResourceId());
    // Given a protection system, find a volume protected by this protection system,
    // and then extract the project and vpool
    Volume protectedVolume = null;
    URIQueryResultList resultList = new URIQueryResultList();
    client.queryByConstraint(ContainmentConstraint.Factory.getProtectionSystemVolumesConstraint(protectionObj.getId()), resultList);
    for (Iterator<URI> volumeItr = resultList.iterator(); volumeItr.hasNext(); ) {
        Volume volume = client.queryObject(Volume.class, volumeItr.next());
        if (volume.getProtectionController().equals(protectionObj.getId())) {
            protectedVolume = volume;
            break;
        }
    }
    if (protectedVolume != null) {
        _logger.info("Found volume " + protectedVolume.getWWN() + " protected by this protection controller.  Get the Cos/Project/Tenant.");
        statObj.setProject(protectedVolume.getProject().getURI());
        statObj.setVirtualPool(protectedVolume.getVirtualPool());
        statObj.setTenant(protectedVolume.getTenant().getURI());
    } else {
        statObj.setProject(null);
        statObj.setVirtualPool(null);
        statObj.setTenant(null);
        throw new SMIPluginException("Cassandra Database Insertion Error.  Cannot identify Project/CoS/Tenant for ProtectionSystem", -1);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 3 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class ConnectionManagerUtils method disallowReaping.

public void disallowReaping(Object profile, Object client) throws BaseCollectionException {
    AccessProfile accessProfile = (AccessProfile) profile;
    DbClient dbClient = (DbClient) client;
    try {
        final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
        connectionFactory.setKeepAliveForConnection(storageSystem);
    } catch (final IllegalStateException ex) {
        log.error("Not able to get CIMOM Client instance for ip {} due to ", accessProfile.getIpAddress(), ex);
        throw new SMIPluginException(SMIPluginException.ERRORCODE_NO_WBEMCLIENT, ex.fillInStackTrace(), ex.getMessage());
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class FirmwareProcessor method processResult.

/**
 * {@inheritDoc}
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        String serialNumber = null;
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        String delimiter = Constants.PATH_DELIMITER_REGEX;
        if (Type.ibmxiv.name().equals(profile.getSystemType())) {
            delimiter = Pattern.quote(Constants.COLON);
        }
        if (it.hasNext()) {
            // e.g., IBM XIV InstanceID, IBMTSDS:IBM.2810-7825363
            CIMInstance firmwareInstance = it.next();
            serialNumber = firmwareInstance.getPropertyValue(INSTANCEID).toString().split(delimiter)[1];
            String nativeGuid = NativeGUIDGenerator.generateNativeGuid(profile.getSystemType(), serialNumber);
            List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, nativeGuid);
            if (!systems.isEmpty()) {
                StorageSystem system = systems.get(0);
                checkFirmwareVersion(firmwareInstance, system);
            }
        } else {
            String errMsg = String.format("No information obtained from Provider %s for Firmware version", profile.getIpAddress());
            throw new SMIPluginException(errMsg, SMIPluginException.ERRORCODE_OPERATIONFAILED);
        }
    } catch (SMIPluginException e) {
        throw e;
    } catch (Exception e) {
        String errMsg = String.format("An error occurred while verifying Firmware version: %s", e.getMessage());
        throw new SMIPluginException(SMIPluginException.ERRORCODE_OPERATIONFAILED, e, errMsg);
    }
}
Also used : Iterator(java.util.Iterator) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) AccessProfile(com.emc.storageos.plugins.AccessProfile) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with SMIPluginException

use of com.emc.storageos.plugins.metering.smis.SMIPluginException in project coprhd-controller by CoprHD.

the class SoftwareIdentityProcessor method processResult.

/**
 * {@inheritDoc}
 */
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    AccessProfile profile = null;
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        coordinator = (CoordinatorClient) keyMap.get(Constants.COORDINATOR_CLIENT);
        profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        @SuppressWarnings("unchecked") final Iterator<CIMInstance> it = (Iterator<CIMInstance>) resultObj;
        if (it.hasNext()) {
            CIMInstance softwareInstance = it.next();
            String providerId = profile.getIpAddress() + "-" + profile.getProviderPort();
            List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerId);
            if (!providers.isEmpty()) {
                checkProviderVersion(softwareInstance, providers.get(0));
            }
        } else {
            String errMsg = String.format("No information obtained from Provider %s for Provider version", profile.getIpAddress());
            throw new SMIPluginException(errMsg, SMIPluginException.ERRORCODE_OPERATIONFAILED);
        }
    } catch (SMIPluginException e) {
        throw e;
    } catch (Exception e) {
        String errMsg = String.format("An error occurred while verifying Provider version: %s", e.getMessage());
        throw new SMIPluginException(SMIPluginException.ERRORCODE_OPERATIONFAILED, e, errMsg);
    }
}
Also used : Iterator(java.util.Iterator) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) AccessProfile(com.emc.storageos.plugins.AccessProfile) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Aggregations

SMIPluginException (com.emc.storageos.plugins.metering.smis.SMIPluginException)22 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)12 List (java.util.List)7 CIMObjectPath (javax.cim.CIMObjectPath)7 WBEMException (javax.wbem.WBEMException)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 AccessProfile (com.emc.storageos.plugins.AccessProfile)6 IOException (java.io.IOException)5 URI (java.net.URI)5 CIMInstance (javax.cim.CIMInstance)5 DbClient (com.emc.storageos.db.client.DbClient)4 Stat (com.emc.storageos.db.client.model.Stat)4 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)3 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)3 LocalReplicaObject (com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.LocalReplicaObject)3 RemoteMirrorObject (com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.processor.detailedDiscovery.RemoteMirrorObject)3 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)3 Iterator (java.util.Iterator)3 CIMArgument (javax.cim.CIMArgument)3