def _process_response(self, response): report = response_to_report_item(response) if report: self._report(report) return report_list = [] node_label = response.request.target.label try: data = json.loads(response.data) if not data["sbd"]["installed"]: report_list.append(reports.sbd_not_installed(node_label)) if not data["watchdog"]["exist"]: report_list.append( reports.watchdog_not_found(node_label, data["watchdog"]["path"])) for device in data.get("device_list", []): if not device["exist"]: report_list.append( reports.sbd_device_does_not_exist( device["path"], node_label)) elif not device["block_device"]: report_list.append( reports.sbd_device_is_not_block_device( device["path"], node_label)) # TODO maybe we can check whenever device is initialized by sbd (by # running 'sbd -d <dev> dump;') except (ValueError, KeyError, TypeError): report_list.append(reports.invalid_response_format(node_label)) if report_list: self._report_list(report_list) else: self._report( reports.sbd_check_success(response.request.target.label))
def check_sbd_on_node(report_processor, node_communicator, node, watchdog): """ Check if SBD can be enabled on specified 'node'. Raises LibraryError if check fails. Raises NodeCommunicationException if there is communication issue. report_processor -- node_communicator -- NodeCommunicator node -- NodeAddresses watchdog -- watchdog path """ report_list = [] try: data = json.loads(check_sbd(node_communicator, node, watchdog)) if not data["sbd"]["installed"]: report_list.append(reports.sbd_not_installed(node.label)) if not data["watchdog"]["exist"]: report_list.append(reports.watchdog_not_found( node.label, watchdog)) except (ValueError, KeyError): raise LibraryError(reports.invalid_response_format(node.label)) if report_list: raise LibraryError(*report_list) report_processor.process(reports.sbd_check_success(node.label))
def _process_response(self, response): report = response_to_report_item(response) if report: self._report(report) return report_list = [] node_label = response.request.target.label try: data = json.loads(response.data) if not data["sbd"]["installed"]: report_list.append(reports.sbd_not_installed(node_label)) if "watchdog" in data: if data["watchdog"]["exist"]: if not data["watchdog"].get("is_supported", True): report_list.append(reports.sbd_watchdog_not_supported( node_label, data["watchdog"]["path"] )) else: report_list.append(reports.watchdog_not_found( node_label, data["watchdog"]["path"] )) for device in data.get("device_list", []): if not device["exist"]: report_list.append(reports.sbd_device_does_not_exist( device["path"], node_label )) elif not device["block_device"]: report_list.append(reports.sbd_device_is_not_block_device( device["path"], node_label )) # TODO maybe we can check whenever device is initialized by sbd # (by running 'sbd -d <dev> dump;') except (ValueError, KeyError, TypeError): report_list.append(reports.invalid_response_format(node_label)) if report_list: self._report_list(report_list) else: self._report( reports.sbd_check_success(response.request.target.label) )
def check_sbd_on_node(report_processor, node_communicator, node, watchdog, device_list): """ Check if SBD can be enabled on specified 'node'. Raises LibraryError if check fails. Raises NodeCommunicationException if there is communication issue. report_processor -- node_communicator -- NodeCommunicator node -- NodeAddresses watchdog -- watchdog path device_list -- list of strings """ report_list = [] try: data = json.loads( check_sbd(node_communicator, node, watchdog, device_list)) if not data["sbd"]["installed"]: report_list.append(reports.sbd_not_installed(node.label)) if not data["watchdog"]["exist"]: report_list.append(reports.watchdog_not_found( node.label, watchdog)) for device in data.get("device_list", []): if not device["exist"]: report_list.append( reports.sbd_device_does_not_exist(device["path"], node.label)) elif not device["block_device"]: report_list.append( reports.sbd_device_is_not_block_device( device["path"], node.label)) # TODO maybe we can check whenever device is initialized by sbd (by # running 'sbd -d <dev> dump;') except (ValueError, KeyError, TypeError): raise LibraryError(reports.invalid_response_format(node.label)) if report_list: raise LibraryError(*report_list) report_processor.process(reports.sbd_check_success(node.label))
def check_sbd_on_node(report_processor, node_communicator, node, watchdog): """ Check if SBD can be enabled on specified 'node'. Raises LibraryError if check fails. Raises NodeCommunicationException if there is communication issue. report_processor -- node_communicator -- NodeCommunicator node -- NodeAddresses watchdog -- watchdog path """ report_list = [] try: data = json.loads(check_sbd(node_communicator, node, watchdog)) if not data["sbd"]["installed"]: report_list.append(reports.sbd_not_installed(node.label)) if not data["watchdog"]["exist"]: report_list.append(reports.watchdog_not_found(node.label, watchdog)) except (ValueError, KeyError): raise LibraryError(reports.invalid_response_format(node.label)) if report_list: raise LibraryError(*report_list) report_processor.process(reports.sbd_check_success(node.label))