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()
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()
def remove(confirm: bool) -> None: "Remove the masternode (containers, networks volumes)" configuration = Configuration(docker_url=docker_url) if not confirm: display.warning_remove_masternode(configuration.name) sys.exit('\n') display.title_remove_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() # networks display.subtitle_remove_networks() for _, network in configuration.networks.items(): display.step_remove_network(network.name) if network.remove(): display.step_close_ok() else: display.step_close_nok() display.newline() # volumes display.subtitle_remove_volumes() for _, volume in configuration.volumes.items(): display.step_remove_volume(volume.name) if volume.remove(): display.step_close_ok() else: display.step_close_nok() display.newline() configuration.remove()
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()