use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.
the class VPlexXIVMaskingOrchestrator method createOrAddVolumesToExportMask.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.impl.block.
* VplexBackEndMaskingOrchestrator#createOrAddVolumesToExportMask(java.net.URI, java.net.URI,
* java.net.URI, java.util.Map, com.emc.storageos.volumecontroller.TaskCompleter, java.lang.String)
*/
@Override
public void createOrAddVolumesToExportMask(URI arrayURI, URI exportGroupURI, URI exportMaskURI, Map<URI, Integer> volumeMap, List<URI> initiatorURIs2, TaskCompleter completer, String stepId) {
try {
WorkflowStepCompleter.stepExecuting(stepId);
StorageSystem array = _dbClient.queryObject(StorageSystem.class, arrayURI);
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
// If the exportMask isn't found, or has been deleted, fail, ask user to retry.
if (exportMask == null || exportMask.getInactive()) {
_log.info(String.format("ExportMask %s deleted or inactive, failing", exportMaskURI));
ServiceError svcerr = VPlexApiException.errors.createBackendExportMaskDeleted(exportMaskURI.toString(), arrayURI.toString());
WorkflowStepCompleter.stepFailed(stepId, svcerr);
return;
}
// Protect concurrent operations by locking {host, array} dupple.
// Lock will be released when workflow step completes.
List<String> lockKeys = ControllerLockingUtil.getHostStorageLockKeys(_dbClient, ExportGroupType.Host, StringSetUtil.stringSetToUriList(exportMask.getInitiators()), arrayURI);
getWorkflowService().acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.VPLEX_BACKEND_EXPORT));
// Refresh the ExportMask
BlockStorageDevice device = _blockController.getDevice(array.getSystemType());
if (exportMask.getNativeId() != null) {
exportMask = refreshExportMask(array, device, exportMask);
}
// We are creating this ExportMask on the hardware! (Maybe not the first time though...)
// Fetch the Initiators
List<URI> initiatorURIs = new ArrayList<URI>();
List<Initiator> initiators = new ArrayList<Initiator>();
for (String initiatorId : exportMask.getInitiators()) {
Initiator initiator = _dbClient.queryObject(Initiator.class, URI.create(initiatorId));
if (initiator != null) {
initiators.add(initiator);
initiatorURIs.add(initiator.getId());
}
}
if (!exportMask.hasAnyVolumes()) {
// Fetch the targets
List<URI> targets = new ArrayList<URI>();
for (String targetId : exportMask.getStoragePorts()) {
targets.add(URI.create(targetId));
}
// If some invalid export mask exists
if (exportMask.getNativeId() != null) {
exportMask.setNativeId("");
_dbClient.updateAndReindexObject(exportMask);
}
// The default completer passed in is for add volume, create correct one
TaskCompleter createCompleter = new ExportMaskCreateCompleter(exportGroupURI, exportMaskURI, initiatorURIs, volumeMap, stepId);
device.doExportCreate(array, exportMask, volumeMap, initiators, targets, createCompleter);
} else {
device.doExportAddVolumes(array, exportMask, initiators, volumeMap, completer);
}
} catch (Exception ex) {
_log.error("Failed to create or add volumes to export mask for XIV: ", ex);
VPlexApiException vplexex = DeviceControllerExceptions.vplex.addStepsForCreateVolumesFailed(ex);
WorkflowStepCompleter.stepFailed(stepId, vplexex);
}
}
use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.
the class VplexVolumeValidator method validateVolume.
/**
* Validates an individual volume.
*
* @param virtualVolume the Volume to validate
* @param delete boolean indicating if this validation is part of a delete operation
* @param remediate boolean indicating whether or not remediation should be attempted
* @param checks variable list of ValCks
*/
public void validateVolume(Volume virtualVolume, boolean delete, boolean remediate, ValCk... checks) {
List<ValCk> checkList = Arrays.asList(checks);
String volumeId = String.format("%s (%s)(%s)", virtualVolume.getLabel(), virtualVolume.getNativeGuid(), virtualVolume.getId());
log.info("Initiating Vplex Volume validation: " + volumeId);
VPlexVirtualVolumeInfo vvinfo = null;
try {
vvinfo = client.findVirtualVolume(virtualVolume.getDeviceLabel(), virtualVolume.getNativeId());
} catch (VPlexApiException ex) {
log.info(ex.getMessage());
}
if (vvinfo == null) {
try {
// Didn't find the virtual volume. Look at the storage volume, and from that determine
// the deviceName. Then lookup the Device or DistributedDevice and check to see if
// the device has been reassigned to a different virtual volume.
Volume storageVolume = VPlexUtil.getVPLEXBackendVolume(virtualVolume, true, getDbClient(), false);
if (storageVolume != null) {
StorageSystem system = getDbClient().queryObject(StorageSystem.class, storageVolume.getStorageController());
// Look up the corresponding device name to our Storage Volume
VolumeInfo volumeInfo = new VolumeInfo(system.getNativeGuid(), system.getSystemType(), storageVolume.getWWN().toUpperCase().replaceAll(":", ""), storageVolume.getNativeId(), storageVolume.getThinlyProvisioned().booleanValue(), VPlexControllerUtils.getVolumeITLs(storageVolume));
String deviceName = client.getDeviceForStorageVolume(volumeInfo);
log.info("device name is " + deviceName);
if (deviceName == null) {
if (!delete) {
// We didn't find a device name for the storage volume. Error if not deleting.
getValidatorLogger().logDiff(volumeId, "Vplex device-name", system.getSerialNumber() + "-" + storageVolume.getNativeId(), ValidatorLogger.NO_MATCHING_ENTRY);
return;
}
}
if (null != deviceName && !deviceName.trim().matches(VPlexApiConstants.STORAGE_VOLUME_NOT_IN_USE)) {
String volumeType = VPlexApiConstants.LOCAL_VIRTUAL_VOLUME;
if (virtualVolume.getAssociatedVolumes() != null && virtualVolume.getAssociatedVolumes().size() > 1) {
volumeType = VPlexApiConstants.DISTRIBUTED_VIRTUAL_VOLUME;
}
VPlexResourceInfo resourceInfo = client.getDeviceStructure(deviceName, volumeType);
if (resourceInfo instanceof VPlexDeviceInfo) {
// local device
VPlexDeviceInfo localDeviceInfo = (VPlexDeviceInfo) resourceInfo;
String virtualVolumeName = localDeviceInfo.getVirtualVolume();
if (virtualVolumeName != null && !virtualVolumeName.equals(virtualVolume.getDeviceLabel())) {
getValidatorLogger().logDiff(volumeId, "virtual-volume name changed", virtualVolume.getDeviceLabel(), virtualVolumeName);
}
} else if (resourceInfo instanceof VPlexDistributedDeviceInfo) {
VPlexDistributedDeviceInfo distDeviceInfo = (VPlexDistributedDeviceInfo) resourceInfo;
String virtualVolumeName = distDeviceInfo.getVirtualVolume();
if (virtualVolumeName != null && !virtualVolumeName.equals(virtualVolume.getDeviceLabel())) {
getValidatorLogger().logDiff(volumeId, "virtual-volume name changed", virtualVolume.getDeviceLabel(), virtualVolumeName);
}
}
}
}
} catch (VPlexApiException ex) {
log.error("Unable to determine if VPLEX device reused: " + volumeId, ex);
if (getValidatorConfig().isValidationEnabled()) {
throw ex;
}
}
if (!delete) {
// If we didn't log an error above indicating that the volume was reused,
// and we are not deleting, it is still an error.
// If we are deleting we won't error if it's just not there.
getValidatorLogger().logDiff(volumeId, "virtual-volume", virtualVolume.getDeviceLabel(), ValidatorLogger.NO_MATCHING_ENTRY);
}
log.info("Vplex Validation complete (no vvinfo found); " + volumeId);
return;
}
if (checkList.contains(ValCk.ID)) {
if (!virtualVolume.getDeviceLabel().equals(vvinfo.getName())) {
getValidatorLogger().logDiff(volumeId, "native-id", virtualVolume.getNativeId(), vvinfo.getName());
}
if (!NullColumnValueGetter.isNullValue(virtualVolume.getWWN()) && vvinfo.getWwn() != null && !virtualVolume.getWWN().equalsIgnoreCase(vvinfo.getWwn())) {
getValidatorLogger().logDiff(volumeId, "wwn", virtualVolume.getWWN(), vvinfo.getWwn());
}
if (virtualVolume.getAssociatedVolumes() != null && !virtualVolume.getAssociatedVolumes().isEmpty()) {
String locality = virtualVolume.getAssociatedVolumes().size() > 1 ? VPlexApiConstants.DISTRIBUTED_VIRTUAL_VOLUME : VPlexApiConstants.LOCAL_VIRTUAL_VOLUME;
if (!locality.equalsIgnoreCase(vvinfo.getLocality())) {
getValidatorLogger().logDiff(volumeId, "locality", locality, vvinfo.getLocality());
}
}
}
if (checkList.contains(ValCk.VPLEX) && !virtualVolume.isIngestedVolumeWithoutBackend(getDbClient())) {
try {
String drillDownInfo = client.getDrillDownInfoForDevice(vvinfo.getSupportingDevice());
VPlexDrillDownParser parser = new VPlexDrillDownParser(drillDownInfo);
VPlexDrillDownParser.Node root = parser.parse();
boolean distributed = (root.getType() == VPlexDrillDownParser.NodeType.DIST) ? true : false;
if (distributed) {
List<VPlexDrillDownParser.Node> svols = root.getNodesOfType(NodeType.SVOL);
boolean hasMirror = svols.size() > 2;
String clusterName = VPlexControllerUtils.getVPlexClusterName(getDbClient(), virtualVolume);
for (VPlexDrillDownParser.Node child : root.getChildren()) {
if (child.getArg2().equals(clusterName)) {
validateStorageVolumes(virtualVolume, volumeId, root.getArg1(), true, child.getArg2(), hasMirror);
}
}
} else {
List<VPlexDrillDownParser.Node> svols = root.getNodesOfType(NodeType.SVOL);
boolean hasMirror = svols.size() > 1;
validateStorageVolumes(virtualVolume, volumeId, root.getArg1(), false, root.getArg2(), hasMirror);
}
} catch (Exception ex) {
getValidatorLogger().logDiff(volumeId, "exception trying to validate storage volumes", virtualVolume.getDeviceLabel(), "N/A");
}
}
log.info("Vplex Validation complete; " + volumeId);
}
use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.
the class AbstractConsistencyGroupManager method deleteCG.
/**
* Deletes the consistency group with the passed URI on the VPLEX storage
* system with the passed URU.
*
* @param vplexSystemURI The URI of the VPlex system.
* @param cgUri The URI of the ViPR consistency group.
* @param cgName The name of the VPlex consistency group to delete.
* @param clusterName The name of the VPlex cluster.
* @param setInactive true to mark the CG for deletion.
* @param stepId The workflow step identifier.
*
* @throws WorkflowException When an error occurs updating the work step
* state.
*/
public void deleteCG(URI vplexSystemURI, URI cgUri, String cgName, String clusterName, Boolean setInactive, String stepId) throws WorkflowException {
StorageSystem vplexSystem = null;
try {
// Update step state to executing.
WorkflowStepCompleter.stepExecuting(stepId);
log.info(String.format("Executing workflow step deleteCG. Storage System: %s, CG Name: %s, Cluster Name: %s", vplexSystemURI, cgName, clusterName));
vplexSystem = getDataObject(StorageSystem.class, vplexSystemURI, dbClient);
VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
log.info("Got VPlex API client for VPlex system {}", vplexSystemURI);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_085);
// Make a call to the VPlex API client to delete the consistency group.
client.deleteConsistencyGroup(cgName);
log.info(String.format("Deleted consistency group %s", cgName));
cleanUpVplexCG(vplexSystemURI, cgUri, cgName, setInactive);
// Update step status to success.
WorkflowStepCompleter.stepSucceded(stepId);
} catch (VPlexApiException vae) {
if (vae.getServiceCode().getCode() == ServiceCode.VPLEX_CG_NOT_FOUND.getCode()) {
log.info(String.format("Consistency group %s not found on storage system: %s. Assumed already deleted.", clusterName + ":" + cgName, (vplexSystem != null && vplexSystem.forDisplay() != null) ? vplexSystem.forDisplay() : vplexSystemURI));
cleanUpVplexCG(vplexSystemURI, cgUri, cgName, setInactive);
WorkflowStepCompleter.stepSucceded(stepId);
} else {
log.error("Exception deleting consistency group: " + vae.getMessage(), vae);
WorkflowStepCompleter.stepFailed(stepId, vae);
}
} catch (Exception ex) {
log.error("Exception deleting consistency group: " + ex.getMessage(), ex);
String opName = ResourceOperationTypeEnum.DELETE_CONSISTENCY_GROUP.getName();
ServiceError serviceError = VPlexApiException.errors.deleteCGFailed(opName, ex);
WorkflowStepCompleter.stepFailed(stepId, serviceError);
}
}
use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.
the class VPlexConsistencyGroupManager method addVolumesToCG.
/**
* Adds volumes to a BlockConsistencyGroup.
* @param vplexSystem - StorageSystem representing the Vplex
* @param cg -- Block Consistency Group the volumes are to be added to
* @param vplexVolumes -- Collection of Vplex volumes to be added
* @param stepId -- String Stepid. WorkflowStepCompleter is called if successful or not.
* @return true if successful, false if not
*/
private boolean addVolumesToCG(StorageSystem vplexSystem, BlockConsistencyGroup cg, Collection<Volume> vplexVolumes, String stepId) {
try {
VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
// Get the names of the volumes to be added.
Volume protoVolume = null;
List<String> vplexVolumeNames = new ArrayList<String>();
for (Volume vplexVolume : vplexVolumes) {
if (protoVolume == null) {
protoVolume = vplexVolume;
}
vplexVolumeNames.add(vplexVolume.getDeviceLabel());
log.info("VPLEX volume:" + vplexVolume.getDeviceLabel());
}
log.info("Got VPLEX volume names.");
String cgName = getVplexCgName(protoVolume, cg.getId());
long startTime = System.currentTimeMillis();
// Add the volumes to the CG.
client.addVolumesToConsistencyGroup(cgName, vplexVolumeNames);
long elapsed = System.currentTimeMillis() - startTime;
log.info(String.format("TIMER: Adding %s virtual volume(s) %s to the consistency group %s took %f seconds", vplexVolumeNames.size(), vplexVolumeNames, cgName, (double) elapsed / (double) 1000));
// adding volumes to a CG after volume creation.
for (Volume vplexVolume : vplexVolumes) {
vplexVolume.setConsistencyGroup(cg.getId());
dbClient.updateObject(vplexVolume);
}
// Update workflow step state to success.
WorkflowStepCompleter.stepSucceded(stepId);
log.info("Updated workflow step state to success for add volumes to consistency group.");
return true;
} catch (VPlexApiException vae) {
log.error("Exception adding volumes to consistency group: " + vae.getMessage(), vae);
WorkflowStepCompleter.stepFailed(stepId, vae);
return false;
} catch (Exception ex) {
log.error("Exception adding volumes to consistency group: " + ex.getMessage(), ex);
ServiceError svcError = VPlexApiException.errors.jobFailed(ex);
WorkflowStepCompleter.stepFailed(stepId, svcError);
return false;
}
}
use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.
the class VPlexConsistencyGroupManager method updateConsistencyGroupReadOnlyState.
/**
* Step to call the VPLEX to update the read-only flag on a consistency group.
* If the Vplex Api library detects the firmware does not properly handle the flag,
* a warning message is put in the SUCCESS status.
* @param vplexVolumeURIs -- List of at least some volumes in the consistency group.
* @param isReadOnly - if true marks read-only, false read-write
* @param stepId - Workflow step id
*/
public void updateConsistencyGroupReadOnlyState(List<URI> vplexVolumeURIs, Boolean isReadOnly, String stepId) {
try {
WorkflowStepCompleter.stepExecuting(stepId);
// Get the first virtual volume, as all volumes should be in the same CG
Volume vplexVolume = dbClient.queryObject(Volume.class, vplexVolumeURIs.get(0));
// Get the storage system for the Vplex.
StorageSystem vplexSystem = dbClient.queryObject(StorageSystem.class, vplexVolume.getStorageController());
// And from that a handle to the VplexApiClient
VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
// From that get the Consistency Group, if there is not one, just return success
if (NullColumnValueGetter.isNullURI(vplexVolume.getConsistencyGroup())) {
log.info("Volume has no ConsistencyGroup: " + vplexVolume.getLabel());
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, vplexVolume.getConsistencyGroup());
// Get the consistency group parameters.
ClusterConsistencyGroupWrapper clusterConsistencyGroup = getClusterConsistencyGroup(vplexVolume, cg);
String cgName = clusterConsistencyGroup.getCgName();
String clusterName = clusterConsistencyGroup.getClusterName();
boolean isDistributed = clusterConsistencyGroup.isDistributed();
// Make the call to update the consistency group read-only status
client.updateConsistencyGroupReadOnly(cgName, clusterName, isDistributed, isReadOnly);
// Complete the step
WorkflowStepCompleter.stepSucceded(stepId);
} catch (VPlexApiException ex) {
if (ServiceCode.VPLEX_API_FIRMWARE_UPDATE_NEEDED.equals(ex.getServiceCode())) {
// The firmware doesn't support read-only flag, inform the user, but do not fail.
WorkflowStepCompleter.stepSucceeded(stepId, ex.getLocalizedMessage());
} else {
log.info("Exception setting Consistency Group read-only state: " + ex.getMessage());
ServiceError svcError = VPlexApiException.errors.jobFailed(ex);
WorkflowStepCompleter.stepFailed(stepId, svcError);
}
} catch (Exception ex) {
log.info("Exception setting Consistency Group read-only state: " + ex.getMessage());
ServiceError svcError = VPlexApiException.errors.jobFailed(ex);
WorkflowStepCompleter.stepFailed(stepId, svcError);
}
}
Aggregations