use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisCommandHelper method deleteMaskingGroup.
public void deleteMaskingGroup(StorageSystem storage, CIMObjectPath maskingGroupPath, SmisCommandHelper.MASKING_GROUP_TYPE groupType, String groupName) throws Exception {
_log.debug("{} Delete {} Masking Group START...", storage.getSerialNumber(), groupType.name());
_log.info("{} Deleting Masking Group {}", maskingGroupPath, groupName);
CIMInstance maskingGroupInstance = null;
try {
maskingGroupInstance = getInstance(storage, maskingGroupPath, false, false, new String[] {});
} catch (WBEMException we) {
_log.debug("{} Problem when trying to get masking group...", storage.getSerialNumber(), we);
if (we.getID() != WBEMException.CIM_ERR_NOT_FOUND) {
throw we;
}
}
if (maskingGroupInstance == null) {
_log.info("{} Masking group already deleted ...", storage.getSerialNumber());
return;
}
CIMArgument[] inArgs = getDeleteMaskingGroupInputArguments(storage, groupName, groupType);
CIMArgument[] outArgs = new CIMArgument[5];
try {
invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "DeleteGroup", inArgs, outArgs, null);
_log.debug("{} Delete {} Masking Group END...", storage.getSystemType(), groupType.name());
} catch (WBEMException we) {
_log.debug("{} Problem when trying to delete masking group ...", storage.getSerialNumber(), we);
if (we.getID() != WBEMException.CIM_ERR_NOT_FOUND) {
throw we;
} else {
_log.debug("{} Masking group already deleted ...", storage.getSerialNumber());
}
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisCommandHelper method renameVolume.
/**
* Rename a volume on the SMIS storage device. Used by SRDF.
*
* @param dbClient - database reference (volume deviceLabel is updated)
* @param storageSystem - StorageSystem
* @param volume - Volume
* @param name - new name String
*/
public void renameVolume(DbClient dbClient, StorageSystem storageSystem, Volume volume, String name) {
try {
CIMObjectPath volumePath = _cimPath.getBlockObjectPath(storageSystem, volume);
_log.info(String.format("Attempting to modify volume %s to %s", volumePath.toString(), name));
CIMInstance toUpdate = new CIMInstance(volumePath, new CIMProperty[] { new CIMPropertyFactory().string(SmisConstants.CP_ELEMENT_NAME, name) });
modifyInstance(storageSystem, toUpdate, SmisConstants.PS_ELEMENT_NAME);
volume.setDeviceLabel(name);
dbClient.updateAndReindexObject(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);
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisCommandHelper method getStoragePortsFromLunMaskingInstance.
/**
* Given a CIMInstance of a ClarLunMaskingProtocolController return a list of storage ports that
* it references.
*
* @param client
* [in] - WBEMClient to be used to talk to SMIS provider
* @param instance
* [in] - CIMInstance object pointing to a ClarLunMaskingProtocolController
* @return List of port name String values. The WWNs will have colons separating the hex digits.
*/
public List<String> getStoragePortsFromLunMaskingInstance(WBEMClient client, CIMInstance instance) {
List<String> storagePorts = new ArrayList<String>();
CloseableIterator<CIMInstance> iterator = null;
try {
iterator = client.associatorInstances(instance.getObjectPath(), null, CIM_PROTOCOL_ENDPOINT, null, null, false, PS_NAME);
while (iterator.hasNext()) {
CIMInstance cimInstance = iterator.next();
String portName = CIMPropertyFactory.getPropertyValue(cimInstance, CP_NAME);
String fixedName = Initiator.toPortNetworkId(portName);
storagePorts.add(fixedName);
}
} catch (WBEMException we) {
_log.error("Caught an error while attempting to get storage ports from " + "masking instance", we);
} finally {
closeCIMIterator(iterator);
}
return storagePorts;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisCommandHelper method removeVolumeFromParkingSLOStorageGroup.
/**
* Removes the volumes from the associated parking SLO storage group.
*
* @param storage the storage system
* @param nativeIds the volume native ids
* @param forceFlag the force flag
* @return the parking SLO storage group instances
* @throws Exception the exception
*/
public Set<CIMInstance> removeVolumeFromParkingSLOStorageGroup(StorageSystem storage, String[] nativeIds, boolean forceFlag) throws Exception {
Map<String, List<CIMObjectPath>> parkingSGToVolumes = new HashMap<>();
Set<CIMInstance> parkingSLOStorageGroups = new HashSet<>();
CloseableIterator<CIMInstance> cimInstanceItr = null;
for (String nativeId : nativeIds) {
try {
CIMObjectPath volumePath = _cimPath.getVolumePath(storage, nativeId);
cimInstanceItr = getAssociatorInstances(storage, volumePath, null, MASKING_GROUP_TYPE.SE_DeviceMaskingGroup.name(), null, null, PS_ELEMENT_NAME);
while (cimInstanceItr.hasNext()) {
CIMInstance groupInstance = cimInstanceItr.next();
String groupName = CIMPropertyFactory.getPropertyValue(groupInstance, CP_ELEMENT_NAME);
_log.debug("Found masking group {} associated for volume {}", groupName, nativeId);
if (groupName.startsWith(Constants.STORAGE_GROUP_PREFIX)) {
List<CIMObjectPath> volumes = parkingSGToVolumes.get(groupName);
if (volumes == null) {
volumes = new ArrayList<CIMObjectPath>();
parkingSGToVolumes.put(groupName, volumes);
// add this SG to the SG instances collection
parkingSLOStorageGroups.add(groupInstance);
}
volumes.add(volumePath);
}
}
} catch (WBEMException ex) {
_log.error("Failed to find associated storage group for volume {}.", nativeId, ex);
throw new DeviceControllerException(ex);
} finally {
if (cimInstanceItr != null) {
cimInstanceItr.close();
}
}
}
for (String parkingSGName : parkingSGToVolumes.keySet()) {
List<CIMObjectPath> volumePaths = parkingSGToVolumes.get(parkingSGName);
CIMObjectPath maskingGroupPath = _cimPath.getMaskingGroupPath(storage, parkingSGName, MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
CIMObjectPath[] memberPaths = volumePaths.toArray(new CIMObjectPath[] {});
CIMArgument[] inArgs = getAddOrRemoveMaskingGroupMembersInputArguments(maskingGroupPath, memberPaths, forceFlag);
CIMArgument[] outArgs = new CIMArgument[5];
_log.info("Invoking remove volume(s) from parking SLO storage group {}", parkingSGName);
invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), SmisConstants.REMOVE_MEMBERS, inArgs, outArgs, null);
}
return parkingSLOStorageGroups;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisCommandHelper method invokeMethodSynchronously.
/**
* Makes a call to SMIS provider and returns the response back to the caller. If the SMIS call
* is a asynchronous, it waits for the SMIS job to complete before returning. This is done to
* allow callers to make consecutive asynchronous calls without the need for a workflow.
* <em>This function should be used for asynchronous SMIS calls only and will throw an exception
* if the call did not return a job path.</em>
*
* @param inArgs
* input arguments
* @param outArgs
* output arguments
* @param job
* for handling special cases of intermediate and final cim job results. Null should
* be used when no special handling is needed.
* @return the return value of the method invocation
* @throws WBEMException
* when a error occurs in the SMIS provider
* @throws SmisException
* when an error occurs while waiting for the asyn job to complete or if the smis
* call did not return a job.
*/
public Object invokeMethodSynchronously(StorageSystem storageDevice, CIMObjectPath objectPath, String methodName, CIMArgument[] inArgs, CIMArgument[] outArgs, SmisJob job) throws WBEMException, SmisException {
Object obj = invokeMethod(storageDevice, objectPath, methodName, inArgs, outArgs);
CIMObjectPath cimJobPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, "Job");
// if this is an async call, wait for the job to complete
if (cimJobPath != null) {
try {
waitForAsyncSmisJob(storageDevice, cimJobPath, job);
} catch (Exception ex) {
_log.error("Exception occurred while waiting on async job {} to complete", cimJobPath);
if (ex instanceof SmisException) {
throw (SmisException) ex;
} else {
throw new SmisException("Exception occurred while waiting on async " + "job to complete.", ex);
}
}
} else {
throw new SmisException(MessageFormat.format("No job was created for method {0}, object {1}, on storage device {2}", methodName, objectPath.getObjectName(), storageDevice.getLabel()));
}
return obj;
}
Aggregations