use of com.emc.storageos.model.pools.VirtualArrayAssignmentChanges in project coprhd-controller by CoprHD.
the class VirtualPoolUpdateBuilder method setVirtualArrays.
public VirtualPoolUpdateBuilder setVirtualArrays(Collection<String> virtualArrays) {
List<String> oldVirtualArrays = stringRefIds(oldVirtualPool.getVirtualArrays());
Set<String> add = Sets.newHashSet(CollectionUtils.subtract(virtualArrays, oldVirtualArrays));
Set<String> remove = Sets.newHashSet(CollectionUtils.subtract(oldVirtualArrays, virtualArrays));
VirtualArrayAssignmentChanges changes = new VirtualArrayAssignmentChanges();
if (!add.isEmpty()) {
changes.setAdd(new VirtualArrayAssignments(add));
}
if (!remove.isEmpty()) {
changes.setRemove(new VirtualArrayAssignments(remove));
}
virtualPool.setVarrayChanges(changes);
return this;
}
use of com.emc.storageos.model.pools.VirtualArrayAssignmentChanges in project coprhd-controller by CoprHD.
the class VirtualArrays method addVirtualArray.
/**
* Creates a change to add a virtual array.
*
* @param virtualArray
* the virtual array to add.
* @return the virtual array assignment changes.
*/
private static VirtualArrayAssignmentChanges addVirtualArray(VirtualArrayRestRep virtualArray) {
VirtualArrayAssignmentChanges changes = new VirtualArrayAssignmentChanges();
changes.setAdd(new VirtualArrayAssignments(Sets.newHashSet(stringId(virtualArray))));
return changes;
}
use of com.emc.storageos.model.pools.VirtualArrayAssignmentChanges in project coprhd-controller by CoprHD.
the class NetworkService method updateNetwork.
/**
* Update a network's name, endpoints or varrays.
* <p>
* When endpoints are changed, added or removed, and the endpoints match some storage ports, the storage ports associations to the
* network are updated accordingly. If the endpoints added exist is another network, they are first removed from their current network.
* Discovered endpoints cannot be removed from their current networks or added to another one.
* <p>
* When the storage ports networks are changed, their corresponding storage pools are also update to reflect any change in varray
* connectivity that may have resulted from the change.
* <p>
* For backward compatibility, this function still allows the varray changes to be done using {@link NetworkUpdate#getVarrays()}. The
* value specified in the parameter will override the existing varrays to maintain the same behavior. Further, only zero or one varray
* may be specified using this input field.
*
* @param id the URN of a ViPR network
* @param param the update request object
* @brief Update network
* @return the details of the updated network
*/
@PUT
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public NetworkRestRep updateNetwork(@PathParam("id") URI id, NetworkUpdate param) {
_log.info("updateNetwork: started for network {}", id);
ArgValidator.checkFieldUriType(id, Network.class, "id");
Network network = queryResource(id);
ArgValidator.checkEntity(network, id, isIdEmbeddedInURL(id));
if (param.getName() != null && !network.getLabel().equalsIgnoreCase(param.getName())) {
// check for active network with same name
checkDuplicateLabel(Network.class, param.getName());
_log.info("updateNetwork: changing network {} to {} ", network.getLabel(), param.getName());
network.setLabel(param.getName());
}
if (param.getVarrays() != null && !param.getVarrays().isEmpty() && param.getVarrays().size() != 1) {
throw APIException.badRequests.networkCanOnlyBeAssociatedWithASingleVirtualArray(network.getId());
}
// define variable to hold changes
List<URI> removedVarrays = null;
List<URI> addedVarrays = null;
List<String> removedEps = null;
List<String> addedEps = null;
// Update the varray association.
if (param.getVarrayChanges() != null) {
VirtualArrayAssignmentChanges varrayChanges = param.getVarrayChanges();
if (varrayChanges.hasRemoved()) {
removedVarrays = checkAndFilterRemoveVarrays(network, varrayChanges.getRemove().getVarrays(), varrayChanges.hasAdded() ? varrayChanges.getAdd().getVarrays() : null);
_log.info("updateNetwork: these varrays will be removed {} ", removedVarrays);
}
if (param.getVarrayChanges().hasAdded()) {
addedVarrays = checkAndFilterAddVarrays(network, varrayChanges.getAdd().getVarrays());
_log.info("updateNetwork: these varrays will be added {} ", addedVarrays);
}
} else if (param.getVarrays() != null) {
// the user is using the old style - still allow full overwrite of the varrays
_log.info("updateNetwork: using the old style update for varrays param {}", param.getVarrays());
if (param.getVarrays().isEmpty()) {
if (network.getAssignedVirtualArrays() != null) {
removedVarrays = checkAndFilterRemoveVarrays(network, network.getAssignedVirtualArrays(), null);
_log.info("updateNetwork: these varrays will be removed {} ", removedVarrays);
}
} else {
addedVarrays = checkAndFilterAddVarrays(network, StringSetUtil.uriListToSet(param.getVarrays()));
_log.info("updateNetwork: these varrays will be added {} ", addedVarrays);
}
}
// Update the endpoints.
if (param.getEndpointChanges() != null) {
if (param.getEndpointChanges().hasRemoved()) {
removedEps = checkAndFilterRemoveEndPoints(network, param.getEndpointChanges().getRemove());
_log.info("updateNetwork: these endpoints will be removed {} ", removedEps);
}
if (param.getEndpointChanges().hasAdded()) {
addedEps = checkAndFilterAddEndpoints(network, param.getEndpointChanges().getAdd());
_log.info("updateNetwork: these endpoints will be added {} ", addedEps);
}
}
if (removedVarrays != null) {
network.removeAssignedVirtualArrays(StringSetUtil.uriListToSet(removedVarrays));
}
if (addedVarrays != null) {
network.addAssignedVirtualArrays(StringSetUtil.uriListToSet(addedVarrays));
}
if (removedEps != null) {
network.removeEndpoints(removedEps);
}
if (addedEps != null) {
network.addEndpoints(addedEps, false);
}
_dbClient.updateAndReindexObject(network);
recordAndAudit(network, OperationTypeEnum.UPDATE_NETWORK);
_log.info("updateNetwork: updating ports and pools associations ");
NetworkAssociationHelper.handleNetworkUpdated(network, addedVarrays, removedVarrays, addedEps, removedEps, _dbClient, _coordinator);
return MapNetwork.toNetworkRestRep(network, _dbClient);
}
use of com.emc.storageos.model.pools.VirtualArrayAssignmentChanges 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;
}
Aggregations