summaryrefslogtreecommitdiff
path: root/virt-install
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2019-06-11 11:54:02 -0400
committerCole Robinson <crobinso@redhat.com>2019-06-11 17:55:05 -0400
commitb3e6ebe28b3b76f49f9c4a7d6700f14b284f5591 (patch)
tree9a0285df744e116b8d3167f7f0c47c44d24d6754 /virt-install
parent078348fbbf1847dce6dab5a6331175b7cb5fd552 (diff)
downloadvirt-manager-b3e6ebe28b3b76f49f9c4a7d6700f14b284f5591.tar.gz
virt-install: Generate default --name
This uses the same logic as virt-manager. The name is mostly derived from --os-variant naming, but we have fallback defaults too. Print the name to stdout so users are informed about what we are doing.
Diffstat (limited to 'virt-install')
-rwxr-xr-xvirt-install13
1 files changed, 8 insertions, 5 deletions
diff --git a/virt-install b/virt-install
index bb1c06e9..346577af 100755
--- a/virt-install
+++ b/virt-install
@@ -321,9 +321,6 @@ def validate_required_options(options, guest, installer):
# aggregate the errors to help first time users get it right
msg = ""
- if not guest.name:
- msg += "\n" + _("--name is required")
-
if not memory_specified(guest):
msg += "\n" + _("--memory amount in MiB is required")
@@ -525,7 +522,13 @@ def build_installer(options, guest):
return installer
-def set_resources_from_osinfo(options, guest):
+def set_cli_defaults(options, guest):
+ if not guest.name:
+ default_name = virtinst.Guest.generate_name(guest)
+ cli.print_stdout(_("Using default --name {vm_name}").format(
+ vm_name=default_name))
+ guest.name = default_name
+
if guest.os.is_container():
return
@@ -580,7 +583,7 @@ def build_guest_instance(conn, options):
# we are operating on any arch/os/type values passed in with --boot
guest.set_capabilities_defaults()
installer = build_installer(options, guest)
- set_resources_from_osinfo(options, guest)
+ set_cli_defaults(options, guest)
if installer:
installer.set_install_defaults(guest)