use of com.emc.storageos.model.block.VolumeCreate in project coprhd-controller by CoprHD.
the class ApiSystemTestUtil method createVolume.
public List<URI> createVolume(String name, String size, Integer count, URI vpool, URI varray, URI project, URI cg) {
List<URI> volumes = new ArrayList<URI>();
VolumeCreate createParam = new VolumeCreate();
createParam.setName(name);
createParam.setSize(size);
;
createParam.setCount(count);
createParam.setVpool(vpool);
createParam.setVarray(varray);
createParam.setProject(project);
createParam.setConsistencyGroup(cg);
try {
Tasks<VolumeRestRep> tasks = client.blockVolumes().create(createParam);
for (VolumeRestRep volumeRestRep : tasks.get()) {
log.info(String.format("Volume %s (%s) created", volumeRestRep.getName(), volumeRestRep.getNativeId()));
volumes.add(volumeRestRep.getId());
}
return volumes;
} catch (ServiceErrorException ex) {
log.error("Exception creating virtual volumes " + ex.getMessage(), ex);
throw ex;
}
}
use of com.emc.storageos.model.block.VolumeCreate in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method upgradeToProtectedVolume.
/**
* Upgrade a local block volume to a protected RP volume
*
* @param changeVpoolVolume the existing volume being protected.
* @param newVpool the requested virtual pool
* @param vpoolChangeParam Param sent down by the API Service
* @param taskId the task identifier
* @throws InternalException
*/
private void upgradeToProtectedVolume(Volume changeVpoolVolume, VirtualPool newVpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
Project project = _dbClient.queryObject(Project.class, changeVpoolVolume.getProject());
if (VirtualPool.vPoolSpecifiesProtection(newVpool)) {
// the volume from the existing CG before they can proceed.
if (!NullColumnValueGetter.isNullURI(changeVpoolVolume.getConsistencyGroup())) {
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, changeVpoolVolume.getConsistencyGroup());
throw APIException.badRequests.cannotCreateRPVolumesInCG(changeVpoolVolume.getLabel(), cg.getLabel());
}
// The user needs to specify a CG for this operation.
if (vpoolChangeParam.getConsistencyGroup() == null) {
throw APIException.badRequests.addRecoverPointProtectionRequiresCG();
}
if (!CollectionUtils.isEmpty(getSnapshotsForVolume(changeVpoolVolume))) {
throw APIException.badRequests.cannotAddProtectionWhenSnapshotsExist(changeVpoolVolume.getLabel());
}
}
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
capabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, changeVpoolVolume.getCapacity());
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, vpoolChangeParam.getConsistencyGroup());
capabilities.put(VirtualPoolCapabilityValuesWrapper.CHANGE_VPOOL_VOLUME, changeVpoolVolume.getId().toString());
List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(changeVpoolVolume, newVpool, vpoolChangeParam, capabilities);
if (recommendations.isEmpty()) {
throw APIException.badRequests.noStorageFoundForVolume();
}
// Get the volume's varray
VirtualArray varray = _dbClient.queryObject(VirtualArray.class, changeVpoolVolume.getVirtualArray());
// Generate a VolumeCreate object that contains the information that createVolumes likes to consume.
VolumeCreate param = new VolumeCreate(changeVpoolVolume.getLabel(), String.valueOf(changeVpoolVolume.getCapacity()), 1, newVpool.getId(), changeVpoolVolume.getVirtualArray(), changeVpoolVolume.getProject().getURI());
TaskList taskList = new TaskList();
createTaskForVolume(changeVpoolVolume, ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VPOOL, taskList, taskId);
Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
recommendationMap.put(VpoolUse.ROOT, recommendations);
createVolumes(param, project, varray, newVpool, recommendationMap, taskList, taskId, capabilities);
}
use of com.emc.storageos.model.block.VolumeCreate in project coprhd-controller by CoprHD.
the class SRDFBlockServiceApiImpl method upgradeToSRDFTargetVolume.
/**
* Upgrade a local block volume to a protected SRDF volume
*
* @param volume
* -- srdf source volume (existing).
* @param vpool
* -- Requested vpool.
* @param taskId
* @throws InternalException
*/
private List<VolumeDescriptor> upgradeToSRDFTargetVolume(final Volume volume, final VirtualPool vpool, final VirtualPoolChangeParam cosChangeParam, final String taskId) throws InternalException {
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(volume, vpool, cosChangeParam);
if (recommendations.isEmpty()) {
throw APIException.badRequests.noStorageFoundForVolume();
}
// Call out to the respective block service implementation to prepare and create the
// volumes based on the recommendations.
Project project = _dbClient.queryObject(Project.class, volume.getProject());
VirtualArray varray = _dbClient.queryObject(VirtualArray.class, volume.getVirtualArray());
// Generate a VolumeCreate object that contains the information that createVolumes likes to
// consume.
VolumeCreate param = new VolumeCreate(volume.getLabel(), String.valueOf(volume.getCapacity()), 1, vpool.getId(), volume.getVirtualArray(), volume.getProject().getURI());
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, new Integer(1));
if (volume.getIsComposite()) {
// add meta volume properties to the capabilities instance
capabilities.put(VirtualPoolCapabilityValuesWrapper.IS_META_VOLUME, volume.getIsComposite());
capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_TYPE, volume.getCompositionType());
capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_MEMBER_COUNT, volume.getMetaMemberCount());
capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_MEMBER_SIZE, volume.getMetaMemberSize());
_log.debug(String.format("Capabilities : isMeta: %s, Meta Type: %s, Member size: %s, Count: %s", capabilities.getIsMetaVolume(), capabilities.getMetaVolumeType(), capabilities.getMetaVolumeMemberSize(), capabilities.getMetaVolumeMemberCount()));
}
TaskList taskList = new TaskList();
// Prepare the Bourne Volumes to be created and associated
// with the actual storage system volumes created. Also create
// a BlockTaskList containing the list of task resources to be
// returned for the purpose of monitoring the volume creation
// operation for each volume to be created.
String volumeLabel = param.getName();
final BlockConsistencyGroup consistencyGroup = capabilities.getBlockConsistencyGroup() == null ? null : _dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
// prepare the volumes
List<URI> volumeURIs = prepareRecommendedVolumes(taskId, taskList, project, varray, vpool, capabilities.getResourceCount(), recommendations, consistencyGroup, volumeLabel, param.getSize());
List<VolumeDescriptor> resultListVolumeDescriptors = new ArrayList<>();
// Execute the volume creations requests for each recommendation.
Iterator<Recommendation> recommendationsIter = recommendations.iterator();
while (recommendationsIter.hasNext()) {
Recommendation recommendation = recommendationsIter.next();
try {
List<VolumeDescriptor> volumeDescriptors = createVolumeDescriptors((SRDFRecommendation) recommendation, volumeURIs, capabilities);
// Log volume descriptor information
logVolumeDescriptorPrecreateInfo(volumeDescriptors, taskId);
resultListVolumeDescriptors.addAll(volumeDescriptors);
} catch (InternalException e) {
if (_log.isErrorEnabled()) {
_log.error("Controller error", e);
}
String errorMsg = String.format("Controller error: %s", e.getMessage());
if (volumeURIs != null) {
for (URI volumeURI : volumeURIs) {
Volume volume1 = _dbClient.queryObject(Volume.class, volumeURI);
if (volume1 != null) {
Operation op = new Operation();
ServiceCoded coded = ServiceError.buildServiceError(ServiceCode.API_RP_VOLUME_CREATE_ERROR, errorMsg.toString());
op.setMessage(errorMsg);
op.error(coded);
_dbClient.createTaskOpStatus(Volume.class, volumeURI, taskId, op);
TaskResourceRep volumeTask = toTask(volume1, taskId, op);
if (volume1.getPersonality() != null && volume1.getPersonality().equals(Volume.PersonalityTypes.SOURCE.toString())) {
taskList.getTaskList().add(volumeTask);
}
}
}
}
// the user what succeeded and what failed.
throw APIException.badRequests.cannotCreateSRDFVolumes(e);
}
}
return resultListVolumeDescriptors;
}
use of com.emc.storageos.model.block.VolumeCreate in project coprhd-controller by CoprHD.
the class SRDFBlockServiceApiImpl method upgradeToTargetVolume.
/**
* Upgrade a local block volume to a protected SRDF volume
*
* @param volume
* -- VPlex volume (existing).
* @param vpool
* -- Requested vpool.
* @param taskId
* @throws InternalException
*/
private void upgradeToTargetVolume(final Volume volume, final VirtualPool vpool, final VirtualPoolChangeParam cosChangeParam, final String taskId) throws InternalException {
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(volume, vpool, cosChangeParam);
if (recommendations.isEmpty()) {
throw APIException.badRequests.noStorageFoundForVolume();
}
// Call out to the respective block service implementation to prepare and create the
// volumes based on the recommendations.
Project project = _dbClient.queryObject(Project.class, volume.getProject());
VirtualArray varray = _dbClient.queryObject(VirtualArray.class, volume.getVirtualArray());
// Generate a VolumeCreate object that contains the information that createVolumes likes to
// consume.
VolumeCreate param = new VolumeCreate(volume.getLabel(), String.valueOf(volume.getCapacity()), 1, vpool.getId(), volume.getVirtualArray(), volume.getProject().getURI());
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, new Integer(1));
if (volume.getIsComposite()) {
// add meta volume properties to the capabilities instance
capabilities.put(VirtualPoolCapabilityValuesWrapper.IS_META_VOLUME, volume.getIsComposite());
capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_TYPE, volume.getCompositionType());
capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_MEMBER_COUNT, volume.getMetaMemberCount());
capabilities.put(VirtualPoolCapabilityValuesWrapper.META_VOLUME_MEMBER_SIZE, volume.getMetaMemberSize());
_log.debug(String.format("Capabilities : isMeta: %s, Meta Type: %s, Member size: %s, Count: %s", capabilities.getIsMetaVolume(), capabilities.getMetaVolumeType(), capabilities.getMetaVolumeMemberSize(), capabilities.getMetaVolumeMemberCount()));
}
Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
recommendationMap.put(VpoolUse.ROOT, recommendations);
createVolumes(param, project, varray, vpool, recommendationMap, null, taskId, capabilities);
}
use of com.emc.storageos.model.block.VolumeCreate in project coprhd-controller by CoprHD.
the class ClusterAutoExportTest method createVolume.
public URI createVolume(VirtualArrayRestRep virtualArray, BlockVirtualPoolRestRep virtualPool, ProjectRestRep project) {
VolumeCreate input = new VolumeCreate();
input.setName("ClusterAutoExportTest" + System.currentTimeMillis());
input.setVarray(virtualArray.getId());
input.setVpool(virtualPool.getId());
input.setSize("2GB");
input.setCount(1);
input.setProject(project.getId());
Task<VolumeRestRep> task = client.blockVolumes().create(input).firstTask();
VolumeRestRep volume = task.get();
System.out.println("Created Volume: " + volume.getId());
return volume.getId();
}
Aggregations