Loading ccnode/ccnodehandlers.py +38 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ VM_TAG_WRAP_MAP = { VM_TAG_HELPER_LIST = [ 'disk', 'nic', ] Loading Loading @@ -176,6 +177,43 @@ class NodeHandler(RpcHandler): logging.debug('_helper_vm_disk returns "%s"' % result) return result def _helper_vm_nic(self, vm): logging.debug('called _helper_vm_nic(%s)' % vm.get_name()) result = {} # fetch NIC list nics = vm.get_nics() logging.debug('_helper_vm_nic: NIC list "%s"' % nics) if len(nics): result['nic'] = " ".join(str(id) for id in range(0, len(nics))) # add NIC info for n, nic in enumerate(nics): try: result['nic%i_type' % n] = nic['type'] except: pass try: result['nic%i_hwaddr' % n] = nic['hwaddr'] except: pass try: result['nic%i_source' % n] = nic['source'] except: pass try: result['nic%i_target' % n] = nic['target'] except: pass try: result['nic%i_tx' % n] = nic['tx'] except: pass try: result['nic%i_rx' % n] = nic['rx'] except: pass logging.debug('_helper_vm_nic returns "%s"' % result) return result @pure def get_tags(self, tags=None): ''' Loading ccnode/libvirtwrapper.py +29 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,35 @@ class LibvirtVm(VM): result.append(d) return result def get_nics(self): result = [] xml_string = self._domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE) xroot = xml.dom.minidom.parseString(xml_string) xdomain = xroot.getElementsByTagName('domain').pop() xdevices = xdomain.getElementsByTagName('devices').pop() # iter on "interface" devices for iface in xdevices.getElementsByTagName('interface'): d = {} # get type try: d['type'] = iface.getAttribute('type') except: pass # get hardware address try: xmac = iface.getElementsByTagName('mac').pop() d['hwaddr'] = xmac.firstChild.nodeValue except: pass # get target interface try: xtarget = iface.getElementsByTagName('target').pop() d['target'] = xtarget.getAttribute('dev') except: pass result.append(d) return result def get_arch(self): result = None try: Loading Loading
ccnode/ccnodehandlers.py +38 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ VM_TAG_WRAP_MAP = { VM_TAG_HELPER_LIST = [ 'disk', 'nic', ] Loading Loading @@ -176,6 +177,43 @@ class NodeHandler(RpcHandler): logging.debug('_helper_vm_disk returns "%s"' % result) return result def _helper_vm_nic(self, vm): logging.debug('called _helper_vm_nic(%s)' % vm.get_name()) result = {} # fetch NIC list nics = vm.get_nics() logging.debug('_helper_vm_nic: NIC list "%s"' % nics) if len(nics): result['nic'] = " ".join(str(id) for id in range(0, len(nics))) # add NIC info for n, nic in enumerate(nics): try: result['nic%i_type' % n] = nic['type'] except: pass try: result['nic%i_hwaddr' % n] = nic['hwaddr'] except: pass try: result['nic%i_source' % n] = nic['source'] except: pass try: result['nic%i_target' % n] = nic['target'] except: pass try: result['nic%i_tx' % n] = nic['tx'] except: pass try: result['nic%i_rx' % n] = nic['rx'] except: pass logging.debug('_helper_vm_nic returns "%s"' % result) return result @pure def get_tags(self, tags=None): ''' Loading
ccnode/libvirtwrapper.py +29 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,35 @@ class LibvirtVm(VM): result.append(d) return result def get_nics(self): result = [] xml_string = self._domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE) xroot = xml.dom.minidom.parseString(xml_string) xdomain = xroot.getElementsByTagName('domain').pop() xdevices = xdomain.getElementsByTagName('devices').pop() # iter on "interface" devices for iface in xdevices.getElementsByTagName('interface'): d = {} # get type try: d['type'] = iface.getAttribute('type') except: pass # get hardware address try: xmac = iface.getElementsByTagName('mac').pop() d['hwaddr'] = xmac.firstChild.nodeValue except: pass # get target interface try: xtarget = iface.getElementsByTagName('target').pop() d['target'] = xtarget.getAttribute('dev') except: pass result.append(d) return result def get_arch(self): result = None try: Loading