Search in sources :

Example 61 with StringSetMap

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;
}
Also used : InputGroup(com.emc.storageos.model.customservices.CustomServicesPrimitiveRestRep.InputGroup) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringSet(com.emc.storageos.db.client.model.StringSet) InputParameterRestRep(com.emc.storageos.model.customservices.InputParameterRestRep)

Example 62 with StringSetMap

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;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 63 with StringSetMap

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);
        }
    }
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringSet(com.emc.storageos.db.client.model.StringSet) UserGroup(com.emc.storageos.db.client.model.UserGroup)

Example 64 with StringSetMap

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;
}
Also used : ACLEntry(com.emc.storageos.model.auth.ACLEntry) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 65 with StringSetMap

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;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet)

Aggregations

StringSetMap (com.emc.storageos.db.client.model.StringSetMap)158 StringSet (com.emc.storageos.db.client.model.StringSet)95 URI (java.net.URI)72 ArrayList (java.util.ArrayList)68 List (java.util.List)49 HashMap (java.util.HashMap)43 StoragePort (com.emc.storageos.db.client.model.StoragePort)37 Map (java.util.Map)32 Initiator (com.emc.storageos.db.client.model.Initiator)31 NamedURI (com.emc.storageos.db.client.model.NamedURI)31 StringMap (com.emc.storageos.db.client.model.StringMap)31 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)26 ExportMask (com.emc.storageos.db.client.model.ExportMask)25 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)25 HashSet (java.util.HashSet)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)21 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)18 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)17 Test (org.junit.Test)16