use of com.emc.storageos.model.pools.VirtualArrayAssignments in project coprhd-controller by CoprHD.
the class VirtualArrays method removeVirtualArray.
/**
* Creates a change to remove a virtual array.
*
* @param virtualArray
* the virtual array to remove.
* @return the virtual array assignment changes.
*/
private static VirtualArrayAssignmentChanges removeVirtualArray(VirtualArrayRestRep virtualArray) {
VirtualArrayAssignmentChanges changes = new VirtualArrayAssignmentChanges();
changes.setRemove(new VirtualArrayAssignments(Sets.newHashSet(stringId(virtualArray))));
return changes;
}
use of com.emc.storageos.model.pools.VirtualArrayAssignments in project coprhd-controller by CoprHD.
the class ComputeVirtualPoolService method updateVirtualArrays.
/**
* Updates the virtual arrays to which the compute virtual pool is assigned.
*
* @param cvp - A reference to the compute virtual pool.
*
* @return true if there was a virtual array assignment change, false otherwise.
*/
private boolean updateVirtualArrays(ComputeVirtualPool cvp, VirtualArrayAssignmentChanges varrayAssignmentChanges) {
// Validate that the Virtual Arrays to be assigned to the Compute Virtual Pool
// reference existing Virtual Arrays in the database and add them to
// to the CVP.
boolean varraysForCvpUpdated = false;
Set<String> varraysAddedToCvp = new HashSet<String>();
Set<String> varraysRemovedFromCvp = new HashSet<String>();
if (varrayAssignmentChanges != null) {
_log.debug("Update request has virtual array assignment changes for compute virtual pool {}", cvp.getId());
// Verify the assignment changes in the request.
verifyAssignmentChanges(cvp, varrayAssignmentChanges);
_log.debug("Requested virtual array assignment changes verified.");
VirtualArrayAssignments addAssignments = varrayAssignmentChanges.getAdd();
if (addAssignments != null) {
Set<String> addVArrays = addAssignments.getVarrays();
if ((addVArrays != null) && (!addVArrays.isEmpty())) {
_log.debug("Request specifies virtual arrays to be added.");
// Validate the requested URIs.
VirtualArrayService.checkVirtualArrayURIs(addVArrays, _dbClient);
// Iterate over the virtual arrays and assign them to the CVP.
StringSet currentAssignments = cvp.getVirtualArrays();
Iterator<String> addVArraysIter = addVArrays.iterator();
while (addVArraysIter.hasNext()) {
String addVArrayId = addVArraysIter.next();
if ((currentAssignments != null) && (currentAssignments.contains(addVArrayId))) {
// Just ignore those already assigned
_log.debug("Compute Virtual Pool already assigned to virtual array {}", addVArrayId);
continue;
}
// Verify that the Virtual Array is active
URI virtualArrayURI = null;
virtualArrayURI = URI.create(addVArrayId);
this.queryObject(VirtualArray.class, virtualArrayURI, true);
varraysAddedToCvp.add(addVArrayId);
varraysForCvpUpdated = true;
_log.debug("Compute Virtual Pool will be assigned to virtual array {}", addVArrayId);
}
}
}
// Validate that the Virtual Arrays to be unassigned from the
// Compute Virtual Pool reference existing Virtual Arrays in the database
// and remove them from the CVP.
VirtualArrayAssignments removeAssignments = varrayAssignmentChanges.getRemove();
if (removeAssignments != null) {
Set<String> removeVArrays = removeAssignments.getVarrays();
// If the vcp is in use, varrays cannot be removed from the vcp.
if (isComputeVirtualPoolInUse(cvp)) {
throw APIException.badRequests.cannotRemoveVarraysFromCVP(cvp.getLabel());
}
if ((removeVArrays != null) && (!removeVArrays.isEmpty())) {
_log.debug("Request specifies virtual arrays to be removed.");
// Iterate over the virtual arrays and unassign from the CVP
StringSet currentAssignments = cvp.getVirtualArrays();
Iterator<String> removeVArraysIter = removeVArrays.iterator();
while (removeVArraysIter.hasNext()) {
String removeVArrayId = removeVArraysIter.next();
if ((currentAssignments == null) || (!currentAssignments.contains(removeVArrayId))) {
// Just ignore those not assigned.
_log.debug("Compute Virtual Pool is not assigned to virtual array {}", removeVArrayId);
continue;
}
varraysRemovedFromCvp.add(removeVArrayId);
varraysForCvpUpdated = true;
_log.debug("Compute Virtual Pool will be unassigned from virtual array {}", removeVArrayId);
}
}
}
}
// Persist virtual array changes for the Compute Virtual Pool, if any.
if (varraysForCvpUpdated) {
if (!varraysAddedToCvp.isEmpty()) {
cvp.addVirtualArrays(varraysAddedToCvp);
}
if (!varraysRemovedFromCvp.isEmpty()) {
cvp.removeVirtualArrays(varraysRemovedFromCvp);
}
}
return varraysForCvpUpdated;
}
Aggregations