use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevice method addVolumesToCG.
private synchronized void addVolumesToCG(StorageSystem storageSystem, URI consistencyGroupId, List<URI> volumeURIs) throws Exception {
BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
if (null != consistencyGroup) {
String groupName = _helper.getConsistencyGroupName(consistencyGroup, storageSystem);
if (groupName.equals(EMPTY_CG_NAME)) {
// may also check if CG instance exists on array, or not, if not, re-create it here need to create CG group
// here with member volumes this will ensure the new CG is associated to right pool without member volumes,
// there is no way to control which pool the CG will be associated to
CIMArgument[] inArgs = _helper.getCreateReplicationGroupInputArguments(storageSystem, consistencyGroup.getLabel(), volumeURIs);
CIMArgument[] outArgs = new CIMArgument[5];
_helper.callReplicationSvc(storageSystem, SmisConstants.CREATE_GROUP, inArgs, outArgs);
// grab the CG name from the instance ID and store it in the db
final CIMObjectPath cgPath = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.CP_REPLICATION_GROUP);
final String deviceName = _helper.getReplicationGroupName(cgPath);
// the order of adding and removing system consistency group makes different somehow, removing before adding won't work
consistencyGroup.addSystemConsistencyGroup(storageSystem.getId().toString(), deviceName);
consistencyGroup.removeSystemConsistencyGroup(storageSystem.getId().toString(), EMPTY_CG_NAME);
_dbClient.updateObject(consistencyGroup);
} else {
// existing CG, add volumes to the CG
CIMObjectPath cgPath = _cimPath.getConsistencyGroupPath(storageSystem, groupName);
CIMInstance cgPathInstance = _helper.checkExists(storageSystem, cgPath, false, false);
// if there is no consistency group with the given name, set the operation to error
if (cgPathInstance == null) {
throw DeviceControllerException.exceptions.consistencyGroupNotFound(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storageSystem.getId()));
}
_helper.addVolumesToConsistencyGroup(storageSystem, new ArrayList<URI>(volumeURIs), cgPath);
}
}
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup 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.db.client.model.BlockConsistencyGroup 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);
}
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method doRemoveFromConsistencyGroup.
@Override
public void doRemoveFromConsistencyGroup(StorageSystem storage, URI consistencyGroupId, List<URI> blockObjects, TaskCompleter taskCompleter) throws DeviceControllerException {
BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
// check if lungroup has been created in the array
String lunGroupId = consistencyGroup.getCgNameOnStorageSystem(storage.getId());
if (lunGroupId == null || lunGroupId.isEmpty()) {
// lun group has not created yet. return error
_logger.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId())));
return;
}
VNXeApiClient apiClient = getVnxeClient(storage);
try {
List<String> luns = new ArrayList<String>();
for (URI volume : blockObjects) {
luns.add(volume.toString());
}
apiClient.removeLunsFromLunGroup(lunGroupId, luns);
for (URI blockObjectURI : blockObjects) {
BlockObject blockObject = BlockObject.fetch(_dbClient, blockObjectURI);
if (blockObject != null) {
blockObject.setConsistencyGroup(NullColumnValueGetter.getNullURI());
}
_dbClient.updateAndReindexObject(blockObject);
}
taskCompleter.ready(_dbClient);
_logger.info("Remove volumes from the consistency group successfully");
} catch (Exception e) {
_logger.error("Exception caught when removing volumes from the consistency group ", e);
taskCompleter.error(_dbClient, DeviceControllerException.exceptions.failedToRemoveMembersToConsistencyGroup(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId()), e.getMessage()));
}
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class AbstractConsistencyGroupManager method addVolumeToCg.
@Override
public void addVolumeToCg(URI cgURI, Volume vplexVolume, VPlexApiClient client, boolean addToViPRCg) throws Exception {
BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
ClusterConsistencyGroupWrapper clusterCgWrapper = this.getClusterConsistencyGroup(vplexVolume, cg);
log.info("Adding volumes to consistency group: " + clusterCgWrapper.getCgName());
// Add the volume from the CG.
client.addVolumesToConsistencyGroup(clusterCgWrapper.getCgName(), Arrays.asList(vplexVolume.getDeviceLabel()));
if (addToViPRCg) {
vplexVolume.setConsistencyGroup(cgURI);
dbClient.updateAndReindexObject(vplexVolume);
}
}
Aggregations