Search in sources :

Example 1 with VolumeGroupVolumeList

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);
}
Also used : VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) WaitForTasks(com.emc.sa.service.vipr.tasks.WaitForTasks) Tasks(com.emc.vipr.client.Tasks) TaskList(com.emc.storageos.model.TaskList) VolumeGroupUpdateParam(com.emc.storageos.model.application.VolumeGroupUpdateParam)

Example 2 with VolumeGroupVolumeList

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);
}
Also used : VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) WaitForTasks(com.emc.sa.service.vipr.tasks.WaitForTasks) Tasks(com.emc.vipr.client.Tasks) TaskList(com.emc.storageos.model.TaskList) VolumeGroupUpdateParam(com.emc.storageos.model.application.VolumeGroupUpdateParam)

Example 3 with VolumeGroupVolumeList

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);
}
Also used : VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) WaitForTasks(com.emc.sa.service.vipr.tasks.WaitForTasks) Tasks(com.emc.vipr.client.Tasks) TaskList(com.emc.storageos.model.TaskList) VolumeGroupUpdateParam(com.emc.storageos.model.application.VolumeGroupUpdateParam)

Example 4 with VolumeGroupVolumeList

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);
}
Also used : VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) WaitForTasks(com.emc.sa.service.vipr.tasks.WaitForTasks) Tasks(com.emc.vipr.client.Tasks) TaskList(com.emc.storageos.model.TaskList) VolumeGroupUpdateParam(com.emc.storageos.model.application.VolumeGroupUpdateParam)

Example 5 with VolumeGroupVolumeList

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;
}
Also used : ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List) VirtualPoolChangeList(com.emc.storageos.model.vpool.VirtualPoolChangeList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Aggregations

TaskList (com.emc.storageos.model.TaskList)5 VolumeGroupVolumeList (com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList)5 WaitForTasks (com.emc.sa.service.vipr.tasks.WaitForTasks)4 VolumeGroupUpdateParam (com.emc.storageos.model.application.VolumeGroupUpdateParam)4 Tasks (com.emc.vipr.client.Tasks)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 Operation (com.emc.storageos.db.client.model.Operation)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 Volume (com.emc.storageos.db.client.model.Volume)1 StorageSystemConnectivityList (com.emc.storageos.model.systems.StorageSystemConnectivityList)1 VirtualPoolChangeList (com.emc.storageos.model.vpool.VirtualPoolChangeList)1 ApplicationAddVolumeList (com.emc.storageos.volumecontroller.ApplicationAddVolumeList)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1