mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-27 03:21:44 +03:00
network: Fix parsing <ip> blocks with prefix=
https://bugzilla.redhat.com/show_bug.cgi?id=872814
This commit is contained in:
parent
8b22d7a763
commit
32f74219b0
@ -101,12 +101,22 @@ class vmmNetwork(vmmLibvirtObject):
|
||||
return None
|
||||
addrStr = util.xpath(xml, "/network/ip/@address")
|
||||
netmaskStr = util.xpath(xml, "/network/ip/@netmask")
|
||||
prefix = util.xpath(xml, "/network/ip/@prefix")
|
||||
|
||||
netmask = IP(netmaskStr)
|
||||
gateway = IP(addrStr)
|
||||
if prefix:
|
||||
prefix = int(prefix)
|
||||
binstr = ((prefix * "1") + ((32 - prefix) * "0"))
|
||||
netmaskStr = str(IP(int(binstr, base=2)))
|
||||
|
||||
network = IP(gateway.int() & netmask.int())
|
||||
return IP(str(network) + "/" + netmaskStr)
|
||||
if netmaskStr:
|
||||
netmask = IP(netmaskStr)
|
||||
gateway = IP(addrStr)
|
||||
network = IP(gateway.int() & netmask.int())
|
||||
ret = IP(str(network) + "/" + netmaskStr)
|
||||
else:
|
||||
ret = IP(str(addrStr))
|
||||
|
||||
return ret
|
||||
|
||||
def get_ipv4_forward(self):
|
||||
xml = self.get_xml()
|
||||
|
Loading…
Reference in New Issue
Block a user