Allow to specify a remote tftp server and pxe loader name

New keys for l2_network_device:

- pxe_bootp_file: filename of PXE loader, default='pxelinux.0'
- pxe_bootp_server: IP address of TFTP server that should be used
                    instead of the libvirt host. default=None

Change-Id: I5b15bcdb623638df939eddf78cf1ff90efa08a7f
This commit is contained in:
Dennis Dmitriev 2017-05-27 21:21:01 +03:00
parent 6847377d9a
commit ce7dd2977b
2 changed files with 14 additions and 4 deletions

View File

@ -379,7 +379,9 @@ class LibvirtL2NetworkDevice(network.L2NetworkDevice):
# than will be used 'stp' setting from the driver object.
has_pxe_server: false # Enable PXE server for this device
tftp_root_dir: /tmp # Specity root directory for TFTP server
pxe_bootp_file: pxelinux.0 # Name of the PXE loader file
tftp_root_dir: /tmp # Specify root directory for TFTP server, or
pxe_bootp_server: None # Specify IP address of the TFTP server
vlan_ifaces: [] # List of integer values that will be used to create
# tagged interfaces to the network device.
@ -527,6 +529,8 @@ class LibvirtL2NetworkDevice(network.L2NetworkDevice):
stp = base.ParamField()
has_pxe_server = base.ParamField(default=False)
pxe_bootp_file = base.ParamField(default='pxelinux.0')
pxe_bootp_server = base.ParamField()
tftp_root_dir = base.ParamField()
vlan_ifaces = base.ParamField(default=[])
@ -648,6 +652,8 @@ class LibvirtL2NetworkDevice(network.L2NetworkDevice):
has_pxe_server=self.has_pxe_server,
dhcp=self.dhcp,
tftp_root_dir=self.tftp_root_dir,
pxe_bootp_file=self.pxe_bootp_file,
pxe_bootp_server=self.pxe_bootp_server,
)
ret = self.driver.conn.networkDefineXML(xml)
ret.setAutostart(True)

View File

@ -42,7 +42,8 @@ class LibvirtXMLBuilder(object):
ip_network_prefixlen=None, stp=True,
has_pxe_server=False, dhcp=False,
dhcp_range_start=None, dhcp_range_end=None,
tftp_root_dir=None):
tftp_root_dir=None, pxe_bootp_file='pxelinux.0',
pxe_bootp_server=None):
"""Generate network XML
:rtype : String
@ -87,8 +88,11 @@ class LibvirtXMLBuilder(object):
name=address['name'],
)
if has_pxe_server:
network_xml.bootp(file='pxelinux.0')
if pxe_bootp_server:
network_xml.bootp(file=pxe_bootp_file,
server=pxe_bootp_server)
else:
network_xml.bootp(file=pxe_bootp_file)
return str(network_xml)
@classmethod