コード例 #1
0
ファイル: setupSso.py プロジェクト: gauravkumar776/ambari
def get_services_requires_sso(options, ambari_properties, admin_login, admin_password):
  if not options.sso_enabled_services:
    configure_for_all_services = get_YN_input("Use SSO for all services [y/n] (n): ", False)
    if configure_for_all_services:
      services = [WILDCARD_FOR_ALL_SERVICES]
    else:
      services = []
      cluster_name = get_cluster_name(ambari_properties, admin_login, admin_password)

      if cluster_name:
        eligible_services = get_eligible_services(ambari_properties, admin_login, admin_password, cluster_name)
        if eligible_services:
          for service in eligible_services:
            question = "Use SSO for {0} [y/n] (y): ".format(service)
            if get_YN_input(question, True):
              services.append(service)
  else:
    services = options.sso_enabled_services.upper().split(',') if options.sso_enabled_services else []

  return services
コード例 #2
0
def get_services_requires_sso(options, properties, admin_login,
                              admin_password):
    if not options.sso_enabled_services:
        configure_for_all_services = get_YN_input(
            "Use SSO for all services [y/n] (n): ", False)
        if configure_for_all_services:
            services = WILDCARD_FOR_ALL_SERVICES
        else:
            cluster_name = get_cluster_name(properties, admin_login,
                                            admin_password)
            eligible_services = get_eligible_services(properties, admin_login,
                                                      admin_password,
                                                      cluster_name)
            services = ''
            for service in eligible_services:
                question = "Use SSO for {0} [y/n] (y): ".format(service)
                if get_YN_input(question, True):
                    if len(services) > 0:
                        services = services + ", "
                    services = services + service
    else:
        services = options.sso_enabled_services

    return services
コード例 #3
0
ファイル: setupSso.py プロジェクト: youfans/ambari
def populate_service_management(options, properties, ambari_properties,
                                admin_login, admin_password):
    if not options.sso_enabled_services:
        if not options.sso_manage_services:
            manage_services = get_boolean_from_dictionary(
                properties, SSO_MANAGE_SERVICES, False)
            manage_services = get_YN_input(
                "Manage SSO configurations for eligible services [y/n] ({0})? "
                .format('y' if manage_services else 'n'), manage_services)
        else:
            manage_services = 'true' == options.sso_manage_services

            if not options.sso_provider_url:
                stored_manage_services = get_boolean_from_dictionary(
                    properties, SSO_MANAGE_SERVICES, False)
                print(
                    "Manage SSO configurations for eligible services [y/n] ({0})? {1}"
                    .format('y' if stored_manage_services else 'n',
                            'y' if manage_services else 'n'))

        if manage_services:
            enabled_services = get_value_from_dictionary(
                properties, SSO_ENABLED_SERVICES, "").upper().split(',')

            all = "*" in enabled_services
            configure_for_all_services = get_YN_input(
                " Use SSO for all services [y/n] ({0})? ".format(
                    'y' if all else 'n'), all)
            if configure_for_all_services:
                services = WILDCARD_FOR_ALL_SERVICES
            else:
                cluster_name = get_cluster_name(ambari_properties, admin_login,
                                                admin_password)

                if cluster_name:
                    eligible_services = get_eligible_services(
                        ambari_properties, admin_login, admin_password,
                        cluster_name)

                    if eligible_services and len(eligible_services) > 0:
                        service_list = []

                        for service in eligible_services:
                            enabled = service.upper() in enabled_services
                            question = "   Use SSO for {0} [y/n] ({1})? ".format(
                                service, 'y' if enabled else 'n')
                            if get_YN_input(question, enabled):
                                service_list.append(service)

                        services = ','.join(service_list)
                    else:
                        print("   There are no eligible services installed.")
                        services = ""
                else:
                    services = ""
        else:
            services = ""
    else:
        if options.sso_manage_services:
            manage_services = 'true' == options.sso_manage_services
        else:
            manage_services = True

        services = options.sso_enabled_services.upper(
        ) if options.sso_enabled_services else ""

    properties[SSO_MANAGE_SERVICES] = 'true' if manage_services else "false"
    properties[SSO_ENABLED_SERVICES] = services