use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeSnapshotOperation method deleteGroupSnapshots.
@Override
public void deleteGroupSnapshots(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
List<BlockSnapshot> snapshots = _dbClient.queryObject(BlockSnapshot.class, Arrays.asList(snapshot));
BlockSnapshot snapshotObj = snapshots.get(0);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeLunGroupSnap lunGroupSnap = apiClient.getLunGroupSnapshot(snapshotObj.getReplicationGroupInstance());
if (lunGroupSnap != null) {
VNXeCommandJob job = apiClient.deleteLunGroupSnap(lunGroupSnap.getId());
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockDeleteSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
} else {
// Should not take this path, but treat as an error if we do
// happen to get a null job due to some error in the client.
_log.error("Unexpected null job from VNXe client call to delete group snapshot.");
ServiceCoded sc = DeviceControllerExceptions.vnxe.nullJobForDeleteGroupSnapshot(snapshotObj.forDisplay(), snapshotObj.getReplicationGroupInstance());
taskCompleter.error(_dbClient, sc);
}
} else {
// Treat as in the single volume snapshot case and presume
// the group snapshot has already been deleted.
List<BlockSnapshot> grpSnapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
for (BlockSnapshot grpSnapshot : grpSnapshots) {
grpSnapshot.setInactive(true);
grpSnapshot.setIsSyncActive(false);
}
_dbClient.updateObject(grpSnapshots);
taskCompleter.ready(_dbClient);
}
} catch (VNXeException e) {
_log.error("Delete group snapshot got the exception", e);
taskCompleter.error(_dbClient, e);
} catch (Exception ex) {
_log.error("Delete group snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeletGroupSnapshot", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeSnapshotOperation method createSingleVolumeSnapshot.
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
String tenantName = tenant.getLabel();
String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeCommandJob job = apiClient.createLunSnap(volume.getNativeId(), snapLabelToUse);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockSnapshotCreateJob(job.getId(), storage.getId(), !createInactive, taskCompleter)));
}
} catch (VNXeException e) {
_log.error("Create volume snapshot got the exception", e);
taskCompleter.error(_dbClient, e);
} catch (Exception ex) {
_log.error("Create volume snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumeSnapshot", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doExpandFS.
@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
_logger.info("expanding file system: ", args.getFsName());
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeCommandJob job = null;
VNXeFileTaskCompleter completer = null;
try {
job = apiClient.expandFileSystem(args.getFsNativeId(), args.getNewFSCapacity());
if (job != null) {
completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
VNXeExpandFileSystemJob expandFSJob = new VNXeExpandFileSystemJob(job.getId(), storage.getId(), completer);
ControllerServiceImpl.enqueueJob(new QueueJob(expandFSJob));
} else {
_logger.error("No job returned from expandFileSystem");
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("expandFileSystem", "No Job returned from expandFileSystem");
return BiosCommandResult.createErrorResult(error);
}
} catch (VNXeException e) {
_logger.error("Expand file system got the exception", e);
if (completer != null) {
completer.error(_dbClient, e);
}
return BiosCommandResult.createErrorResult(e);
} catch (Exception ex) {
_logger.error("Expand file system got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("ExpandFileSystem", ex.getMessage());
if (completer != null) {
completer.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Expand filesystem job submitted - Array:%s, fileSystem: %s, new size: %d", storage.getSerialNumber(), args.getFsName(), args.getNewFSCapacity()));
_logger.info(logMsgBuilder.toString());
return BiosCommandResult.createPendingResult();
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeStorageDevice 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 = getVnxeClient(storage);
List<String> jobs = new ArrayList<String>();
boolean opFailed = false;
try {
boolean isCG = false;
Volume vol = volumes.get(0);
if (vol.getConsistencyGroup() != null) {
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.persistObject(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) {
URI cg = vol.getConsistencyGroup();
BlockConsistencyGroup cgObj = _dbClient.queryObject(BlockConsistencyGroup.class, cg);
String cgId = cgObj.getCgNameOnStorageSystem(storage.getId());
VNXeCommandJob job = apiClient.createLunsInLunGroup(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.persistObject(vol);
}
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doCreateConsistencyGroup.
@Override
public void doCreateConsistencyGroup(StorageSystem storage, URI consistencyGroup, String replicationGroupName, TaskCompleter taskCompleter) throws DeviceControllerException {
_logger.info("creating consistency group, array: {}", storage.getSerialNumber());
BlockConsistencyGroup consistencyGroupObj = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
VNXeApiClient apiClient = getVnxeClient(storage);
String tenantName = "";
try {
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, consistencyGroupObj.getTenant().getURI());
tenantName = tenant.getLabel();
} catch (DatabaseException e) {
_logger.error("Error lookup TenantOrb object", e);
}
String label = nameGenerator.generate(tenantName, consistencyGroupObj.getLabel(), consistencyGroupObj.getId().toString(), '-', VNXeConstants.MAX_NAME_LENGTH);
try {
VNXeCommandResult result = apiClient.createLunGroup(label);
if (result.getStorageResource() != null) {
consistencyGroupObj.addSystemConsistencyGroup(storage.getId().toString(), result.getStorageResource().getId());
consistencyGroupObj.addConsistencyGroupTypes(Types.LOCAL.name());
if (NullColumnValueGetter.isNullURI(consistencyGroupObj.getStorageController())) {
consistencyGroupObj.setStorageController(storage.getId());
}
_dbClient.persistObject(consistencyGroupObj);
taskCompleter.ready(_dbClient);
} else {
_logger.error("No storage resource Id returned");
consistencyGroupObj.setInactive(true);
_dbClient.persistObject(consistencyGroupObj);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateConsistencyGroup failed");
taskCompleter.error(_dbClient, error);
}
} catch (Exception e) {
_logger.error("Exception caught when createing consistency group ", e);
consistencyGroupObj.setInactive(true);
_dbClient.persistObject(consistencyGroupObj);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateConsistencyGroup", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
Aggregations