nic_ip = ip
- # TODO: check the ip address for uniqueness
- if nic_mode == constants.NIC_MODE_ROUTED and not nic_ip:
- raise errors.OpPrereqError("Routed nic mode requires an ip address",
- errors.ECODE_INVAL)
-
# MAC address verification
mac = nic.get(constants.INIC_MAC, constants.VALUE_AUTO)
if mac not in (constants.VALUE_AUTO, constants.VALUE_GENERATE):
nics=NICListToTuple(self, self.nics),
disk_template=self.op.disk_template,
disks=[(d[constants.IDISK_NAME], d.get("uuid", ""),
- d[constants.IDISK_SIZE], d[constants.IDISK_MODE])
+ d[constants.IDISK_SIZE], d[constants.IDISK_MODE], {})
for d in self.disks],
bep=self.be_full,
hvp=self.hv_full,
elif new_mode == constants.NIC_MODE_ROUTED:
ip = params.get(constants.INIC_IP, old_ip)
- if ip is None:
- raise errors.OpPrereqError("Cannot set the NIC IP address to None"
- " on a routed NIC", errors.ECODE_INVAL)
elif new_mode == constants.NIC_MODE_OVS:
# TODO: check OVS link
self.op.disk_template))
raise errors.OpPrereqError(errmsg, errors.ECODE_STATE)
+ # too many local variables
+ # pylint: disable=R0914
def CheckPrereq(self):
"""Check prerequisites.
constants.DT_EXT),
errors.ECODE_INVAL)
- if self.op.hotplug:
+ if self.op.hotplug or self.op.hotplug_if_possible:
result = self.rpc.call_hotplug_supported(self.instance.primary_node,
self.instance)
- result.Raise("Hotplug is not supported.")
+ if result.fail_msg:
+ 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
# OS change
if self.op.os_name and not self.op.force:
(anno_disk,) = AnnotateDiskParams(self.instance, [root], self.cfg)
for node, disk in anno_disk.ComputeNodeTree(self.instance.primary_node):
+ if self.op.keep_disks and disk.dev_type in constants.DT_EXT:
+ continue
self.cfg.SetDiskID(disk, node)
msg = self.rpc.call_blockdev_remove(node, disk).fail_msg
if msg: