mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-10 07:25:51 -06:00
network: Centralize pxe support check
This commit is contained in:
parent
6da801f944
commit
e9b8a289b5
10
virt-install
10
virt-install
@ -33,7 +33,6 @@ import urlgrabber.progress as progress
|
||||
|
||||
import virtinst
|
||||
import virtinst.cli as cli
|
||||
import virtinst.util as util
|
||||
from virtinst.cli import fail, print_stdout, print_stderr
|
||||
|
||||
|
||||
@ -82,12 +81,9 @@ def supports_pxe(guest):
|
||||
return True
|
||||
|
||||
try:
|
||||
xml = nic.conn.networkLookupByName(nic.network).XMLDesc(0)
|
||||
if util.xpath(xml, "/network/ip/dhcp/bootp/@file"):
|
||||
return True
|
||||
|
||||
forward = util.xpath(xml, "/network/forward/@mode")
|
||||
if forward and forward != "nat":
|
||||
netobj = nic.conn.networkLookupByName(nic.network)
|
||||
xmlobj = virtinst.Network(nic.conn, parsexml=netobj.XMLDesc(0))
|
||||
if xmlobj.can_pxe():
|
||||
return True
|
||||
except:
|
||||
logging.debug("Error checking if PXE supported", exc_info=True)
|
||||
|
@ -126,13 +126,7 @@ class vmmNetwork(vmmLibvirtObject):
|
||||
return self._get_xmlobj().forward.pretty_desc()
|
||||
|
||||
def can_pxe(self):
|
||||
forward = self.get_ipv4_forward_mode()
|
||||
if forward and forward != "nat":
|
||||
return True
|
||||
for ip in self._get_xmlobj().ips:
|
||||
if ip.bootp_file:
|
||||
return True
|
||||
return False
|
||||
return self._get_xmlobj().can_pxe()
|
||||
|
||||
def _get_static_route(self, family):
|
||||
xmlobj = self._get_xmlobj()
|
||||
|
@ -106,6 +106,19 @@ class Network(XMLBuilder):
|
||||
self._random_uuid = None
|
||||
|
||||
|
||||
###################
|
||||
# Helper routines #
|
||||
###################
|
||||
|
||||
def can_pxe(self):
|
||||
forward = self.forward.mode
|
||||
if forward and forward != "nat":
|
||||
return True
|
||||
for ip in self.ips:
|
||||
if ip.bootp_file:
|
||||
return True
|
||||
return False
|
||||
|
||||
######################
|
||||
# Validation helpers #
|
||||
######################
|
||||
|
Loading…
Reference in New Issue
Block a user