Further integrate NodeConfiguration with CLI

pull/440/head
Kieran Prasch 2018-09-19 13:20:29 -07:00
parent 6116dac451
commit d2b35f8ed0
1 changed files with 19 additions and 19 deletions

View File

@ -136,14 +136,14 @@ def configure(config, action, config_file, config_root, temp):
"""Manage the nucypher .ini configuration file""" """Manage the nucypher .ini configuration file"""
if temp: if temp:
node_configuration = UrsulaConfiguration(temp=temp) node_configuration = NodeConfiguration(temp=temp, auto_initialize=True)
elif config_root: elif config_root:
node_configuration = UrsulaConfiguration(config_root=config_root) node_configuration = NodeConfiguration(config_root=config_root)
elif config_file: else:
node_configuration = NodeConfiguration.from_config_file(filepath=config_file)
click.echo("Using configuration file at: {}".format(config_file)) click.echo("Using configuration file at: {}".format(config_file))
node_configuration = NodeConfiguration.from_configuration_file(filepath=config_file)
click.echo("Using configuration root directory: {}".format(node_configuration.config_root)) click.echo("Using configuration directory: {}".format(node_configuration.config_root))
def __destroy(): def __destroy():
click.confirm("Permanently destroy all nucypher configurations, known nodes, certificates and keys?", abort=True) click.confirm("Permanently destroy all nucypher configurations, known nodes, certificates and keys?", abort=True)
@ -157,9 +157,10 @@ def configure(config, action, config_file, config_root, temp):
if action == "validate": if action == "validate":
if validate_configuration_file(config_file): if validate_configuration_file(config_file):
click.echo('{} is Valid.'.format(config_file)) result = 'Valid'
else: else:
click.echo('{} is Invalid.'.format(config_file)) result = 'Invalid'
click.echo('{} is {}'.format(config_file, result))
elif action == "init": elif action == "init":
__initialize() __initialize()
@ -413,7 +414,7 @@ def simulate(config, action, nodes, federated_only):
click.confirm("Deploy all nucypher contracts to blockchain?", abort=True) click.confirm("Deploy all nucypher contracts to blockchain?", abort=True)
click.echo("Bootstrapping simulated blockchain network") click.echo("Bootstrapping simulated blockchain network")
blockchain = TesterBlockchain.from_config() blockchain = TesterBlockchain()
# TODO: Enforce Saftey - ensure this is "fake" # # TODO: Enforce Saftey - ensure this is "fake" #
conditions = () conditions = ()
@ -703,26 +704,23 @@ def run_ursula(rest_port,
temp = True if dev else False temp = True if dev else False
if config_file: if config_file:
ursula_config = UrsulaConfiguration.from_config_file(filepath=config_file) ursula_config = UrsulaConfiguration.from_configuration_file(filepath=config_file)
else: else:
ursula_config = UrsulaConfiguration(temp=temp, ursula_config = UrsulaConfiguration(temp=temp,
auto_initialize=temp,
rest_host=rest_host, rest_host=rest_host,
rest_port=rest_port, rest_port=rest_port,
db_name=db_name, db_name=db_name,
is_me=True, is_me=True,
federated_only=federated_only, federated_only=federated_only,
checksum_address=checksum_address, checksum_address=checksum_address,
network_middleware=RestMiddleware(),
save_metadata=True, save_metadata=True,
known_metadata_dir=metadata_dir) known_metadata_dir=metadata_dir)
if dev: if dev:
ursula_config.initialize_configuration() ursula_config.load_known_nodes(known_metadata_dir=metadata_dir)
ursula_config.load_known_nodes()
ursula_config.check_config_tree()
ursula = ursula_config.produce() ursula = ursula_config.produce()
if teacher_uri: if teacher_uri:
if 'http' not in teacher_uri: if 'http' not in teacher_uri:
@ -730,11 +728,13 @@ def run_ursula(rest_port,
url = urlparse(url=teacher_uri) url = urlparse(url=teacher_uri)
host, port = url.hostname, url.port host, port = url.hostname, url.port
teacher = Ursula(rest_host=host, teacher_config = UrsulaConfiguration(temp=True,
rest_port=port, rest_host=host,
is_me=False, rest_port=port,
federated_only=federated_only, is_me=False,
known_nodes=(ursula, )) federated_only=federated_only,
known_nodes=(ursula, ))
teacher = teacher_config.produce()
# Know each other # Know each other
# ursula.remember_node(teacher) # ursula.remember_node(teacher)