cloudinit: Add root-password-generate=yes|no instead of root-password=xxxx

Now --cloud-init defaults to root-password-generate=yes,disable=yes.
Option for plaintext password given through the cli is completely removed.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
This commit is contained in:
Athina Plaskasoviti 2019-07-16 15:45:16 +03:00 committed by Cole Robinson
parent 050d4dd62a
commit 7a2c53612f
3 changed files with 7 additions and 10 deletions

View File

@ -873,9 +873,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

View File

@ -1626,7 +1626,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)
@ -1635,8 +1635,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

View File

@ -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):