mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-11 05:17:59 +03:00
cloudinit: Add cli option root-password-file=/path/to/file
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
This commit is contained in:
parent
66d95c6792
commit
050d4dd62a
@ -875,7 +875,8 @@ 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") # default --cloud-init behavior is root-password=generate,disable=yes
|
||||
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password=generate,disable=no", "cloud-init-options") # --cloud-init options
|
||||
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password=a1b2c3d4,disable=no", "cloud-init-options") #--cloud-init-options
|
||||
c.add_compare("--disk %(EXISTIMG1)s --os-variant fedora28 --cloud-init root-password=a1b2c3d4,disable=no", "cloud-init-options") # --cloud-init-options
|
||||
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-options
|
||||
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("--nodisks --pxe", grep="VM performance may suffer") # os variant warning
|
||||
|
@ -1627,6 +1627,7 @@ class ParserCloudInit(VirtCLIParser):
|
||||
def _init_class(cls, **kwargs):
|
||||
VirtCLIParser._init_class(**kwargs)
|
||||
cls.add_arg("root-password", "root_password")
|
||||
cls.add_arg("root-password-file", "root_password_file")
|
||||
cls.add_arg("disable", "disable", is_onoff=True)
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@ from ..logger import log
|
||||
class CloudInitData():
|
||||
disable = None
|
||||
root_password = None
|
||||
root_password_file = None
|
||||
generated_root_password = None
|
||||
|
||||
def generate_password(self):
|
||||
@ -15,9 +16,15 @@ class CloudInitData():
|
||||
self.generated_root_password += random.choice(string.ascii_letters + string.digits)
|
||||
return self.generated_root_password
|
||||
|
||||
def _get_password(self, pwdfile):
|
||||
with open(pwdfile, "r") as fobj:
|
||||
return fobj.readline().rstrip("\n\r")
|
||||
|
||||
def get_root_password(self):
|
||||
if self.root_password == "generate":
|
||||
return self.generate_password()
|
||||
elif self.root_password_file:
|
||||
return self._get_password(self.root_password_file)
|
||||
else:
|
||||
return self.root_password
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user