cli: --cloud-init add network-config option
This commit is contained in:
parent
fa78a0c3f2
commit
7da5daff92
|
@ -878,6 +878,9 @@ Sub options are:
|
||||||
Specify a public key to inject into the guest, providing ssh access to the
|
Specify a public key to inject into the guest, providing ssh access to the
|
||||||
unprivileged account. Example: ssh-key=/home/user/.ssh/id_rsa.pub
|
unprivileged account. Example: ssh-key=/home/user/.ssh/id_rsa.pub
|
||||||
|
|
||||||
|
``network-config=``
|
||||||
|
Specify a cloud-init netowrk-config file to add directly to the iso.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
``--boot``
|
``--boot``
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
version: 2
|
||||||
|
ethernets:
|
||||||
|
enp1s0:
|
||||||
|
dhcp4: true
|
|
@ -957,6 +957,7 @@ c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-pass
|
||||||
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password-file=%(ADMIN-PASSWORD-FILE)s,disable=no", "cloud-init-options") # --cloud-init root-password-file
|
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password-file=%(ADMIN-PASSWORD-FILE)s,disable=no", "cloud-init-options") # --cloud-init root-password-file
|
||||||
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init ssh-key=%(XMLDIR)s/cloudinit/ssh-key.txt", "cloud-init-options") # --cloud-init ssh-key
|
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init ssh-key=%(XMLDIR)s/cloudinit/ssh-key.txt", "cloud-init-options") # --cloud-init ssh-key
|
||||||
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init user-data=%(XMLDIR)s/cloudinit/user-data.txt,meta-data=%(XMLDIR)s/cloudinit/meta-data.txt", "cloud-init-options") # --cloud-init user-data=,meta-data=
|
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init user-data=%(XMLDIR)s/cloudinit/user-data.txt,meta-data=%(XMLDIR)s/cloudinit/meta-data.txt", "cloud-init-options") # --cloud-init user-data=,meta-data=
|
||||||
|
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init user-data=%(XMLDIR)s/cloudinit/user-data.txt,meta-data=%(XMLDIR)s/cloudinit/meta-data.txt,network-config=%(XMLDIR)s/cloudinit/network-config.txt", "cloud-init-options") # --cloud-init user-data=,meta-data=,network-config=
|
||||||
c.add_valid("--panic help --disk=? --check=help", grep="path_in_use") # Make sure introspection doesn't blow up
|
c.add_valid("--panic help --disk=? --check=help", grep="path_in_use") # Make sure introspection doesn't blow up
|
||||||
c.add_valid("--connect test:///default --test-stub-command", use_default_args=False) # --test-stub-command
|
c.add_valid("--connect test:///default --test-stub-command", use_default_args=False) # --test-stub-command
|
||||||
c.add_valid("--nodisks --pxe", grep="VM performance may suffer") # os variant warning
|
c.add_valid("--nodisks --pxe", grep="VM performance may suffer") # os variant warning
|
||||||
|
|
|
@ -1756,6 +1756,7 @@ class ParserCloudInit(VirtCLIParser):
|
||||||
cls.add_arg("ssh-key", "ssh_key")
|
cls.add_arg("ssh-key", "ssh_key")
|
||||||
cls.add_arg("user-data", "user_data")
|
cls.add_arg("user-data", "user_data")
|
||||||
cls.add_arg("meta-data", "meta_data")
|
cls.add_arg("meta-data", "meta_data")
|
||||||
|
cls.add_arg("network-config", "network_config")
|
||||||
|
|
||||||
|
|
||||||
def parse_cloud_init(optstr):
|
def parse_cloud_init(optstr):
|
||||||
|
|
|
@ -20,6 +20,7 @@ class CloudInitData():
|
||||||
ssh_key = None
|
ssh_key = None
|
||||||
user_data = None
|
user_data = None
|
||||||
meta_data = None
|
meta_data = None
|
||||||
|
network_config = None
|
||||||
|
|
||||||
def _generate_password(self):
|
def _generate_password(self):
|
||||||
if not self.generated_root_password:
|
if not self.generated_root_password:
|
||||||
|
@ -91,14 +92,27 @@ def _create_userdata_content(cloudinit_data):
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
def _create_network_config_content(cloudinit_data):
|
||||||
|
content = ""
|
||||||
|
if cloudinit_data.network_config:
|
||||||
|
log.debug("Using network-config content from path=%s",
|
||||||
|
cloudinit_data.network_config)
|
||||||
|
content = open(cloudinit_data.network_config).read()
|
||||||
|
return content
|
||||||
|
|
||||||
|
|
||||||
def create_files(scratchdir, cloudinit_data):
|
def create_files(scratchdir, cloudinit_data):
|
||||||
metadata = _create_metadata_content(cloudinit_data)
|
metadata = _create_metadata_content(cloudinit_data)
|
||||||
userdata = _create_userdata_content(cloudinit_data)
|
userdata = _create_userdata_content(cloudinit_data)
|
||||||
|
|
||||||
|
datas = [(metadata, "meta-data"), (userdata, "user-data")]
|
||||||
|
network_config = _create_network_config_content(cloudinit_data)
|
||||||
|
if network_config:
|
||||||
|
datas.append((network_config, 'network-config'))
|
||||||
|
|
||||||
filepairs = []
|
filepairs = []
|
||||||
try:
|
try:
|
||||||
for content, destfile in [(metadata, "meta-data"),
|
for content, destfile in datas:
|
||||||
(userdata, "user-data")]:
|
|
||||||
fileobj = tempfile.NamedTemporaryFile(
|
fileobj = tempfile.NamedTemporaryFile(
|
||||||
prefix="virtinst-", suffix=("-%s" % destfile),
|
prefix="virtinst-", suffix=("-%s" % destfile),
|
||||||
dir=scratchdir, delete=False)
|
dir=scratchdir, delete=False)
|
||||||
|
|
Loading…
Reference in New Issue