This will be useful for an external entity using RAPI that
wants to modify devices of instances.
The common use case for that is:
"I want to add a NIC/disk to an instance. If it is running
then try to hotplug the device. If not, then just add it to config."
Another use case is that if we are unaware of the instance's
hypervisor: "I want do add a NIC/disk to an instance and if
its hypervisor is KVM try to hotplug it."
For all those cases just print a warning in CheckPrereq() and
disable any further hotplug related actions (and let
modifications take place after reboot).
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
"HID_OS_OPT",
"GLOBAL_SHARED_FILEDIR_OPT",
"HOTPLUG_OPT",
"HID_OS_OPT",
"GLOBAL_SHARED_FILEDIR_OPT",
"HOTPLUG_OPT",
+ "HOTPLUG_IF_POSSIBLE_OPT",
"KEEPDISKS_OPT",
"HVLIST_OPT",
"HVOPTS_OPT",
"KEEPDISKS_OPT",
"HVLIST_OPT",
"HVOPTS_OPT",
action="store_true", default=False,
help="Do not remove disks")
action="store_true", default=False,
help="Do not remove disks")
+HOTPLUG_IF_POSSIBLE_OPT = cli_option("--hotplug-if-possible",
+ dest="hotplug_if_possible",
+ action="store_true", default=False,
+ help="Hotplug devices in case"
+ " hotplug is supported")
+
#: Options provided by all commands
COMMON_OPTS = [DEBUG_OPT, REASON_OPT]
#: Options provided by all commands
COMMON_OPTS = [DEBUG_OPT, REASON_OPT]
nics=nics,
disks=disks,
hotplug=opts.hotplug,
nics=nics,
disks=disks,
hotplug=opts.hotplug,
+ hotplug_if_possible=opts.hotplug_if_possible,
keep_disks=opts.keep_disks,
disk_template=opts.disk_template,
remote_node=opts.node,
keep_disks=opts.keep_disks,
disk_template=opts.disk_template,
remote_node=opts.node,
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,
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,
- NOCONFLICTSCHECK_OPT, NEW_PRIMARY_OPT, HOTPLUG_OPT, KEEPDISKS_OPT],
+ NOCONFLICTSCHECK_OPT, NEW_PRIMARY_OPT, HOTPLUG_OPT, KEEPDISKS_OPT,
+ HOTPLUG_IF_POSSIBLE_OPT],
"<instance>", "Alters the parameters of an instance"),
"shutdown": (
GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()],
"<instance>", "Alters the parameters of an instance"),
"shutdown": (
GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()],
# dictionary with instance information after the modification
ispec = {}
# dictionary with instance information after the modification
ispec = {}
+ if self.op.hotplug or self.op.hotplug_if_possible:
result = self.rpc.call_hotplug_supported(self.instance.primary_node,
self.instance)
result = self.rpc.call_hotplug_supported(self.instance.primary_node,
self.instance)
- # result.Raise("Hotplug is not supported.")
- self.LogWarning(result.fail_msg)
- self.op.hotplug = False
- self.LogInfo("Continuing execution..")
+ if self.op.hotplug:
+ result.Raise("Hotplug is not possible: %s" % result.fail_msg,
+ prereq=True)
+ else:
+ self.LogWarning(result.fail_msg)
+ self.op.hotplug = False
+ self.LogInfo("Modification will take place without hotplugging.")
+ else:
+ self.op.hotplug = True
# Check disk modifications. This is done here and not in CheckArguments
# (as with NICs), because we need to know the instance's disk template
# Check disk modifications. This is done here and not in CheckArguments
# (as with NICs), because we need to know the instance's disk template
"""
try:
output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
"""
try:
output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
- except errors.HypervisorError, err:
- raise errors.HotplugError("Cannot hotplug on a stopped VM.")
+ except errors.HypervisorError:
+ raise errors.HotplugError("Instance is probably down")
# TODO: search for netdev_add, drive_add, device_add.....
match = self._INFO_VERSION_RE.search(output.stdout)
if not match:
# TODO: search for netdev_add, drive_add, device_add.....
match = self._INFO_VERSION_RE.search(output.stdout)
if not match:
- raise errors.HotplugError("Cannot parse qemu version via monitor.")
+ raise errors.HotplugError("Cannot parse qemu version via monitor")
+
v_major, v_min, _, _ = match.groups()
if (int(v_major), int(v_min)) < (1, 0):
raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0")
v_major, v_min, _, _ = match.groups()
if (int(v_major), int(v_min)) < (1, 0):
raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0")
| [\--submit]
| [\--ignore-ipolicy]
| [\--hotplug]
| [\--submit]
| [\--ignore-ipolicy]
| [\--hotplug]
+| [\--hotplug-if-possible]
| {*instance*}
Modifies the memory size, number of vcpus, ip address, MAC address
| {*instance*}
Modifies the memory size, number of vcpus, ip address, MAC address
is currently supported only for KVM hypervisor and for versions greater
than 1.0.
is currently supported only for KVM hypervisor and for versions greater
than 1.0.
+If ``--hotplug-if-possible`` is given then ganeti won't abort in case
+hotplug is not supported. It will continue execution and modification
+will take place after reboot. This covers use cases where instances are
+not running or hypervisor is not KVM.
+
See **ganeti**\(7) for a description of ``--submit`` and other common
options.
See **ganeti**\(7) for a description of ``--submit`` and other common
options.
, pOffline
, pIpConflictsCheck
, pHotplug
, pOffline
, pIpConflictsCheck
, pHotplug
, pKeepDisks
])
, ("OpInstanceGrowDisk",
, pKeepDisks
])
, ("OpInstanceGrowDisk",
, pDiskState
, pIgnoreIpolicy
, pHotplug
, pDiskState
, pIgnoreIpolicy
, pHotplug
, pKeepDisks
, pAllowRuntimeChgs
, pInstDisks
, pKeepDisks
, pAllowRuntimeChgs
, pInstDisks
pHotplug :: Field
pHotplug = defaultFalse "hotplug"
pHotplug :: Field
pHotplug = defaultFalse "hotplug"
+pHotplugIfPossible :: Field
+pHotplugIfPossible = defaultFalse "hotplug_if_possible"
+
-- | Whether to remove disks.
pKeepDisks :: Field
pKeepDisks = defaultFalse "keep_disks"
-- | Whether to remove disks.
pKeepDisks :: Field
pKeepDisks = defaultFalse "keep_disks"