use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.
the class HDSMirrorOperations method createSingleVolumeMirror.
/**
* 1. Find ReplicationGroup objId from Device Manager
* 2. Check dummy Host Group available on Storage System. if not available create a dummy Host Group name.
* 3. Create a secondary volume and add dummy host group on it.
* 4. create a SI pair.
*
* @param storageSystem {@link StorageSystem}
* @param mirrorVolumeURI {@link URI}
* @param createInactive {@link Boolean}
* @param taskCompleter {@link TaskCompleter}
*/
@Override
public void createSingleVolumeMirror(StorageSystem storageSystem, URI mirrorVolumeURI, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("START createSingleVolumeMirror operation");
try {
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
HDSApiProtectionManager hdsApiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
String replicationGroupObjectID = hdsApiClient.getHdsApiProtectionManager().getReplicationGroupObjectId();
if (replicationGroupObjectID == null) {
log.error("Unable to find replication group information/pair management server for pair configuration");
throw HDSException.exceptions.replicationGroupNotAvailable();
}
BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirrorVolumeURI);
Volume source = dbClient.queryObject(Volume.class, mirrorObj.getSource());
hdsProtectionOperations.createSecondaryVolumeForMirror(storageSystem, source.getId(), mirrorObj);
mirrorObj = dbClient.queryObject(BlockMirror.class, mirrorVolumeURI);
hdsProtectionOperations.addDummyLunPath(hdsApiClient, mirrorObj);
String pairName = hdsProtectionOperations.generatePairName(source, mirrorObj);
log.info("Pair Name :{}", pairName);
ReplicationInfo replicationInfo = hdsApiProtectionManager.createShadowImagePair(replicationGroupObjectID, pairName, HDSUtils.getSystemArrayType(storageSystem), HDSUtils.getSystemSerialNumber(storageSystem), source.getNativeId(), mirrorObj.getNativeId(), storageSystem.getModel());
mirrorObj.setSyncState(SynchronizationState.SYNCHRONIZED.name());
dbClient.persistObject(mirrorObj);
log.info("Replication Info object :{}", replicationInfo.toXMLString());
taskCompleter.ready(dbClient);
} catch (Exception e) {
String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, mirrorVolumeURI);
log.error(errorMsg, e);
ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("createSingleVolumeMirror", e.getMessage());
taskCompleter.error(dbClient, serviceError);
}
log.info("FINISHED createSingleVolumeMirror operation");
}
use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method removeDummyLunPath.
/**
* Removes Dummy Lun Path from Secondary Volume
*
* @param storageSystem
* @param blockObjectURI
* @throws Exception
*/
public void removeDummyLunPath(StorageSystem storageSystem, URI blockObjectURI) throws Exception {
log.info("Started dummy lun path removal from secondary volume");
HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
HDSApiExportManager apiExportManager = apiClient.getHDSApiExportManager();
String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
// Volume volume=dbClient.queryObject(Volume.class, volumeURI);
BlockObject blockObj = BlockObject.fetch(dbClient, blockObjectURI);
String dummyLunPathId = getDummyHSDPathId(storageSystem, blockObj);
if (dummyLunPathId != null) {
apiExportManager.deleteLunPathsFromSystem(systemObjectId, Arrays.asList(dummyLunPathId), storageSystem.getModel());
log.info("Deleted Dummy Lun path from secondary volume");
} else {
log.info("Dummy lun path has been removed already");
}
}
use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method createSecondaryVolumeForMirror.
/**
* Creates secondary volume for ShadowImage pair operations.
*
* @param storageSystem
* @param sourceVolume
* @param mirror
* @throws Exception
*/
public void createSecondaryVolumeForMirror(StorageSystem storageSystem, URI sourceVolume, BlockMirror mirror) throws Exception {
log.info("SecondaryVolume for mirror creation operation started");
String taskId = UUID.randomUUID().toString();
TaskCompleter taskCompleter = new BlockMirrorCreateCompleter(mirror.getId(), taskId);
String asyncTaskMessageId = null;
HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
StoragePool targetPool = dbClient.queryObject(StoragePool.class, mirror.getPool());
Volume source = dbClient.queryObject(Volume.class, sourceVolume);
TenantOrg tenant = dbClient.queryObject(TenantOrg.class, source.getTenant().getURI());
String tenantName = tenant.getLabel();
String targetLabelToUse = nameGenerator.generate(tenantName, mirror.getLabel(), mirror.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
if (mirror.getThinlyProvisioned()) {
asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, targetPool.getNativeId(), mirror.getCapacity(), 1, targetLabelToUse, HDSConstants.QUICK_FORMAT_TYPE, storageSystem.getModel());
} else {
String poolObjectID = HDSUtils.getPoolObjectID(targetPool);
asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, mirror.getCapacity(), 1, targetLabelToUse, null, storageSystem.getModel(), null);
}
if (asyncTaskMessageId != null) {
HDSJob createHDSJob = new HDSBlockCreateMirrorJob(asyncTaskMessageId, mirror.getStorageController(), targetPool.getId(), taskCompleter);
hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
}
log.info("SecondaryVolume for mirror creation operation completed successfully");
}
use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method createSecondaryVolumeForClone.
/**
* Creates secondary volume for ShadowImage pair operations.
*
* @param storageSystem
* @param sourceVolume
* @param targetVolume
* @throws Exception
*/
public void createSecondaryVolumeForClone(StorageSystem storageSystem, URI sourceVolume, Volume targetVolume) throws Exception {
log.info("SecondaryVolume creation operation started");
String taskId = UUID.randomUUID().toString();
TaskCompleter taskCompleter = new VolumeCreateCompleter(targetVolume.getId(), taskId);
String asyncTaskMessageId = null;
HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
BlockObject sourceObj = BlockObject.fetch(dbClient, sourceVolume);
URI tenantUri = null;
StoragePool targetPool = dbClient.queryObject(StoragePool.class, targetVolume.getPool());
if (sourceObj instanceof BlockSnapshot) {
// In case of snapshot, get the tenant from its parent volume
NamedURI parentVolUri = ((BlockSnapshot) sourceObj).getParent();
Volume parentVolume = dbClient.queryObject(Volume.class, parentVolUri);
tenantUri = parentVolume.getTenant().getURI();
TenantOrg tenantOrg = dbClient.queryObject(TenantOrg.class, tenantUri);
// String cloneLabel = generateLabel(tenantOrg, cloneObj);
} else {
// This is a default flow
tenantUri = ((Volume) sourceObj).getTenant().getURI();
}
if (targetVolume.getThinlyProvisioned()) {
asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, targetPool.getNativeId(), targetVolume.getCapacity(), 1, targetVolume.getLabel(), HDSConstants.QUICK_FORMAT_TYPE, storageSystem.getModel());
} else {
String poolObjectID = HDSUtils.getPoolObjectID(targetPool);
asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, targetVolume.getCapacity(), 1, targetVolume.getLabel(), null, storageSystem.getModel(), null);
}
if (asyncTaskMessageId != null) {
HDSJob createHDSJob = new HDSCreateVolumeJob(asyncTaskMessageId, targetVolume.getStorageController(), targetPool.getId(), taskCompleter);
hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
}
log.info("SecondaryVolume creation operation completed successfully");
}
use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.
the class HDSProtectionOperations method getDummyHSDPathId.
/**
* Get Dummy Lun Path's path objectID
*
* @param storageSystem
* @param volume
* @return
* @throws Exception
*/
private String getDummyHSDPathId(StorageSystem storageSystem, BlockObject blockObj) throws Exception {
String dummyLunPathId = null;
HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
HDSApiExportManager apiExportManager = apiClient.getHDSApiExportManager();
String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
List<HostStorageDomain> hsdList = apiExportManager.getHostStorageDomains(systemObjectId);
if (hsdList != null) {
for (HostStorageDomain hsd : hsdList) {
if (hsd != null && HDSConstants.DUMMY_HSD.equalsIgnoreCase(hsd.getNickname())) {
if (hsd.getPathList() != null) {
for (Path path : hsd.getPathList()) {
if (path.getDevNum().equalsIgnoreCase(blockObj.getNativeId())) {
dummyLunPathId = path.getObjectID();
log.info("Found secondary volume's dummy lun path id :{}", dummyLunPathId);
return dummyLunPathId;
}
}
}
}
}
}
log.info("Dummy lun path has been removed already for this secondary volume");
return dummyLunPathId;
}
Aggregations