From 13b3790829cc7f950237d5134ab2dc2c7982cf5d Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 11 Jun 2019 12:15:35 -0400 Subject: [PATCH] virt-install: Print when we set default memory and disk Since we never defaulted here before, print out the values we are setting. Users can see right away if they actually want those values or not. --- .../virt-install-osvariant-defaults-pxe.xml | 116 ++++++++++++++++++ .../virt-install-osvariant-noargs-fail.xml | 6 + tests/clitest.py | 2 + virt-install | 10 +- virtinst/cli.py | 1 + 5 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 tests/cli-test-xml/compare/virt-install-osvariant-defaults-pxe.xml create mode 100644 tests/cli-test-xml/compare/virt-install-osvariant-noargs-fail.xml diff --git a/tests/cli-test-xml/compare/virt-install-osvariant-defaults-pxe.xml b/tests/cli-test-xml/compare/virt-install-osvariant-defaults-pxe.xml new file mode 100644 index 000000000..85c9961f6 --- /dev/null +++ b/tests/cli-test-xml/compare/virt-install-osvariant-defaults-pxe.xml @@ -0,0 +1,116 @@ + + fedora26 + 00000000-1111-2222-3333-444444444444 + + + + + + 2097152 + 2097152 + 2 + + hvm + + + + + + + + + destroy + + + + + + /usr/bin/test-hv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fedora26 + 00000000-1111-2222-3333-444444444444 + + + + + + 2097152 + 2097152 + 2 + + hvm + + + + + + + + + + + + + /usr/bin/test-hv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cli-test-xml/compare/virt-install-osvariant-noargs-fail.xml b/tests/cli-test-xml/compare/virt-install-osvariant-noargs-fail.xml new file mode 100644 index 000000000..961ae4c6e --- /dev/null +++ b/tests/cli-test-xml/compare/virt-install-osvariant-noargs-fail.xml @@ -0,0 +1,6 @@ +Using default --name fedora26 +Using fedora26 default --memory 2048 +Using fedora26 default --disk size=20 +ERROR +An install method must be specified +(--location URL, --cdrom CD/ISO, --pxe, --import, --boot hd|cdrom|...) \ No newline at end of file diff --git a/tests/clitest.py b/tests/clitest.py index 2ecd55e61..b094f7ff0 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -834,6 +834,8 @@ c.add_invalid("--paravirt --import --print-xml 2") # PV Import install, no seco 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_valid("--panic help --disk=? --check=help", grep="path_in_use") # Make sure introspection doesn't blow up c.add_valid("--test-stub-command") # --test-stub-command c.add_valid("--nodisks --pxe", grep="VM performance may suffer") # os variant warning diff --git a/virt-install b/virt-install index 346577af3..0e2d5c9dc 100755 --- a/virt-install +++ b/virt-install @@ -538,17 +538,25 @@ def set_cli_defaults(options, guest): ncpus = res.get_recommended_ncpus(guest.os.arch) if ram and not memory_specified(guest): + mbram = str(ram / (1024 * 1024)).rstrip("0").rstrip(".") + cli.print_stdout( + _("Using {os_name} default --memory {megabytes}").format( + os_name=guest.osinfo.name, megabytes=mbram)) guest.currentMemory = ram // 1024 if ncpus: # We need to do this upfront, so we don't incorrectly set guest.vcpus guest.sync_vcpus_topology() if not guest.vcpus: + # I don't think we need to print anything here as this was never + # a required value. guest.vcpus = ncpus if storage and not storage_specified(options, guest): diskstr = 'size=%d' % (storage // (1024 ** 3)) - logging.debug("Generated default libosinfo '--disk %s'", diskstr) + cli.print_stdout( + _("Using {os_name} default --disk {disk_options}".format( + os_name=guest.osinfo.name, disk_options=diskstr))) options.disk = [diskstr] cli.ParserDisk(diskstr, guest=guest).parse(None) diff --git a/virtinst/cli.py b/virtinst/cli.py index 912fb0674..f4b609816 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -263,6 +263,7 @@ def fail(msg, do_exit=True): def print_stdout(msg, do_force=False): + logging.debug(msg) if do_force or not get_global_state().quiet: print(msg)