[virt-tools-list] [virt-manager PATCH] cloudinit: Add root-password-generate=yes|no instead of root-password=xxxx
Athina Plaskasoviti
athina.plaskasoviti at gmail.com
Tue Jul 16 12:45:16 UTC 2019
Now --cloud-init defaults to root-password-generate=yes,disable=yes.
Option for plaintext password given through the cli is completely removed.
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti at gmail.com>
---
tests/clitest.py | 5 ++---
virtinst/cli.py | 6 +++---
virtinst/install/cloudinit.py | 6 ++----
3 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/tests/clitest.py b/tests/clitest.py
index 36844573..c3d0297d 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -870,9 +870,8 @@ c = vinst.add_category("misc-install", "--nographics --noautoconsole")
c.add_compare("--connect %s" % (utils.URIs.test_suite), "noargs-fail", use_default_args=False) # No arguments
c.add_compare("--connect %s --os-variant fedora26" % (utils.URIs.test_suite), "osvariant-noargs-fail", use_default_args=False) # No arguments
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", "cloud-init-default") # 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", "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
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 5cbe67db..77d38c69 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1613,7 +1613,7 @@ class ParserCloudInit(VirtCLIParser):
@classmethod
def _init_class(cls, **kwargs):
VirtCLIParser._init_class(**kwargs)
- cls.add_arg("root-password", "root_password")
+ 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)
@@ -1622,8 +1622,8 @@ def parse_cloud_init(optstr):
ret = CloudInitData()
if optstr == 1:
# This means bare --cloud-init, so there's nothing to parse.
- log.warning("Defaulting to --cloud-init root-password=generate,disable=yes")
- ret.root_password = "generate"
+ log.warning("Defaulting to --cloud-init root-password-generate=yes,disable=yes")
+ ret.root_password_generate = True
ret.disable = True
return ret
diff --git a/virtinst/install/cloudinit.py b/virtinst/install/cloudinit.py
index dd43a9e6..9760e8a6 100644
--- a/virtinst/install/cloudinit.py
+++ b/virtinst/install/cloudinit.py
@@ -6,7 +6,7 @@ from ..logger import log
class CloudInitData():
disable = None
- root_password = None
+ root_password_generate = None
root_password_file = None
generated_root_password = None
@@ -21,12 +21,10 @@ class CloudInitData():
return fobj.readline().rstrip("\n\r")
def get_root_password(self):
- if self.root_password == "generate":
+ 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
def create_metadata(scratchdir):
--
2.20.1
More information about the virt-tools-list
mailing list