def _remove_device_model_net(lib_env, cluster_nodes, skip_offline_nodes): """ remove configuration used by qdevice model net NodeAddressesList cluster_nodes list of cluster nodes addresses bool skip_offline_nodes continue even if not all nodes are accessible """ reporter = lib_env.report_processor communicator = lib_env.node_communicator() reporter.process( reports.qdevice_certificate_removal_started() ) def do_and_report(reporter, communicator, node): qdevice_net.remote_client_destroy(communicator, node) reporter.process( reports.qdevice_certificate_removed_from_node(node.label) ) parallel_nodes_communication_helper( do_and_report, [ [(reporter, communicator, node), {}] for node in cluster_nodes ], lib_env.report_processor, skip_offline_nodes )
def remove_device(lib_env: LibraryEnvironment, skip_offline_nodes=False): """ Stop using quorum device, distribute and reload configs if live skip_offline_nodes continue even if not all nodes are accessible """ cfg = lib_env.get_corosync_conf() if not cfg.has_quorum_device(): raise LibraryError(reports.qdevice_not_defined()) model = cfg.get_quorum_device_model() cfg.remove_quorum_device() if lib_env.is_corosync_conf_live: report_processor = lib_env.report_processor # get nodes for communication cluster_nodes_names, report_list = get_existing_nodes_names( cfg, # Pcs is unable to communicate with nodes missing names. It cannot # send new corosync.conf to them. That might break the cluster. # Hence we error out. error_on_missing_name=True) if report_processor.report_list(report_list).has_errors: raise LibraryError() target_list = lib_env.get_node_target_factory().get_target_list( cluster_nodes_names, skip_non_existing=skip_offline_nodes, ) # fix quorum options for SBD to work properly if sbd.atb_has_to_be_enabled(lib_env.cmd_runner(), cfg): lib_env.report_processor.report( reports.corosync_quorum_atb_will_be_enabled_due_to_sbd()) cfg.set_quorum_options({"auto_tie_breaker": "1"}) # disable qdevice lib_env.report_processor.report( reports.service_disable_started("corosync-qdevice")) com_cmd_disable = qdevice_com.Disable(lib_env.report_processor, skip_offline_nodes) com_cmd_disable.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd_disable) # stop qdevice lib_env.report_processor.report( reports.service_stop_started("corosync-qdevice")) com_cmd_stop = qdevice_com.Stop(lib_env.report_processor, skip_offline_nodes) com_cmd_stop.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd_stop) # handle model specific configuration if model == "net": lib_env.report_processor.report( reports.qdevice_certificate_removal_started()) com_cmd_client_destroy = qdevice_net_com.ClientDestroy( lib_env.report_processor, skip_offline_nodes) com_cmd_client_destroy.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd_client_destroy) lib_env.push_corosync_conf(cfg, skip_offline_nodes)
def remove_device(lib_env, skip_offline_nodes=False): """ Stop using quorum device, distribute and reload configs if live skip_offline_nodes continue even if not all nodes are accessible """ __ensure_not_cman(lib_env) cfg = lib_env.get_corosync_conf() if not cfg.has_quorum_device(): raise LibraryError(reports.qdevice_not_defined()) model = cfg.get_quorum_device_model() cfg.remove_quorum_device() if lib_env.is_corosync_conf_live: target_list = lib_env.get_node_target_factory().get_target_list( cfg.get_nodes_names(), skip_non_existing=skip_offline_nodes, ) # fix quorum options for SBD to work properly if sbd.atb_has_to_be_enabled(lib_env.cmd_runner(), cfg): lib_env.report_processor.process( reports.corosync_quorum_atb_will_be_enabled_due_to_sbd() ) cfg.set_quorum_options({"auto_tie_breaker": "1"}) # disable qdevice lib_env.report_processor.process( reports.service_disable_started("corosync-qdevice") ) com_cmd = qdevice_com.Disable( lib_env.report_processor, skip_offline_nodes ) com_cmd.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd) # stop qdevice lib_env.report_processor.process( reports.service_stop_started("corosync-qdevice") ) com_cmd = qdevice_com.Stop( lib_env.report_processor, skip_offline_nodes ) com_cmd.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd) # handle model specific configuration if model == "net": lib_env.report_processor.process( reports.qdevice_certificate_removal_started() ) com_cmd = qdevice_net_com.ClientDestroy( lib_env.report_processor, skip_offline_nodes ) com_cmd.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd) lib_env.push_corosync_conf(cfg, skip_offline_nodes)
def _remove_device_model_net(lib_env, cluster_nodes, skip_offline_nodes): """ remove configuration used by qdevice model net NodeAddressesList cluster_nodes list of cluster nodes addresses bool skip_offline_nodes continue even if not all nodes are accessible """ reporter = lib_env.report_processor reporter.process(reports.qdevice_certificate_removal_started()) com_cmd = qdevice_net_com.ClientDestroy(reporter) com_cmd.set_targets( lib_env.get_node_target_factory().get_target_list(cluster_nodes)) run_and_raise(lib_env.get_node_communicator(), com_cmd)
def _remove_device_model_net(lib_env, cluster_nodes, skip_offline_nodes): """ remove configuration used by qdevice model net NodeAddressesList cluster_nodes list of cluster nodes addresses bool skip_offline_nodes continue even if not all nodes are accessible """ reporter = lib_env.report_processor communicator = lib_env.node_communicator() reporter.process(reports.qdevice_certificate_removal_started()) def do_and_report(reporter, communicator, node): qdevice_net.remote_client_destroy(communicator, node) reporter.process( reports.qdevice_certificate_removed_from_node(node.label)) parallel_nodes_communication_helper(do_and_report, [[(reporter, communicator, node), {}] for node in cluster_nodes], lib_env.report_processor, skip_offline_nodes)
def remove_device(lib_env, skip_offline_nodes=False): """ Stop using quorum device, distribute and reload configs if live skip_offline_nodes continue even if not all nodes are accessible """ cfg = lib_env.get_corosync_conf() if not cfg.has_quorum_device(): raise LibraryError(reports.qdevice_not_defined()) model = cfg.get_quorum_device_model() cfg.remove_quorum_device() if lib_env.is_corosync_conf_live: report_processor = SimpleReportProcessor(lib_env.report_processor) # get nodes for communication cluster_nodes_names, report_list = get_existing_nodes_names( cfg, # Pcs is unable to communicate with nodes missing names. It cannot # send new corosync.conf to them. That might break the cluster. # Hence we error out. error_on_missing_name=True ) report_processor.report_list(report_list) if report_processor.has_errors: raise LibraryError() target_list = lib_env.get_node_target_factory().get_target_list( cluster_nodes_names, skip_non_existing=skip_offline_nodes, ) # fix quorum options for SBD to work properly if sbd.atb_has_to_be_enabled(lib_env.cmd_runner(), cfg): lib_env.report_processor.process( reports.corosync_quorum_atb_will_be_enabled_due_to_sbd() ) cfg.set_quorum_options({"auto_tie_breaker": "1"}) # disable qdevice lib_env.report_processor.process( reports.service_disable_started("corosync-qdevice") ) com_cmd = qdevice_com.Disable( lib_env.report_processor, skip_offline_nodes ) com_cmd.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd) # stop qdevice lib_env.report_processor.process( reports.service_stop_started("corosync-qdevice") ) com_cmd = qdevice_com.Stop( lib_env.report_processor, skip_offline_nodes ) com_cmd.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd) # handle model specific configuration if model == "net": lib_env.report_processor.process( reports.qdevice_certificate_removal_started() ) com_cmd = qdevice_net_com.ClientDestroy( lib_env.report_processor, skip_offline_nodes ) com_cmd.set_targets(target_list) run_and_raise(lib_env.get_node_communicator(), com_cmd) lib_env.push_corosync_conf(cfg, skip_offline_nodes)