use of com.emc.storageos.hds.model.LogicalUnit in project coprhd-controller by CoprHD.
the class HDSVolumeDiscoverer method discoverUnManagedVolumes.
public void discoverUnManagedVolumes(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(accessProfile), accessProfile.getUserName(), accessProfile.getPassword());
List<UnManagedVolume> newUnManagedVolumeList = new ArrayList<UnManagedVolume>();
List<UnManagedVolume> updateUnManagedVolumeList = new ArrayList<UnManagedVolume>();
Set<URI> allDiscoveredUnManagedVolumes = new HashSet<URI>();
HDSApiVolumeManager volumeManager = hdsApiClient.getHDSApiVolumeManager();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
List<LogicalUnit> luList = volumeManager.getAllLogicalUnits(systemObjectId);
if (null != luList && !luList.isEmpty()) {
log.info("Processing {} volumes received from HiCommand server.", luList.size());
URIQueryResultList storagePoolURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
HashMap<String, StoragePool> pools = new HashMap<String, StoragePool>();
Iterator<URI> poolsItr = storagePoolURIs.iterator();
while (poolsItr.hasNext()) {
URI storagePoolURI = poolsItr.next();
StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
pools.put(storagePool.getNativeGuid(), storagePool);
}
for (LogicalUnit logicalUnit : luList) {
log.info("Processing LogicalUnit: {}", logicalUnit.getObjectID());
UnManagedVolume unManagedVolume = null;
String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), String.valueOf(logicalUnit.getDevNum()));
if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
}
String unManagedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), String.valueOf(logicalUnit.getDevNum()));
unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNativeGuid);
boolean unManagedVolumeExists = (null != unManagedVolume) ? true : false;
StoragePool storagePool = getStoragePoolOfUnManagedVolume(logicalUnit, storageSystem, pools, dbClient);
if (null != storagePool) {
if (!unManagedVolumeExists) {
unManagedVolume = createUnManagedVolume(unManagedVolumeNativeGuid, logicalUnit, storageSystem, storagePool, dbClient);
newUnManagedVolumeList.add(unManagedVolume);
} else {
updateUnManagedVolumeInfo(logicalUnit, storageSystem, storagePool, unManagedVolume, dbClient);
updateUnManagedVolumeList.add(unManagedVolume);
}
allDiscoveredUnManagedVolumes.add(unManagedVolume.getId());
} else {
log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", logicalUnit.getObjectID());
}
performUnManagedVolumesBookKeepting(newUnManagedVolumeList, updateUnManagedVolumeList, partitionManager, dbClient, Constants.DEFAULT_PARTITION_SIZE);
}
performUnManagedVolumesBookKeepting(newUnManagedVolumeList, updateUnManagedVolumeList, partitionManager, dbClient, 0);
// Process those active unmanaged volume objects available in database but not in newly discovered items, to mark them inactive.
DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, allDiscoveredUnManagedVolumes, dbClient, partitionManager);
} else {
log.info("No volumes retured by HiCommand Server for system {}", storageSystem.getId());
}
}
use of com.emc.storageos.hds.model.LogicalUnit in project coprhd-controller by CoprHD.
the class HDSMirrorOperations method deleteSingleVolumeMirror.
/**
* Deletes mirror instance from StorageSystem
*/
@Override
public void deleteSingleVolumeMirror(StorageSystem storageSystem, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Mirror Start - Array:%s", storageSystem.getSerialNumber()));
Set<String> thickLogicalUnitIdList = new HashSet<String>();
Set<String> thinLogicalUnitIdList = new HashSet<String>();
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
logMsgBuilder.append(String.format("%nMirror:%s", mirrorObj.getLabel()));
String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(mirrorObj.getNativeId(), storageSystem);
LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, logicalUnitObjectId);
if (logicalUnit == null) {
// related volume state (if any) has been deleted. skip
// processing, if already deleted from array.
log.info(String.format("Mirror %s already deleted: ", mirrorObj.getNativeId()));
// HDSMirrorOperations.removeReferenceFromSourceVolume(dbClient, mirrorObj);
dbClient.markForDeletion(mirrorObj);
} else {
if (mirrorObj.getThinlyProvisioned()) {
thinLogicalUnitIdList.add(logicalUnitObjectId);
} else {
thickLogicalUnitIdList.add(logicalUnitObjectId);
}
log.info(logMsgBuilder.toString());
if (!thickLogicalUnitIdList.isEmpty()) {
String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectID, thickLogicalUnitIdList, storageSystem.getModel());
if (null != asyncThickLUsJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThickLUsJobId, mirrorObj.getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
}
}
if (!thinLogicalUnitIdList.isEmpty()) {
String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectID, thinLogicalUnitIdList, storageSystem.getModel());
if (null != asyncThinHDSJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSBlockMirrorDeleteJob(asyncThinHDSJobId, mirrorObj.getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete mirror call");
}
}
}
log.info("Delete Mirror End - Array: {} Mirror: {}", storageSystem.getSerialNumber(), mirror);
} catch (Exception e) {
log.error("Problem in deleteSingleVolumeMirror: ", e);
ServiceError error = DeviceControllerErrors.hds.methodFailed("deleteSingleVolumeMirror", e.getMessage());
taskCompleter.error(dbClient, error);
}
}
use of com.emc.storageos.hds.model.LogicalUnit in project coprhd-controller by CoprHD.
the class HDSStorageDevice method doModifyVolumes.
@Override
public void doModifyVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Modify Volume Start - Array:%s, Pool:%s", storage.getSerialNumber(), storagePool.getNativeGuid()));
String systemObjectID = HDSUtils.getSystemObjectID(storage);
for (Volume volume : volumes) {
try {
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s, tieringPolicy: %s", volume.getLabel(), volume.getThinlyProvisioned(), volume.getAutoTieringPolicyUri()));
LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storage));
String policyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
String autoTierPolicyName = null;
if (policyName.equals(Constants.NONE)) {
autoTierPolicyName = null;
} else {
autoTierPolicyName = HitachiTieringPolicy.getPolicy(policyName.replaceAll(HDSConstants.SLASH_OPERATOR, HDSConstants.UNDERSCORE_OPERATOR)).getKey();
}
if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
if (ldevItr.hasNext()) {
LDEV ldev = ldevItr.next();
String asyncMessageId = hdsApiClient.modifyThinVolumeTieringPolicy(systemObjectID, logicalUnit.getObjectID(), ldev.getObjectID(), autoTierPolicyName, storage.getModel());
if (null != asyncMessageId) {
HDSJob modifyHDSJob = new HDSModifyVolumeJob(asyncMessageId, volume.getStorageController(), taskCompleter, HDSModifyVolumeJob.VOLUME_MODIFY_JOB);
ControllerServiceImpl.enqueueJob(new QueueJob(modifyHDSJob));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the modify volume call");
}
}
} else {
String errorMsg = String.format("No LDEV's found for volume: %s", volume.getId());
log.info(errorMsg);
ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doModifyVolumes", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
} catch (final Exception e) {
log.error("Problem in doModifyVolumes: ", e);
ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doModifyVolumes", e.getMessage());
taskCompleter.error(dbClient, serviceError);
}
}
}
use of com.emc.storageos.hds.model.LogicalUnit in project coprhd-controller by CoprHD.
the class HDSStorageDevice method doDeleteVolumes.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteVolumes(com.emc.storageos.db.client.model.StorageSystem,
* java.lang.String, java.util.List, com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getSerialNumber()));
MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
Set<String> thickLogicalUnitIdList = new HashSet<String>();
Set<String> thinLogicalUnitIdList = new HashSet<String>();
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
log.info("volumes size: {}", volumes.size());
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
String logicalUnitObjectId = HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storageSystem);
LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectId, logicalUnitObjectId);
if (logicalUnit == null) {
// related volume state (if any) has been deleted. skip
// processing, if already deleted from array.
log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
volume.setInactive(true);
dbClient.persistObject(volume);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
deleteTaskCompleter.ready(dbClient);
continue;
}
if (volume.getThinlyProvisioned()) {
thinLogicalUnitIdList.add(logicalUnitObjectId);
} else {
thickLogicalUnitIdList.add(logicalUnitObjectId);
}
}
log.info(logMsgBuilder.toString());
if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
if (null != thickLogicalUnitIdList && !thickLogicalUnitIdList.isEmpty()) {
String asyncThickLUsJobId = hdsApiClient.deleteThickLogicalUnits(systemObjectId, thickLogicalUnitIdList, storageSystem.getModel());
if (null != asyncThickLUsJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSDeleteVolumeJob(asyncThickLUsJobId, volumes.get(0).getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete volume call");
}
}
if (null != thinLogicalUnitIdList && !thinLogicalUnitIdList.isEmpty()) {
String asyncThinHDSJobId = hdsApiClient.deleteThinLogicalUnits(systemObjectId, thinLogicalUnitIdList, storageSystem.getModel());
// in single operation.
if (null != asyncThinHDSJobId) {
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSDeleteVolumeJob(asyncThinHDSJobId, volumes.get(0).getStorageController(), taskCompleter)));
} else {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the delete volume call");
}
}
} else {
// If we are here, there are no volumes to delete, we have
// invoked ready() for the VolumeDeleteCompleter, and told
// the multiVolumeTaskCompleter to skip these completers.
// In this case, the multiVolumeTaskCompleter complete()
// method will not be invoked and the result is that the
// workflow that initiated this delete request will never
// be updated. So, here we just call complete() on the
// multiVolumeTaskCompleter to ensure the workflow status is
// updated.
multiVolumeTaskCompleter.ready(dbClient);
}
} catch (Exception e) {
log.error("Problem in doDeleteVolume: ", e);
ServiceError error = DeviceControllerErrors.hds.methodFailed("doDeleteVolume", e.getMessage());
taskCompleter.error(dbClient, error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getSerialNumber()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
}
log.info(logMsgBuilder.toString());
}
use of com.emc.storageos.hds.model.LogicalUnit in project coprhd-controller by CoprHD.
the class HDSBlockCreateSnapshotJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
// Do nothing if the job is not completed yet
if (_status == JobStatus.IN_PROGRESS) {
return;
}
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
HDSApiClient hdsApiClient = jobContext.getHdsApiFactory().getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
URI snapshotId = getTaskCompleter().getId(0);
log.info("snapshotId :{}", snapshotId);
if (_status == JobStatus.SUCCESS) {
LogicalUnit logicalUnit = (LogicalUnit) _javaResult.getBean("virtualVolume");
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotId);
snapshot.setNativeId(String.valueOf(logicalUnit.getDevNum()));
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storageSystem, snapshot));
snapshot.setInactive(false);
snapshot.setCreationTime(Calendar.getInstance());
long capacityInBytes = Long.valueOf(logicalUnit.getCapacityInKB()) * 1024L;
snapshot.setProvisionedCapacity(capacityInBytes);
snapshot.setAllocatedCapacity(capacityInBytes);
snapshot.setWWN(HDSUtils.generateHitachiWWN(logicalUnit.getObjectID(), String.valueOf(logicalUnit.getDevNum())));
snapshot.setIsSyncActive(true);
dbClient.persistObject(snapshot);
changeSnapshotName(dbClient, hdsApiClient, snapshot);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Created Snapshot successfully .. NativeId: %s, URI: %s", snapshot.getNativeId(), getTaskCompleter().getId()));
} else if (_status == JobStatus.FAILED) {
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, getTaskCompleter().getId().toString()));
Snapshot snapshot = dbClient.queryObject(Snapshot.class, snapshotId);
if (snapshot != null) {
snapshot.setInactive(true);
dbClient.persistObject(snapshot);
}
}
log.info(logMsgBuilder.toString());
} catch (Exception e) {
log.error("Caught an exception while trying to updateStatus for HDSBlockCreateSnapshotJob", e);
setErrorStatus("Encountered an internal error during snapshot create job status processing : " + e.getMessage());
} finally {
_postProcessingStatus = JobStatus.SUCCESS;
super.updateStatus(jobContext);
}
}
Aggregations