MCPcopy
hub / github.com/retspen/webvirtcloud / get_net_device

Method get_net_device

vrtManager/instance.py:200–225  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

198 return range_pcpus
199
200 def get_net_device(self):
201 def get_mac_ipaddr(net, mac_host):
202 def fixed(ctx):
203 for net in ctx.xpathEval('/network/ip/dhcp/host'):
204 mac = net.xpathEval('@mac')[0].content
205 host = net.xpathEval('@ip')[0].content
206 if mac == mac_host:
207 return host
208 return None
209
210 return util.get_xml_path(net.XMLDesc(0), func=fixed)
211
212 def networks(ctx):
213 result = []
214 for net in ctx.xpathEval('/domain/devices/interface'):
215 mac_host = net.xpathEval('mac/@address')[0].content
216 nic_host = net.xpathEval('source/@network|source/@bridge|source/@dev|target/@dev')[0].content
217 try:
218 net = self.get_network(nic_host)
219 ip = get_mac_ipaddr(net, mac_host)
220 except:
221 ip = None
222 result.append({'mac': mac_host, 'nic': nic_host, 'ip': ip})
223 return result
224
225 return util.get_xml_path(self._XMLDesc(0), func=networks)
226
227 def get_disk_device(self):
228 def disks(ctx):

Callers 3

net_usageMethod · 0.95
interfacesFunction · 0.45
instanceFunction · 0.45

Calls 1

_XMLDescMethod · 0.95

Tested by

no test coverage detected