use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class VnxSnapshotOperations method deleteConsistencyGroupSnapshot.
/**
* This method will delete a snapshot that was created as part of volume consistency
* group 'snap-set'.
*
* @param storage [required] - StorageSystem object representing the array
* @param snapshot [required] - BlockSnapshot URI representing the previously created
* snap for the volume
* @param taskCompleter - TaskCompleter object used for the updating operation status.
* @return true - All the snaps in the 'snap-set' where deleted successfully.
* @throws WorkflowException
*/
private boolean deleteConsistencyGroupSnapshot(StorageSystem storage, BlockSnapshot snap, TaskCompleter taskCompleter) throws DeviceControllerException {
boolean wasSuccess = false;
try {
callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snap.getId()));
CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, snap);
if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
deactivateSnapshot(storage, snap, syncObjectPath);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callModifyReplica(storage, _helper.getDeleteSnapshotSynchronousInputArguments(syncObjectPath), outArgs);
if (snap.getSettingsInstance() != null) {
Volume volume = _dbClient.queryObject(Volume.class, snap.getParent());
outArgs = new CIMArgument[5];
_helper.callModifySettingsDefineState(storage, _helper.getDeleteSettingsForSnapshotInputArguments(storage, volume, snap), outArgs);
}
}
wasSuccess = true;
} catch (WBEMException e) {
String message = String.format("Error encountered during delete snapshot %s on array %s", snap.getId().toString(), storage.getSerialNumber());
_log.error(message, e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
} catch (Exception e) {
String message = String.format("Generic exception when trying to delete snapshot %s on array %s", snap.getId().toString(), storage.getSerialNumber());
_log.error(message, e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("deleteConsistencyGroupSnapshot", e.getMessage());
taskCompleter.error(_dbClient, error);
}
return wasSuccess;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class VmaxExportOperations method deleteMaskingView.
private boolean deleteMaskingView(StorageSystem storage, URI exportMaskURI, Map<StorageGroupPolicyLimitsParam, List<String>> childrenStorageGroupMap, TaskCompleter taskCompleter) throws Exception {
boolean maskingWasDeleted = false;
_log.debug("{} deleteMaskingView START...", storage.getSerialNumber());
String groupName = _helper.getExportMaskName(exportMaskURI);
CIMInstance maskingViewInstance = maskingViewExists(storage, groupName);
if (maskingViewInstance == null) {
_log.info("{} deleteMaskingView END...Masking view already deleted: {}", storage.getSerialNumber(), groupName);
return true;
}
try {
// get parent ig from masking view
CIMObjectPath igPath = _helper.getInitiatorGroupForGivenMaskingView(maskingViewInstance.getObjectPath(), storage);
// Flag to indicate whether or not we need to use the EMCForce flag on this operation.
// We currently use this flag when dealing with RP Volumes as they are tagged for RP and the
// operation on these volumes would fail otherwise.
boolean forceFlag = false;
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
for (String volURI : exportMask.getUserAddedVolumes().values()) {
forceFlag = ExportUtils.useEMCForceFlag(_dbClient, URI.create(volURI));
if (forceFlag) {
break;
}
}
CIMArgument[] inArgs = _helper.getDeleteMaskingViewInputArguments(storage, exportMaskURI, forceFlag);
CIMArgument[] outArgs = new CIMArgument[5];
// Collect the current list of associated IGs for the MaskingView. This
// will include cascaded and child IGs.
List<CIMObjectPath> igPaths = new ArrayList<CIMObjectPath>();
getInitiatorGroupsFromMvOrIg(storage, maskingViewInstance.getObjectPath(), igPaths);
// remove parent IG
igPaths.remove(igPath);
WBEMClient client = _helper.getConnection(storage).getCimClient();
// if SG is associated with other MVs/parent groups, set IO Limits back on it at the end
for (Entry<StorageGroupPolicyLimitsParam, List<String>> storageGroupEntry : childrenStorageGroupMap.entrySet()) {
for (String storageGroupName : storageGroupEntry.getValue()) {
CIMObjectPath storageGroupPath = _cimPath.getMaskingGroupPath(storage, storageGroupName, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
_helper.resetHostIOLimits(client, storage, storageGroupPath);
}
}
// Invoke operation to delete the MaskingView. This should clean up
// IG that are directly related to the MV. We will have to check if any
// others that may be child IGs are left dangling. If they are and not
// associated with other IGs or MVs, we shall have to delete them.
SmisSynchSubTaskJob deleteJob = new SmisSynchSubTaskJob(null, storage.getId(), "DeleteMaskingView");
_helper.invokeMethodSynchronously(storage, _cimPath.getControllerConfigSvcPath(storage), "DeleteMaskingView", inArgs, outArgs, deleteJob);
if (deleteJob.isSuccess()) {
if (_helper.checkExists(storage, igPath, true, false) != null) {
List<CIMObjectPath> associatedMaskingViews = getAssociatedMaskingViews(storage, igPath);
List<CIMObjectPath> associatedIGs = getAssociatedParentIGs(storage, igPath);
if (associatedMaskingViews.isEmpty() && (associatedIGs.isEmpty() || _helper.isCascadedIG(storage, igPath))) {
// parentIGs has associated IGs, not the parent
// delete CIG if it is not associated with any MV (CTRL-9662)
// CTRL-9323 : deleting Parent IG associated with masking view.
deleteInitiatorGroup(storage, igPath);
} else {
_log.info(String.format("Did not delete %s as it is still associated to MaskingViews [%s] and/or AssociatedIGs [%s]", igPath.toString(), Joiner.on(',').join(associatedMaskingViews), Joiner.on(',').join(associatedIGs)));
}
} else {
_log.info("IG already deleted {}", igPath);
}
// CTRL-9323 : only child IGs will be processed, as parent is deleted already we will not hit the cyclic
// issue
maskingWasDeleted = checkIGsAndDeleteIfUnassociated(storage, igPaths);
if (!maskingWasDeleted) {
taskCompleter.error(_dbClient, DeviceControllerException.errors.unableToDeleteIGs(groupName));
return false;
}
} else {
String opName = ResourceOperationTypeEnum.DELETE_EXPORT_GROUP.getName();
ServiceError serviceError = DeviceControllerException.errors.jobFailedOp(opName);
taskCompleter.error(_dbClient, serviceError);
return maskingWasDeleted;
}
_log.debug("{} deleteMaskingView END...", storage.getSerialNumber());
} catch (WBEMException we) {
_log.error(String.format("Problem when trying to delete masking view - array: %s, view: %s", storage.getSerialNumber(), groupName), we);
String opName = ResourceOperationTypeEnum.DELETE_EXPORT_GROUP.getName();
ServiceError serviceError = DeviceControllerException.errors.jobFailed(we);
taskCompleter.error(_dbClient, serviceError);
throw we;
}
_log.debug("{} deleteMaskingView END...", storage.getSerialNumber());
return maskingWasDeleted;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class VmaxExportOperations method createVolumeGroup.
// //////////// VMAX specific export helpers ////////////////
private CIMObjectPath createVolumeGroup(StorageSystem storage, String groupName, VolumeURIHLU[] volumeURIHLUs, TaskCompleter taskCompleter, boolean addVolumes) throws Exception {
_log.debug("{} createVolumeGroup START...", storage.getSerialNumber());
CIMObjectPath volumeGroupObjectPath = null;
int index = 0;
String[] volumeNames = new String[volumeURIHLUs.length];
String policyName = null;
// Flag to indicate whether or not we need to use the EMCForce flag on this operation.
// We currently use this flag when dealing with RP Volumes as they are tagged for RP and the
// operation on these volumes would fail otherwise.
boolean setOnce = false;
boolean forceFlag = false;
boolean disableCompression = false;
for (VolumeURIHLU volURIHlu : volumeURIHLUs) {
String volumeNativeId = _helper.getBlockObjectNativeId(volURIHlu.getVolumeURI());
volumeNames[index++] = volumeNativeId;
if (null == policyName && storage.checkIfVmax3()) {
policyName = _helper.getVMAX3FastSettingForVolume(volURIHlu.getVolumeURI(), volURIHlu.getAutoTierPolicyName(), volURIHlu.getCompression());
if (_helper.checkVolumeAssociatedWithAnySGWithPolicy(volumeNativeId, storage, policyName)) {
// A volume cannot be in multiple fast managed storage groups. Reset the fast policy
policyName = Constants.NONE.toString();
}
}
// The force flag only needs to be set once
if (!setOnce) {
setOnce = true;
forceFlag = ExportUtils.useEMCForceFlag(_dbClient, volURIHlu.getVolumeURI());
disableCompression = _helper.disableVMAX3Compression(volURIHlu.getVolumeURI(), storage);
}
}
CIMArgument[] inArgs = null;
String truncatedGroupName = groupName.length() >= 64 ? StringUtils.substring(groupName, 0, 63) : groupName;
if (storage.checkIfVmax3()) {
_helper.removeVolumeFromParkingSLOStorageGroup(storage, volumeNames, forceFlag);
_log.info("Done invoking remove volumes from parking SLO storage group before export");
policyName = _helper.getVMAX3FastSettingWithRightNoneString(storage, policyName);
String[] tokens = policyName.split(Constants.SMIS_PLUS_REGEX);
inArgs = _helper.getCreateVolumeGroupInputArguments(storage, truncatedGroupName, tokens[0], tokens[2], tokens[1], addVolumes ? volumeNames : null, disableCompression);
} else {
inArgs = _helper.getCreateVolumeGroupInputArguments(storage, truncatedGroupName, addVolumes ? volumeNames : null);
}
CIMArgument[] outArgs = new CIMArgument[5];
try {
_helper.invokeMethod(storage, _cimPath.getControllerConfigSvcPath(storage), "CreateGroup", inArgs, outArgs);
volumeGroupObjectPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, "MaskingGroup");
ExportOperationContext.insertContextOperation(taskCompleter, VmaxExportOperationContext.OPERATION_CREATE_STORAGE_GROUP, groupName, volumeURIHLUs);
} catch (WBEMException we) {
// If the VG by the same name exists, the WBEM exception thrown is CIM_ERR_FAILED.
_log.info("{} Problem when trying to create volume group ... going to look up volume group.", storage.getSystemType(), we);
volumeGroupObjectPath = handleCreateMaskingGroupException(storage, truncatedGroupName, inArgs, SmisCommandHelper.MASKING_GROUP_TYPE.SE_DeviceMaskingGroup);
if (volumeGroupObjectPath == null) {
_log.info("{} Problem looking up volume group.", storage.getSerialNumber(), we);
throw we;
} else {
_log.info("{} Found volume group.", storage.getSerialNumber());
}
}
_log.debug("{} createVolumeGroup END...", storage.getSerialNumber());
return volumeGroupObjectPath;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class VmaxExportOperations method createTargetPortGroup.
private CIMObjectPath createTargetPortGroup(StorageSystem storage, String portGroupName, ExportMask mask, List<URI> targetURIList, TaskCompleter taskCompleter) throws Exception {
_log.debug("{} createTargetPortGroup START...", storage.getSerialNumber());
CIMObjectPath targetPortGroupPath = null;
CIMArgument[] inArgs = _helper.getCreateTargetPortGroupInputArguments(storage, portGroupName, targetURIList);
CIMArgument[] outArgs = new CIMArgument[5];
try {
// Try to look up the port group. If it already exists, use it,
// otherwise try to create it.
targetPortGroupPath = _cimPath.getMaskingGroupPath(storage, portGroupName, SmisConstants.MASKING_GROUP_TYPE.SE_TargetMaskingGroup);
CIMInstance instance = _helper.checkExists(storage, targetPortGroupPath, false, false);
if (instance == null) {
_helper.invokeMethod(storage, _cimPath.getControllerConfigSvcPath(storage), "CreateGroup", inArgs, outArgs);
targetPortGroupPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, "MaskingGroup");
ExportOperationContext.insertContextOperation(taskCompleter, VmaxExportOperationContext.OPERATION_CREATE_PORT_GROUP, portGroupName, targetURIList);
// Create port group
StoragePortGroup portGroup = new StoragePortGroup();
String guid = String.format("%s+%s", storage.getNativeGuid(), portGroupName);
portGroup.setId(URIUtil.createId(StoragePortGroup.class));
portGroup.setLabel(portGroupName);
portGroup.setNativeGuid(guid);
portGroup.setStorageDevice(storage.getId());
portGroup.setInactive(false);
portGroup.setRegistrationStatus(RegistrationStatus.UNREGISTERED.name());
portGroup.setMutable(true);
portGroup.setStoragePorts(StringSetUtil.uriListToStringSet(targetURIList));
_dbClient.createObject(portGroup);
mask.setPortGroup(portGroup.getId());
_dbClient.updateObject(mask);
}
} catch (WBEMException we) {
_log.info("{} Problem when trying to create target port group ... going to look up target port group.", storage.getSystemType(), we);
targetPortGroupPath = handleCreateMaskingGroupException(storage, portGroupName, inArgs, SmisCommandHelper.MASKING_GROUP_TYPE.SE_TargetMaskingGroup);
if (targetPortGroupPath == null) {
_log.info("{} Problem looking up target port group.", storage.getSerialNumber(), we);
throw we;
} else {
_log.info("{} Found target port group.", storage.getSerialNumber());
}
}
_log.debug("{} createTargetPortGroup END...", storage.getSerialNumber());
return targetPortGroupPath;
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class VmaxExportOperations method createMaskingView.
private void createMaskingView(StorageSystem storage, URI exportMaskURI, String maskingViewName, CIMObjectPath volumeGroupPath, VolumeURIHLU[] volumeURIHLUs, CIMObjectPath targetPortGroupPath, CIMObjectPath initiatorGroupPath, TaskCompleter taskCompleter) throws Exception {
_log.info("{} createMaskingView START...", storage.getSerialNumber());
// Flag to indicate whether or not we need to use the EMCForce flag on this operation.
// We currently use this flag when dealing with RP Volumes as they are tagged for RP and the
// operation on these volumes would fail otherwise.
boolean forceFlag = false;
List<String> deviceNumbers = new ArrayList<String>();
for (VolumeURIHLU volURIHlu : volumeURIHLUs) {
String hlu = volURIHlu.getHLU();
// LUN_UNASSIGNED value (as a hex string).
if (hlu != null && !hlu.equalsIgnoreCase(ExportGroup.LUN_UNASSIGNED_STR)) {
deviceNumbers.add(hlu);
}
// The force flag only needs to be set once
if (!forceFlag) {
forceFlag = ExportUtils.useEMCForceFlag(_dbClient, volURIHlu.getVolumeURI());
}
}
String[] deviceNumbersStr = {};
CIMArgument[] inMVArgs = _helper.getCreateMaskingViewInputArguments(volumeGroupPath, targetPortGroupPath, initiatorGroupPath, deviceNumbers.toArray(deviceNumbersStr), maskingViewName, forceFlag);
CIMArgument[] outMVArgs = new CIMArgument[5];
try {
_helper.invokeMethod(storage, _cimPath.getControllerConfigSvcPath(storage), "CreateMaskingView", inMVArgs, outMVArgs);
CIMObjectPath cimJobPath = _cimPath.getCimObjectPathFromOutputArgs(outMVArgs, "Job");
if (cimJobPath != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCreateMaskingViewJob(cimJobPath, storage.getId(), exportMaskURI, volumeURIHLUs, volumeGroupPath, taskCompleter)));
} else {
// simulated environments
throw new WBEMException("No output argument was returned from CreateMaskingView operation");
}
// Rollback context is set in the job upon completion.
} catch (WBEMException we) {
_log.info("{} Problem when trying to create masking view ... going to look up masking view.", storage.getSerialNumber(), we);
boolean handleException = false;
try {
handleException = handleCreateMaskingViewException(storage, maskingViewName);
} catch (Exception e) {
_log.error("Issue trying to handle Export Mask exception", e);
}
if (handleException) {
_log.info("{} Found masking view: {}", storage.getSerialNumber(), maskingViewName);
taskCompleter.ready(_dbClient);
} else {
_log.debug("{} Problem when looking up masking view: {}", storage.getSerialNumber(), maskingViewName);
throw we;
}
}
_log.info("{} createMaskingView END...", storage.getSerialNumber());
}
Aggregations