async def fetch_status(genesis_path: str, nodes: str = None, ident: DidKey = None, status_only: bool = False): pool = await open_pool(transactions_path=genesis_path) result = [] if ident: request = build_get_validator_info_request(ident.did) ident.sign_request(request) else: request = build_get_txn_request(None, 1, 1) from_nodes = [] if nodes: from_nodes = nodes.split(",") response = await pool.submit_action(request, node_aliases=from_nodes) primary = "" packages = {} for node, val in response.items(): jsval = [] status = {} errors = [] warnings = [] entry = {"name": node} try: jsval = json.loads(val) if not primary: primary = await get_primary_name(jsval, node) errors, warnings = await detect_issues(jsval, node, primary, ident) packages[node] = await get_package_info(jsval) except json.JSONDecodeError: errors = [val] # likely "timeout" # Status Summary entry["status"] = await get_status_summary(jsval, errors) # Errors / Warnings if len(errors) > 0: entry["status"]["errors"] = len(errors) entry["errors"] = errors if len(warnings) > 0: entry["status"]["warnings"] = len(warnings) entry["warnings"] = warnings # Full Response if not status_only and jsval: entry["response"] = jsval result.append(entry) # Package Mismatches if packages: await merge_package_mismatch_info(result, packages) print(json.dumps(result, indent=2))
async def fetch_status(genesis_path: str, ident: DidKey): pool = await open_pool(transactions_path=genesis_path) req = build_get_validator_info_request(ident.did) ident.sign_request(req) result = await pool.submit_action(req) for node, val in result.items(): try: jsval = json.loads(val) result[node] = jsval except json.JSONDecodeError: pass print(json.dumps(result, indent=2))
async def fetch(self, network_id: str, monitor_plugins: PluginCollection, nodes: str = None, ident: DidKey = None): result = [] verifiers = {} pool, network_name = await self.pool_collection.get_pool(network_id) if ident: log(f"Building request with did: {ident.did} ...") request = build_get_validator_info_request(ident.did) ident.sign_request(request) else: log("Building an anonymous request ...") request = build_get_txn_request(None, 1, 1) from_nodes = [] if nodes: from_nodes = nodes.split(",") try: # Introduced in https://github.com/hyperledger/indy-vdr/commit/ce0e7c42491904e0d563f104eddc2386a52282f7 log("Getting list of verifiers ...") verifiers = await pool.get_verifiers() except AttributeError: log("Unable to get list of verifiers. Please make sure you have the latest version of indy-vdr.") pass if verifiers and from_nodes: for node in from_nodes: if not node in verifiers: raise NodeNotFound(f'{node} is not a member of {network_name}.') log("Submitting request ...") response = await pool.submit_action(request, node_aliases = from_nodes) log("Passing results to plugins for processing ...") result = await monitor_plugins.apply_all_plugins_on_value(result, network_name, response, verifiers) log("Processing complete.") return result
async def fetch_status(genesis_path: str, nodes: str = None, ident: DidKey = None, network_name: str = None): # Start Of Engine attempt = 3 while attempt: try: pool = await open_pool(transactions_path=genesis_path) except: log("Pool Timed Out! Trying again...") if not attempt: print("Unable to get pool Response! 3 attempts where made. Exiting...") exit() attempt -= 1 continue break result = [] verifiers = {} if ident: request = build_get_validator_info_request(ident.did) ident.sign_request(request) else: request = build_get_txn_request(None, 1, 1) from_nodes = [] if nodes: from_nodes = nodes.split(",") response = await pool.submit_action(request, node_aliases = from_nodes) try: # Introduced in https://github.com/hyperledger/indy-vdr/commit/ce0e7c42491904e0d563f104eddc2386a52282f7 verifiers = await pool.get_verifiers() except AttributeError: pass # End Of Engine result = await monitor_plugins.apply_all_plugins_on_value(result, network_name, response, verifiers) print(json.dumps(result, indent=2))
async def get_validator_info(pool: Pool): req = build_get_validator_info_request("V4SGRU86Z58d6TV7PBUe6f") return await pool.submit_action(req)
async def fetch_status(genesis_path: str, nodes: str = None, ident: DidKey = None, status_only: bool = False, alerts_only: bool = False): pool = await open_pool(transactions_path=genesis_path) result = [] verifiers = {} if ident: request = build_get_validator_info_request(ident.did) ident.sign_request(request) else: request = build_get_txn_request(None, 1, 1) from_nodes = [] if nodes: from_nodes = nodes.split(",") response = await pool.submit_action(request, node_aliases = from_nodes) try: # Introduced in https://github.com/hyperledger/indy-vdr/commit/ce0e7c42491904e0d563f104eddc2386a52282f7 verifiers = await pool.get_verifiers() except AttributeError: pass primary = "" packages = {} for node, val in response.items(): jsval = [] status = {} errors = [] warnings = [] info = [] entry = {"name": node} try: await get_node_addresses(entry, verifiers) jsval = json.loads(val) if not primary: primary = await get_primary_name(jsval, node) errors, warnings = await detect_issues(jsval, node, primary, ident) info = await get_info(jsval, ident) packages[node] = await get_package_info(jsval) except json.JSONDecodeError: errors = [val] # likely "timeout" # Status Summary entry["status"] = await get_status_summary(jsval, errors) # Info if len(info) > 0: entry["status"]["info"] = len(info) entry["info"] = info # Errors / Warnings if len(errors) > 0: entry["status"]["errors"] = len(errors) entry["errors"] = errors if len(warnings) > 0: entry["status"]["warnings"] = len(warnings) entry["warnings"] = warnings # Full Response if not status_only and jsval: entry["response"] = jsval result.append(entry) # Package Mismatches if packages: await merge_package_mismatch_info(result, packages) # Connection Issues await detect_connection_issues(result) # Filter on alerts if alerts_only: filtered_result = [] for item in result: if ("info" in item["status"]) or ("warnings" in item["status"]) or ("errors" in item["status"]): filtered_result.append(item) result = filtered_result print(json.dumps(result, indent=2))