use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class UnManagedFilesystemService method doesNASServerSupportVPoolProtocols.
/**
* Checks the NAS server protocols with vpool protocols
*
* @param nasUri the NAS server ID
* @param vpoolProtocols the protocols configured in vpool
* @return true if NAS server protocols matches with vpool protocols; false otherwise
*/
private boolean doesNASServerSupportVPoolProtocols(String nasUri, StringSet vpoolProtocols) {
NASServer nasServer = null;
boolean supports = false;
boolean isVNAS = false;
if (StringUtils.equals("VirtualNAS", URIUtil.getTypeName(nasUri))) {
nasServer = _dbClient.queryObject(VirtualNAS.class, URI.create(nasUri));
isVNAS = true;
} else {
nasServer = _dbClient.queryObject(PhysicalNAS.class, URI.create(nasUri));
}
if (nasServer != null) {
StringSet nasProtocols = nasServer.getProtocols();
if (isVNAS) {
if (VirtualNasState.LOADED.name().equals(nasServer.getNasState())) {
_logger.info("NAS server is: {}. Supported protocols: {}. Vpool protocols: {}", nasServer.getNasName(), nasProtocols, vpoolProtocols);
supports = nasProtocols.containsAll(vpoolProtocols);
} else {
_logger.warn("NAS server: {} not in LOADED state. So this vNAS server is not supported.", nasServer.getNasName());
supports = false;
}
} else {
// Perform check on Physical NAS
supports = nasProtocols.containsAll(vpoolProtocols);
}
}
return supports;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class UnManagedFilesystemService method createRule.
private void createRule(UnManagedFileExportRule orig, List<FileExportRule> fsExportRules) {
FileExportRule dest = new FileExportRule();
dest.setId(URIUtil.createId(FileExportRule.class));
dest.setFileSystemId(orig.getFileSystemId());
dest.setExportPath(orig.getExportPath());
dest.setSecFlavor(orig.getSecFlavor());
dest.setAnon(orig.getAnon());
dest.setMountPoint(orig.getMountPoint());
dest.setDeviceExportId(orig.getDeviceExportId());
if (orig.getReadOnlyHosts() != null && !orig.getReadOnlyHosts().isEmpty()) {
dest.setReadOnlyHosts(new StringSet(orig.getReadOnlyHosts()));
}
if (orig.getReadWriteHosts() != null && !orig.getReadWriteHosts().isEmpty()) {
dest.setReadWriteHosts(new StringSet(orig.getReadWriteHosts()));
}
if (orig.getRootHosts() != null && !orig.getRootHosts().isEmpty()) {
dest.setRootHosts(new StringSet(orig.getRootHosts()));
}
_logger.info("Ingesting Export Rule : {}", dest);
fsExportRules.add(dest);
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class UserGroupService method overlayUserGroup.
/**
* Overlay the UserGroup (a db object) with the information
* for the update api payload.
*
* @param to user group db object to be updated.
* @param from user group update api payload to be
* updated in the user group db object.
*/
private void overlayUserGroup(UserGroup to, UserGroupUpdateParam from) {
if (from == null || to == null) {
throw APIException.badRequests.resourceEmptyConfiguration("user group");
}
if (!to.getLabel().equalsIgnoreCase(from.getLabel())) {
throw APIException.badRequests.cannotRenameUserGroup(to.getLabel());
}
if (!to.getDomain().equalsIgnoreCase(from.getDomain())) {
checkForActiveUsageOfUserGroup(to.getDomain(), to.getLabel());
}
to.setDomain(from.getDomain());
to.setLabel(from.getLabel());
Map<String, UserAttributeParam> userAttributeParamMap = getUserAttributesToMap(to.getAttributes());
Map<String, UserAttributeParam> FromUserAttributeParamMap = getUserAttributesToMap(from.getAddAttributes());
if (!CollectionUtils.isEmpty(FromUserAttributeParamMap)) {
for (Map.Entry<String, UserAttributeParam> addAttribute : FromUserAttributeParamMap.entrySet()) {
addToMapIfNotExist(userAttributeParamMap, addAttribute);
}
}
if (!CollectionUtils.isEmpty(from.getRemoveAttributes())) {
for (String removeAttribute : from.getRemoveAttributes()) {
userAttributeParamMap.remove(removeAttribute);
}
}
if (CollectionUtils.isEmpty(userAttributeParamMap)) {
ArgValidator.checkFieldNotEmpty(userAttributeParamMap, "Attempt to remove the last attribute is not allowed. At least one attribute must be in the user group.");
}
StringSet attributesToAdd = new StringSet();
for (UserAttributeParam userAttributeParam : userAttributeParamMap.values()) {
attributesToAdd.add(userAttributeParam.toString());
}
to.getAttributes().replace(attributesToAdd);
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VirtualPoolService method getVArraysWithVPoolResources.
/**
* Calculate the virtual arrays which have the vpool resources.
* 1) Get list of vpool resources
* 2) Get the resources for each of the passed in virtual array
* 3) If there is resource in virtual array which is also in the vpool resource list, add to the virtual array list
*
* @param vpool
* @param varrays
* @param dbClient
* @return List of virtual arrays with vpool resources.
*/
public static Set<String> getVArraysWithVPoolResources(VirtualPool vpool, Set<String> varrays, DbClient dbClient) {
Set<String> resourcePools = new StringSet();
_log.debug("Getting the virtual arrays with resources of virtual pool {}.", vpool.getLabel());
if (null != varrays && !varrays.isEmpty()) {
Iterator<String> varrayItr = varrays.iterator();
while (varrayItr.hasNext()) {
String varray = varrayItr.next();
URI varrayURI = URI.create(varray);
URIQueryResultList varrayResourcesResultList = new URIQueryResultList();
URIQueryResultList vpoolResourcesResultList = new URIQueryResultList();
if (VirtualPool.Type.block.name().equals(vpool.getType())) {
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualArrayVolumeConstraint(varrayURI), varrayResourcesResultList);
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolVolumeConstraint(vpool.getId()), vpoolResourcesResultList);
} else if (VirtualPool.Type.file.name().equals(vpool.getType())) {
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayFileSharesConstraint(varrayURI.toString()), varrayResourcesResultList);
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolFileshareConstraint(vpool.getId()), vpoolResourcesResultList);
} else if (VirtualPool.Type.object.name().equals(vpool.getType())) {
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualArrayBucketsConstraint(varrayURI), varrayResourcesResultList);
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolBucketConstraint(vpool.getId()), vpoolResourcesResultList);
}
// Create a set of vpoolResourcesResultList
HashSet<URI> vpoolResourceSet = new HashSet<URI>();
for (URI vpoolResource : vpoolResourcesResultList) {
vpoolResourceSet.add(vpoolResource);
}
// Now look up if there are varray resources in the vpool resources set.
for (URI varrayResource : varrayResourcesResultList) {
if (vpoolResourceSet.contains(varrayResource)) {
boolean inactive = false;
if (VirtualPool.Type.block.name().equals(vpool.getType())) {
Volume resource = dbClient.queryObject(Volume.class, varrayResource);
inactive = resource.getInactive();
} else if (VirtualPool.Type.file.name().equals(vpool.getType())) {
FileShare resource = dbClient.queryObject(FileShare.class, varrayResource);
inactive = resource.getInactive();
} else if (VirtualPool.Type.object.name().equals(vpool.getType())) {
Bucket resource = dbClient.queryObject(Bucket.class, varrayResource);
inactive = resource.getInactive();
}
if (!inactive) {
_log.info("Found vpool resource {} in the varray {}", varrayResource, varray);
resourcePools.add(varray);
break;
}
}
}
}
}
return resourcePools;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VirtualPoolService method populateCommonVirtualPoolCreateParams.
/**
* This method is used to set the common VirtualPool create params in
* VirtualPool model.
*
* @param vpool : VirtualPool object to populate params.
* @param param : VirtualPoolCreate params.
* @throws DatabaseException
*/
protected void populateCommonVirtualPoolCreateParams(VirtualPool vpool, VirtualPoolCommonParam param) throws DatabaseException {
// ArgValidator.checkFieldNotEmpty(param.getName(), VPOOL_NAME);
if (StringUtils.isNotEmpty(param.getName())) {
vpool.setLabel(param.getName());
}
if (StringUtils.isNotEmpty(param.getDescription())) {
vpool.setDescription(param.getDescription());
}
ArgValidator.checkFieldNotEmpty(param.getProvisionType(), VPOOL_PROVISIONING_TYPE);
ArgValidator.checkFieldValueFromEnum(param.getProvisionType(), VPOOL_PROVISIONING_TYPE, EnumSet.of(ProvisioningType.Thick, ProvisioningType.Thin));
vpool.setId(URIUtil.createId(VirtualPool.class));
if (null != param.getProvisionType()) {
vpool.setSupportedProvisioningType(param.getProvisionType());
}
vpool.setMaxNativeSnapshots(0);
vpool.setProtocols(new StringSet());
// Validate the protocols for not null and non-empty values
ArgValidator.checkFieldNotEmpty(param.getProtocols(), VPOOL_PROTOCOLS);
// Validate the protocols for type of VirtualPool.
validateVirtualPoolProtocol(vpool.getType(), param.getProtocols());
vpool.getProtocols().addAll(param.getProtocols());
// validate and set neighborhoods
if (param.getVarrays() != null) {
vpool.setVirtualArrays(new StringSet());
for (String neighborhood : param.getVarrays()) {
URI neighborhoodURI = URI.create(neighborhood);
ArgValidator.checkUri(neighborhoodURI);
VirtualArray varray = _dbClient.queryObject(VirtualArray.class, neighborhoodURI);
ArgValidator.checkEntity(varray, neighborhoodURI, isIdEmbeddedInURL(neighborhoodURI));
vpool.getVirtualArrays().add(neighborhood);
}
}
// Set the useMatchedPools flag.
vpool.setUseMatchedPools(param.getUseMatchedPools());
}
Aggregations