Commit e8448672 authored by Agata Murawska's avatar Agata Murawska Committed by Michael Hanselmann
Browse files

Allow importing instance with full auto parameters


Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 45fe090b
......@@ -8538,7 +8538,8 @@ class LUInstanceCreate(LogicalUnit):
raise errors.OpPrereqError("Cluster does not support lvm-based"
" instances", errors.ECODE_STATE)
if self.op.hypervisor is None:
if (self.op.hypervisor is None or
self.op.hypervisor.lower() == constants.VALUE_AUTO):
self.op.hypervisor = self.cfg.GetHypervisorType()
cluster = self.cfg.GetClusterInfo()
......@@ -8564,6 +8565,10 @@ class LUInstanceCreate(LogicalUnit):
_CheckGlobalHvParams(self.op.hvparams)
# fill and remember the beparams dict
default_beparams = cluster.beparams[constants.PP_DEFAULT]
for param, value in self.op.beparams.iteritems():
if value.lower() == constants.VALUE_AUTO:
self.op.beparams[param] = default_beparams[param]
utils.ForceDictType(self.op.beparams, constants.BES_PARAMETER_TYPES)
self.be_full = cluster.SimpleFillBE(self.op.beparams)
......@@ -8580,7 +8585,7 @@ class LUInstanceCreate(LogicalUnit):
for idx, nic in enumerate(self.op.nics):
nic_mode_req = nic.get(constants.INIC_MODE, None)
nic_mode = nic_mode_req
if nic_mode is None:
if nic_mode is None or nic_mode.lower() == constants.VALUE_AUTO:
nic_mode = cluster.nicparams[constants.PP_DEFAULT][constants.NIC_MODE]
# in routed mode, for the first nic, the default ip is 'auto'
......@@ -8624,9 +8629,11 @@ class LUInstanceCreate(LogicalUnit):
# Build nic parameters
link = nic.get(constants.INIC_LINK, None)
if link.lower() == constants.VALUE_AUTO:
link = cluster.nicparams[constants.PP_DEFAULT][constants.NIC_LINK]
nicparams = {}
if nic_mode_req:
nicparams[constants.NIC_MODE] = nic_mode_req
nicparams[constants.NIC_MODE] = nic_mode
if link:
nicparams[constants.NIC_LINK] = link
......
......@@ -401,7 +401,8 @@ class NIC(ConfigObject):
@raise errors.ConfigurationError: when a parameter is not valid
"""
if nicparams[constants.NIC_MODE] not in constants.NIC_VALID_MODES:
if (nicparams[constants.NIC_MODE] not in constants.NIC_VALID_MODES and
nicparams[constants.NIC_MODE] != constants.VALUE_AUTO):
err = "Invalid nic mode: %s" % nicparams[constants.NIC_MODE]
raise errors.ConfigurationError(err)
......
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