mirror of https://github.com/nucypher/nucypher.git
adds deploy command, rename create to 'up'
parent
2f0dd8cf2f
commit
1cfa93a113
|
@ -30,6 +30,7 @@ def filter_staker_addresses(stakers, stakes):
|
|||
|
||||
staker_addresses = set()
|
||||
for staker in stakers:
|
||||
|
||||
for stake in staker.stakes:
|
||||
if stakes:
|
||||
if not stake.staker_address in stakes:
|
||||
|
@ -42,7 +43,7 @@ def filter_staker_addresses(stakers, stakes):
|
|||
def cloudworkers():
|
||||
"""Manage stakes and other staker-related operations."""
|
||||
|
||||
@cloudworkers.command('create')
|
||||
@cloudworkers.command('up')
|
||||
@group_staker_options
|
||||
@option_config_file
|
||||
@click.option('--cloudprovider', help="currently aws", default='aws')
|
||||
|
@ -52,8 +53,9 @@ def cloudworkers():
|
|||
@click.option('--seed-network', help="Do you want the 1st node to be --lonely and act as a seed node for this network", default=False, is_flag=True)
|
||||
@click.option('--sentry-dsn', help="a sentry dsn for these workers (https://sentry.io/)", default=None)
|
||||
@click.option('--include-stakeholder', 'stakes', help="limit worker to specified stakeholder addresses", multiple=True)
|
||||
@click.option('--wipe', help="Clear your nucypher config and start a fresh node with new kets", default=False, is_flag=True)
|
||||
@group_general_config
|
||||
def create(general_config, staker_options, config_file, cloudprovider, cloud_profile, remote_provider, nucypher_image, seed_network, sentry_dsn, stakes):
|
||||
def up(general_config, staker_options, config_file, cloudprovider, cloud_profile, remote_provider, nucypher_image, seed_network, sentry_dsn, stakes, wipe):
|
||||
"""Creates workers for all stakes owned by the user for the given network."""
|
||||
|
||||
emitter = setup_emitter(general_config)
|
||||
|
@ -77,7 +79,48 @@ def create(general_config, staker_options, config_file, cloudprovider, cloud_pro
|
|||
|
||||
if config.get('instances') and len(config.get('instances')) >= len(staker_addresses):
|
||||
emitter.echo('Nodes exist for all active stakers', color="yellow")
|
||||
deployer.deploy_nucypher_on_existing_nodes(staker_addresses)
|
||||
deployer.deploy_nucypher_on_existing_nodes(staker_addresses, wipe_nucypher=wipe)
|
||||
|
||||
|
||||
@cloudworkers.command('deploy')
|
||||
@group_staker_options
|
||||
@option_config_file
|
||||
@click.option('--cloudprovider', help="currently aws", default='aws')
|
||||
@click.option('--cloud-profile', help="The cloud provider account profile you'd like to use", default=None)
|
||||
@click.option('--remote-provider', help="The blockchain provider for the remote node, if not provided nodes will run geth.", default=None)
|
||||
@click.option('--nucypher-image', help="The docker image containing the nucypher code to run on the remote nodes.", default=None)
|
||||
@click.option('--seed-network', help="Do you want the 1st node to be --lonely and act as a seed node for this network", default=False, is_flag=True)
|
||||
@click.option('--sentry-dsn', help="a sentry dsn for these workers (https://sentry.io/)", default=None)
|
||||
@click.option('--include-stakeholder', 'stakes', help="limit worker to specified stakeholder addresses", multiple=True)
|
||||
@click.option('--wipe', help="Clear your nucypher config and start a fresh node with new kets", default=False, is_flag=True)
|
||||
@group_general_config
|
||||
def deploy(general_config, staker_options, config_file, cloudprovider, cloud_profile, remote_provider, nucypher_image, seed_network, sentry_dsn, stakes, wipe):
|
||||
"""Creates workers for all stakes owned by the user for the given network."""
|
||||
|
||||
emitter = setup_emitter(general_config)
|
||||
|
||||
if not CloudDeployers:
|
||||
emitter.echo("Ansible is required to use `nucypher cloudworkers *` commands. (Please run 'pip install ansible'.)", color="red")
|
||||
return
|
||||
STAKEHOLDER = staker_options.create_character(emitter, config_file)
|
||||
|
||||
stakers = STAKEHOLDER.get_stakers()
|
||||
if not stakers:
|
||||
emitter.echo("No staking accounts found.")
|
||||
return
|
||||
|
||||
staker_addresses = filter_staker_addresses(stakers, stakes)
|
||||
|
||||
config_file = config_file or StakeHolderConfiguration.default_filepath()
|
||||
|
||||
deployer = CloudDeployers.get_deployer(cloudprovider)(emitter, STAKEHOLDER, config_file, cloud_profile, remote_provider, nucypher_image, seed_network, sentry_dsn)
|
||||
|
||||
emitter.echo("found nodes for the following stakers:")
|
||||
for staker_address in staker_addresses:
|
||||
if deployer.config['instances'].get(staker_address):
|
||||
data = deployer.config['instances'].get(staker_address)
|
||||
emitter.echo(f'\t{staker_address}: {data["publicaddress"]}', color="yellow")
|
||||
deployer.deploy_nucypher_on_existing_nodes(staker_addresses, wipe_nucypher=wipe)
|
||||
|
||||
|
||||
@cloudworkers.command('destroy')
|
||||
|
|
Loading…
Reference in New Issue