use of com.emc.storageos.model.pools.VirtualArrayAssignments 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.VirtualArrayAssignments in project coprhd-controller by CoprHD.
the class ProtectionSystemUpdateRequestParamTest method test.
@Test
public void test() {
ProtectionSystemUpdateRequestParam param = new ProtectionSystemUpdateRequestParam();
param.setIpAddress("foobarIP");
param.setPassword("password");
param.setPortNumber(344);
param.setUserName("username");
RPClusterVirtualArrayAssignmentChanges c1 = new RPClusterVirtualArrayAssignmentChanges();
VirtualArrayAssignments va1 = new VirtualArrayAssignments();
Set<String> vas = new HashSet<String>();
vas.add("varray1");
vas.add("varray2");
va1.setVarrays(vas);
c1.setClusterId("cluster1");
c1.setAdd(va1);
RPClusterVirtualArrayAssignmentChanges c2 = new RPClusterVirtualArrayAssignmentChanges();
VirtualArrayAssignments va2 = new VirtualArrayAssignments();
Set<String> vas2 = new HashSet<String>();
vas2.add("varray3");
vas2.add("varray4");
va2.setVarrays(vas2);
c2.setClusterId("cluster2");
c2.setAdd(va2);
Set<RPClusterVirtualArrayAssignmentChanges> cs = new HashSet<>();
cs.add(c1);
cs.add(c2);
param.setVarrayChanges(cs);
// create JAXB context and instantiate marshaller
JAXBContext context;
try {
context = JAXBContext.newInstance(ProtectionSystemUpdateRequestParam.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
// Write to System.out
m.marshal(param, System.out);
} catch (JAXBException e) {
logger.error(e.getMessage(), e);
}
}
use of com.emc.storageos.model.pools.VirtualArrayAssignments in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method runUpdatePortAssociationsProcessForVArrayChange.
/**
* This method executes process to update varrays for the passed port parameter.
*
* @param port storage port for which varrays have been changed
* @param dbClient
* @param coordinator
* @param pools pools which may require vpool changes as a result of port varray changes
* @param varrayAssignmentChanges varray changes for the port
*/
public static void runUpdatePortAssociationsProcessForVArrayChange(StoragePort port, DbClient dbClient, CoordinatorClient coordinator, List<StoragePool> pools, VirtualArrayAssignmentChanges varrayAssignmentChanges) {
try {
// If there was no change in connection between virtual array and storage system which owns port,
// we will run only NumPathsMatcher. Even when varray to storage system connectivity had not changed,
// change in varray ports may have impact on max. number of paths available for varray pools.
// If there was change in connectivity between virtual array and storage system, we will run all vpool
// matchers.
// This is our storage system.
URI storageSystemURI = port.getStorageDevice();
Set<String> varraysToAddIds = new HashSet<>();
Set<String> varraysToRemoveIds = new HashSet<>();
VirtualArrayAssignments varraysToAdd = varrayAssignmentChanges.getAdd();
if (varraysToAdd != null) {
varraysToAddIds = varraysToAdd.getVarrays();
}
VirtualArrayAssignments varraysToRemove = varrayAssignmentChanges.getRemove();
if (varraysToRemove != null) {
varraysToRemoveIds = varraysToRemove.getVarrays();
}
Set<String> varraysWithOutChangedConnectivity = new HashSet<>(varraysToAddIds);
varraysWithOutChangedConnectivity.addAll(varraysToRemoveIds);
// Set of varrays which changed connection to our storage system as result of storage port to varrays assignment change.
Set<String> varraysWithChangedConnectivity = StoragePortAssociationHelper.getVArraysWithChangedConnectivityToStorageSystem(port, varraysToAddIds, varraysToRemoveIds, dbClient);
varraysWithOutChangedConnectivity.removeAll(varraysWithChangedConnectivity);
Collection<StoragePort> ports = Collections.singleton(port);
if (null == pools) {
pools = new ArrayList<StoragePool>();
}
// for better reading, added a method to group Ports by Network
Map<NetworkLite, List<StoragePort>> portsByNetwork = groupPortsByNetwork(ports, dbClient);
if (!portsByNetwork.isEmpty()) {
updatePortAssociations(ports, portsByNetwork, dbClient);
// if any ports are associated with network, then add pools to existing list and run matching pools
Set<URI> poolUris = getStoragePoolIds(pools);
List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(dbClient, ports, null);
for (StoragePool pool : modifiedPools) {
if (!poolUris.contains(pool.getId())) {
pools.add(pool);
}
}
}
if (!varraysWithChangedConnectivity.isEmpty()) {
// If there are varrays which changed connectivity to our storage system, we need to process all their vpools to match them
// to
// our system's storage pools.
// Match the VPools defined in VArrays with changed connectivity to the StoragePools with all vpool matchers
_log.info("Varrays which changed connectivity to storage system {} are {}", storageSystemURI, varraysWithChangedConnectivity);
List<URI> vpoolURIs = getVpoolsForVarrays(varraysWithChangedConnectivity, dbClient);
_log.info("There are {} vpools for varrays. Execute all vpool matchers for vpools {}", vpoolURIs.size(), vpoolURIs);
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchModifiedStoragePoolsWithVirtualPools(pools, vpoolURIs, dbClient, coordinator, AttributeMatcher.VPOOL_MATCHERS, errorMessage);
}
if (!varraysWithOutChangedConnectivity.isEmpty()) {
_log.info("Varrays which did not change connection to storage system {} are {}", storageSystemURI, varraysWithOutChangedConnectivity);
// Match the VPools defined in VArrays without changed connectivity to the StoragePools only with num paths matcher
List<URI> vpoolURIs = getVpoolsForVarrays(varraysWithOutChangedConnectivity, dbClient);
_log.info("There are {} vpools for varrays. Execute num paths matcher for vpools {}", vpoolURIs.size(), vpoolURIs);
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchModifiedStoragePoolsWithVirtualPools(pools, vpoolURIs, dbClient, coordinator, AttributeMatcher.CONNECTIVITY_PLACEMENT_MATCHERS, errorMessage);
}
// get all the system that were affected and update their virtual
// arrays
HashSet<URI> systemsToProcess = StoragePoolAssociationHelper.getStorageSytemsFromPorts(ports, null);
// Now that pools have changed varrays, we need to update RP systems
ConnectivityUtil.updateRpSystemsConnectivity(systemsToProcess, dbClient);
} catch (Exception e) {
_log.error("Update Port Association process failed", e);
}
}
use of com.emc.storageos.model.pools.VirtualArrayAssignments in project coprhd-controller by CoprHD.
the class VirtualPoolService method populateCommonVirtualPoolUpdateParams.
/**
* This method is responsible to populate common VirtualPoolUpdateParams.
*
* @param vpool : id of VirtualPool to update.
* @param param : VirtualPoolParam to update.
*/
protected void populateCommonVirtualPoolUpdateParams(VirtualPool vpool, VirtualPoolUpdateParam param) {
if (param.getName() != null && !param.getName().isEmpty()) {
if (!param.getName().equalsIgnoreCase(vpool.getLabel())) {
if (vpool.getType().equalsIgnoreCase(Type.file.name())) {
// check if any file policies are assigned to the vpool
if ((vpool.getFilePolicies() != null) && !(vpool.getFilePolicies().isEmpty())) {
_log.error(String.format("Failed to update the name of virtual pool %s as a policy is assigned", vpool.getLabel()));
throw APIException.badRequests.cannotUpdateVpoolNameAssignedFilePolicy(vpool.getLabel());
}
// if file policy is assigned to project level then also it has file vpool associated with it.
// In this scenario association is only way.so need to iterate through all the policy to get vpool
// reference.
List<URI> filePolicyList = _dbClient.queryByType(FilePolicy.class, true);
for (URI filePolicy : filePolicyList) {
FilePolicy policyObj = _dbClient.queryObject(FilePolicy.class, filePolicy);
if ((policyObj != null && policyObj.getAssignedResources() != null) && (!NullColumnValueGetter.isNullURI(policyObj.getFilePolicyVpool())) && (policyObj.getFilePolicyVpool().equals(vpool.getId()))) {
_log.error(String.format("Failed to update the name of virtual pool %s as policy %s is assigned at higher level", vpool.getLabel(), policyObj.getFilePolicyName()));
throw APIException.badRequests.cannotUpdateVpoolNameAssignedFilePolicyAtHigherLevel(vpool.getLabel(), policyObj.getFilePolicyName());
}
}
}
checkForDuplicateName(param.getName(), VirtualPool.class);
}
vpool.setLabel(param.getName());
}
ArgValidator.checkFieldValueWithExpected(!VirtualPool.ProvisioningType.NONE.name().equalsIgnoreCase(param.getProvisionType()), VPOOL_PROVISIONING_TYPE, param.getProvisionType(), VirtualPool.ProvisioningType.Thick, VirtualPool.ProvisioningType.Thin);
if (null != param.getProtocolChanges()) {
if (null != param.getProtocolChanges().getAdd()) {
validateVirtualPoolProtocol(vpool.getType(), param.getProtocolChanges().getAdd().getProtocols());
vpool.addProtocols(param.getProtocolChanges().getAdd().getProtocols());
}
if (null != param.getProtocolChanges().getRemove()) {
validateVirtualPoolProtocol(vpool.getType(), param.getProtocolChanges().getRemove().getProtocols());
vpool.removeProtocols(param.getProtocolChanges().getRemove().getProtocols());
}
// There should be at least one protocol associated with vPool all the time.
if (vpool.getProtocols().isEmpty()) {
throw APIException.badRequests.cannotRemoveAllValues(VPOOL_PROTOCOLS, "vPool");
}
}
if (null != param.getProvisionType()) {
vpool.setSupportedProvisioningType(param.getProvisionType());
}
StringSetMap arrayInfo = vpool.getArrayInfo();
if (null == arrayInfo) {
vpool.setArrayInfo(new StringSetMap());
}
// the storage pool.
if (null != param.getVarrayChanges()) {
VirtualArrayAssignments addedNH = param.getVarrayChanges().getAdd();
if ((addedNH != null) && (!addedNH.getVarrays().isEmpty())) {
VirtualArrayService.checkVirtualArrayURIs(addedNH.getVarrays(), _dbClient);
vpool.addVirtualArrays(addedNH.getVarrays());
}
// Validate that the neighborhoods to be unassigned from the storage
// pool reference existing neighborhoods in the database and remove
// them from the storage pool.
VirtualArrayAssignments removedNH = param.getVarrayChanges().getRemove();
if ((removedNH != null) && (!removedNH.getVarrays().isEmpty())) {
VirtualArrayService.checkVirtualArrayURIs(removedNH.getVarrays(), _dbClient);
vpool.removeVirtualArrays(removedNH.getVarrays());
}
}
if (null != param.getDescription()) {
vpool.setDescription(param.getDescription());
}
if (null != param.getUseMatchedPools()) {
// are not removed
if (!param.getUseMatchedPools() && vpool.getUseMatchedPools()) {
checkPoolsWithResources(null, vpool, _dbClient);
}
vpool.setUseMatchedPools(param.getUseMatchedPools());
}
}
use of com.emc.storageos.model.pools.VirtualArrayAssignments in project coprhd-controller by CoprHD.
the class StoragePortService method verifyAssignmentChanges.
/**
* Verifies the virtual array assignment changes in the update request are
* valid, else throws a bad request exception.
*
* @param storagePort A reference to a storage port.
* @param varrayAssignmentChanges The virtual array assignment changes in a
* storage port update request.
*/
private void verifyAssignmentChanges(StoragePort storagePort, VirtualArrayAssignmentChanges varrayAssignmentChanges) {
// Verify the add/remove sets do not overlap.
VirtualArrayAssignments addAssignments = varrayAssignmentChanges.getAdd();
VirtualArrayAssignments removeAssignments = varrayAssignmentChanges.getRemove();
if ((addAssignments != null) && (removeAssignments != null)) {
Set<String> addVArrays = addAssignments.getVarrays();
Set<String> removeVArrays = removeAssignments.getVarrays();
if ((addVArrays != null) && (removeVArrays != null)) {
Set<String> addSet = new HashSet<String>(addVArrays);
Set<String> removeSet = new HashSet<String>(removeVArrays);
addSet.retainAll(removeSet);
if (!addSet.isEmpty()) {
_log.error("Request specifies the same virtual array(s) in both the add and remove lists {}", addSet);
throw APIException.badRequests.sameVirtualArrayInAddRemoveList();
}
}
}
// TODO: Any other add restrictions and/or remove restrictions.
if (addAssignments != null) {
Set<String> addVArrays = addAssignments.getVarrays();
if ((addVArrays != null) && (!addVArrays.isEmpty()) && (ConnectivityUtil.isAVplexPort(storagePort, _dbClient))) {
Iterator<String> addVArraysIterator = addVArrays.iterator();
while (addVArraysIterator.hasNext()) {
String varrayId = addVArraysIterator.next();
if (!ConnectivityUtil.vplexPortCanBeAssignedToVirtualArray(storagePort, varrayId, _dbClient)) {
_log.error("VPLEX port {} cannot be assigned to virtual array {}", storagePort.getId(), varrayId);
throw APIException.badRequests.virtualArrayHasPortFromOtherVPLEXCluster(storagePort.getNativeGuid(), varrayId);
}
}
}
}
}
Aggregations