[virt-tools-list] [PATCH virt-manager 05/14] cli: Add check if device boot order is supported
Marc Hartmayer
mhartmay at linux.ibm.com
Tue Feb 26 09:56:35 UTC 2019
Add a check if device boot order is supported to
Parser(Network|Disk|Redirdev|...) and throw an exception if not.
Signed-off-by: Marc Hartmayer <mhartmay at linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
virtinst/cli.py | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/virtinst/cli.py b/virtinst/cli.py
index d50a0391ae73..e483905524b4 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -20,6 +20,7 @@ import types
import libvirt
+from virtinst import support
from virtcli import CLIConfig
from . import util, xmlapi
@@ -2204,6 +2205,18 @@ def _add_device_address_args(cls):
cls.add_arg("address.base", "address.base")
+def _add_device_boot_order_arg(cls):
+ def set_boot_order_cb(self, inst, val, virtarg):
+ val = int(val)
+ guest = self.guest
+ if not guest.conn.check_support(support.SUPPORT_CONN_DEVICE_BOOT_ORDER):
+ raise NotImplementedError('Device boot order isn\'t supported by the connection')
+
+ inst.boot.order = val
+ cls.set_boot_order_cb = set_boot_order_cb
+ cls.add_arg("boot.order", "boot_order", cb=cls.set_boot_order_cb)
+
+
##################
# --disk parsing #
##################
@@ -2373,7 +2386,7 @@ class ParserDisk(VirtCLIParser):
cls.add_arg("startup_policy", "startup_policy")
cls.add_arg("read_only", "readonly", is_onoff=True)
cls.add_arg("shareable", "shareable", is_onoff=True)
- cls.add_arg("boot.order", "boot_order")
+ _add_device_boot_order_arg(cls)
cls.add_arg("iotune_rbs", "read_bytes_sec")
cls.add_arg("iotune_wbs", "write_bytes_sec")
@@ -2469,7 +2482,7 @@ class ParserNetwork(VirtCLIParser):
cls.add_arg("model", "model")
cls.add_arg("macaddr", "mac", cb=cls.set_mac_cb)
cls.add_arg("filterref", "filterref")
- cls.add_arg("boot.order", "boot_order")
+ _add_device_boot_order_arg(cls)
cls.add_arg("link_state", "link_state",
cb=cls.set_link_state)
@@ -2687,7 +2700,7 @@ class ParserRedir(VirtCLIParser):
_add_device_address_args(cls)
cls.add_arg("bus", "bus", ignore_default=True)
cls.add_arg("type", "type", ignore_default=True)
- cls.add_arg("boot.order", "boot_order")
+ _add_device_boot_order_arg(cls)
cls.add_arg(None, "server", cb=cls.set_server_cb)
@@ -3098,7 +3111,7 @@ class ParserHostdev(VirtCLIParser):
cb=cls.set_name_cb,
lookup_cb=cls.name_lookup_cb)
cls.add_arg("driver_name", "driver_name")
- cls.add_arg("boot.order", "boot_order")
+ _add_device_boot_order_arg(cls)
cls.add_arg("rom_bar", "rom_bar", is_onoff=True)
--
2.17.0
More information about the virt-tools-list
mailing list