use of com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList in project coprhd-controller by CoprHD.
the class AddVolumesToMobilityGroup method doExecute.
@Override
protected Tasks<TaskResourceRep> doExecute() throws Exception {
VolumeGroupUpdateParam input = new VolumeGroupUpdateParam();
VolumeGroupVolumeList addVolumesList = new VolumeGroupVolumeList();
addVolumesList.setVolumes(volumeIds);
input.setAddVolumesList(addVolumesList);
TaskList taskList = getClient().application().updateApplication(mobilityGroupId, input);
return new Tasks<TaskResourceRep>(getClient().auth().getClient(), taskList.getTaskList(), TaskResourceRep.class);
}
use of com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList in project coprhd-controller by CoprHD.
the class RemoveVolumesFromMobilityGroup method doExecute.
@Override
protected Tasks<TaskResourceRep> doExecute() throws Exception {
VolumeGroupUpdateParam input = new VolumeGroupUpdateParam();
VolumeGroupVolumeList removeVolumesList = new VolumeGroupVolumeList();
removeVolumesList.setVolumes(volumeIds);
input.setRemoveVolumesList(removeVolumesList);
TaskList taskList = getClient().application().updateApplication(mobilityGroupId, input);
return new Tasks<TaskResourceRep>(getClient().auth().getClient(), taskList.getTaskList(), TaskResourceRep.class);
}
use of com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList in project coprhd-controller by CoprHD.
the class AddVolumesToApplication method doExecute.
@Override
protected Tasks<TaskResourceRep> doExecute() throws Exception {
VolumeGroupUpdateParam input = new VolumeGroupUpdateParam();
VolumeGroupVolumeList addVolumesList = new VolumeGroupVolumeList();
addVolumesList.setVolumes(volumeIds);
if (replicationGroup != null && !replicationGroup.isEmpty()) {
addVolumesList.setReplicationGroupName(replicationGroup);
}
input.setAddVolumesList(addVolumesList);
TaskList taskList = getClient().application().updateApplication(applicationId, input);
return new Tasks<TaskResourceRep>(getClient().auth().getClient(), taskList.getTaskList(), TaskResourceRep.class);
}
use of com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList in project coprhd-controller by CoprHD.
the class RemoveVolumesFromApplication method doExecute.
@Override
protected Tasks<TaskResourceRep> doExecute() throws Exception {
VolumeGroupUpdateParam input = new VolumeGroupUpdateParam();
VolumeGroupVolumeList removeVolumesList = new VolumeGroupVolumeList();
removeVolumesList.setVolumes(volumeIds);
input.setRemoveVolumesList(removeVolumesList);
TaskList taskList = getClient().application().updateApplication(applicationId, input);
return new Tasks<TaskResourceRep>(getClient().auth().getClient(), taskList.getTaskList(), TaskResourceRep.class);
}
use of com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList in project coprhd-controller by CoprHD.
the class DefaultBlockServiceApiImpl method addVolumesToApplication.
/**
* Update volumes with volumeGroup Id, if the volumes are application ready
* (non VNX, or VNX volumes not in a real replication group)
*
* @param volumesList
* The add volume list
* @param application
* The application that the volumes are added to
* @param taskId
* @return ApplicationVolumeList The volumes that are not application ready (in real VNX CG with array replication
* group)
*/
private ApplicationAddVolumeList addVolumesToApplication(VolumeGroupVolumeList volumeList, VolumeGroup application, String taskId) {
ApplicationAddVolumeList addVolumeList = new ApplicationAddVolumeList();
Map<URI, List<URI>> addCGVolsMap = new HashMap<URI, List<URI>>();
String newRGName = volumeList.getReplicationGroupName();
for (URI voluri : volumeList.getVolumes()) {
Volume volume = _dbClient.queryObject(Volume.class, voluri);
if (volume == null || volume.getInactive()) {
_log.info(String.format("The volume %s does not exist or has been deleted", voluri));
continue;
}
URI cgUri = volume.getConsistencyGroup();
if (!NullColumnValueGetter.isNullURI(cgUri)) {
List<URI> vols = addCGVolsMap.get(cgUri);
if (vols == null) {
vols = new ArrayList<URI>();
}
vols.add(voluri);
addCGVolsMap.put(cgUri, vols);
} else {
// The volume is not in CG
throw APIException.badRequests.volumeGroupCantBeUpdated(application.getLabel(), String.format("The volume %s is not in a consistency group", volume.getLabel()));
}
String rgName = volume.getReplicationGroupInstance();
if (NullColumnValueGetter.isNotNullValue(rgName) && !rgName.equals(newRGName)) {
throw APIException.badRequests.volumeGroupCantBeUpdated(application.getLabel(), String.format("The volume %s is already in an array replication group, only the existing group name is allowed.", volume.getLabel()));
}
}
Set<URI> appReadyCGUris = new HashSet<URI>();
Set<Volume> appReadyCGVols = new HashSet<Volume>();
Set<URI> nonAppReadyCGVolUris = new HashSet<URI>();
// validate input volumes first, then batch processing, to avoid partial success
for (Map.Entry<URI, List<URI>> entry : addCGVolsMap.entrySet()) {
URI cgUri = entry.getKey();
List<URI> cgVolsToAdd = entry.getValue();
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
List<Volume> cgVolumes = getActiveCGVolumes(cg);
Set<URI> cgVolumeURIs = new HashSet<URI>();
for (Volume cgVol : cgVolumes) {
cgVolumeURIs.add(cgVol.getId());
}
Volume firstVolume = _dbClient.queryObject(Volume.class, cgVolsToAdd.get(0));
// Check if all CG volumes are adding into the application
if (!cgVolumeURIs.containsAll(cgVolsToAdd) || cgVolsToAdd.size() != cgVolumeURIs.size()) {
throw APIException.badRequests.volumeCantBeAddedToVolumeGroup(firstVolume.getLabel(), "not all volumes in consistency group are in the add volume list");
}
if (ControllerUtils.isVnxVolume(firstVolume, _dbClient) && !ControllerUtils.isNotInRealVNXRG(firstVolume, _dbClient)) {
// VNX CG cannot have snapshots, user has to remove the snapshots first in order to add the CG to an
// application
URIQueryResultList cgSnapshotsResults = new URIQueryResultList();
_dbClient.queryByConstraint(getBlockSnapshotByConsistencyGroup(cgUri), cgSnapshotsResults);
Iterator<URI> cgSnapshotsIter = cgSnapshotsResults.iterator();
while (cgSnapshotsIter.hasNext()) {
BlockSnapshot cgSnapshot = _dbClient.queryObject(BlockSnapshot.class, cgSnapshotsIter.next());
if ((cgSnapshot != null) && (!cgSnapshot.getInactive())) {
throw APIException.badRequests.notAllowedWhenVNXCGHasSnapshot();
}
}
nonAppReadyCGVolUris.addAll(cgVolumeURIs);
} else {
// non VNX CG volume, or volume in VNX CG with no array replication group
appReadyCGUris.add(cgUri);
appReadyCGVols.addAll(cgVolumes);
}
}
if (!appReadyCGVols.isEmpty()) {
for (Volume cgVol : appReadyCGVols) {
StringSet applications = cgVol.getVolumeGroupIds();
applications.add(application.getId().toString());
cgVol.setVolumeGroupIds(applications);
// handle clones
StringSet fullCopies = cgVol.getFullCopies();
List<Volume> fullCopiesToUpdate = new ArrayList<Volume>();
if (fullCopies != null && !fullCopies.isEmpty()) {
for (String fullCopyId : fullCopies) {
Volume fullCopy = _dbClient.queryObject(Volume.class, URI.create(fullCopyId));
if (fullCopy != null && !fullCopy.getInactive()) {
fullCopy.setFullCopySetName(fullCopy.getReplicationGroupInstance());
fullCopiesToUpdate.add(fullCopy);
}
}
}
if (!fullCopiesToUpdate.isEmpty()) {
_dbClient.updateObject(fullCopiesToUpdate);
}
Operation op = cgVol.getOpStatus().get(taskId);
op.ready();
cgVol.getOpStatus().updateTaskStatus(taskId, op);
}
_dbClient.updateObject(appReadyCGVols);
}
if (!appReadyCGUris.isEmpty()) {
for (URI cgUri : appReadyCGUris) {
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
if (cg != null && !cg.getInactive()) {
cg.setArrayConsistency(false);
Operation op = cg.getOpStatus().get(taskId);
op.ready();
cg.getOpStatus().updateTaskStatus(taskId, op);
_dbClient.updateObject(cg);
}
}
}
addVolumeList.getVolumes().addAll(nonAppReadyCGVolUris);
_log.info("Added volumes in CG to the application");
return addVolumeList;
}
Aggregations