Fixes default Alice/Bob controller ports; Docstrings for all CLI functionsl partialy resote bob view command.

pull/1146/head
Kieran Prasch 2019-07-24 21:35:25 -07:00
parent d8e6486283
commit e9e89ef495
No known key found for this signature in database
GPG Key ID: 199AB839D4125A62
8 changed files with 55 additions and 52 deletions

View File

@ -222,7 +222,7 @@ class BlockchainInterface:
self.log.debug('Injecting POA middleware at layer 0')
self.client.inject_middleware(geth_poa_middleware, layer=0)
def connect(self, fetch_registry: bool = True, sync_now: bool = True):
def connect(self, fetch_registry: bool = True, sync_now: bool = False):
# Spawn child process
if self._provider_process:

View File

@ -19,7 +19,7 @@ from nucypher.config.characters import AliceConfiguration
@click.option('--teacher', 'teacher_uri', help="An Ursula URI to start learning from (seednode)", type=click.STRING)
@click.option('--min-stake', help="The minimum stake the teacher must have to be a teacher", type=click.INT, default=0)
@click.option('--discovery-port', help="The host port to run node discovery services on", type=NETWORK_PORT)
@click.option('--controller-port', help="The host port to run Alice HTTP services on", type=NETWORK_PORT)
@click.option('--controller-port', help="The host port to run Alice HTTP services on", type=NETWORK_PORT, default=AliceConfiguration.DEFAULT_CONTROLLER_PORT)
@click.option('--federated-only', '-F', help="Connect only to federated nodes", is_flag=True)
@click.option('--network', help="Network Domain Name", type=click.STRING)
@click.option('--config-root', help="Custom configuration directory", type=click.Path())
@ -84,6 +84,9 @@ def alice(click_config,
message_kit,
):
"""
"Alice the Policy Authority" management commands.
"""
#
# Validate
@ -212,27 +215,31 @@ def alice(click_config,
if action == "run":
"""Start Alice Controller"""
# RPC
if click_config.json_ipc:
rpc_controller = ALICE.make_rpc_controller()
_transport = rpc_controller.make_control_transport()
rpc_controller.start()
try:
# RPC
if click_config.json_ipc:
rpc_controller = ALICE.make_rpc_controller()
_transport = rpc_controller.make_control_transport()
rpc_controller.start()
return
# HTTP
else:
emitter.message(f"Alice Verifying Key {bytes(ALICE.stamp).hex()}", color="green", bold=True)
controller = ALICE.make_web_controller(crash_on_error=click_config.debug)
ALICE.log.info('Starting HTTP Character Web Controller')
emitter.message(f'Running HTTP Alice Controller at http://localhost:{controller_port}')
return controller.start(http_port=controller_port, dry_run=dry_run)
# Handle Crash
except Exception as e:
alice_config.log.critical(str(e))
emitter.message(f"{e.__class__.__name__} {e}", color='red', bold=True)
if click_config.debug:
raise # Crash :-(
return
# HTTP
else:
emitter.message(f"Alice Verifying Key {bytes(ALICE.stamp).hex()}", color="green", bold=True)
controller = ALICE.make_web_controller(crash_on_error=click_config.debug)
ALICE.log.info('Starting HTTP Character Web Controller')
return controller.start(http_port=controller_port, dry_run=dry_run)
elif action == "destroy":
"""Delete all configuration files from the disk"""
if dev:
message = "'nucypher alice destroy' cannot be used in --dev mode"
raise click.BadOptionUsage(option_name='--dev', message=message)
return actions.destroy_configuration(emitter, character_config=alice_config, force=force)
#
# Alice API
#
@ -270,7 +277,6 @@ def alice(click_config,
if not ALICE.federated_only:
grant_request.update({'value': value})
return ALICE.controller.grant(request=grant_request)
elif action == "revoke":

View File

@ -18,7 +18,7 @@ from nucypher.crypto.powers import DecryptingPower
@click.option('--teacher', 'teacher_uri', help="An Ursula URI to start learning from (seednode)", type=click.STRING)
@click.option('--min-stake', help="The minimum stake the teacher must have to be a teacher", type=click.INT, default=0)
@click.option('--discovery-port', help="The host port to run node discovery services on", type=NETWORK_PORT)
@click.option('--http-port', help="The host port to run Moe HTTP services on", type=NETWORK_PORT)
@click.option('--controller-port', help="The host port to run Bob HTTP services on", type=NETWORK_PORT, default=BobConfiguration.DEFAULT_CONTROLLER_PORT)
@click.option('--federated-only', '-F', help="Connect only to federated nodes", is_flag=True)
@click.option('--network', help="Network Domain Name", type=click.STRING)
@click.option('--config-root', help="Custom configuration directory", type=click.Path())
@ -100,12 +100,6 @@ def bob(click_config,
return painting.paint_new_installation_help(emitter, new_configuration=new_bob_config)
# TODO
# elif action == "view":
# """Paint an existing configuration to the console"""
# response = BobConfiguration._read_configuration_file(filepath=config_file or bob_config.config_file_location)
# return BOB.controller.emitter.ipc(response)
#
# Make Bob
#
@ -158,7 +152,12 @@ def bob(click_config,
# Start Controller
controller = BOB.make_web_controller(crash_on_error=click_config.debug)
BOB.log.info('Starting HTTP Character Web Controller')
return controller.start(http_port=http_port, dry_run=dry_run)
return controller.start(http_port=controller_port , dry_run=dry_run)
elif action == "view":
"""Paint an existing configuration to the console"""
response = BobConfiguration._read_configuration_file(filepath=config_file or bob_config.config_file_location)
return BOB.controller.emitter.ipc(response)
elif action == "destroy":
"""Delete Bob's character configuration files from the disk"""

View File

@ -16,7 +16,7 @@ from nucypher.cli.types import NETWORK_PORT
@nucypher_click_config
def enrico(click_config, action, policy_encrypting_key, dry_run, http_port, message):
"""
Start and manage an "Enrico" character control HTTP server
"Enrico the Encryptor" management commands.
"""
#

View File

@ -53,6 +53,9 @@ def felix(click_config,
registry_filepath,
dev,
force):
"""
"Felix the Faucet" management commands.
"""
emitter = click_config.emitter

View File

@ -18,9 +18,8 @@ from nucypher.network.middleware import RestMiddleware
@click.option('--learn-on-launch', help="Conduct first learning loop on main thread at launch.", is_flag=True)
@nucypher_click_config
def moe(click_config, teacher_uri, min_stake, network, ws_port, dry_run, http_port, learn_on_launch):
"""
"Moe" NuCypher node monitor CLI.
"Moe the Monitor" management commands.
"""
emitter = click_config.emitter

View File

@ -60,8 +60,6 @@ from nucypher.utilities.sandbox.constants import (
@click.option('--config-root', help="Custom configuration directory", type=click.Path())
@click.option('--config-file', help="Path to configuration file", type=EXISTING_READABLE_FILE)
@click.option('--poa', help="Inject POA middleware", is_flag=True, default=None)
@click.option('--sync/--no-sync', default=True)
@click.option('--hw-wallet/--no-hw-wallet', default=False)
@click.option('--geth', '-G', help="Run using the built-in geth node", is_flag=True)
@click.option('--provider', 'provider_uri', help="Blockchain provider's URI", type=click.STRING)
@click.option('--registry-filepath', help="Custom contract registry filepath", type=EXISTING_READABLE_FILE)
@ -82,8 +80,6 @@ def ursula(click_config,
worker_address,
federated_only,
poa,
sync,
hw_wallet,
config_root,
config_file,
provider_uri,
@ -92,7 +88,7 @@ def ursula(click_config,
interactive,
) -> None:
"""
Manage and run an "Ursula" PRE node.
"Ursula the Untrusted" PRE Re-encryption node management commands.
\b
Actions

View File

@ -68,21 +68,21 @@ def stake(click_config,
) -> None:
"""
Manage stakes and other staker-related operations
Manage stakes and other staker-related operations
\b
Actions
-------------------------------------------------
\b
new-stakeholder Create a new stakeholder configuration
list List active stakes for current stakeholder
accounts Show ETH and NU balances for stakeholder's accounts
sync Synchronize stake data with on-chain information
set-worker Bound a worker to a staker
detach-worker Detach worker currently bound to a staker
init Create a new stake
divide Create a new stake from part of an existing one
collect-reward Withdraw staking reward
\b
Actions
-------------------------------------------------
\b
new-stakeholder Create a new stakeholder configuration
list List active stakes for current stakeholder
accounts Show ETH and NU balances for stakeholder's accounts
sync Synchronize stake data with on-chain information
set-worker Bound a worker to a staker
detach-worker Detach worker currently bound to a staker
init Create a new stake
divide Create a new stake from part of an existing one
collect-reward Withdraw staking reward
"""