class RGDemoteNode(RequestGenerator): _req_types = ["0"] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._pool_registry = PoolRegistry() def _rand_data(self): # pick random node from PoolRegistry to demote it result = self._pool_registry.select_new_random_node() return result async def _gen_req(self, submitter_did, req_data): data = {'alias': req_data['node_alias'], 'services': []} return await ledger.build_node_request(submitter_did, req_data['node_dest'], json.dumps(data))
class RGDemoteNode(RequestGenerator): _req_types = ["0"] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._pool_registry = PoolRegistry() def _rand_data(self): # pick random node from PoolRegistry to demote it result = self._pool_registry.select_new_random_node() return result async def _gen_req(self, submitter_did, req_data): data = {'alias': req_data['node_alias'], 'services': []} return await ledger.build_node_request(submitter_did, req_data['node_dest'], json.dumps(data)) async def on_request_replied(self, req_data, gen_req, resp_or_exp): # stop demoted node host = testinfra.get_host('ssh://persistent_node' + req_data['node_alias'][4:]) host.run('sudo systemctl stop indy-node')
except Exception as ex: raise argparse.ArgumentTypeError(ex) loop.run_until_complete(pool.close_pool_ledger(pool_handle)) dir_to_dlt = os.path.join(os.path.expanduser("~/.indy_client/pool"), pool_name) if os.path.isdir(dir_to_dlt): shutil.rmtree(dir_to_dlt, ignore_errors=True) if __name__ == '__main__': multiprocessing.set_start_method('spawn') args, extra = parser.parse_known_args() dict_args = vars(args) pool_registry = PoolRegistry(dict_args["genesis_path"], dict_args["promotion_shift"]) if len(extra) > 1: raise argparse.ArgumentTypeError( "Only path to config file expected, but found extra arguments: {}". format(extra)) conf_vals = {} try: if extra: with open(extra[0], "r") as conf_file: conf_vals = yaml.load(conf_file) except Exception as ex: print("Config parse error", ex) conf_vals = {}
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._pool_registry = PoolRegistry()
raise argparse.ArgumentTypeError(ex) loop.run_until_complete(pool.close_pool_ledger(pool_handle)) dir_to_dlt = os.path.join(os.path.expanduser("~/.indy_client/pool"), pool_name) if os.path.isdir(dir_to_dlt): shutil.rmtree(dir_to_dlt, ignore_errors=True) if __name__ == '__main__': multiprocessing.set_start_method('spawn') args, extra = parser.parse_known_args() dict_args = vars(args) pool_registry = PoolRegistry(dict_args["genesis_path"], dict_args["promotion_shift"], dict_args["nodes_untouched"]) if len(extra) > 1: raise argparse.ArgumentTypeError( "Only path to config file expected, but found extra arguments: {}". format(extra)) conf_vals = {} try: if extra: with open(extra[0], "r") as conf_file: conf_vals = yaml.load(conf_file) except Exception as ex: print("Config parse error", ex) conf_vals = {}