-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from piotr-roslaniec/ruff
- Loading branch information
Showing
17 changed files
with
2,366 additions
and
1,304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,78 @@ | ||
from nucypher_ops.constants import DEFAULT_NAMESPACE, DEFAULT_NETWORK | ||
from nucypher_ops.ops.fleet_ops import CloudDeployers | ||
import os | ||
|
||
import click | ||
|
||
from nucypher_ops.constants import DEFAULT_NAMESPACE, DEFAULT_NETWORK | ||
from nucypher_ops.ops.fleet_ops import CloudDeployers | ||
|
||
emitter = click | ||
|
||
|
||
@click.group('ethereum') | ||
@click.group("ethereum") | ||
def cli(): | ||
"""deploy and update geth nodes""" | ||
|
||
|
||
@cli.command('deploy') | ||
@click.option('--image', help="The geth image to deploy", default='ethereum/client-go:stable') | ||
@click.option('--namespace', help="Namespace for these operations. Used to address hosts and data locally and name hosts on cloud platforms.", type=click.STRING, default=DEFAULT_NAMESPACE) | ||
@click.option('--network', help="The Nucypher network name these hosts will run on.", type=click.STRING, default=DEFAULT_NETWORK) | ||
@click.option('--include-host', 'include_hosts', help="specify hosts to update", multiple=True, type=click.STRING) | ||
@click.option('--env', '-e', 'envvars', help="additional environment variables (ENVVAR=VALUE)", multiple=True, type=click.STRING, default=[]) | ||
@click.option('--cli', '-c', 'cliargs', help="additional cli arguments for geth", multiple=True, type=click.STRING, default=[]) | ||
@cli.command("deploy") | ||
@click.option( | ||
"--image", help="The geth image to deploy", default="ethereum/client-go:stable" | ||
) | ||
@click.option( | ||
"--namespace", | ||
help="Namespace for these operations. Used to address hosts and data locally and name hosts on cloud platforms.", | ||
type=click.STRING, | ||
default=DEFAULT_NAMESPACE, | ||
) | ||
@click.option( | ||
"--network", | ||
help="The Nucypher network name these hosts will run on.", | ||
type=click.STRING, | ||
default=DEFAULT_NETWORK, | ||
) | ||
@click.option( | ||
"--include-host", | ||
"include_hosts", | ||
help="specify hosts to update", | ||
multiple=True, | ||
type=click.STRING, | ||
) | ||
@click.option( | ||
"--env", | ||
"-e", | ||
"envvars", | ||
help="additional environment variables (ENVVAR=VALUE)", | ||
multiple=True, | ||
type=click.STRING, | ||
default=[], | ||
) | ||
@click.option( | ||
"--cli", | ||
"-c", | ||
"cliargs", | ||
help="additional cli arguments for geth", | ||
multiple=True, | ||
type=click.STRING, | ||
default=[], | ||
) | ||
def deploy(image, namespace, network, include_hosts, envvars, cliargs): | ||
"""Deploys NuCypher on managed hosts.""" | ||
|
||
deployer = CloudDeployers.get_deployer('ethereum')(emitter, | ||
docker_image=image, | ||
namespace=namespace, | ||
network=network, | ||
envvars=envvars, | ||
cliargs=cliargs, | ||
resource_name='ethereum' | ||
) | ||
deployer = CloudDeployers.get_deployer("ethereum")( | ||
emitter, | ||
docker_image=image, | ||
namespace=namespace, | ||
network=network, | ||
envvars=envvars, | ||
cliargs=cliargs, | ||
resource_name="ethereum", | ||
) | ||
|
||
hostnames = deployer.config['instances'].keys() | ||
hostnames = deployer.config["instances"].keys() | ||
if include_hosts: | ||
hostnames = include_hosts | ||
for name, hostdata in [(n, d) for n, d in deployer.config['instances'].items() if n in hostnames]: | ||
for name, hostdata in [ | ||
(n, d) for n, d in deployer.config["instances"].items() if n in hostnames | ||
]: | ||
emitter.echo(f'\t{name}: {hostdata["publicaddress"]}', color="yellow") | ||
os.environ['ANSIBLE_HOST_KEY_CHECKING'] = 'False' | ||
os.environ["ANSIBLE_HOST_KEY_CHECKING"] = "False" | ||
deployer.deploy(hostnames) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,41 @@ | ||
from nucypher_ops.constants import DEFAULT_NAMESPACE, DEFAULT_NETWORK, NETWORKS | ||
from nucypher_ops.ops.fleet_ops import CloudDeployers | ||
import os | ||
import click | ||
|
||
from nucypher_ops.constants import NETWORKS | ||
from nucypher_ops.ops.fleet_ops import CloudDeployers | ||
|
||
emitter = click | ||
|
||
|
||
@click.group('namespaces') | ||
@click.group("namespaces") | ||
def cli(): | ||
"""Organize the machinery""" | ||
|
||
@cli.command('list') | ||
@click.option('--all', help="list all namespaces under all networks", default=False, is_flag=True) | ||
@click.option('--network', help="The network whose namespaces you want to see.", type=click.Choice(NETWORKS.keys()), default='mainnet') | ||
|
||
@cli.command("list") | ||
@click.option( | ||
"--all", help="list all namespaces under all networks", default=False, is_flag=True | ||
) | ||
@click.option( | ||
"--network", | ||
help="The network whose namespaces you want to see.", | ||
type=click.Choice(NETWORKS.keys()), | ||
default="mainnet", | ||
) | ||
def list_namespaces(network, all): | ||
"""lists namespaces""" | ||
if all: | ||
networks = NETWORKS.keys() | ||
else: | ||
networks = [network] | ||
deployers = [ | ||
CloudDeployers.get_deployer('generic')(emitter, network=network, pre_config={"namespace": None}) | ||
for network in networks] | ||
CloudDeployers.get_deployer("generic")( | ||
emitter, network=network, pre_config={"namespace": None} | ||
) | ||
for network in networks | ||
] | ||
for deployer in deployers: | ||
namespaces = deployer.get_namespace_names() | ||
if namespaces: | ||
emitter.echo(deployer.network) | ||
for ns in namespaces: | ||
emitter.echo(f'\t{ns}') | ||
|
||
emitter.echo(f"\t{ns}") |
Oops, something went wrong.