[pve-devel] [RFC PATCH common] schema extension: grouped keys

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Mar 23 11:51:08 CET 2016


The name is open for discussion I guess ;-)
See the commit message for a detailed description.

This is a slightly more convenient alternative to simple 'conflicts'.
With 'conflicts' the user of a property string needs to figure out
which keys have been used, which in the use case for which this patch
was meant is rather inconvenient and slow.
The advantage for one is that after doing parse_property_string() you
also get a key/value pair telling you which key was used.
The commit message in the patch has a detailed description about how
that works.

In the end this allows us to exactly represent what qemu-server's
parse_net() function currently does, which is to parse 'virtio=xyz'
into:
{
    model => 'virtio',
    macaddr => 'xyz'
}

And print_property_string will turn it back into 'virtio=xyz'.

Another advantage is that this means we could have a 'modify' command
where you can modify 'model' and 'macaddr' individually. Ie change
from virtio to e1000 without having to type in the mac address (eg.
`qm set 100 -modify -net0 model=e1000`... but this has other problems
that need to be solved first anyway.)

Additionally we should think about whether we want to be able to sort
keys. Currently qemu-server's print_net() always puts the mode=key
part first, while print_proprty_string() sorts alphabetically by key.
We could introduce a 'sort_order' or 'print_order' key which would
default to 0 and be the first sorting criteria (after which it's
alphabetically again).

Wolfgang Bumiller (1):
  property strings: introduce key grouping feature

 src/PVE/JSONSchema.pm | 59 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 54 insertions(+), 5 deletions(-)

-- 
2.1.4





More information about the pve-devel mailing list