Commit 5f23e043 authored by Iustin Pop's avatar Iustin Pop
Browse files

Op/LUCreateInstance support for (no) name checks

This adds a new opcode parameter ‘name_check’ (similar to ip_check) that
is not required to be present (to easy backwards compatibility for

It also adds a CheckArguments to LUCreateInstance and changes the
workflow related to instance IP checks and NIC initialisation based on
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
parent 8b2df5f6
......@@ -5619,6 +5619,19 @@ class LUCreateInstance(LogicalUnit):
"hvparams", "beparams"]
REQ_BGL = False
def CheckArguments(self):
"""Check arguments.
# do not require name_check to ease forward/backward compatibility
# for tools
if not hasattr(self.op, "name_check"):
self.op.name_check = True
if self.op.ip_check and not self.op.name_check:
# TODO: make the ip check more flexible and not depend on the name check
raise errors.OpPrereqError("Cannot do ip checks without a name check",
def _ExpandNode(self, node):
"""Expands and checks one node name.
......@@ -5683,8 +5696,14 @@ class LUCreateInstance(LogicalUnit):
#### instance parameters check
# instance name verification
hostname1 = utils.GetHostInfo(self.op.instance_name)
self.op.instance_name = instance_name =
if self.op.name_check:
hostname1 = utils.GetHostInfo(self.op.instance_name)
self.op.instance_name = instance_name =
# used in CheckPrereq for ip ping check
self.check_ip = hostname1.ip
instance_name = self.op.instance_name
self.check_ip = None
# this is just a preventive check, but someone might still add this
# instance in the meantime, and creation will fail at lock-add time
......@@ -5713,6 +5732,10 @@ class LUCreateInstance(LogicalUnit):
if ip is None or ip.lower() == constants.VALUE_NONE:
nic_ip = None
elif ip.lower() == constants.VALUE_AUTO:
if not self.op.name_check:
raise errors.OpPrereqError("IP address set to auto but name checks"
" have been skipped. Aborting.",
nic_ip = hostname1.ip
if not utils.IsValidIP(ip):
......@@ -5780,9 +5803,6 @@ class LUCreateInstance(LogicalUnit):
self.disks.append({"size": size, "mode": mode})
# used in CheckPrereq for ip ping check
self.check_ip = hostname1.ip
# file storage checks
if (self.op.file_driver and
not self.op.file_driver in constants.FILE_DRIVER):
......@@ -447,7 +447,7 @@ class OpCreateInstance(OpCode):
"pnode", "disk_template", "snode", "mode",
"disks", "nics",
"src_node", "src_path", "start",
"wait_for_sync", "ip_check",
"wait_for_sync", "ip_check", "name_check",
"file_storage_dir", "file_driver",
"hypervisor", "hvparams", "beparams",
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment