Example #1
0
def get_dev_info(node_dev):
    ''' Parse the node device XML string into dict according to
    http://libvirt.org/formatnode.html.

    scsi_generic is not documented in libvirt official website. Try to
    parse scsi_generic according to the following libvirt path series.
    https://www.redhat.com/archives/libvir-list/2013-June/msg00014.html

    scsi_target is not documented in libvirt official website. Try to
    parse scsi_target according to the libvirt commit db19834a0a.
    '''
    xmlstr = node_dev.XMLDesc(0)
    info = dictize(xmlstr)['device']
    dev_type = info['capability'].pop('type')
    info['device_type'] = dev_type
    cap_dict = info.pop('capability')
    info.update(cap_dict)

    # parent device not found: set as None
    info["parent"] = info.get("parent")

    if dev_type in ('scsi', 'scsi_generic', 'scsi_target', 'system', 'usb'):
        return info

    if dev_type in ('net', 'pci', 'scsi_host', 'storage', 'usb_device'):
        return globals()['_get_%s_dev_info' % dev_type](info)

    kimchi_log.error("Unknown device type: %s", dev_type)
    return info
Example #2
0
 def _get_access_info(self, dom):
     users = groups = list()
     access_xml = (get_metadata_node(dom, "access",
                                     self.caps.metadata_support) or
                   """<access></access>""")
     access_info = dictize(access_xml)
     auth = config.get("authentication", "method")
     if ('auth' in access_info['access'] and
             ('type' in access_info['access']['auth'] or
              len(access_info['access']['auth']) > 1)):
         users = xpath_get_text(access_xml,
                                "/access/auth[@type='%s']/user" % auth)
         groups = xpath_get_text(access_xml,
                                 "/access/auth[@type='%s']/group" % auth)
     elif auth == 'pam':
         # Compatible to old permission tagging
         users = xpath_get_text(access_xml, "/access/user")
         groups = xpath_get_text(access_xml, "/access/group")
     return users, groups
Example #3
0
 def _get_access_info(self, dom):
     users = groups = list()
     access_xml = (get_metadata_node(dom, "access",
                                     self.caps.metadata_support) or
                   """<access></access>""")
     access_info = dictize(access_xml)
     auth = config.get("authentication", "method")
     if ('auth' in access_info['access'] and
             ('type' in access_info['access']['auth'] or
              len(access_info['access']['auth']) > 1)):
         users = xpath_get_text(access_xml,
                                "/access/auth[@type='%s']/user" % auth)
         groups = xpath_get_text(access_xml,
                                 "/access/auth[@type='%s']/group" % auth)
     elif auth == 'pam':
         # Compatible to old permission tagging
         users = xpath_get_text(access_xml, "/access/user")
         groups = xpath_get_text(access_xml, "/access/group")
     return users, groups