def set_node_utilization(node, argv): cib = utils.get_cib_dom() node_el = utils.dom_get_node(cib, node) if node_el is None: if utils.usefile: utils.err("Unable to find a node: {0}".format(node)) for attrs in utils.getNodeAttributesFromPacemaker(): if attrs.name == node and attrs.type == "remote": node_attrs = attrs break else: utils.err("Unable to find a node: {0}".format(node)) nodes_section_list = cib.getElementsByTagName("nodes") if len(nodes_section_list) == 0: utils.err("Unable to get nodes section of cib") dom = nodes_section_list[0].ownerDocument node_el = dom.createElement("node") node_el.setAttribute("id", node_attrs.id) node_el.setAttribute("type", node_attrs.type) node_el.setAttribute("uname", node_attrs.name) nodes_section_list[0].appendChild(node_el) utils.dom_update_utilization(node_el, prepare_options(argv), "nodes-") utils.replace_cib_configuration(cib)
def print_node_utilization(node): cib = utils.get_cib_dom() node_el = utils.dom_get_node(cib, node) if node_el is None: utils.err("Unable to find a node: {0}".format(node)) utilization = utils.get_utilization_str(node_el) print("Node Utilization:") print(" {0}: {1}".format(node, utilization))
def set_node_utilization(node, argv): cib = utils.get_cib_dom() node_el = utils.dom_get_node(cib, node) if node_el is None: utils.err("Unable to find a node: {0}".format(node)) utils.dom_update_utilization( node_el, utils.convert_args_to_tuples(argv), "nodes-" ) utils.replace_cib_configuration(cib)
def set_node_utilization(node, argv): """ Commandline options: * -f - CIB file """ nvpair_dict = prepare_options(argv) if not nvpair_dict: return only_removing = True for value in nvpair_dict.values(): if value != "": only_removing = False break cib = utils.get_cib_dom() node_el = utils.dom_get_node(cib, node) if node_el is None: if utils.usefile: utils.err("Unable to find a node: {0}".format(node)) for attrs in utils.getNodeAttributesFromPacemaker(): if attrs.name == node and attrs.type == "remote": node_attrs = attrs break else: utils.err("Unable to find a node: {0}".format(node)) nodes_section_list = cib.getElementsByTagName("nodes") if not nodes_section_list: utils.err("Unable to get nodes section of cib") if only_removing: # Do not create new node if we are only removing values from it. return dom = nodes_section_list[0].ownerDocument node_el = dom.createElement("node") node_el.setAttribute("id", node_attrs.id) node_el.setAttribute("type", node_attrs.type) node_el.setAttribute("uname", node_attrs.name) nodes_section_list[0].appendChild(node_el) utils.dom_update_utilization(node_el, nvpair_dict, "nodes-") utils.replace_cib_configuration(cib)