예제 #1
0
def unpack_node_xmldata(node, is_offline):
    """
    takes an XML element defining a node, and
    returns the data to pass to print_node
    is_offline: function(uname) -> offline?
    """
    type = uname = id = ""
    inst_attr = []
    other = {}
    for attr in node.keys():
        v = node.get(attr)
        if attr == "type":
            type = v
        elif attr == "uname":
            uname = v
        elif attr == "id":
            id = v
        else:
            other[attr] = v
    inst_attr = [cli_nvpairs(nvpairs2list(elem))
                 for elem in node.xpath('./instance_attributes')]
    return uname, id, type, other, inst_attr, is_offline(uname)
예제 #2
0
 def do_show(self, context, node=None):
     'usage: show [<node>]'
     cib_elem = xmlutil.cibdump2elem()
     if cib_elem is None:
         return False
     try:
         nodes_node = cib_elem.xpath("//configuration/nodes")[0]
         status = cib_elem.findall("status")[0]
     except:
         return False
     for c in nodes_node.iterchildren():
         if c.tag != "node":
             continue
         if node is not None and c.get("uname") != node:
             continue
         type = uname = id = ""
         inst_attr = []
         other = {}
         for attr in c.keys():
             v = c.get(attr)
             if attr == "type":
                 type = v
             elif attr == "uname":
                 uname = v
             elif attr == "id":
                 id = v
             else:
                 other[attr] = v
         for c2 in c.iterchildren():
             if c2.tag == "instance_attributes":
                 inst_attr += nvpairs2list(c2)
         offline = False
         for c2 in status.xpath(".//node_state"):
             if uname != c2.get("uname"):
                 continue
             offline = c2.get("crmd") == "offline"
         print_node(uname, id, type, other, inst_attr, offline)
예제 #3
0
def unpack_node_xmldata(node, is_offline):
    """
    takes an XML element defining a node, and
    returns the data to pass to print_node
    is_offline: function(uname) -> offline?
    """
    type = uname = id = ""
    inst_attr = []
    other = {}
    for attr in node.keys():
        v = node.get(attr)
        if attr == "type":
            type = v
        elif attr == "uname":
            uname = v
        elif attr == "id":
            id = v
        else:
            other[attr] = v
    inst_attr = [
        cli_nvpairs(nvpairs2list(elem))
        for elem in node.xpath('./instance_attributes')
    ]
    return uname, id, type, other, inst_attr, is_offline(uname)