diff --git a/man/virt-image.pod b/man/virt-image.pod index 0e9619942..6ff7c22e1 100644 --- a/man/virt-image.pod +++ b/man/virt-image.pod @@ -58,11 +58,6 @@ Memory to allocate for the guest, in megabytes. Defaults to C for more details. -=item -u UUID, --uuid=UUID - -UUID for the guest; if none is given a random UUID will be generated. If -you specify UUID, you should use a 32-digit hexadecimal number. - =item --vcpus=VCPUS Number of vcpus to configure for your guest. Defaults to diff --git a/man/virt-install.pod b/man/virt-install.pod index 568ba4612..89c273011 100644 --- a/man/virt-install.pod +++ b/man/virt-install.pod @@ -107,12 +107,11 @@ The machine type to emulate. This will typically not need to be specified for Xen or KVM, but is useful for choosing machine types of more exotic architectures. -=item -u UUID, --uuid=UUID +=item --metadata OPT=VAL,[...] -UUID for the guest; if none is given a random UUID will be generated. If you -specify UUID, you should use a 32-digit hexadecimal number. UUID are intended -to be unique across the entire data center, and indeed world. Bear this in -mind if manually specifying a UUID +Specify metadata values for the guest. Possible options include name, uuid, title, and description. This option deprecates -u/--uuid and --description. + +Use --metadata=? to see a list of all available sub options. Complete details at L =item --vcpus=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#][,cpuset=CPUSET] @@ -175,11 +174,6 @@ may cause issues if migrating the guest to a host without an identical CPU. Use --cpu=? to see a list of all available sub options. Complete details at L -=item --description - -Human readable text description of the virtual machine. This will be stored -in the guests XML configuration for access by other applications. - =item --security type=TYPE[,label=LABEL][,relabel=yes|no] Configure domain security driver settings. Type can be either 'static' or diff --git a/tests/cli-test-xml/compare/virtxml-edit-simple-metadata.xml b/tests/cli-test-xml/compare/virtxml-edit-simple-metadata.xml new file mode 100644 index 000000000..99b9cb68c --- /dev/null +++ b/tests/cli-test-xml/compare/virtxml-edit-simple-metadata.xml @@ -0,0 +1,25 @@ +--- Original XML ++++ Altered XML +@@ -1,9 +1,9 @@ + +- test-many-devices +- 12345678-12f4-1234-1234-123456789012 +- Foo bar baz & +- yeah boii < > yeahfoo +- ++ foo-my-new-name ++ 12345678-12F4-1234-1234-123456789AFA ++ hey this is my ++new ++very,very=new desc' + 409600 + 204800 + +@@ -303,4 +303,5 @@ + + + ++ This is my,funky=new title + + +Domain 'foo-my-new-name' defined successfully. \ No newline at end of file diff --git a/tests/clitest.py b/tests/clitest.py index dec25c9a2..8122479a7 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -759,6 +759,9 @@ c.add_invalid("--domain test-many-devices --edit 5 --tpm /dev/tpm") # device ed c.add_compare("--domain test --print-xml --edit --vcpus 7", "virtxml-print-xml") # test --print-xml c = vixml.add_category("simple edit diff", "--domain test-many-devices --edit --print-diff --define") +c.add_compare("""--metadata name=foo-my-new-name,uuid=12345678-12F4-1234-1234-123456789AFA,description="hey this is my +new +very,very=new desc\\\'",title="This is my,funky=new title" """, "virtxml-edit-simple-metadata") c.add_compare("--memory 500,maxmemory=1000,hugepages=off", "virtxml-edit-simple-memory") c.add_compare("--vcpus 10,maxvcpus=20,cores=5,sockets=4,threads=1", "virtxml-edit-simple-vcpus") c.add_compare("--cpu model=pentium2,+x2apic,forbid=pbe", "virtxml-edit-simple-cpu") diff --git a/virt-install b/virt-install index f26c4bdf1..ca78d1ef1 100755 --- a/virt-install +++ b/virt-install @@ -516,10 +516,11 @@ def build_guest_instance(conn, options, parsermap): cli.get_name(guest, options.name) - # Guest configuration if options.uuid: guest.uuid = options.uuid - guest.description = options.description + # This might be difficult to convert into options.metadata + if options.description: + guest.description = options.description # We don't want to auto-parse --disk, but we wanted it for earlier # parameter introspection @@ -882,12 +883,11 @@ def parse_args(): geng = parser.add_argument_group(_("General Options")) geng.add_argument("-n", "--name", help=_("Name of the guest instance")) - geng.add_argument("-u", "--uuid", help=argparse.SUPPRESS) cli.add_memory_option(geng, backcompat=True) cli.vcpu_cli_options(geng) - geng.add_argument("--description", - help=_("Human readable description of the VM to store in " - "the generated XML.")) + cli.add_metadata_option(geng) + geng.add_argument("-u", "--uuid", help=argparse.SUPPRESS) + geng.add_argument("--description", help=argparse.SUPPRESS) cli.add_guest_xml_options(geng) insg = parser.add_argument_group(_("Installation Method Options")) diff --git a/virt-xml b/virt-xml index c694d095e..f75fdfedc 100755 --- a/virt-xml +++ b/virt-xml @@ -197,6 +197,7 @@ def parse_args(): cli.add_disk_option(g) cli.add_net_option(g) cli.add_gfx_option(g) + cli.add_metadata_option(g) cli.add_memory_option(g) cli.vcpu_cli_options(g) cli.add_guest_xml_options(g) diff --git a/virtinst/cli.py b/virtinst/cli.py index f8eeb899a..ecef52966 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -769,6 +769,13 @@ def add_misc_options(grp, prompt=False, replace=False, help=_("Print debugging information")) +def add_metadata_option(grp): + grp.add_argument("--metadata", + help=_("Configure guest metadata. Ex:\n" + "--metadata name=foo,title=\"My pretty title\",uuid=...\n" + "--metadata description=\"My nice long description\"")) + + def add_memory_option(grp, backcompat=False): grp.add_argument("--memory", help=_("Configure guest memory allocation. Ex:\n" @@ -1292,6 +1299,16 @@ class VirtCLIParser(object): raise NotImplementedError() +###################### +# --metadata parsing # +###################### + +class ParserMetadata(VirtCLIParser): + def _init_params(self): + self.set_param("name", "name", can_comma=True) + self.set_param("title", "title", can_comma=True) + self.set_param("uuid", "uuid") + self.set_param("description", "description", can_comma=True) ###################### @@ -2122,6 +2139,7 @@ def build_parser_map(options, skip=None, only=None): parserobj.cli_arg_name, parserclass)) parsermap[parserobj.option_variable_name] = parserobj + register_parser("metadata", ParserMetadata) register_parser("memory", ParserMemory) register_parser("vcpus", ParserVCPU) register_parser("cpu", ParserCPU)