def get_eligible_services(properties, admin_login, admin_password, cluster_name): print_info_msg("Fetching SSO enabled services") safe_cluster_name = urllib2.quote(cluster_name) response_code, json_data = get_json_via_rest_api( properties, admin_login, admin_password, FETCH_SERVICES_FOR_SSO_ENTRYPOINT % safe_cluster_name) services = [] if json_data and 'items' in json_data: services = [ item['ServiceInfo']['service_name'] for item in json_data['items'] if eligible(item['ServiceInfo']) ] if len(services) > 0: print_info_msg('Found SSO enabled services: %s' % ', '.join(services)) else: print_info_msg('No SSO enabled services were found') return services
def get_sso_properties(properties, admin_login, admin_password): print_info_msg("Fetching SSO configuration from DB") try: response_code, json_data = get_json_via_rest_api(properties, admin_login, admin_password, SSO_CONFIG_API_ENTRYPOINT) except urllib2.HTTPError as http_error: if http_error.code == 404: # This means that there is no SSO configuration in the database yet -> we can not fetch the # property (but this is NOT an error) json_data = None else: raise http_error if json_data and 'Configuration' in json_data and 'properties' in json_data['Configuration']: return json_data['Configuration']['properties'] else: return {}
def get_trusted_proxy_properties(ambari_properties, admin_login, admin_password): print_info_msg("Fetching Trusted Proxy configuration from DB") try: response_code, json_data = get_json_via_rest_api( ambari_properties, admin_login, admin_password, TPROXY_CONFIG_API_ENTRYPOINT) except urllib2.HTTPError as http_error: if http_error.code == httplib.NOT_FOUND: # This means that there is no Trusted Proxy configuration in the database yet -> we can not fetch the properties; but this is NOT an error json_data = None else: raise http_error return json_data.get('Configuration', {}).get('properties', {}) if json_data else {}