use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class VnxSnapshotOperations method deleteSingleVolumeSnapshot.
/**
* Should implement deletion of single volume snapshot. That is, deleting a snap that was
* created independent of other volumes.
*
* @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.
*/
@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
BlockSnapshot snap = _dbClient.queryObject(BlockSnapshot.class, snapshot);
CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, snap);
if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callModifyReplica(storage, _helper.getDeleteSnapshotSynchronousInputArguments(syncObjectPath), outArgs);
snap.setInactive(true);
snap.setIsSyncActive(false);
_dbClient.updateObject(snap);
taskCompleter.ready(_dbClient);
} else {
// Perhaps, it's already been deleted or was deleted on the array.
// In that case, we'll just say all is well, so that this operation
// is idempotent.
snap.setInactive(true);
snap.setIsSyncActive(false);
_dbClient.updateObject(snap);
taskCompleter.ready(_dbClient);
}
} catch (WBEMException e) {
String message = String.format("Error encountered during delete snapshot %s on array %s", snapshot.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", snapshot.toString(), storage.getSerialNumber());
_log.error(message, e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("deleteSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class VnxSnapshotOperations method restoreSingleVolumeSnapshot.
/**
* Implementation for restoring of a single volume snapshot restore. That is, this
* volume is independent of other volumes and a snapshot was taken previously, and
* now we want to restore that snap to the original volume.
*
* @param storage [required] - StorageSystem object representing the array
* @param volume [required] - Volume URI for the volume to be restored
* @param snapshot [required] - BlockSnapshot URI representing the previously created
* snap for the volume
* @param taskCompleter - TaskCompleter object used for the updating operation status.
*/
@Override
public void restoreSingleVolumeSnapshot(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
callEMCRefreshIfRequired(_dbClient, _helper, storage, Arrays.asList(snapshot));
BlockSnapshot from = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume to = _dbClient.queryObject(Volume.class, volume);
CIMObjectPath syncObjectPath = _cimPath.getSyncObject(storage, from);
if (_helper.checkExists(storage, syncObjectPath, false, false) != null) {
CIMObjectPath cimJob;
if (_helper.isThinlyProvisioned(storage, to) || isBasedOnVNXThinStoragePool(to)) {
_log.info("Volume {} is thinly provisioned or based on a Thin StoragePool, need to deactivate the volume before restore", to.getLabel());
deactivateSnapshot(storage, from, syncObjectPath);
cimJob = _helper.callModifySettingsDefineState(storage, _helper.getRestoreFromSnapshotInputArguments(storage, to, from));
} else {
// Thick volumes do not need to be deactivated prior to restore.
// The can be restored directly. WaitForCopyState should not be supplied in this scenario
_log.info("Volume {} is not thinly provisioned, will attempt restore", to.getLabel());
cimJob = _helper.callModifyReplica(storage, _helper.getRestoreFromReplicaInputArgumentsWithForce(syncObjectPath));
}
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockRestoreSnapshotJob(cimJob, storage.getId(), taskCompleter)));
} else {
ServiceError error = DeviceControllerErrors.smis.unableToFindSynchPath(storage.getLabel());
taskCompleter.error(_dbClient, error);
}
} catch (WBEMException e) {
String message = String.format("Error encountered when trying to restore from snapshot %s on array %s", snapshot.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 restore from snapshot %s on array %s", snapshot.toString(), storage.getSerialNumber());
_log.error(message, e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("restoreSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doCreateVolumes.
@Override
public void doCreateVolumes(final StorageSystem storageSystem, final StoragePool storagePool, final String opId, final List<Volume> volumes, final VirtualPoolCapabilityValuesWrapper capabilities, final TaskCompleter taskCompleter) throws DeviceControllerException {
String label = null;
Long capacity = null;
Long thinVolumePreAllocationSize = null;
CIMInstance poolSetting = null;
boolean opCreationFailed = false;
StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
StorageSystem forProvider = _helper.getStorageSystemForProvider(storageSystem, volumes.get(0));
// volumeGroupObjectPath is required for VMAX3
CIMObjectPath volumeGroupObjectPath = _helper.getVolumeGroupPath(forProvider, storageSystem, volumes.get(0), storagePool);
List<String> volumeLabels = new ArrayList<>();
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s", volume.getLabel(), volume.getThinlyProvisioned()));
String tenantName = "";
try {
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
tenantName = tenant.getLabel();
} catch (DatabaseException e) {
_log.error("Error lookup TenantOrb object", e);
}
label = _nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH);
volumeLabels.add(label);
if (capacity == null) {
capacity = volume.getCapacity();
}
if (thinVolumePreAllocationSize == null && volume.getThinVolumePreAllocationSize() > 0) {
thinVolumePreAllocationSize = volume.getThinVolumePreAllocationSize();
}
}
_log.info(logMsgBuilder.toString());
boolean isThinlyProvisioned = volumes.get(0).getThinlyProvisioned();
try {
CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
CIMArgument[] inArgs = null;
// I didn't find any ways to add this branching logic based on device Types.
if (DiscoveredDataObject.Type.vnxblock.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
String autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volumes.get(0).getId(), _dbClient);
if (autoTierPolicyName.equals(Constants.NONE)) {
autoTierPolicyName = null;
}
inArgs = _helper.getCreateVolumesInputArgumentsOnFastEnabledPool(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, autoTierPolicyName);
} else {
if (!storageSystem.checkIfVmax3() && isThinlyProvisioned && null != thinVolumePreAllocationSize) {
poolSetting = _smisStorageDevicePreProcessor.createStoragePoolSetting(storageSystem, storagePool, thinVolumePreAllocationSize);
}
if (storageSystem.checkIfVmax3()) {
inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, true, volumeGroupObjectPath, (null != thinVolumePreAllocationSize));
} else {
inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, poolSetting, true);
}
}
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(forProvider, configSvcPath, _helper.createVolumesMethodName(forProvider), inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
SmisJob createSmisJob = volumes.size() > 1 ? new SmisCreateMultiVolumeJob(job, forProvider.getId(), storagePool.getId(), volumes.size(), taskCompleter) : new SmisCreateVolumeJob(job, forProvider.getId(), storagePool.getId(), taskCompleter);
ControllerServiceImpl.enqueueJob(new QueueJob(createSmisJob));
}
} catch (final InternalException e) {
_log.error("Problem in doCreateVolumes: ", e);
opCreationFailed = true;
taskCompleter.error(_dbClient, e);
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
opCreationFailed = true;
ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, serviceError);
} catch (Exception e) {
_log.error("Problem in doCreateVolumes: ", e);
opCreationFailed = true;
ServiceError serviceError = DeviceControllerErrors.smis.methodFailed("doCreateVolumes", e.getMessage());
taskCompleter.error(_dbClient, serviceError);
}
if (opCreationFailed) {
for (Volume vol : volumes) {
vol.setInactive(true);
_dbClient.updateObject(vol);
}
}
logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
}
_log.info(logMsgBuilder.toString());
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doInitiatorAliasSet.
/**
* This method will be used to set 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 set
*
* @param storage
* - StorageSystem object
* @param initiator
* - Initiator Object for which the Alias needs to be set
* @param initiatorAlias
* - User Friendly Name
* @throws Exception
*/
@Override
public void doInitiatorAliasSet(StorageSystem storage, Initiator initiator, String initiatorAlias) throws Exception {
try {
checkIfProviderSupportsAliasOperations(storage);
CIMObjectPath hwManagementIDSvcPath = _cimPath.getStorageHardwareIDManagementService(storage);
CIMObjectPath shidPath = getSHIDPathForAliasOperation(storage, hwManagementIDSvcPath, initiator);
CIMArgument[] inArgs = _helper.getEMCInitiatorAliasSetArgs(shidPath, initiatorAlias);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storage, hwManagementIDSvcPath, SmisConstants.INITIATOR_ALIAS_SET, inArgs, outArgs);
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
throw e;
} catch (Exception e) {
_log.error("Unexpected error: EMCInitiatorAliasSet failed.", e);
throw e;
}
}
use of javax.wbem.WBEMException in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doUntagVolumes.
@Override
public void doUntagVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Untag Volume Start - Array:%s", storageSystem.getSerialNumber()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
_helper.doApplyRecoverPointTag(storageSystem, volume, false);
}
} 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 doUntagVolume: ", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("doUntagVolume", e.getMessage());
taskCompleter.error(_dbClient, error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Untag Volume End - Array: %s", storageSystem.getSerialNumber()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
}
_log.info(logMsgBuilder.toString());
}
Aggregations