Exemplo n.º 1
0
def status() -> None:
    "Show the status of the masternode containers"
    configuration = Configuration(docker_url=docker_url)
    if configuration.force_recreate:
        display.error_breaking_change()
        sys.exit('\n')
    display.title_status_masternode(configuration.name)
    for _, service in configuration.services.items():
        status = service.status()
        if status and status == 'absent':
            display.status(name=service.name)
        if status and status in ['running']:
            display.status(name=service.name,
                           status=status,
                           id=service.container.short_id,
                           status_color='green')
        elif status:
            display.status(
                name=service.name,
                status=status,
                id=service.container.short_id,
            )
        else:
            display.status(name=service.name, status='error')
    display.newline()
Exemplo n.º 2
0
def stop() -> None:
    "Stop the masternode containers"
    configuration = Configuration(docker_url=docker_url)
    if configuration.force_recreate:
        display.error_breaking_change()
        sys.exit('\n')
    display.title_stop_masternode(configuration.name)
    for _, service in configuration.services.items():
        display.step_stop_container(service.name)
        if service.stop():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()
Exemplo n.º 3
0
def start(name: str, net: str, pkey: str, api: bool) -> None:
    "Start the containers needed to run a masternode"
    configuration = Configuration(name=name,
                                  net=net,
                                  pkey=pkey,
                                  start=True,
                                  docker_url=docker_url,
                                  api=api)
    if configuration.force_recreate:
        display.error_breaking_change()
        sys.exit('\n')
    display.title_start_masternode(configuration.name)
    # volumes
    display.subtitle_create_volumes()
    for _, value in configuration.volumes.items():
        display.step_create_volume(value.name)
        if value.create():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()
    # networks
    display.subtitle_create_networks()
    for _, value in configuration.networks.items():
        display.step_create_network(value.name)
        if value.create():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()
    # container
    # create
    display.subtitle_create_containers()
    for _, value in configuration.services.items():
        display.step_create_container(value.name)
        if value.create():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()
    # start
    for _, value in configuration.services.items():
        display.step_start_container(value.name)
        if value.start():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()
Exemplo n.º 4
0
def inspect() -> None:
    "Show details about the tomochain masternode"
    configuration = Configuration(docker_url=docker_url)
    if configuration.force_recreate:
        display.error_breaking_change()
        sys.exit('\n')
    display.title_inspect_masternode(configuration.name)
    identity = configuration.services['tomochain'].execute(
        'echo $IDENTITY') or 'container not running'
    display.detail_identity(identity)
    display.newline()
    coinbase = configuration.services['tomochain'].execute(
        'tomo account list --keystore keystore 2> /dev/null | head -n 1 | cut '
        '-d"{" -f 2 | cut -d"}" -f 1')
    if coinbase:
        coinbase = '0x{}'.format(coinbase)
    else:
        coinbase = 'container not running'
    display.detail_coinbase(coinbase)
    display.newline()
Exemplo n.º 5
0
def update() -> None:
    "Update the tomochain masternode with the lastest images"
    configuration = Configuration(docker_url=docker_url)
    if configuration.force_recreate:
        display.error_breaking_change()
        sys.exit('\n')
    display.title_update_masternode(configuration.name)
    display.subtitle_remove_containers()
    # containers
    # stop
    for _, service in configuration.services.items():
        display.step_stop_container(service.name)
        if service.stop():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()
    # remove
    for _, service in configuration.services.items():
        display.step_remove_container(service.name)
        if service.remove():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()
    # create
    for _, value in configuration.services.items():
        display.step_create_container(value.name)
        if value.create():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()
    # start
    for _, value in configuration.services.items():
        display.step_start_container(value.name)
        if value.start():
            display.step_close_ok()
        else:
            display.step_close_nok()
    display.newline()