use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class CustomServicesDBHelper method mapInput.
/**
* @param inputGroups
* @return
*/
private static StringSetMap mapInput(Map<String, InputGroup> inputGroups) {
final StringSetMap input = new StringSetMap();
if (null != inputGroups) {
for (final Entry<String, InputGroup> inputGroup : inputGroups.entrySet()) {
final StringSet set = new StringSet();
for (final InputParameterRestRep param : inputGroup.getValue().getInputGroup()) {
set.add(param.getName());
}
input.put(inputGroup.getKey(), set);
}
}
return input;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class CustomServicesRESTApiPrimitiveDAO method createInput.
private StringSetMap createInput(final CustomServicesPrimitiveCreateParam param) {
final StringSetMap input = CustomServicesDBHelper.createInput(REQUEST_INPUT_TYPES, param.getInput());
final Set<String> pathParams = getPathParams(param.getAttributes().get(CustomServicesConstants.PATH));
final Set<String> bodyParams = getBodyParams(param.getAttributes().get(CustomServicesConstants.BODY));
final StringSet inputParams = new StringSet();
inputParams.addAll(pathParams);
inputParams.addAll(bodyParams);
input.put(CustomServicesConstants.INPUT_PARAMS.toString(), inputParams);
return input;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method updateUserVdcRolesBasedOnUserGroup.
/**
* Add the vdc roles to the user based on the user group in the
* vdc role-assignments.
*
* @param user who's roles to be updated based on the user group in the
* vdc role-assignments.
* @param vdc to get its role-assignments.
*/
private void updateUserVdcRolesBasedOnUserGroup(StorageOSUser user, VirtualDataCenter vdc) {
if (user == null || vdc == null) {
_log.error("Invalid user {} or vdc {}", user, vdc);
return;
}
StringSetMap roleAssignments = vdc.getRoleAssignments();
Map<UserGroup, StringSet> userGroupsWithRoles = getUserGroupsFromRoleAssignments(roleAssignments);
if (CollectionUtils.isEmpty(userGroupsWithRoles)) {
_log.info("There are no role assignments for VDC {} with user group", vdc.getLabel());
return;
}
StringSet roleSet = findAllRolesToAdd(user, userGroupsWithRoles);
if (CollectionUtils.isEmpty(roleSet)) {
_log.debug("There are no roles found for user group in the vdc {}", vdc.getLabel());
return;
}
for (String role : roleSet) {
if (isRoleZoneLevel(role)) {
_log.debug("Adding the vdc role {} to the user {}", role, user.getDistinguishedName());
user.addRole(role);
}
}
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method convertToACLEntries.
/**
* Converts StringSetMap of acls into a list of ACLEntry as used by the API
*
* @param acls to be converted into the ACLEntry list.
* @return the converted ACLEntry list.
*/
public static List<ACLEntry> convertToACLEntries(StringSetMap acls) {
List<ACLEntry> assignments = new ArrayList<ACLEntry>();
if (CollectionUtils.isEmpty(acls)) {
return assignments;
}
for (Map.Entry<String, AbstractChangeTrackingSet<String>> ace : acls.entrySet()) {
PermissionsKey rowKey = new PermissionsKey();
rowKey.parseFromString(ace.getKey());
ACLEntry entry = new ACLEntry();
if (rowKey.getType().equals(PermissionsKey.Type.GROUP)) {
entry.setGroup(rowKey.getValue());
} else if (rowKey.getType().equals(PermissionsKey.Type.SID)) {
entry.setSubjectId(rowKey.getValue());
} else if (rowKey.getType().equals(PermissionsKey.Type.TENANT)) {
entry.setTenant(rowKey.getValue());
}
for (String priv : ace.getValue()) {
// skip owner
if (priv.equalsIgnoreCase(ACL.OWN.toString())) {
continue;
}
entry.getAces().add(priv);
}
if (!entry.getAces().isEmpty()) {
assignments.add(entry);
}
}
return assignments;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VNXeUnManagedObjectDiscoverer method createUnManagedVolume.
/**
* Creates a new UnManagedVolume with the given arguments.
*
* @param unManagedVolumeNativeGuid
* @param lun
* @param system
* @param pool
* @param dbClient
* @return
*/
private UnManagedVolume createUnManagedVolume(UnManagedVolume unManagedVolume, String unManagedVolumeNativeGuid, VNXeLun lun, StorageSystem system, StoragePool pool, DbClient dbClient) {
boolean created = false;
if (null == unManagedVolume) {
unManagedVolume = new UnManagedVolume();
unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
unManagedVolume.setNativeGuid(unManagedVolumeNativeGuid);
unManagedVolume.setStorageSystemUri(system.getId());
unManagedVolume.setStoragePoolUri(pool.getId());
created = true;
}
unManagedVolume.setLabel(lun.getName());
StringSetMap unManagedVolumeInformation = new StringSetMap();
Map<String, String> unManagedVolumeCharacteristics = new HashMap<String, String>();
Boolean isVolumeExported = false;
if (lun.getHostAccess() != null && !lun.getHostAccess().isEmpty()) {
isVolumeExported = true;
}
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), isVolumeExported.toString());
Boolean isVolumeInCG = lun.getType() == VNXeApiClient.GENERIC_STORAGE_LUN_TYPE ? true : false;
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), isVolumeInCG.toString());
StringSet deviceLabel = new StringSet();
deviceLabel.add(lun.getName());
unManagedVolumeInformation.put(SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
String volumeWWN = lun.getWwn().replaceAll(":", "");
unManagedVolume.setWwn(volumeWWN);
StringSet systemTypes = new StringSet();
systemTypes.add(system.getSystemType());
StringSet provCapacity = new StringSet();
provCapacity.add(String.valueOf(lun.getSizeTotal()));
unManagedVolumeInformation.put(SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
StringSet allocatedCapacity = new StringSet();
allocatedCapacity.add(String.valueOf(lun.getSizeAllocated()));
unManagedVolumeInformation.put(SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
unManagedVolumeInformation.put(SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
StringSet nativeId = new StringSet();
nativeId.add(lun.getId());
unManagedVolumeInformation.put(SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), Boolean.TRUE.toString());
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), lun.getIsThinEnabled().toString());
if (null != pool) {
unManagedVolume.setStoragePoolUri(pool.getId());
StringSet pools = new StringSet();
pools.add(pool.getId().toString());
unManagedVolumeInformation.put(SupportedVolumeInformation.STORAGE_POOL.toString(), pools);
StringSet driveTypes = pool.getSupportedDriveTypes();
if (null != driveTypes) {
unManagedVolumeInformation.put(SupportedVolumeInformation.DISK_TECHNOLOGY.toString(), driveTypes);
}
StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(dbClient, pool.getId(), unManagedVolumeCharacteristics.get(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString()), unManagedVolume);
log.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
if (null == matchedVPools || matchedVPools.isEmpty()) {
// clear all existing supported vpools.
unManagedVolume.getSupportedVpoolUris().clear();
} else {
// replace with new StringSet
unManagedVolume.getSupportedVpoolUris().replace(matchedVPools);
log.info("Replaced Pools : {}", Joiner.on("\t").join(unManagedVolume.getSupportedVpoolUris()));
}
}
unManagedVolume.setVolumeInformation(unManagedVolumeInformation);
if (unManagedVolume.getVolumeCharacterstics() == null) {
unManagedVolume.setVolumeCharacterstics(new StringMap());
}
unManagedVolume.getVolumeCharacterstics().replace(unManagedVolumeCharacteristics);
if (created) {
unManagedVolumesInsert.add(unManagedVolume);
} else {
unManagedVolumesUpdate.add(unManagedVolume);
}
return unManagedVolume;
}
Aggregations