mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 07:03:02 -06:00
cli: Add --metadata option
Can take name, description, uuid, and title (new). This deprecates the separate --description and --uuid element, but we won't require it for specifying a name with virt-install/virt-image since that's quite overkill. Allowing --name with this option is mostly for the benefit of virt-xml.
This commit is contained in:
parent
ed25983d14
commit
927a7ef265
@ -58,11 +58,6 @@ Memory to allocate for the guest, in megabytes. Defaults to C</image/devices/mem
|
||||
|
||||
See L<virt-install(1)> 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
|
||||
|
@ -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<http://libvirt.org/formatdomain.html#elementsMetadata>
|
||||
|
||||
=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<http://libvirt.org/formatdomain.html#elementsCPU>
|
||||
|
||||
=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
|
||||
|
25
tests/cli-test-xml/compare/virtxml-edit-simple-metadata.xml
Normal file
25
tests/cli-test-xml/compare/virtxml-edit-simple-metadata.xml
Normal file
@ -0,0 +1,25 @@
|
||||
--- Original XML
|
||||
+++ Altered XML
|
||||
@@ -1,9 +1,9 @@
|
||||
<domain type="test" id="3">
|
||||
- <name>test-many-devices</name>
|
||||
- <uuid>12345678-12f4-1234-1234-123456789012</uuid>
|
||||
- <description>Foo bar baz &
|
||||
- yeah boii < > yeahfoo
|
||||
- </description>
|
||||
+ <name>foo-my-new-name</name>
|
||||
+ <uuid>12345678-12F4-1234-1234-123456789AFA</uuid>
|
||||
+ <description>hey this is my
|
||||
+new
|
||||
+very,very=new desc'</description>
|
||||
<memory unit="KiB">409600</memory>
|
||||
<currentMemory unit="KiB">204800</currentMemory>
|
||||
<memoryBacking>
|
||||
@@ -303,4 +303,5 @@
|
||||
</backend>
|
||||
</rng>
|
||||
</devices>
|
||||
+ <title>This is my,funky=new title</title>
|
||||
</domain>
|
||||
|
||||
Domain 'foo-my-new-name' defined successfully.
|
@ -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")
|
||||
|
12
virt-install
12
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"))
|
||||
|
1
virt-xml
1
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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user