def do(args): # ip = ansible.get_node_ip(args.node, args.id) config = network.config.load(args.id) ip = tf.get_node_ip(args.node, config) os.execlp( "ssh", "ssh", "ubuntu@{}".format(ip), "-i", config['key_file'] )
def do(args): # ip = ansible.get_node_ip(args.node, args.id) config = network.config.load(args.id) ip = tf.get_node_ip(args.node, config) cwd = os.getcwd() # Need this to use ansible.cfg os.chdir(BIN_PATH) runner.run( [os.path.join(BIN_PATH, "init_bond"), config['sawtooth_path'], ip]) os.chdir(cwd)
def run(args, network_config): print("got {}, {}".format(args, network_config)) procs = [] if 'family' in args: if args['family'] not in FAMILY: raise LrException("Unkown load family: {}".format(family)) family = FAMILY[args['family']] else: family = FAMILY['intkey'] if 'sawtooth_path' in network_config: src_dir = network_config['sawtooth_path'] if not os.path.exists(src_dir): raise LrException("Sawtooth not found at: {}", src_dir) else: raise LrException( "Network config does not contain `sawtooth_path`." " Cannot load without access to sawtooth-core." ) if 'duration' in args: try: duration = sim.timeline.parse_time(args['duration']) except: raise LrException( "Duration must be integral, {} is invalid".format(duration) ) else: duration = -1 for node in args['nodes']: node_url = "http://{}:8800".format( tf.get_node_ip(node, network_config)) rate = args['nodes'][node] print("Starting {} workload: {} TPM => {} for {} seconds...".format( family, rate, node_url, duration)) procs.append( runner.spawn([ PYTHON, HELPER, node_url, str(rate), src_dir, family, str(duration) ]) ) return procs
def playbook(name, config, playbook_args=None, retries=0, delay=0, delay_factor=1): """Playbook must be located in ansible_data/playbooks""" extra_vars = [ "genesis_tag='{}'".format( get_name_tag(0, config['network_id']) ), "genesis_ip='{}'".format( tf.get_node_ip(0, config) ), "sawtooth_packages='{}'".format(config['sawtooth_packages']), "sawtooth_version='{}'".format(config['sawtooth_version']), "sawtooth_services='{}'".format(config['sawtooth_services']), "sawtooth_configs='{}'".format(config['sawtooth_configs']), "sawtooth_repo='{}'".format(config['sawtooth_repo']), "influx_url='{}'".format(config['influx_url']), "influx_database='metrics_{}'".format(config['network_id']), # "influx_username='******'".format(os.environ['INFLUX_USERNAME']), # "influx_password='******'".format(os.environ['INFLUX_PASSWORD']), "syslog_server='{}'".format(config['syslog_server']), "syslog_port='{}'".format(config['syslog_port']), "max_batches_per_block='{}'".format(config['max_batches_per_block']), "scheduler='{}'".format(config['scheduler']), ] if playbook_args is not None: extra_vars.extend(playbook_args) playbook = _get_playbook_args(name, config, extra_vars) cwd = os.getcwd() # Need this to use ansible.cfg os.chdir(ANSIBLE_PATH) print("Running `%s`" % " ".join(playbook)) runner.run(playbook, retries=retries, delay=delay, delay_factor=delay_factor) os.chdir(cwd)
def run(args, network_config): print("Load: {}, {}".format(args, network_config)) procs = [] if 'family' not in args: raise LrException("No family specified for load command") else: family = args['family'] if family not in FAMILIES: raise LrException("Unkown load family: {}".format(family)) if 'sawtooth_path' in network_config: src_dir = network_config['sawtooth_path'] if not os.path.exists(src_dir): raise LrException("Sawtooth not found at: {}".format(src_dir)) else: raise LrException("Network config does not contain `sawtooth_path`." " Cannot load without access to sawtooth-core.") if 'duration' in args: try: duration = sim.timeline.parse_time(args['duration']) except: raise LrException("Duration {} is invalid".format( args['duration'])) else: duration = -1 if 'transactor_key' not in args: raise LrException("No transactor signing key specified") key = args['transactor_key'] if 'rate' not in args: raise LrException("No rate specified") try: rate = int(args['rate']) except: raise LrException("Rate {} is invalid".format(args['rate'])) if 'batch_size' in args: if family != 'smallbank': raise LrException("Batch size only supported in smallbank") batch_size = int(args['batch_size']) else: batch_size = 1 urls = ",".join([ "http://{}:8080".format(tf.get_node_ip(node, network_config)) for node in args['nodes'] ]) print("Starting {} workload: {} TPS => {} for {} seconds...".format( family, rate, urls, duration)) procs.append( runner.spawn([ PYTHON, HELPER, family, urls, str(rate), str(batch_size), src_dir, str(duration), key ])) return procs