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