@Test public void testGetRoleConfigsWithSingleRolesPerHostGroup() { HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1); HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2); String inputJson = getBlueprintText("input/clouderamanager-db-config.bp"); CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson); TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, worker)) .withBlueprintView(new BlueprintView(inputJson, "", "", cmTemplateProcessor)) .withRdsConfigs(Set.of(rdsConfig(DatabaseType.RANGER))) .build(); Map<String, List<ApiClusterTemplateConfig>> roleConfigs = underTest.getRoleConfigs(cmTemplateProcessor, preparationObject); assertEquals(1, roleConfigs.size()); List<ApiClusterTemplateConfig> masterRangerAdmin = roleConfigs.get("ranger-RANGER_ADMIN-BASE"); assertEquals(5, masterRangerAdmin.size()); assertEquals("ranger_database_host", masterRangerAdmin.get(0).getName()); assertEquals("10.1.1.1", masterRangerAdmin.get(0).getValue()); assertEquals("ranger_database_name", masterRangerAdmin.get(1).getName()); assertEquals("ranger", masterRangerAdmin.get(1).getValue()); assertEquals("ranger_database_type", masterRangerAdmin.get(2).getName()); assertEquals("PostgreSQL", masterRangerAdmin.get(2).getValue()); assertEquals("ranger_database_user", masterRangerAdmin.get(3).getName()); assertEquals("heyitsme", masterRangerAdmin.get(3).getValue()); assertEquals("ranger_database_password", masterRangerAdmin.get(4).getName()); assertEquals("iamsoosecure", masterRangerAdmin.get(4).getValue()); }
@Override protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) { switch (roleType) { case RangerRoles.RANGER_ADMIN: String cdhVersion = getCdhVersion(source); List<ApiClusterTemplateConfig> configList = new ArrayList<>(); if (!isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_2_1)) { addDbConfigs(getRdsView(source), configList, cdhVersion); } if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_0_1)) { VirtualGroupRequest virtualGroupRequest = source.getVirtualGroupRequest(); String adminGroup = virtualGroupService.getVirtualGroup(virtualGroupRequest, UmsRight.RANGER_ADMIN.getRight()); configList.add(config("ranger.default.policy.groups", adminGroup)); } return configList; default: return List.of(); } }
RangerRoleConfigProvider extends AbstractRdsRoleConfigProvider { @Override protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) { switch (roleType) { case RangerRoles.RANGER_ADMIN: String cdhVersion = getCdhVersion(source); List<ApiClusterTemplateConfig> configList = new ArrayList<>(); if (!isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_2_1)) { addDbConfigs(getRdsView(source), configList, cdhVersion); } if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_0_1)) { VirtualGroupRequest virtualGroupRequest = source.getVirtualGroupRequest(); String adminGroup = virtualGroupService.getVirtualGroup(virtualGroupRequest, UmsRight.RANGER_ADMIN.getRight()); configList.add(config("ranger.default.policy.groups", adminGroup)); } return configList; default: return List.of(); } } }
RangerRoleConfigProvider extends AbstractRdsRoleConfigProvider { @Override protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) { switch (roleType) { case RangerRoles.RANGER_ADMIN: String cdhVersion = getCdhVersion(source); List<ApiClusterTemplateConfig> configList = new ArrayList<>(); if (!isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_2_1)) { addDbConfigs(getRdsView(source), configList, cdhVersion); } if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_0_1)) { VirtualGroupRequest virtualGroupRequest = source.getVirtualGroupRequest(); String adminGroup = virtualGroupService.getVirtualGroup(virtualGroupRequest, UmsRight.RANGER_ADMIN.getRight()); configList.add(config("ranger.default.policy.groups", adminGroup)); } return configList; default: return List.of(); } }  }
RangerRoleConfigProvider extends AbstractRdsRoleConfigProvider { @Override protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) { switch (roleType) { case RangerRoles.RANGER_ADMIN: String cdhVersion = getCdhVersion(source); List<ApiClusterTemplateConfig> configList = new ArrayList<>(); if (!isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_2_1)) { addDbConfigs(getRdsView(source), configList, cdhVersion); } if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_0_1)) { VirtualGroupRequest virtualGroupRequest = source.getVirtualGroupRequest(); String adminGroup = virtualGroupService.getVirtualGroup(virtualGroupRequest, UmsRight.RANGER_ADMIN.getRight()); configList.add(config("ranger.default.policy.groups", adminGroup)); } return configList; default: return List.of(); } }  @Override List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source); @Override String getServiceType(); @Override List<String> getRoleTypes(); }
RangerRoleConfigProvider extends AbstractRdsRoleConfigProvider { @Override protected List<ApiClusterTemplateConfig> getRoleConfigs(String roleType, TemplatePreparationObject source) { switch (roleType) { case RangerRoles.RANGER_ADMIN: String cdhVersion = getCdhVersion(source); List<ApiClusterTemplateConfig> configList = new ArrayList<>(); if (!isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_2_1)) { addDbConfigs(getRdsView(source), configList, cdhVersion); } if (isVersionNewerOrEqualThanLimited(cdhVersion, CLOUDERAMANAGER_VERSION_7_0_1)) { VirtualGroupRequest virtualGroupRequest = source.getVirtualGroupRequest(); String adminGroup = virtualGroupService.getVirtualGroup(virtualGroupRequest, UmsRight.RANGER_ADMIN.getRight()); configList.add(config("ranger.default.policy.groups", adminGroup)); } return configList; default: return List.of(); } }  @Override List<ApiClusterTemplateConfig> getServiceConfigs(CmTemplateProcessor templateProcessor, TemplatePreparationObject source); @Override String getServiceType(); @Override List<String> getRoleTypes();  }