diff --git a/lib/cli.py b/lib/cli.py index feb0fe41a0e6cd0e9088381824112dbd45ba2f61..e4c6a803f264425525132bc92112778cdce3a0e5 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -89,6 +89,7 @@ __all__ = [ "GLOBAL_FILEDIR_OPT", "HID_OS_OPT", "GLOBAL_SHARED_FILEDIR_OPT", + "HOTPLUG_OPT", "HVLIST_OPT", "HVOPTS_OPT", "HYPERVISOR_OPT", @@ -1431,6 +1432,10 @@ ABSOLUTE_OPT = cli_option("--absolute", dest="absolute", help="Marks the grow as absolute instead of the" " (default) relative mode") +HOTPLUG_OPT = cli_option("--hotplug", dest="hotplug", + action="store_true", default=False, + help="Enable disk/nic hotplug") + #: Options provided by all commands COMMON_OPTS = [DEBUG_OPT] @@ -2390,6 +2395,11 @@ def GenericInstanceCreate(mode, opts, args): else: raise errors.ProgrammerError("Invalid creation mode %s" % mode) + if opts.hotplug: + hotplug = True + else: + hotplug = False + op = opcodes.OpInstanceCreate(instance_name=instance, disks=disks, disk_template=opts.disk_template, @@ -2412,6 +2422,7 @@ def GenericInstanceCreate(mode, opts, args): src_node=src_node, src_path=src_path, tags=tags, + hotplug=hotplug, no_install=no_install, identify_defaults=identify_defaults, ignore_ipolicy=opts.ignore_ipolicy) diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index c59817b5d049cfbd97dbf831d02c8d36a738cf0f..f394a911044353ce35c5194e9859af79c9edea26 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -1403,9 +1403,15 @@ def SetInstanceParams(opts, args): else: offline = None + if opts.hotplug: + hotplug = True + else: + hotplug = False + op = opcodes.OpInstanceSetParams(instance_name=args[0], nics=nics, disks=disks, + hotplug=hotplug, disk_template=opts.disk_template, remote_node=opts.node, hvparams=opts.hvparams, @@ -1517,6 +1523,7 @@ add_opts = [ FORCE_VARIANT_OPT, NO_INSTALL_OPT, IGNORE_IPOLICY_OPT, + HOTPLUG_OPT, ] commands = { @@ -1603,7 +1610,7 @@ commands = { [BACKEND_OPT, DISK_OPT, FORCE_OPT, HVOPTS_OPT, NET_OPT, SUBMIT_OPT, DISK_TEMPLATE_OPT, SINGLE_NODE_OPT, OS_OPT, FORCE_VARIANT_OPT, OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT, NWSYNC_OPT, OFFLINE_INST_OPT, - ONLINE_INST_OPT, IGNORE_IPOLICY_OPT, RUNTIME_MEM_OPT], + ONLINE_INST_OPT, IGNORE_IPOLICY_OPT, RUNTIME_MEM_OPT, HOTPLUG_OPT], "<instance>", "Alters the parameters of an instance"), "shutdown": ( GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()], diff --git a/lib/opcodes.py b/lib/opcodes.py index aa7cce1e0ade0abcec689d9070d4e53eeb284baa..8a1c41098501054de2307638b67e48df0b315541 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -1222,6 +1222,7 @@ class OpInstanceCreate(OpCode): ("src_path", None, ht.TMaybeString, "Source directory for import"), ("start", True, ht.TBool, "Whether to start instance after creation"), ("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), "Instance tags"), + ("hotplug", None, ht.TMaybeBool, "Whether to hotplug devices"), ] OP_RESULT = ht.Comment("instance nodes")(ht.TListOf(ht.TNonEmptyString)) @@ -1525,6 +1526,7 @@ class OpInstanceSetParams(OpCode): ("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize, when changing template"), ("offline", None, ht.TMaybeBool, "Whether to mark instance as offline"), + ("hotplug", None, ht.TMaybeBool, "Whether to hotplug devices"), ] OP_RESULT = _TSetParamsResult