def _validate_guest_change( tree, nodes_to_validate_against, meta_attributes, allow_not_suitable_command, detect_remove=False ): if not guest_node.is_node_name_in_options(meta_attributes): return [] node_name = guest_node.get_node_name_from_options(meta_attributes) report_list = [] create_report = reports.use_command_node_add_guest if detect_remove and not guest_node.get_guest_option_value(meta_attributes): create_report = reports.use_command_node_remove_guest report_list.append( reports.get_problem_creator( report_codes.FORCE_NOT_SUITABLE_COMMAND, allow_not_suitable_command )(create_report) ) report_list.extend( guest_node.validate_conflicts( tree, nodes_to_validate_against, node_name, meta_attributes ) ) return report_list
def validate(node_name, options): tree = etree.fromstring( """ <cib> <configuration> <resources> <primitive id="CONFLICT"/> <primitive id="A"> <meta_attributes> <nvpair name="remote-node" value="GUEST_CONFLICT" /> </meta_attributes> </primitive> <primitive id="B" class="ocf" provider="pacemaker" type="remote" > <instance_attributes> <nvpair name="server" value="REMOTE_CONFLICT"/> </instance_attributes> </primitive> <primitive id="C"> <meta_attributes> <nvpair name="remote-node" value="some"/> <nvpair name="remote-addr" value="GUEST_ADDR_CONFLICT" /> </meta_attributes> </primitive> </resources> </configuration> </cib> """ ) existing_nodes_names = ["R1", "B", "GUEST_CONFLICT", "some"] existing_nodes_addrs = [ "RING0", "RING1", "REMOTE_CONFLICT", "GUEST_CONFLICT", "GUEST_ADDR_CONFLICT", ] return guest_node.validate_conflicts( tree, existing_nodes_names, existing_nodes_addrs, node_name, options )
def validate(node_name, options): tree = etree.fromstring(""" <cib> <configuration> <resources> <primitive id="CONFLICT"/> <primitive id="A"> <meta_attributes> <nvpair name="remote-node" value="GUEST_CONFLICT" /> </meta_attributes> </primitive> <primitive id="B" class="ocf" provider="pacemaker" type="remote" > <instance_attributes> <nvpair name="server" value="REMOTE_CONFLICT"/> </instance_attributes> </primitive> <primitive id="C"> <meta_attributes> <nvpair name="remote-node" value="some"/> <nvpair name="remote-addr" value="GUEST_ADDR_CONFLICT" /> </meta_attributes> </primitive> </resources> </configuration> </cib> """) existing_nodes_names = ["R1", "B", "GUEST_CONFLICT", "some"] existing_nodes_addrs = [ "RING0", "RING1", "REMOTE_CONFLICT", "GUEST_CONFLICT", "GUEST_ADDR_CONFLICT" ] return guest_node.validate_conflicts( tree, existing_nodes_names, existing_nodes_addrs, node_name, options )