virt-install: Rename --cloud-init ssh-key -> root-ssh-key

Originally we thought it would be for the clouduser, but then
we changed it, and now it's ambiguous. Rename it to make the
usage clear, and add an alias to keep any users working

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson
2022-03-01 14:29:46 -05:00
parent 906604c972
commit c8afd1f51e
5 changed files with 17 additions and 10 deletions
+2 -2
View File
@@ -894,9 +894,9 @@ Sub options are:
Specify a cloud-init user-data file to add directly to the iso. All other
user-data configuration options on the --cloud-init command line are ignored.
``ssh-key=``
``root-ssh-key=``
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
root account. Example: root-ssh-key=/home/user/.ssh/id_rsa.pub
``network-config=``
Specify a cloud-init network-config file to add directly to the iso.
@@ -3,6 +3,10 @@ chpasswd:
list: |
root:[SCRUBBLED]
expire: False
users:
- name: root
ssh-authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAuibybX5lw2G/LPIyqgQS5KwgbOnKMA9TZyQPtRmIfKSGypdMJmGQ+Gsf54A9VI8zoL2fnq2t66zQIPJU53XveXU0oqCm7PfsEcoYjnqDeUeiqvCfTye8bIbEmIkLriH0SaISNnzyN0JSfb0VDYIg8Za6iW3/PfPs+tV0PSYyVEm3pBNJ9bHat2liA1/Afk0UWNrhCQG9/5v9kR36aIxNU+4qI9cZ2npFWt61/7t2otz2GcygJDCUYEp6wDlmoW6DHXnaUUj1USjZ9uI1IrgmjZYxfjlt/UaB7AJOJP/3bOC1iPXBe9HKt30YUG23KaVfK9DDeGD/tlAeIklaYK8RZd4zUXSm3eZjeZCGiC3XFYIIyf7e7M/IZE+/DbD1jQEGxGd7AmdVBJZPBFtkAd4Blypaidykx7n1UcfF0WWISfFsae956PHnqnSBKM5OUDh2y5LowgXjWmr/BVJmnaiNbeMhgC3axZVL3EmFSVtvwnup+sRmDwYoHh/RbmInyns=
<domain type="test">
<name>fedora28</name>
+1 -1
View File
@@ -1013,7 +1013,7 @@ c.add_compare("--connect %s --os-variant fedora26" % (utils.URIs.test_suite), "o
c.add_compare("--connect %s --os-variant fedora26 --pxe --print-xml" % (utils.URIs.test_suite), "osvariant-defaults-pxe", use_default_args=False) # No arguments
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init", "cloud-init-default", env={"VIRTINST_TEST_SUITE_CLOUDINIT": "1"}) # default --cloud-init behavior is root-password-generate=yes,disable=yes
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password-generate=yes,disable=no --sysinfo system.serial=foobar", "cloud-init-options1", env={"VIRTINST_TEST_SUITE_PRINT_CLOUDINIT": "1"}) # --cloud-init root-password-generate, with --sysinfo override
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password-file=%(ADMIN-PASSWORD-FILE)s,disable=no --boot smbios.mode=none", "cloud-init-options2", env={"VIRTINST_TEST_SUITE_PRINT_CLOUDINIT": "1"}) # --cloud-init root-password-file with smbios.mode override
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password-file=%(ADMIN-PASSWORD-FILE)s,root-ssh-key=%(XMLDIR)s/cloudinit/ssh-key.txt --boot smbios.mode=none", "cloud-init-options2", env={"VIRTINST_TEST_SUITE_PRINT_CLOUDINIT": "1"}) # --cloud-init root-password-file with smbios.mode override
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init ssh-key=%(XMLDIR)s/cloudinit/ssh-key.txt", "cloud-init-options3", env={"VIRTINST_TEST_SUITE_PRINT_CLOUDINIT": "1"}) # --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-options4", env={"VIRTINST_TEST_SUITE_PRINT_CLOUDINIT": "1"}) # --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-options5", env={"VIRTINST_TEST_SUITE_PRINT_CLOUDINIT": "1"}) # --cloud-init user-data=,meta-data=,network-config=
+4 -1
View File
@@ -1762,6 +1762,9 @@ def parse_install(optstr):
class ParserCloudInit(VirtCLIParser):
cli_arg_name = "cloud_init"
supports_clearxml = False
aliases = {
"root-ssh-key": "ssh-key",
}
@classmethod
def _virtcli_class_init(cls):
@@ -1769,7 +1772,7 @@ class ParserCloudInit(VirtCLIParser):
cls.add_arg("root-password-generate", "root_password_generate", is_onoff=True)
cls.add_arg("root-password-file", "root_password_file")
cls.add_arg("disable", "disable", is_onoff=True)
cls.add_arg("ssh-key", "ssh_key")
cls.add_arg("root-ssh-key", "root_ssh_key")
cls.add_arg("user-data", "user_data")
cls.add_arg("meta-data", "meta_data")
cls.add_arg("network-config", "network_config")
+6 -6
View File
@@ -17,7 +17,7 @@ class CloudInitData():
root_password_generate = None
root_password_file = None
generated_root_password = None
ssh_key = None
root_ssh_key = None
user_data = None
meta_data = None
network_config = None
@@ -43,9 +43,9 @@ class CloudInitData():
return self._get_password(self.root_password_file)
return self.get_password_if_generated()
def get_ssh_key(self):
if self.ssh_key:
return self._get_password(self.ssh_key)
def get_root_ssh_key(self):
if self.root_ssh_key:
return self._get_password(self.root_ssh_key)
def _create_metadata_content(cloudinit_data):
@@ -76,8 +76,8 @@ def _create_userdata_content(cloudinit_data):
elif cloudinit_data.root_password_file:
content += " expire: False\n"
if cloudinit_data.ssh_key:
rootpass = cloudinit_data.get_ssh_key()
if cloudinit_data.root_ssh_key:
rootpass = cloudinit_data.get_root_ssh_key()
content += "users:\n"
content += " - name: root\n"
content += " ssh-authorized-keys:\n"