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;
}
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);
}
}
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);
}
}
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);
}
}
}
}
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);
}
}
Aggregations