Search in sources :

Example 91 with WBEMException

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

the class SmisStorageDevice method doExpandVolume.

@Override
public void doExpandVolume(final StorageSystem storageSystem, final StoragePool pool, final Volume volume, final Long size, final TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info(String.format("Expand Volume Start - Array: %s, Pool: %s, Volume: %s, New size: %d", storageSystem.getSerialNumber(), pool.getNativeGuid(), volume.getLabel(), size));
    MetaVolumeTaskCompleter metaVolumeTaskCompleter = new MetaVolumeTaskCompleter(taskCompleter);
    try {
        if (!doesStorageSystemSupportVolumeExpand(storageSystem)) {
            ServiceError error = DeviceControllerErrors.smis.volumeExpandIsNotSupported(storageSystem.getNativeGuid());
            taskCompleter.error(_dbClient, error);
            return;
        }
        boolean tagSet = _helper.doApplyRecoverPointTag(storageSystem, volume, false);
        if (!tagSet) {
            ServiceError error = DeviceControllerErrors.smis.errorSettingRecoverPointTag("disable");
            taskCompleter.error(_dbClient, error);
            return;
        }
        CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
        CIMArgument[] inArgs = _helper.getExpandVolumeInputArguments(storageSystem, pool, volume, size);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storageSystem, configSvcPath, SmisConstants.CREATE_OR_MODIFY_ELEMENT_FROM_STORAGE_POOL, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisVolumeExpandJob(job, storageSystem.getId(), pool.getId(), metaVolumeTaskCompleter, "ExpandVolume")));
        }
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
    } catch (Exception e) {
        _log.error("Problem in doExpandVolume: ", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("doExpandVolume", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _log.info(String.format("Expand Volume End - Array: %s, Pool: %s, Volume: %s", storageSystem.getSerialNumber(), pool.getNativeGuid(), volume.getLabel()));
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) MetaVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MetaVolumeTaskCompleter) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument) SmisVolumeExpandJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisVolumeExpandJob)

Example 92 with WBEMException

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

the class SmisStorageDevice method doRemoveStorageSystem.

@Override
public void doRemoveStorageSystem(final StorageSystem storage) throws DeviceControllerException {
    try {
        CIMObjectPath seSystemRegistrationSvc = _helper.getRegistrationService(storage);
        CIMArgument[] inArgs = _helper.getRemStorageCIMArguments(storage);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, seSystemRegistrationSvc, SmisConstants.EMC_REMOVE_SYSTEM, inArgs, outArgs);
    } catch (WBEMException ex) {
        _log.debug("Failed to remove storage system from SMI-S Provider : " + ex.getMessage());
        throw new DeviceControllerException(ex);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 93 with WBEMException

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

the class SmisStorageDevice method doInitiatorAliasGet.

/**
 * This method will be used to get the Initiator Alias for a given initiator.
 * The SMI-S version that supports this operation is Version 8.2 onwards.
 * The initiator must be part of the an Initiator Group for the Value to be retrieved
 * If the Alias is not set, an EMPTY string will be returned
 *
 * @param storage
 *            - StorageSystem object
 * @param initiator
 *            - Initiator Object for which the Alias needs to be set
 * @return initiatorAlias - User Friendly Name
 * @throws Exception
 */
@Override
public String doInitiatorAliasGet(StorageSystem storage, Initiator initiator) throws Exception {
    String initiatorAlias = null;
    try {
        checkIfProviderSupportsAliasOperations(storage);
        CIMObjectPath hwManagementIDSvcPath = _cimPath.getStorageHardwareIDManagementService(storage);
        CIMObjectPath shidPath = getSHIDPathForAliasOperation(storage, hwManagementIDSvcPath, initiator);
        CIMArgument[] inArgs = _helper.getEMCInitiatorAliasGetArgs(shidPath);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, hwManagementIDSvcPath, SmisConstants.INITIATOR_ALIAS_GET, inArgs, outArgs);
        for (CIMArgument arg : outArgs) {
            if (arg != null && arg.getName().equalsIgnoreCase(SmisConstants.CP_ALIAS_STORAGEID)) {
                initiatorAlias = (String) arg.getValue();
            }
        }
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        throw e;
    } catch (Exception e) {
        _log.error("Unexpected error: EMCInitiatorAliasGet failed.", e);
        throw e;
    }
    return initiatorAlias;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 94 with WBEMException

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

the class SmisStorageDevice method getSHIDPathForAliasOperation.

/**
 * Get the StorageHardwareID CIM path when found on the Storage System
 * Throw an exception if it is not found.
 *
 * @param storage
 *            storage system
 * @param hwManagementIDSvcPath
 * @param initiator
 *            initiator Object
 * @return CIMObjectPath corresponding to that StorageHardwareID
 * @throws Exception
 */
private CIMObjectPath getSHIDPathForAliasOperation(StorageSystem storage, CIMObjectPath hwManagementIDSvcPath, Initiator initiator) throws Exception {
    // Multiple arrays can be managed by a single SMI-S instance. The SE_StorageHardwareID is
    // global to the provider, so we need to get the SE_StorageHardware_ID object that are
    // associated with a specific array.
    CIMObjectPath shidPath = null;
    String normalizedPortName = Initiator.normalizePort(initiator.getInitiatorPort());
    CloseableIterator<CIMInstance> initiatorInstances = null;
    try {
        initiatorInstances = _helper.getAssociatorInstances(storage, hwManagementIDSvcPath, null, SmisConstants.CP_SE_STORAGE_HARDWARE_ID, null, null, SmisConstants.PS_STORAGE_ID);
        while (initiatorInstances.hasNext()) {
            CIMInstance initiatorInstance = initiatorInstances.next();
            String storageId = CIMPropertyFactory.getPropertyValue(initiatorInstance, SmisConstants.CP_STORAGE_ID);
            if (normalizedPortName.equals(storageId)) {
                shidPath = initiatorInstance.getObjectPath();
                break;
            }
        }
    } catch (WBEMException we) {
        _log.error("Caught an error will attempting to execute query and process query result. Query: ", we);
    } finally {
        initiatorInstances.close();
    }
    if ((shidPath == null) || shidPath.toString().isEmpty()) {
        String errMsg = String.format("Supplied initiator: %s was not found on the Storage System: %s", normalizedPortName, storage.getSerialNumber());
        _log.error(errMsg);
        throw DeviceControllerException.exceptions.couldNotPerformAliasOperation(errMsg);
    }
    return shidPath;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance)

Example 95 with WBEMException

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

the class SmisStorageDevice method doAddSnapshotSessionsToConsistencyGroup.

@Override
public void doAddSnapshotSessionsToConsistencyGroup(StorageSystem storageSystem, URI consistencyGroup, List<URI> volumes, TaskCompleter taskCompleter) {
    List<? extends BlockObject> blockObjects = BlockObject.fetch(_dbClient, volumes);
    BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
    Map<String, List<BlockSnapshotSession>> sessionLabelsMap = new HashMap<>();
    for (BlockObject blockObject : blockObjects) {
        List<BlockSnapshotSession> sessions = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(blockObject.getId()));
        if (!sessions.isEmpty()) {
            for (BlockSnapshotSession session : sessions) {
                if (!sessionLabelsMap.containsKey(session.getSessionLabel())) {
                    sessionLabelsMap.put(session.getSessionLabel(), new ArrayList<BlockSnapshotSession>());
                }
                sessionLabelsMap.get(session.getSessionLabel()).add(session);
            }
        }
    }
    try {
        fabricateSourceGroupAspects(storageSystem, cg, sessionLabelsMap);
        taskCompleter.ready(_dbClient);
    } catch (WBEMException e) {
        _log.error("Problem in adding snapshot sessions to Consistency Group {}", consistencyGroup, e);
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.failedToAddMembersToConsistencyGroup(cg.getLabel(), cg.getCgNameOnStorageSystem(storageSystem.getId()), e.getMessage()));
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) WBEMException(javax.wbem.WBEMException) BlockObject(com.emc.storageos.db.client.model.BlockObject) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

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