use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method modifyThinVolumeTieringPolicy.
public String modifyThinVolumeTieringPolicy(String systemObjectID, String luObjectID, String ldevObjectID, String tieringPolicyName, String model) {
InputStream responseStream = null;
String asyncTaskMessageId = null;
Map<String, Object> attributeMap = new HashMap<String, Object>();
Modify modifyOp = new Modify(HDSConstants.VIRTUALVOLUME);
StorageArray array = new StorageArray(systemObjectID);
LogicalUnit logicalUnit = new LogicalUnit();
logicalUnit.setObjectID(luObjectID);
LDEV ldev = new LDEV(ldevObjectID);
ldev.setTierLevel(Integer.parseInt(tieringPolicyName));
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.MODIFY, modifyOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
attributeMap.put(HDSConstants.LDEV, ldev);
String modifyThinVolumeTieringPolicyPayload = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_THIN_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
URI endpointURI = hdsApiClient.getBaseURI();
log.info("Modify Volume TieringPolicy payload:{}", modifyThinVolumeTieringPolicyPayload);
ClientResponse response = hdsApiClient.post(endpointURI, modifyThinVolumeTieringPolicyPayload);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
EchoCommand command = result.getBean(EchoCommand.class);
log.info("command Status :{} MessageId :{}", command.getStatus(), command.getMessageID());
if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus()) || HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
asyncTaskMessageId = command.getMessageID();
} else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
Error error = result.getBean(Error.class);
log.error("Modify Volume TieringPolicy failed status messageID: {}", command.getMessageID());
log.error("Modify Volume TieringPolicy failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
}
} else {
log.error("Modify Volume TieringPolicy failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Modify Volume TieringPolicy failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
}
return asyncTaskMessageId;
}
use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.
the class HDSMetaVolumeOperations method expandVolumeAsMetaVolume.
@Override
public void expandVolumeAsMetaVolume(StorageSystem storageSystem, StoragePool storagePool, Volume metaHead, List<String> newMetaMembers, String metaType, MetaVolumeTaskCompleter metaVolumeTaskCompleter) throws Exception {
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
LogicalUnit metaHeadVolume = hdsApiClient.getLogicalUnitInfo(systemObjectID, HDSUtils.getLogicalUnitObjectId(metaHead.getNativeId(), storageSystem));
String metaHeadLdevId = null;
List<String> metaMembersLdevObjectIds = new ArrayList<String>();
// Step 1: Get LDEV id's of the meta members and format them
if (null != newMetaMembers && !newMetaMembers.isEmpty()) {
for (String metaMember : newMetaMembers) {
if (null != metaMember) {
String asyncTaskMessageId = hdsApiClient.formatLogicalUnit(systemObjectID, metaMember);
if (asyncTaskMessageId == null) {
throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the expand volume call");
}
HDSJob formatLUJob = new HDSJob(asyncTaskMessageId, storageSystem.getId(), metaVolumeTaskCompleter.getVolumeTaskCompleter(), "formatLogicalUnit");
invokeMethodSynchronously(hdsApiFactory, asyncTaskMessageId, formatLUJob);
}
LogicalUnit metaMemberVolume = hdsApiClient.getLogicalUnitInfo(systemObjectID, metaMember);
if (null != metaMemberVolume && !metaMemberVolume.getLdevList().isEmpty()) {
for (LDEV ldev : metaMemberVolume.getLdevList()) {
// Format the logical unit. This is synchronous operation
// should wait it the operation completes.
metaMembersLdevObjectIds.add(ldev.getObjectID());
}
}
}
}
log.info("New Meta member LDEV ids: {}", metaMembersLdevObjectIds);
// Step 2: Get LDEV id of the meta volume head.
if (null != metaHeadVolume && null != metaHeadVolume.getLdevList()) {
for (LDEV ldev : metaHeadVolume.getLdevList()) {
// will be created during expansion of volume.
if (getLDEVID(ldev.getObjectID()).equalsIgnoreCase(metaHead.getNativeId())) {
metaHeadLdevId = ldev.getObjectID();
break;
}
}
}
// Step 3: Create LUSE Volume using metaHead LDEV & meta
// members LDEV Ids.
LogicalUnit logicalUnit = hdsApiClient.createLUSEVolume(systemObjectID, metaHeadLdevId, metaMembersLdevObjectIds);
if (null != logicalUnit) {
long capacityInBytes = Long.valueOf(logicalUnit.getCapacityInKB()) * 1024L;
metaHead.setProvisionedCapacity(capacityInBytes);
metaHead.setAllocatedCapacity(capacityInBytes);
dbClient.persistObject(metaHead);
}
}
use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.
the class HDSAbstractCreateVolumeJob method changeVolumeName.
/**
* Method will modify the name of a given volume to a generate name.
*
* @param dbClient [in] - Client instance for reading/writing from/to DB
* @param client [in] - HDSApiClient used for reading/writing from/to HiCommand DM.
* @param volume [in] - Volume object
*/
protected void changeVolumeName(DbClient dbClient, HDSApiClient client, Volume volume, String name) {
try {
_log.info(String.format("Attempting to add volume label %s to %s", name, volume.getWWN()));
StorageSystem system = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
String systemObjectId = HDSUtils.getSystemObjectID(system);
LogicalUnit logicalUnit = client.getLogicalUnitInfo(systemObjectId, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), system));
if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
if (ldevItr.hasNext()) {
LDEV ldev = ldevItr.next();
ObjectLabel objectLabel = client.addVolumeLabel(ldev.getObjectID(), name);
volume.setDeviceLabel(objectLabel.getLabel());
dbClient.persistObject(volume);
}
} else {
_log.info("No LDEV's found on volume: {}", volume.getWWN());
}
_log.info(String.format("Volume label has been added to volume %s", volume.getWWN()));
} catch (DatabaseException e) {
_log.error("Encountered an error while trying to set the volume name", e);
} catch (Exception e) {
_log.error("Encountered an error while trying to set the volume name", e);
}
}
use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.
the class HDSBlockCreateSnapshotJob method changeSnapshotName.
/**
* Method will modify the name of a given volume to a generate name.
*
* @param dbClient [in] - Client instance for reading/writing from/to DB
* @param client [in] - HDSApiClient used for reading/writing from/to HiCommand DM.
* @param snapshotObj [in] - Volume object
*/
private void changeSnapshotName(DbClient dbClient, HDSApiClient client, BlockSnapshot snapshotObj) {
try {
Volume source = dbClient.queryObject(Volume.class, snapshotObj.getParent());
// Get the tenant name from the volume
TenantOrg tenant = dbClient.queryObject(TenantOrg.class, source.getTenant().getURI());
String tenantName = tenant.getLabel();
// that was successfully created
if (_nameGeneratorRef.get() == null) {
_nameGeneratorRef.compareAndSet(null, (NameGenerator) ControllerServiceImpl.getBean("defaultNameGenerator"));
}
String generatedName = _nameGeneratorRef.get().generate(tenantName, snapshotObj.getLabel(), snapshotObj.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
log.info(String.format("Attempting to add snapshot label %s to %s", generatedName, snapshotObj.getNativeId()));
StorageSystem system = dbClient.queryObject(StorageSystem.class, snapshotObj.getStorageController());
String systemObjectId = HDSUtils.getSystemObjectID(system);
LogicalUnit logicalUnit = client.getLogicalUnitInfo(systemObjectId, HDSUtils.getLogicalUnitObjectId(snapshotObj.getNativeId(), system));
if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
if (ldevItr.hasNext()) {
LDEV ldev = ldevItr.next();
ObjectLabel objectLabel = client.addVolumeLabel(ldev.getObjectID(), generatedName);
snapshotObj.setDeviceLabel(objectLabel.getLabel());
dbClient.persistObject(snapshotObj);
}
} else {
log.info("No LDEV's found on volume: {}", snapshotObj.getNativeId());
}
log.info(String.format("snapshot label has been added to snapshot %s", snapshotObj.getNativeId()));
} catch (Exception e) {
log.error("Encountered an error while trying to set the snapshot name", e);
}
}
use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.
the class HDSModifyVolumeJob method updateStatus.
/**
* Called to update the job status when the volume expand job completes.
*
* @param jobContext
* The job context.
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
LogicalUnit logicalUnit = null;
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
DbClient dbClient = jobContext.getDbClient();
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), _status.name(), opId));
if (_status == JobStatus.SUCCESS) {
logicalUnit = (LogicalUnit) _javaResult.getBean("logicalunit");
if (null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
Iterator<LDEV> ldevListItr = logicalUnit.getLdevList().iterator();
if (ldevListItr.hasNext()) {
LDEV ldev = ldevListItr.next();
if (null != ldev && -1 != ldev.getTierLevel()) {
logMsgBuilder.append(String.format("Task %s is successful to update volume %s tieringPolicy: %s", opId, logicalUnit.getObjectID(), ldev.getTierLevel()));
}
}
}
} else if (_status == JobStatus.FAILED && VOLUME_MODIFY_JOB.equalsIgnoreCase(getJobName())) {
URI id = getTaskCompleter().getId();
logMsgBuilder.append(String.format("Task %s failed to update volume tieringPolicy: %s", opId, id.toString()));
Volume volume = dbClient.queryObject(Volume.class, id);
volume.setInactive(true);
dbClient.persistObject(volume);
}
log.info(logMsgBuilder.toString());
} catch (Exception e) {
log.error("Caught an exception while trying to updating tieringPolicy of the volume", e);
setErrorStatus("Encountered an internal error during tieringPolicy updation of volume: " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
Aggregations