use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doDeleteSnapshot.
@Override
public BiosCommandResult doDeleteSnapshot(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_logger.info("Deleting file system {} snapshot {} ", args.getFsName(), args.getSnapshotLabel());
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeCommandJob job = null;
VNXeFileTaskCompleter completer = null;
try {
job = apiClient.deleteFileSystemSnap(args.getSnapNativeId());
if (job != null) {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
VNXeDeleteFileSystemSnapshotJob snapJob = new VNXeDeleteFileSystemSnapshotJob(job.getId(), storage.getId(), completer);
ControllerServiceImpl.enqueueJob(new QueueJob(snapJob));
} else {
_logger.error("No job returned from deleteFileSystemSnap");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("snapshotFileSystem", "No Job returned from deleteFileSystemSnap");
return BiosCommandResult.createErrorResult(error);
}
} catch (VNXeException e) {
_logger.error("Delete file system snapshot got the exception", e);
if (completer != null) {
completer.error(_dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("Delete file system snpashot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystemSnapshot", ex.getMessage());
if (completer != null) {
completer.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete filesystem snapshot job submitted - Array:%s, fileSystem: %s, snapshot: %s", storage.getSerialNumber(), args.getFsName(), args.getSnapshotName()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createPendingResult();
}
use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXUnityBlockStorageDevice method doCreateVolumes.
@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
logger.info("creating volumes, array: {}, pool : {}", storage.getSerialNumber(), storagePool.getNativeId());
VNXeApiClient apiClient = getVnxUnityClient(storage);
List<String> jobs = new ArrayList<String>();
boolean opFailed = false;
try {
boolean isCG = false;
Volume vol = volumes.get(0);
String cgName = vol.getReplicationGroupInstance();
if (vol.getConsistencyGroup() != null && NullColumnValueGetter.isNotNullValue(cgName)) {
isCG = true;
}
List<String> volNames = new ArrayList<String>();
String autoTierPolicyName = null;
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_022);
for (Volume volume : volumes) {
String tenantName = "";
try {
TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
tenantName = tenant.getLabel();
} catch (DatabaseException e) {
logger.error("Error lookup TenantOrb object", e);
}
String label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', VNXeConstants.MAX_NAME_LENGTH);
autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
if (autoTierPolicyName.equals(Constants.NONE)) {
autoTierPolicyName = null;
}
volume.setNativeGuid(label);
dbClient.updateObject(volume);
if (!isCG) {
VNXeCommandJob job = apiClient.createLun(label, storagePool.getNativeId(), volume.getCapacity(), volume.getThinlyProvisioned(), autoTierPolicyName);
jobs.add(job.getId());
} else {
volNames.add(label);
}
}
if (isCG) {
logger.info(String.format("cg %s for the volume", cgName));
String cgId = apiClient.getConsistencyGroupIdByName(cgName);
VNXeUtils.getCGLock(workflowService, storage, cgName, opId);
VNXeCommandJob job = apiClient.createLunsInConsistencyGroup(volNames, storagePool.getNativeId(), vol.getCapacity(), vol.getThinlyProvisioned(), autoTierPolicyName, cgId);
jobs.add(job.getId());
}
VNXeCreateVolumesJob createVolumesJob = new VNXeCreateVolumesJob(jobs, storage.getId(), taskCompleter, storagePool.getId(), isCG);
ControllerServiceImpl.enqueueJob(new QueueJob(createVolumesJob));
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_023);
} catch (VNXeException e) {
logger.error("Create volumes got the exception", e);
opFailed = true;
taskCompleter.error(dbClient, e);
} catch (Exception ex) {
logger.error("Create volumes got the exception", ex);
opFailed = true;
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumes", ex.getMessage());
taskCompleter.error(dbClient, error);
}
if (opFailed) {
for (Volume vol : volumes) {
vol.setInactive(true);
dbClient.updateObject(vol);
}
}
}
use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXUnityBlockStorageDevice method doDeleteVolumes.
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter completer) throws DeviceControllerException {
logger.info("deleting volumes, array: {}", storageSystem.getSerialNumber());
VNXeApiClient apiClient = getVnxUnityClient(storageSystem);
Map<String, List<String>> cgNameMap = new HashMap<String, List<String>>();
try {
Set<URI> updateStoragePools = new HashSet<URI>();
// Invoke a test failure if testing
for (Volume volume : volumes) {
String lunId = volume.getNativeId();
if (NullColumnValueGetter.isNullValue(lunId)) {
logger.info(String.format("The volume %s does not have native id, do nothing", volume.getLabel()));
continue;
}
updateStoragePools.add(volume.getPool());
if (!apiClient.checkLunExists(lunId)) {
logger.info(String.format("The volume %s does not exist in the array, do nothing", volume.getLabel()));
continue;
}
String cgName = volume.getReplicationGroupInstance();
if (NullColumnValueGetter.isNotNullValue(cgName)) {
List<String> lunIds = cgNameMap.get(cgName);
if (lunIds == null) {
lunIds = new ArrayList<String>();
cgNameMap.put(cgName, lunIds);
}
lunIds.add(volume.getNativeId());
} else {
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_035);
apiClient.deleteLunSync(volume.getNativeId(), false);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_036);
}
}
for (Map.Entry<String, List<String>> entry : cgNameMap.entrySet()) {
String cgName = entry.getKey();
List<String> lunIDs = entry.getValue();
String cgId = apiClient.getConsistencyGroupIdByName(cgName);
boolean isRP = false;
if (cgId != null && !cgId.isEmpty()) {
// Check if the CG has blockHostAccess to a RP host. if the CG is exported to a RP, we could not delete the lun
// directly, we have to remove the volume from the CG first, then delete it.
StorageResource cg = apiClient.getStorageResource(cgId);
List<BlockHostAccess> hosts = cg.getBlockHostAccess();
if (hosts != null && !hosts.isEmpty()) {
for (BlockHostAccess hostAccess : hosts) {
VNXeBase hostId = hostAccess.getHost();
if (hostId != null) {
VNXeHost host = apiClient.getHostById(hostId.getId());
if (host != null) {
if (host.getType() == HostTypeEnum.RPA.getValue()) {
// Remove the luns from the CG
isRP = true;
logger.info(String.format("Removing volumes from CG because the CG %sis exported to RP", cgName));
VNXeUtils.getCGLock(workflowService, storageSystem, cgName, opId);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_034);
apiClient.removeLunsFromConsistencyGroup(cgId, lunIDs);
for (String lunId : lunIDs) {
logger.info(String.format("Deleting the volume %s", lunId));
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_035);
apiClient.deleteLunSync(lunId, false);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_036);
}
break;
}
}
}
}
}
}
if (!isRP) {
VNXeUtils.getCGLock(workflowService, storageSystem, cgName, opId);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_034);
apiClient.deleteLunsFromConsistencyGroup(cgId, lunIDs);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_037);
}
}
for (URI pool : updateStoragePools) {
VNXeJob.updateStoragePoolCapacity(dbClient, apiClient, pool, null);
}
completer.ready(dbClient);
} catch (VNXeException e) {
logger.error("Delete volumes got the exception", e);
completer.error(dbClient, e);
} catch (Exception ex) {
logger.error("Delete volumes got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteVolumes", ex.getMessage());
completer.error(dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXUnityBlockStorageDevice method doExpandVolume.
@Override
public void doExpandVolume(StorageSystem storage, StoragePool pool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
logger.info(String.format("Expand Volume Start - Array: %s, Pool: %s, Volume: %s, New size: %d", storage.getSerialNumber(), pool.getNativeGuid(), volume.getLabel(), size));
String cgName = volume.getReplicationGroupInstance();
String consistencyGroupId = null;
try {
VNXeApiClient apiClient = getVnxUnityClient(storage);
if (NullColumnValueGetter.isNotNullValue(cgName)) {
consistencyGroupId = apiClient.getConsistencyGroupIdByName(cgName);
VNXeUtils.getCGLock(workflowService, storage, cgName, taskCompleter.getOpId());
}
VNXeCommandJob commandJob = apiClient.expandLun(volume.getNativeId(), size, consistencyGroupId);
VNXeExpandVolumeJob expandVolumeJob = new VNXeExpandVolumeJob(commandJob.getId(), storage.getId(), taskCompleter);
ControllerServiceImpl.enqueueJob(new QueueJob(expandVolumeJob));
} catch (VNXeException e) {
logger.error("Expand volume got the exception", e);
taskCompleter.error(dbClient, e);
} catch (Exception ex) {
logger.error("Expand volume got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("ExpandVolume", ex.getMessage());
taskCompleter.error(dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doDeleteSnapshot.
@Override
public BiosCommandResult doDeleteSnapshot(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_logger.info("Deleting file system {} snapshot {} ", args.getFsName(), args.getSnapshotLabel());
VNXeApiClient apiClient = getVnxUnityClient(storage);
VNXeCommandJob job = null;
VNXeFileTaskCompleter completer = null;
try {
job = apiClient.deleteFileSystemSnap(args.getSnapNativeId());
if (job != null) {
completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
VNXeDeleteFileSystemSnapshotJob snapJob = new VNXeDeleteFileSystemSnapshotJob(job.getId(), storage.getId(), completer);
ControllerServiceImpl.enqueueJob(new QueueJob(snapJob));
} else {
_logger.error("No job returned from deleteFileSystemSnap");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("snapshotFileSystem", "No Job returned from deleteFileSystemSnap");
return BiosCommandResult.createErrorResult(error);
}
} catch (VNXeException e) {
_logger.error("Delete file system snapshot got the exception", e);
if (completer != null) {
completer.error(dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("Delete file system snpashot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystemSnapshot", ex.getMessage());
if (completer != null) {
completer.error(dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete filesystem snapshot job submitted - Array:%s, fileSystem: %s, snapshot: %s", storage.getSerialNumber(), args.getFsName(), args.getSnapshotName()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createPendingResult();
}
Aggregations