@Test(expected = IllegalStateException.class) public void testRoleConfigsForMultipleDb() { HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1); HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2); TemplatePreparationObject preparationObject = Builder.builder().withHostgroupViews(Set.of(master, worker)) .withRdsConfigs(new HashSet<>(List.of(rdsConfig(DatabaseType.RANGER), rdsConfig(DatabaseType.RANGER)))).build(); String inputJson = getBlueprintText("input/clouderamanager-db-config.bp"); CmTemplateProcessor cmTemplateProcessor = new CmTemplateProcessor(inputJson); try { underTest.getRoleConfigs(cmTemplateProcessor, preparationObject); } catch (CloudbreakServiceException cse) { assertEquals("Multiple databases have been provided for RANGER_ADMIN component", cse.getMessage()); throw cse; } }
@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();  }