diff options
author | Cole Robinson <crobinso@redhat.com> | 2018-03-20 17:23:34 -0400 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2018-03-21 11:17:36 -0400 |
commit | 7b61c45d3b5b6c6cf1207fca79a1b07566d1b06d (patch) | |
tree | a1a0baff6535c135265a4242fd45dc84b82fe6c1 /virt-xml | |
parent | fe9ed2340cd5b62c2c212bbe269064e91b345643 (diff) | |
download | virt-manager-7b61c45d3b5b6c6cf1207fca79a1b07566d1b06d.tar.gz |
guest: Move all_devices to guest.devices.X
The way we enumerate devices doesn't conform with the way all
other XMLBuilder instances expose child objects. Move more towards
that direction.
This requires some virt-xml and cli.py hacks but we will remove those
in future patches
Diffstat (limited to 'virt-xml')
-rwxr-xr-x | virt-xml | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -92,7 +92,10 @@ def get_domain_and_guest(conn, domstr): ################ def _find_objects_to_edit(guest, action_name, editval, parserclass): - objlist = guest.list_children_for_class(parserclass.objclass) + if issubclass(parserclass.objclass, virtinst.Device): + objlist = guest.devices.list_children_for_class(parserclass.objclass) + else: + objlist = guest.list_children_for_class(parserclass.objclass) idx = None if editval is None: @@ -179,16 +182,22 @@ def action_edit(guest, options, parserclass): return cli.parse_option_strings(options, guest, inst, update=True) +def _is_singleton(guest, objclass): + if not objclass: + return True + if issubclass(objclass, virtinst.devices.Device): + return False + return guest.child_class_is_singleton(objclass) + + def action_add_device(guest, options, parserclass): - if (not parserclass.objclass or - guest.child_class_is_singleton(parserclass.objclass)): + if _is_singleton(guest, parserclass.objclass): fail(_("Cannot use --add-device with --%s") % parserclass.cli_arg_name) return cli.parse_option_strings(options, guest, None) def action_remove_device(guest, options, parserclass): - if (not parserclass.objclass or - guest.child_class_is_singleton(parserclass.objclass)): + if _is_singleton(guest, parserclass.objclass): fail(_("Cannot use --remove-device with --%s") % parserclass.cli_arg_name) |