コード例 #1
0
ファイル: configauth.py プロジェクト: tjjh89017/maas
def prompt_for_external_auth_url(existing_url):
    if existing_url == '':
        existing_url = 'none'
    new_url = read_input(
        "URL to external Candid server [default={}]: ".format(existing_url))
    if new_url == '':
        new_url = existing_url
    return new_url
コード例 #2
0
ファイル: snappy.py プロジェクト: pfxuan/maas
def required_prompt(prompt, help_text=None):
    """Prompt for required input."""
    value = None
    while not value or value == "help":
        value = read_input(prompt)
        if value == "help":
            if help_text:
                print_msg(help_text)
    return value
コード例 #3
0
ファイル: configauth.py プロジェクト: tjjh89017/maas
def _get_or_prompt(options, option, message, replace_none=False):
    """Return a config option either from command line or interactive input."""
    config = options.get(option)
    if config is None:
        config = read_input(message)
    if replace_none and config == 'none':
        config = ''
    if config is None:
        config = ''
    return config
コード例 #4
0
ファイル: snappy.py プロジェクト: pfxuan/maas
def prompt_for_maas_url():
    """Prompt for the MAAS URL."""
    default_url = get_default_url()
    url = None
    while not url or url == "help":
        url = read_input("MAAS URL [default=%s]: " % default_url)
        if not url:
            url = default_url
        if url == "help":
            print_msg(
                'URL that MAAS should use for communicate from the nodes '
                'to MAAS and other controllers of MAAS.')
    return url
コード例 #5
0
ファイル: configauth.py プロジェクト: tjjh89017/maas
def _pick_service(services):
    print('Please select which service to register this MAAS as:\n')
    services_list = sorted(
        (service['name'], service['pending']) for service in services.values())
    for idx, (name, pending) in enumerate(services_list, 1):
        print(' {:3} - {} {}'.format(idx, name,
                                     '(pending)' if pending else ''))
    print()
    idx = read_input('Select service index: ')
    try:
        service_name = services_list[int(idx) - 1][0]
    except (ValueError, IndexError):
        raise CommandError('Invalid index')
    return services[service_name]
コード例 #6
0
def _pick_service(services):
    print("Please select which service to register this MAAS as:\n")
    services_list = sorted(
        (service["name"], service["pending"]) for service in services.values())
    for idx, (name, pending) in enumerate(services_list, 1):
        print(" {:3} - {} {}".format(idx, name,
                                     "(pending)" if pending else ""))
    print()
    idx = read_input("Select service index: ")
    try:
        service_name = services_list[int(idx) - 1][0]
    except (ValueError, IndexError):
        raise CommandError("Invalid index")
    return services[service_name]
コード例 #7
0
ファイル: snap.py プロジェクト: casual-lemon/maas
def required_prompt(title, help_text=None, default=None):
    """Prompt for required input."""
    value = None
    if default is not None:
        default_text = f" [default={default}]"
    else:
        default_text = ""
    prompt = f"{title}{default_text}: "
    while not value or value == "help":
        value = read_input(prompt)
        if not value and default is not None:
            value = default

        if value == "help":
            if help_text:
                print_msg(help_text)
    return value
コード例 #8
0
def prompt_for_ssh_import():
    """Prompt user for protocal and user-id to import SSH keys."""
    return read_input(
        "Import SSH keys [] (lp:user-id or gh:user-id): ")
コード例 #9
0
def prompt_for_email():
    """Prompt user for an email."""
    email = read_input("Email: ")
    if not email:
        raise EmptyEmail("You must input an email or provide it with --email")
    return email
コード例 #10
0
def prompt_for_username():
    username = read_input("Username: "******"You must input a username or "
                            "provide it with --username.")
    return username