use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class FilePolicyService method assignFilePolicyToProjects.
/**
* Assign policy at project level
*
* @param param
* @param filepolicy
*/
private TaskResourceRep assignFilePolicyToProjects(FilePolicyAssignParam param, FilePolicy filePolicy) {
StringBuilder errorMsg = new StringBuilder();
StringBuilder recommendationErrorMsg = new StringBuilder();
ArgValidator.checkFieldNotNull(param.getProjectAssignParams(), "project_assign_param");
ArgValidator.checkFieldUriType(param.getProjectAssignParams().getVpool(), VirtualPool.class, "vpool");
URI vpoolURI = param.getProjectAssignParams().getVpool();
VirtualPool vpool = null;
if (NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool())) {
ArgValidator.checkFieldUriType(vpoolURI, VirtualPool.class, "vpool");
vpool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
ArgValidator.checkEntity(vpool, vpoolURI, false);
// Check if the vpool supports provided policy type..
FilePolicyServiceUtils.validateVpoolSupportPolicyType(filePolicy, vpool);
// Check if the vpool supports policy at project level..
if (!vpool.getAllowFilePolicyAtProjectLevel()) {
errorMsg.append("Provided vpool :" + vpool.getLabel() + " doesn't support policy at project level");
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
} else if (vpoolURI != null) {
vpool = _dbClient.queryObject(VirtualPool.class, filePolicy.getFilePolicyVpool());
if (!vpoolURI.equals(filePolicy.getFilePolicyVpool())) {
errorMsg.append("File policy: " + filePolicy.getFilePolicyName() + " is already assigned at project level under the vpool: " + vpool.getLabel());
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
}
ArgValidator.checkFieldNotEmpty(param.getProjectAssignParams().getAssigntoProjects(), "assign_to_projects");
Set<URI> projectURIs = param.getProjectAssignParams().getAssigntoProjects();
List<URI> filteredProjectURIs = new ArrayList<URI>();
for (URI projectURI : projectURIs) {
ArgValidator.checkFieldUriType(projectURI, Project.class, "project");
Project project = _permissionsHelper.getObjectById(projectURI, Project.class);
ArgValidator.checkEntity(project, projectURI, false);
if (filePolicy.getAssignedResources() != null && filePolicy.getAssignedResources().contains(project.getId().toString())) {
_log.info("Policy {} is already assigned to project {} ", filePolicy.getFilePolicyName(), project.getLabel());
continue;
}
// only single replication policy per vpool-project combination.
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_replication.name()) && FilePolicyServiceUtils.projectHasReplicationPolicy(_dbClient, projectURI, vpool.getId())) {
errorMsg.append("Virtual pool " + vpool.getLabel() + " project " + project.getLabel() + "pair is already assigned with replication policy.");
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_snapshot.name()) && FilePolicyServiceUtils.projectHasSnapshotPolicyWithSameSchedule(_dbClient, projectURI, vpool.getId(), filePolicy)) {
errorMsg.append("Snapshot policy with similar schedule is already present on project " + project.getLabel());
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
filteredProjectURIs.add(projectURI);
}
if (param.getApplyOnTargetSite() != null) {
filePolicy.setApplyOnTargetSite(param.getApplyOnTargetSite());
}
// Verify the virtual pool has storage pools!!!
List<URI> storageSystems = getAssociatedStorageSystemsByVPool(vpool);
if (storageSystems == null || storageSystems.isEmpty()) {
String errorMessage = "No matching storage pools exists for given vpools ";
_log.error(errorMessage);
throw APIException.badRequests.noStoragePoolsExists(vpool.getLabel());
}
String task = UUID.randomUUID().toString();
TaskResourceRep taskResponse = createAssignFilePolicyTask(filePolicy, task);
FileServiceApi fileServiceApi = getDefaultFileServiceApi();
FilePolicyType policyType = FilePolicyType.valueOf(filePolicy.getFilePolicyType());
switch(policyType) {
case file_snapshot:
Map<URI, List<URI>> vpoolToStorageSystemMap = new HashMap<URI, List<URI>>();
vpoolToStorageSystemMap.put(vpoolURI, getAssociatedStorageSystemsByVPool(vpool));
AssignFileSnapshotPolicyToProjectSchedulingThread.executeApiTask(this, _asyncTaskService.getExecutorService(), _dbClient, filePolicy.getId(), vpoolToStorageSystemMap, filteredProjectURIs, fileServiceApi, taskResponse, task);
break;
case file_replication:
if (filteredProjectURIs.isEmpty()) {
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), "No projects to assign to policy.");
}
// update replication topology info
updateFileReplicationTopologyInfo(param, filePolicy);
List<URI> validRecommendationProjects = new ArrayList<URI>();
List<FileStorageSystemAssociation> associations = new ArrayList<FileStorageSystemAssociation>();
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
StringSet sourceVArraysSet = getSourceVArraySet(vpool, filePolicy);
updatePolicyCapabilities(_dbClient, sourceVArraysSet, vpool, filePolicy, capabilities, errorMsg);
// Replication policy has to be created on each applicable source storage system!!
if (storageSystems != null && !storageSystems.isEmpty()) {
for (Iterator<String> iterator = sourceVArraysSet.iterator(); iterator.hasNext(); ) {
String vArrayURI = iterator.next();
for (URI projectURI : filteredProjectURIs) {
List<FileStorageSystemAssociation> projectAssociations = new ArrayList<FileStorageSystemAssociation>();
Project project = _dbClient.queryObject(Project.class, projectURI);
VirtualArray srcVarray = _dbClient.queryObject(VirtualArray.class, URI.create(vArrayURI));
for (URI storageSystem : storageSystems) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.FILE_PROTECTION_SOURCE_STORAGE_SYSTEM, storageSystem);
try {
List<FileRecommendation> newRecs = _filePlacementManager.getRecommendationsForFileCreateRequest(srcVarray, project, vpool, capabilities);
if (newRecs != null && !newRecs.isEmpty()) {
projectAssociations.addAll(convertRecommendationsToStorageSystemAssociations(newRecs, filePolicy.getApplyAt(), vpool.getId(), projectURI));
}
} catch (Exception ex) {
_log.error("No recommendations found for storage system {} and virtualArray {} with error {} ", storageSystem, srcVarray.getLabel(), ex.getMessage());
if (ex.getMessage() != null) {
recommendationErrorMsg.append(ex.getMessage());
}
// Continue to get the recommedations for next storage system!!
continue;
}
}
if (!projectAssociations.isEmpty()) {
associations.addAll(projectAssociations);
validRecommendationProjects.add(projectURI);
}
}
}
} else {
String errorMessage = "No matching storage pools exists for vpool " + vpool.getLabel();
_log.error(errorMessage);
recommendationErrorMsg.append(errorMessage);
}
// Throw an exception!!
if (associations == null || associations.isEmpty()) {
// If no other resources are assigned to replication policy
// Remove the replication topology from the policy
FileOrchestrationUtils.removeTopologyInfo(filePolicy, _dbClient);
_log.error("No matching storage pools recommendations found for policy {} with due to {}", filePolicy.getFilePolicyName(), recommendationErrorMsg.toString());
throw APIException.badRequests.noFileStorageRecommendationsFound(filePolicy.getFilePolicyName());
}
fileServiceApi.assignFileReplicationPolicyToProjects(associations, vpoolURI, validRecommendationProjects, filePolicy.getId(), task);
break;
default:
break;
}
auditOp(OperationTypeEnum.ASSIGN_FILE_POLICY, true, AuditLogManager.AUDITOP_BEGIN, filePolicy.getLabel());
if (taskResponse != null) {
// As the action done by system admin
// Set system uri as task's tenant!!!
Task taskObj = _dbClient.queryObject(Task.class, taskResponse.getId());
StorageOSUser user = getUserFromContext();
URI userTenantUri = URI.create(user.getTenantId());
FilePolicyServiceUtils.updateTaskTenant(_dbClient, filePolicy, "assign", taskObj, userTenantUri);
}
return taskResponse;
}
use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class FilePolicyService method assignFilePolicyToVpools.
/**
* Assigning policy at vpool level
*
* @param param
* @param filepolicy
*/
private TaskResourceRep assignFilePolicyToVpools(FilePolicyAssignParam param, FilePolicy filePolicy) {
StringBuilder errorMsg = new StringBuilder();
StringBuilder recommendationErrorMsg = new StringBuilder();
ArgValidator.checkFieldNotNull(param.getVpoolAssignParams(), "vpool_assign_param");
// Policy has to be applied on specified file vpools..
ArgValidator.checkFieldNotEmpty(param.getVpoolAssignParams().getAssigntoVpools(), "assign_to_vpools");
Set<URI> vpoolURIs = param.getVpoolAssignParams().getAssigntoVpools();
Map<URI, List<URI>> vpoolToStorageSystemMap = new HashMap<URI, List<URI>>();
List<URI> filteredVpoolURIs = new ArrayList<URI>();
StringBuffer vPoolWithNoStoragePools = new StringBuffer();
for (URI vpoolURI : vpoolURIs) {
ArgValidator.checkFieldUriType(vpoolURI, VirtualPool.class, "vpool");
VirtualPool virtualPool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
ArgValidator.checkEntity(virtualPool, vpoolURI, false);
if (filePolicy.getAssignedResources() != null && filePolicy.getAssignedResources().contains(virtualPool.getId().toString())) {
_log.info("File policy: {} has already been assigned to vpool: {} ", filePolicy.getFilePolicyName(), virtualPool.getLabel());
continue;
}
// only single replication policy per vpool.
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_replication.name()) && (FilePolicyServiceUtils.vPoolHasReplicationPolicy(_dbClient, vpoolURI) || FilePolicyServiceUtils.vPoolHasReplicationPolicyAtProjectLevel(_dbClient, vpoolURI))) {
errorMsg.append("Provided vpool : " + virtualPool.getLabel() + " already assigned with replication policy");
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
if (filePolicy.getFilePolicyType().equalsIgnoreCase(FilePolicyType.file_snapshot.name()) && FilePolicyServiceUtils.vPoolHasSnapshotPolicyWithSameSchedule(_dbClient, vpoolURI, filePolicy)) {
errorMsg.append("Snapshot policy with similar schedule is already present on vpool " + virtualPool.getLabel());
_log.error(errorMsg.toString());
throw APIException.badRequests.invalidFilePolicyAssignParam(filePolicy.getFilePolicyName(), errorMsg.toString());
}
FilePolicyServiceUtils.validateVpoolSupportPolicyType(filePolicy, virtualPool);
List<URI> storageSystems = getAssociatedStorageSystemsByVPool(virtualPool);
if (storageSystems != null && !storageSystems.isEmpty()) {
vpoolToStorageSystemMap.put(vpoolURI, storageSystems);
filteredVpoolURIs.add(vpoolURI);
} else {
vPoolWithNoStoragePools.append(virtualPool.getLabel()).append(",");
}
}
if (filteredVpoolURIs.isEmpty()) {
String errorMessage = "No matching storage pools exists for given vpools ";
_log.error(errorMessage);
throw APIException.badRequests.noStoragePoolsExists(vPoolWithNoStoragePools.toString());
}
if (param.getApplyOnTargetSite() != null) {
filePolicy.setApplyOnTargetSite(param.getApplyOnTargetSite());
}
FileServiceApi fileServiceApi = getDefaultFileServiceApi();
FilePolicyType policyType = FilePolicyType.valueOf(filePolicy.getFilePolicyType());
String task = UUID.randomUUID().toString();
TaskResourceRep taskResponse = null;
switch(policyType) {
case file_snapshot:
taskResponse = createAssignFilePolicyTask(filePolicy, task);
AssignFileSnapshotPolicyToVpoolSchedulingThread.executeApiTask(this, _asyncTaskService.getExecutorService(), _dbClient, filePolicy.getId(), vpoolToStorageSystemMap, fileServiceApi, taskResponse, task);
break;
case file_replication:
// update replication topology info
updateFileReplicationTopologyInfo(param, filePolicy);
List<URI> validRecommendationVpools = new ArrayList<URI>();
List<FileStorageSystemAssociation> associations = new ArrayList<FileStorageSystemAssociation>();
for (URI vpoolURI : filteredVpoolURIs) {
VirtualPool vpool = _permissionsHelper.getObjectById(vpoolURI, VirtualPool.class);
StringSet sourceVArraysSet = getSourceVArraySet(vpool, filePolicy);
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
updatePolicyCapabilities(_dbClient, sourceVArraysSet, vpool, filePolicy, capabilities, errorMsg);
// Replication policy has to be created on each applicable source storage system!!
List<URI> storageSystems = getAssociatedStorageSystemsByVPool(vpool);
if (storageSystems != null && !storageSystems.isEmpty()) {
List<FileStorageSystemAssociation> vpoolAssociations = new ArrayList<FileStorageSystemAssociation>();
for (URI storageSystem : storageSystems) {
capabilities.put(VirtualPoolCapabilityValuesWrapper.FILE_PROTECTION_SOURCE_STORAGE_SYSTEM, storageSystem);
for (Iterator<String> iterator = sourceVArraysSet.iterator(); iterator.hasNext(); ) {
String vArrayURI = iterator.next();
VirtualArray srcVarray = _dbClient.queryObject(VirtualArray.class, URI.create(vArrayURI));
try {
List<FileRecommendation> newRecs = _filePlacementManager.getRecommendationsForFileCreateRequest(srcVarray, null, vpool, capabilities);
if (newRecs != null && !newRecs.isEmpty()) {
vpoolAssociations.addAll(convertRecommendationsToStorageSystemAssociations(newRecs, filePolicy.getApplyAt(), vpool.getId(), null));
}
} catch (Exception ex) {
_log.error("No recommendations found for storage system {} and virtualArray {} with error {} ", storageSystem, srcVarray.getLabel(), ex.getMessage());
if (ex.getMessage() != null) {
recommendationErrorMsg.append(ex.getMessage());
}
// Continue to get the recommendations for next storage system!!
continue;
}
}
}
if (!vpoolAssociations.isEmpty()) {
validRecommendationVpools.add(vpoolURI);
associations.addAll(vpoolAssociations);
}
} else {
String errorMessage = "No matching storage pools exists for vpool " + vpool.getLabel();
_log.error(errorMessage);
recommendationErrorMsg.append(errorMessage);
}
}
// Throw an exception!!
if (associations == null || associations.isEmpty()) {
// If no other resources are assigned to replication policy
// Remove the replication topology from the policy
FileOrchestrationUtils.removeTopologyInfo(filePolicy, _dbClient);
_log.error("No matching storage pools recommendations found for policy {} with due to {}", filePolicy.getFilePolicyName(), recommendationErrorMsg.toString());
throw APIException.badRequests.noFileStorageRecommendationsFound(filePolicy.getFilePolicyName());
}
taskResponse = createAssignFilePolicyTask(filePolicy, task);
fileServiceApi.assignFileReplicationPolicyToVirtualPools(associations, validRecommendationVpools, filePolicy.getId(), task);
break;
default:
break;
}
auditOp(OperationTypeEnum.ASSIGN_FILE_POLICY, true, AuditLogManager.AUDITOP_BEGIN, filePolicy.getLabel());
if (taskResponse != null) {
// As the action done by system admin
// Set system uri as task's tenant!!!
Task taskObj = _dbClient.queryObject(Task.class, taskResponse.getId());
StorageOSUser user = getUserFromContext();
URI userTenantUri = URI.create(user.getTenantId());
FilePolicyServiceUtils.updateTaskTenant(_dbClient, filePolicy, "assign", taskObj, userTenantUri);
}
return taskResponse;
}
use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class WorkflowService method isTopLevelWorkflowForUserTenant.
/**
* Determines if the passed top-level workflow is valid for the user's tenant.
* Child workflows should not be passed to this routine.
*
* @param topLevelWorkflow A reference to a top-level workflow.
*
* @return true if the user's tenant is the workflow tenant.
*/
private boolean isTopLevelWorkflowForUserTenant(Workflow topLevelWorkflow) {
boolean workflowForTenant = false;
// Since the tenant is not directly associated to a workflow, we find the
// Task instance(s) whose request id is the same as the orchestration task
// id for the workflow. We can then get the tenant from the task and compare
// that tenant to the user tenant.
String wfOrchTaskId = topLevelWorkflow.getOrchTaskId();
List<Task> wfTasks = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Task.class, AlternateIdConstraint.Factory.getTasksByRequestIdConstraint(wfOrchTaskId));
if (!wfTasks.isEmpty()) {
for (Task wfTask : wfTasks) {
// the tenant.
if (wfTask.getTenant().toString().equals(getUserFromContext().getTenantId())) {
workflowForTenant = true;
break;
}
}
}
return workflowForTenant;
}
use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class ExportService method waitForTaskCompletion.
boolean waitForTaskCompletion(URI resourceId, String task) throws InterruptedException {
int tryCnt = 0;
Task taskObj = null;
// while(tryCnt < RETRY_COUNT){
while (true) {
_log.info("THE TASK var is {}", task);
Thread.sleep(40000);
taskObj = TaskUtils.findTaskForRequestId(_dbClient, resourceId, task);
_log.info("THE TASKOBJ is {}", taskObj.toString());
_log.info("THE TASKOBJ.GETSTATUS is {}", taskObj.getStatus().toString());
if (taskObj != null) {
if (taskObj.getStatus().equals("ready")) {
return true;
}
if (taskObj.getStatus().equals("error")) {
return false;
} else {
tryCnt++;
}
} else {
return false;
}
}
}
use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.
the class VolumeService method getVolumeDetail.
// INTERNAL FUNCTIONS
protected VolumeDetail getVolumeDetail(Volume vol, String isV1Call, String openstackTenantId) {
VolumeDetail detail = new VolumeDetail();
int sizeInGB = (int) ((vol.getCapacity() + halfGB) / GB);
detail.size = sizeInGB;
detail.id = getCinderHelper().trimId(vol.getId().toString());
detail.host_name = getCinderHelper().trimId(vol.getStorageController().toString());
detail.tenant_id = openstackTenantId;
detail.attachments = new ArrayList<Attachment>();
if (vol.getInactive()) {
detail.status = "deleted";
} else {
if (vol.getExtensions() == null) {
vol.setExtensions(new StringMap());
}
if (vol.getProvisionedCapacity() == ZERO_BYTES) {
detail.status = CinderConstants.ComponentStatus.CREATING.getStatus().toLowerCase();
} else if (vol.getExtensions().containsKey("status") && vol.getExtensions().get("status").equals(CinderConstants.ComponentStatus.DELETING.getStatus().toLowerCase())) {
Task taskObj = null;
String task = vol.getExtensions().get(DELETE_TASK_ID).toString();
taskObj = TaskUtils.findTaskForRequestId(_dbClient, vol.getId(), task);
if (taskObj != null) {
if (taskObj.getStatus().equals("error")) {
_log.info(String.format("Error Deleting volume %s, but moving volume to original state so that it will be usable: ", detail.name));
vol.getExtensions().put("status", CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase());
vol.getExtensions().remove(DELETE_TASK_ID);
detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
} else if (taskObj.getStatus().equals("pending")) {
detail.status = CinderConstants.ComponentStatus.DELETING.getStatus().toLowerCase();
}
_dbClient.updateObject(vol);
} else {
detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
}
} else if (vol.getExtensions().containsKey("status") && vol.getExtensions().get("status").equals(CinderConstants.ComponentStatus.EXTENDING.getStatus().toLowerCase())) {
_log.info("Extending Volume {}", vol.getId().toString());
Task taskObj = null;
String task = vol.getExtensions().get("task_id").toString();
taskObj = TaskUtils.findTaskForRequestId(_dbClient, vol.getId(), task);
_log.debug("THE TASKOBJ is {}, task_id {}", taskObj.toString(), task);
_log.debug("THE TASKOBJ STATUS is {}", taskObj.getStatus().toString());
if (taskObj != null) {
if (taskObj.getStatus().equals("ready")) {
detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
_log.debug(" STATUS is {}", detail.status);
vol.getExtensions().remove("task_id");
vol.getExtensions().put("status", "");
} else if (taskObj.getStatus().equals("error")) {
detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
_log.info(String.format("Error in Extending volume %s, but moving volume to original state so that it will be usable: ", detail.name));
vol.getExtensions().remove("task_id");
vol.getExtensions().put("status", "");
} else {
detail.status = CinderConstants.ComponentStatus.EXTENDING.getStatus().toLowerCase();
_log.info("STATUS is {}", detail.status);
}
} else {
detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
_log.info(String.format("Error in Extending volume %s, but moving volume to original state so that it will be usable: ", detail.name));
vol.getExtensions().remove("task_id");
vol.getExtensions().put("status", "");
}
_dbClient.updateObject(vol);
} else if (vol.getExtensions().containsKey("status") && !vol.getExtensions().get("status").equals("")) {
detail.status = vol.getExtensions().get("status").toString().toLowerCase();
} else {
detail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
}
}
detail.created_at = date(vol.getCreationTime().getTimeInMillis());
URI vpoolUri = vol.getVirtualPool();
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolUri);
if (vpool != null) {
detail.volume_type = vpool.getLabel();
}
URI varrayUri = vol.getVirtualArray();
VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayUri);
if (varray != null) {
detail.availability_zone = varray.getLabel();
}
if (vol.getExtensions().containsKey("bootable") && vol.getExtensions().get("bootable").equals(TRUE)) {
detail.bootable = true;
_log.debug("Volumes Bootable Flag is TRUE");
} else {
detail.bootable = false;
_log.debug("Volumes Bootable Flag is False");
}
detail.setLink(DbObjectMapper.toLink(vol));
detail.metadata = new HashMap<String, String>();
String description = null;
StringMap extensions = vol.getExtensions();
if (extensions != null) {
description = extensions.get("display_description");
}
if (isV1Call != null) {
detail.display_name = vol.getLabel();
detail.display_description = (description == null) ? "" : description;
detail.description = null;
detail.name = null;
} else {
detail.name = vol.getLabel();
detail.description = (description == null) ? "" : description;
detail.display_name = null;
detail.display_description = null;
}
if (vol.getExtensions().containsKey("readonly") && vol.getExtensions().get("readonly").equals(TRUE)) {
_log.debug("Volumes Readonly Flag is TRUE");
detail.metadata.put("readonly", "true");
} else {
_log.debug("Volumes Readonly Flag is FALSE");
detail.metadata.put("readonly", "false");
}
if (detail.status.equals("in-use")) {
if (vol.getExtensions() != null && vol.getExtensions().containsKey("OPENSTACK_NOVA_INSTANCE_ID")) {
detail.metadata.put("attached_mode", vol.getExtensions().get("OPENSTACK_ATTACH_MODE"));
detail.attachments = getVolumeAttachments(vol);
}
}
if (vol.getConsistencyGroup() != null) {
detail.consistencygroup_id = CinderApiUtils.splitString(vol.getConsistencyGroup().toString(), ":", 3);
}
return detail;
}
Aggregations