Search in sources :

Example 51 with CIMObjectPath

use of javax.cim.CIMObjectPath 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 52 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class AbstractCIMObjectPathFactory method getSyncObject.

/**
 * Return a single CIM_StorageSynchronized instance referenced by the given BlockObject.
 *
 * @deprecated In cases where there may be more than one CIM_StorageSynchronized instance, we
 *             should favor using #getSyncObjects instead and inspect each instances'
 *             [System|Synced] Element property to ensure that we're operating on the correct
 *             one.
 * @param storage
 * @param subject
 * @return
 */
public CIMObjectPath getSyncObject(StorageSystem storage, BlockObject subject) {
    CloseableIterator<CIMObjectPath> syncReference = null;
    CIMObjectPath syncObjectPath = NULL_CIM_OBJECT_PATH;
    try {
        syncReference = getSyncObjects(storage, subject);
        if (syncReference != null) {
            while (syncReference.hasNext()) {
                syncObjectPath = syncReference.next();
                if (syncObjectPath != null) {
                    break;
                }
            }
        }
    } finally {
        if (syncReference != null) {
            syncReference.close();
        }
    }
    return syncObjectPath;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath)

Example 53 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class AbstractCloneOperations method fractureSingleClone.

@Override
@SuppressWarnings("rawtypes")
public void fractureSingleClone(StorageSystem storageSystem, URI source, URI cloneVolume, TaskCompleter taskCompleter) {
    _log.info("START fractureSingleClone operation");
    Volume clone = null;
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storageSystem, Arrays.asList(cloneVolume));
        clone = _dbClient.queryObject(Volume.class, cloneVolume);
        URI sourceUri = clone.getAssociatedSourceVolume();
        if (!NullColumnValueGetter.isNullURI(sourceUri)) {
            BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceUri);
            if (sourceObj != null) {
                StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceObj.getStorageController());
                CIMObjectPath syncObject = _cimPath.getStorageSynchronized(sourceSystem, sourceObj, storageSystem, clone);
                CIMInstance instance = _helper.checkExists(storageSystem, syncObject, false, false);
                if (instance != null) {
                    fractureReplica(storageSystem, syncObject);
                } else {
                    String errorMsg = "The clone is already detached. fracture will not be performed.";
                    _log.info(errorMsg);
                    ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
                    taskCompleter.error(_dbClient, error);
                }
            } else {
                String errorMsg = "The clone's source volume cannot be found in the database. Fractrure will not be performed.";
                _log.info(errorMsg);
                ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
                taskCompleter.error(_dbClient, error);
            }
        } else {
            String errorMsg = "The clone does not have a source volume. Fracture will not be performed.";
            _log.info(errorMsg);
            ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
            taskCompleter.error(_dbClient, error);
        }
        clone.setReplicaState(ReplicationState.SYNCHRONIZED.name());
        _dbClient.persistObject(clone);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        String errorMsg = String.format(FRACTURE_ERROR_MSG_FORMAT, cloneVolume, clone.getAssociatedSourceVolume());
        _log.error(errorMsg, e);
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.fractureFullCopyFailed(e));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 54 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class AbstractCloneOperations method resyncSingleClone.

@Override
@SuppressWarnings("rawtypes")
public void resyncSingleClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
    _log.info("START resyncSingleClone operation");
    Volume clone = null;
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storageSystem, Arrays.asList(cloneVolume));
        clone = _dbClient.queryObject(Volume.class, cloneVolume);
        URI sourceUri = clone.getAssociatedSourceVolume();
        Volume sourceObj = _dbClient.queryObject(Volume.class, sourceUri);
        StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceObj.getStorageController());
        CIMObjectPath syncObject = _cimPath.getStorageSynchronized(sourceSystem, sourceObj, storageSystem, clone);
        CIMInstance instance = _helper.checkExists(storageSystem, syncObject, false, false);
        if (instance != null) {
            CIMArgument[] inArgs = _helper.getResyncReplicaInputArguments(syncObject);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.callModifyReplica(storageSystem, inArgs, outArgs);
            CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneResyncJob(job, storageSystem.getId(), taskCompleter)));
            }
        } else {
            String errorMsg = "The clone is already detached. resync will not be performed.";
            _log.info(errorMsg);
            ServiceError error = DeviceControllerErrors.smis.methodFailed("resyncSingleClone", errorMsg);
            taskCompleter.error(_dbClient, error);
        }
    } catch (Exception e) {
        String errorMsg = String.format(RESYNC_ERROR_MSG_FORMAT, cloneVolume);
        _log.error(errorMsg, e);
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.resynchronizeFullCopyFailed(e));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) SmisCloneResyncJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneResyncJob) CIMObjectPath(javax.cim.CIMObjectPath) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 55 with CIMObjectPath

use of javax.cim.CIMObjectPath in project coprhd-controller by CoprHD.

the class AbstractCloneOperations method getReplicationSettingDataInstanceForThinProvisioningPolicy.

@SuppressWarnings("rawtypes")
private CIMInstance getReplicationSettingDataInstanceForThinProvisioningPolicy(final StorageSystem storageSystem, int desiredValue) {
    CIMInstance modifiedInstance = null;
    try {
        CIMObjectPath replicationSettingCapabilities = _cimPath.getReplicationServiceCapabilitiesPath(storageSystem);
        CIMArgument[] inArgs = _helper.getReplicationSettingDataInstance();
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storageSystem, replicationSettingCapabilities, GET_DEFAULT_REPLICATION_SETTING_DATA, inArgs, outArgs);
        for (CIMArgument<?> outArg : outArgs) {
            if (null == outArg) {
                continue;
            }
            if (outArg.getName().equalsIgnoreCase(SmisConstants.DEFAULT_INSTANCE)) {
                CIMInstance repInstance = (CIMInstance) outArg.getValue();
                if (null != repInstance) {
                    CIMProperty<?> thinProvisioningPolicy = new CIMProperty<Object>(SmisConstants.THIN_PROVISIONING_POLICY, UINT16_T, new UnsignedInteger16(desiredValue));
                    CIMProperty<?> targetElementSupplier = new CIMProperty<Object>(TARGET_ELEMENT_SUPPLIER, UINT16_T, new UnsignedInteger16(CREATE_NEW_TARGET_VALUE));
                    CIMProperty<?>[] propArray = new CIMProperty<?>[] { thinProvisioningPolicy, targetElementSupplier };
                    modifiedInstance = repInstance.deriveInstance(propArray);
                    break;
                }
            }
        }
    } catch (Exception e) {
        _log.error("Error retrieving Replication Setting Data Instance ", e);
    }
    return modifiedInstance;
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) UnsignedInteger16(javax.cim.UnsignedInteger16) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

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