Search in sources :

Example 71 with WBEMException

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

the class MultipleVmaxMaskForInitiatorsValidator method getVolumesFromLunMaskingInstance.

/**
 * Get Volumes from the Masking view.
 * @param client
 * @param instance
 * @return
 * @throws WBEMException
 */
public Set<String> getVolumesFromLunMaskingInstance(CIMInstance instance) throws WBEMException {
    Set<String> wwnList = new HashSet<String>();
    CloseableIterator<CIMInstance> iterator = null;
    try {
        log.info(String.format("getVolumesFromLunMaskingInstance(%s)", instance.getObjectPath().toString()));
        iterator = getHelper().getAssociatorInstances(storage, instance.getObjectPath(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null, SmisConstants.PS_EMCWWN);
        while (iterator.hasNext()) {
            CIMInstance cimInstance = iterator.next();
            String wwn = CIMPropertyFactory.getPropertyValue(cimInstance, SmisConstants.CP_WWN_NAME);
            wwnList.add(wwn);
        }
        log.info(String.format("getVolumesFromLunMaskingInstance(%s)", instance.getObjectPath().toString()));
    } catch (WBEMException we) {
        log.error("Caught an error will attempting to get volume list from " + "masking instance", we);
        throw we;
    } finally {
        if (null != iterator) {
            iterator.close();
        }
    }
    return wwnList;
}
Also used : WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) HashSet(java.util.HashSet)

Example 72 with WBEMException

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

the class SmisCreateMaskingViewJob method enableRecoverPointTag.

/**
 * Method will set the EMCRecoverPointEnabled flag on the device masking group for VMAX.
 *
 * @param dbClient [in] - Client instance for reading/writing from/to DB
 * @param client [in] - WBEMClient used for reading/writing from/to SMI-S
 * @param deviceGroupPath [in] - CIMObjectPath referencing the volume
 */
private void enableRecoverPointTag(DbClient dbClient, WBEMClient client, CIMObjectPath deviceGroupPath) {
    try {
        boolean isRPTagNeeded = false;
        // Check if the volumes being protected are RP volumes
        for (VolumeURIHLU volUriHlu : _volumeURIHLUs) {
            URI volumeURI = volUriHlu.getVolumeURI();
            BlockObject bo = null;
            if (URIUtil.isType(volumeURI, BlockSnapshot.class)) {
                bo = dbClient.queryObject(BlockSnapshot.class, volumeURI);
            } else if (URIUtil.isType(volumeURI, Volume.class)) {
                bo = dbClient.queryObject(Volume.class, volumeURI);
            }
            if (bo != null && BlockObject.checkForRP(dbClient, bo.getId())) {
                isRPTagNeeded = true;
                break;
            }
        }
        // Do nothing and return from if none of the volumes are RP protected
        if (isRPTagNeeded) {
            _log.info("Attempting to enable RecoverPoint tag on Device Group : " + deviceGroupPath.toString());
            CIMPropertyFactory factoryRef = (CIMPropertyFactory) ControllerServiceImpl.getBean("CIMPropertyFactory");
            CIMInstance toUpdate = new CIMInstance(deviceGroupPath, new CIMProperty[] { factoryRef.bool(SmisConstants.EMC_RECOVERPOINT_ENABLED, true) });
            _log.debug("Params: " + toUpdate.toString());
            client.modifyInstance(toUpdate, SmisConstants.CP_EMC_RECOVERPOINT_ENABLED);
            _log.info(String.format("Device group has been successfully set with RecoverPoint tag "));
        }
    } catch (WBEMException e) {
        _log.error("Encountered an error while trying to set the RecoverPoint tag", e);
    } catch (DatabaseException e) {
        _log.error("Encountered an error while trying to set the RecoverPoint tag", e);
    }
}
Also used : CIMPropertyFactory(com.emc.storageos.volumecontroller.impl.smis.CIMPropertyFactory) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMInstance(javax.cim.CIMInstance) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 73 with WBEMException

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

the class SmisCreateMaskingViewJob method enableRecoverPointTagOn803.

/**
 * Method will set the EMCRecoverPointEnabled flag on all the volumes within 8.0.3 Provider.
 * 8.0.3 Provider doesnt support setting RP tag on Storage Groups.
 *
 * @param dbClient [in] - Client instance for reading/writing from/to DB
 * @param client [in] - WBEMClient used for reading/writing from/to SMI-S
 * @param deviceGroupPath [in] - CIMObjectPath referencing the volume
 */
private void enableRecoverPointTagOn803(DbClient dbClient, WBEMClient client, StorageSystem storage, JobContext jobContext) {
    try {
        boolean isRPTagNeeded = false;
        List<URI> blockObjectUris = new ArrayList<URI>();
        for (VolumeURIHLU volUriHlu : _volumeURIHLUs) {
            URI volumeURI = volUriHlu.getVolumeURI();
            BlockObject bo = null;
            if (URIUtil.isType(volumeURI, BlockSnapshot.class)) {
                bo = dbClient.queryObject(BlockSnapshot.class, volumeURI);
            } else if (URIUtil.isType(volumeURI, Volume.class)) {
                bo = dbClient.queryObject(Volume.class, volumeURI);
            }
            if (bo != null) {
                blockObjectUris.add(bo.getId());
                if (BlockObject.checkForRP(dbClient, bo.getId())) {
                    isRPTagNeeded = true;
                }
            }
        }
        // Do nothing and return from if none of the volumes are RP protected
        if (isRPTagNeeded) {
            SmisCommandHelper helper = jobContext.getSmisCommandHelper();
            helper.setRecoverPointTag(storage, helper.getVolumeMembers(storage, blockObjectUris), true);
        }
    } catch (WBEMException e) {
        _log.error("Encountered an error while trying to set the RecoverPoint tag", e);
    } catch (DatabaseException e) {
        _log.error("Encountered an error while trying to set the RecoverPoint tag", e);
    } catch (Exception e) {
        _log.error("Encountered an error while trying to set the RecoverPoint tag", e);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BlockObject(com.emc.storageos.db.client.model.BlockObject) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 74 with WBEMException

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

the class SmisCreateMultiVolumeJob method changeVolumeName.

/**
 * Method will modify the name of a given volume to a generate name.
 *
 * @param dbClient [in] - Client instance for reading/writing from/to DB
 * @param client [in] - WBEMClient used for reading/writing from/to SMI-S
 * @param volumePath [in] - CIMObjectPath referencing the volume
 * @param volume [in] - Volume object
 */
private void changeVolumeName(DbClient dbClient, WBEMClient client, CIMObjectPath volumePath, Volume volume, String name) {
    Lease lease = null;
    try {
        _log.info(String.format("Attempting to modify volume %s to %s", volumePath.toString(), name));
        if (_propertyFactoryRef.get() == null) {
            _propertyFactoryRef.compareAndSet(null, (CIMPropertyFactory) ControllerServiceImpl.getBean("CIMPropertyFactory"));
        }
        CIMInstance toUpdate = new CIMInstance(volumePath, new CIMProperty[] { _propertyFactoryRef.get().string(SmisConstants.CP_ELEMENT_NAME, name) });
        if (_distributedLock.get() == null) {
            if (_coordinator.get() == null) {
                _coordinator.compareAndSet(null, (CoordinatorClient) ControllerServiceImpl.getBean("coordinator"));
            }
            _distributedLock.compareAndSet(null, _coordinator.get().getSemaphore(this.getClass().getSimpleName(), MAX_PERMITS));
        }
        lease = _distributedLock.get().acquireLease();
        client.modifyInstance(toUpdate, SmisConstants.PS_ELEMENT_NAME);
        _distributedLock.get().returnLease(lease);
        lease = null;
        volume.setDeviceLabel(name);
        dbClient.persistObject(volume);
        _log.info(String.format("Volume name has been modified to %s", name));
    } catch (WBEMException e) {
        _log.error("Encountered an error while trying to set the volume name", e);
    } catch (DatabaseException e) {
        _log.error("Encountered an error while trying to set the volume name", e);
    } catch (Exception e) {
        _log.error("Encountered an error while trying to set the volume name", e);
    } finally {
        if (lease != null) {
            try {
                _distributedLock.get().returnLease(lease);
            } catch (Exception e) {
                _log.error("Exception when trying to return lease", e);
            }
        }
    }
}
Also used : Lease(org.apache.curator.framework.recipes.locks.Lease) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 75 with WBEMException

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

the class CommunicationInterfaceTest method getCIMClient.

private void getCIMClient(AccessProfile accessProfile, WBEMClient cimClient) throws SMIPluginException {
    try {
        CIMObjectPath path = CimObjectPathCreator.createInstance(accessProfile.getProtocol(), accessProfile.getIpAddress(), accessProfile.getProviderPort(), accessProfile.getInteropNamespace(), null, null);
        UserPrincipal userPr = new UserPrincipal(accessProfile.getUserName(), accessProfile.getIpAddress());
        PasswordCredential pwCred = new PasswordCredential(accessProfile.getPassword(), accessProfile.getIpAddress());
        Subject subject = new Subject();
        subject.getPrincipals().add(userPr);
        subject.getPublicCredentials().add(pwCred);
        subject.getPrivateCredentials().add(pwCred);
        cimClient.initialize(path, subject, new Locale[] { Locale.US });
    } catch (WBEMException e) {
        final int errorCode = e.getID() + SMIPluginException.ERRORCODE_START_WBEMEXCEPTION;
        // _logger.error(fetchWBEMErrorMessage(e), errorCode);
        throw new SMIPluginException("CIMOM Initializing Error", errorCode);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) PasswordCredential(javax.wbem.client.PasswordCredential) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException) WBEMException(javax.wbem.WBEMException) UserPrincipal(javax.wbem.client.UserPrincipal) Subject(javax.security.auth.Subject)

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