def node_clear(env, node_name, allow_clear_cluster_node=False): """ Remove specified node from various cluster caches. LibraryEnvironment env provides all for communication with externals string node_name bool allow_clear_cluster_node -- flag allows to clear node even if it's still in a cluster """ mocked_envs = [] if not env.is_cib_live: mocked_envs.append("CIB") if not env.is_corosync_conf_live: mocked_envs.append("COROSYNC_CONF") if mocked_envs: raise LibraryError(reports.live_environment_required(mocked_envs)) current_nodes = get_nodes(env.get_corosync_conf(), env.get_cib()) if (node_addresses_contain_name(current_nodes, node_name) or node_addresses_contain_host(current_nodes, node_name)): env.report_processor.process( reports.get_problem_creator( report_codes.FORCE_CLEAR_CLUSTER_NODE, allow_clear_cluster_node)( reports.node_to_clear_is_still_in_cluster, node_name)) remove_node(env.cmd_runner(), node_name)
def test_return_false_if_not_match(self): self.assertFalse( lib.node_addresses_contain_name( [lib.NodeAddresses(ring0="NAME")], "NAME" ) )
def test_return_true_if_is_as_name(self): self.assertTrue( lib.node_addresses_contain_name( [lib.NodeAddresses("HOST", name="NAME")], "NAME" ) )
def validate_conflicts(tree, nodes, node_name, options): report_list = [] if (does_id_exist(tree, node_name) or node_addresses_contain_name(nodes, node_name) or ("remote-addr" not in options and node_addresses_contain_host(nodes, node_name))): report_list.append(reports.id_already_exists(node_name)) if ("remote-addr" in options and node_addresses_contain_host(nodes, options["remote-addr"])): report_list.append(reports.id_already_exists(options["remote-addr"])) return report_list
def validate_create(nodes, resource_agent, host, node_name, instance_attributes): """ validate inputs for create list of NodeAddresses nodes -- nodes already used string node_name -- name of future node dict instance_attributes -- data for future resource instance attributes """ report_list = _validate_server_not_used(resource_agent, instance_attributes) host_is_used = False if node_addresses_contain_host(nodes, host): report_list.append(reports.id_already_exists(host)) host_is_used = True if not host_is_used or host != node_name: if node_addresses_contain_name(nodes, node_name): report_list.append(reports.id_already_exists(node_name)) return report_list