Example #1
0
def reset_network_config():
    """restore initial blank /etc/network/configure"""

    if reset_netplan():
        display_success("Network configuration has been reset via netplan.")
    else:
        display_error("Failed to reset network config via netplan.")
Example #2
0
def reset_devices():
    cli.info_2("Reseting devices configuration")
    ready = cli.ask_yes_no("Sure you want to remove all devices conf?", default=False)
    if not ready:
        return

    if reset_writers():
        display_success("Devices configuration removed.")
    else:
        display_error("Failed to reset devices configuration.")
    pause()
Example #3
0
def display_toggle_host():
    enabled = read_conf().get("enabled", False)
    answer = cli.ask_yes_no(
        "You are about to {} this host. Are you sure?".format(
            "disable" if enabled else "enable"))
    if answer:
        enabled = not enabled  # toggled
        ns = "enabled" if enabled else "disabled"
        if toggle_host(enabled):
            display_success("Successfuly {} host!".format(ns))
        else:
            display_error("Error: host could not be {}.".format(ns))

        pause()
Example #4
0
def add_device():
    cli.info_2("Please remove all SD-cards from all writers.")
    ready = cli.ask_yes_no("Ready?", default=False)
    if not ready:
        return

    cli.info(
        "Great! Now please insert",
        cli.bold,
        "one",
        cli.reset,
        "SD-card into the writer you want to configure.",
    )
    cli.info_3("waiting for card", end="")
    block_name = None
    while block_name is None:
        time.sleep(1)
        cli.dot()
        block_name = find_device()
    cli.info("FOUND")

    # we now have a new DEVICE.
    device_id = get_device_id(block_name)
    slot = get_next_slot()

    # update configured writers list
    writers = read_conf().get("writers", {})
    writers.update({slot: device_id})
    if update_conf({"writers": writers}):
        display_success(
            "Found your",
            humanfriendly.format_size(get_block_size(block_name), binary=True),
            "card on",
            cli.bold,
            block_name,
            cli.reset,
            "({})".format(get_display_name(block_name)),
            ".\n",
            "Assigned slot:",
            cli.bold,
            slot,
        )
    else:
        display_error("Failed to configure a slot for", cli.bold, block_name)

    pause()
Example #5
0
def exit_to_logout():
    display_success("Exiting to logout.")
    sys.exit(20)
Example #6
0
def exit_to_shell():
    display_success("Exiting to shell.")
    sys.exit(10)