1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-10-31 19:44:16 +00:00

fix macvtap network list

This commit is contained in:
catborise 2020-07-20 14:52:55 +03:00
parent de63d9746d
commit 46884304b0
2 changed files with 8 additions and 3 deletions

View file

@ -1342,8 +1342,8 @@ class wvmInstance(wvmConnect):
net_source_type = network_data.get('net-source-' + str(num) + '-type') net_source_type = network_data.get('net-source-' + str(num) + '-type')
net_filter = network_data.get('net-nwfilter-' + str(num)) net_filter = network_data.get('net-nwfilter-' + str(num))
net_model = network_data.get('net-model-' + str(num)) net_model = network_data.get('net-model-' + str(num))
bridge_name = self.get_bridge_name(net_source, net_source_type)
if interface.get('type') == 'bridge': if interface.get('type') == 'bridge':
bridge_name = self.get_bridge_name(net_source, net_source_type)
source = interface.find('mac') source = interface.find('mac')
source.set('address', net_mac) source.set('address', net_mac)
source = interface.find('source') source = interface.find('source')

View file

@ -1,4 +1,5 @@
from lxml import etree from lxml import etree
from libvirt import libvirtError
from libvirt import VIR_NETWORK_SECTION_IP_DHCP_HOST from libvirt import VIR_NETWORK_SECTION_IP_DHCP_HOST
from libvirt import VIR_NETWORK_UPDATE_COMMAND_ADD_LAST, VIR_NETWORK_UPDATE_COMMAND_DELETE, VIR_NETWORK_UPDATE_COMMAND_MODIFY from libvirt import VIR_NETWORK_UPDATE_COMMAND_ADD_LAST, VIR_NETWORK_UPDATE_COMMAND_DELETE, VIR_NETWORK_UPDATE_COMMAND_MODIFY
from libvirt import VIR_NETWORK_UPDATE_AFFECT_LIVE, VIR_NETWORK_UPDATE_AFFECT_CONFIG from libvirt import VIR_NETWORK_UPDATE_AFFECT_LIVE, VIR_NETWORK_UPDATE_AFFECT_CONFIG
@ -32,7 +33,11 @@ class wvmNetworks(wvmConnect):
for network in get_networks: for network in get_networks:
net = self.get_network(network) net = self.get_network(network)
net_status = net.isActive() net_status = net.isActive()
net_bridge = net.bridgeName() try:
net_bridge = net.bridgeName()
except libvirtError:
net_bridge = util.get_xml_path(net.XMLDesc(0), "/network/forward/interface/@dev")
net_forward = util.get_xml_path(net.XMLDesc(0), "/network/forward/@mode") net_forward = util.get_xml_path(net.XMLDesc(0), "/network/forward/@mode")
networks.append({'name': network, 'status': net_status, networks.append({'name': network, 'status': net_status,
'device': net_bridge, 'forward': net_forward}) 'device': net_bridge, 'forward': net_forward})
@ -114,7 +119,7 @@ class wvmNetwork(wvmConnect):
try: try:
return self.net.bridgeName() return self.net.bridgeName()
except: except:
return None return util.get_xml_path(self._XMLDesc(0), "/network/forward/interface/@dev")
def start(self): def start(self):
self.net.create() self.net.create()