Commit 0af0f641 authored by Iustin Pop's avatar Iustin Pop
Browse files

Reuse NIC information from export



If the user doesn't pass any nics in import, do not use a default
one-nic, but instead read the nics from the export file as is.

Fortunately the export and the way nics are read from the command line
are compatible…
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent cc0d88e9
......@@ -1536,9 +1536,12 @@ def GenericInstanceCreate(mode, opts, args):
elif opts.no_nics:
# no nics
nics = []
else:
elif mode == constants.INSTANCE_CREATE:
# default of one nic, all auto
nics = [{}]
else:
# mode == import
nics = []
if opts.disk_template == constants.DT_DISKLESS:
if opts.disks or opts.sd_size is not None:
......
......@@ -6278,6 +6278,17 @@ class LUCreateInstance(LogicalUnit):
" is missing the disk information",
errors.ECODE_INVAL)
if (not self.op.nics and
einfo.has_option(constants.INISECT_INS, "nic_count")):
nics = []
for idx in range(einfo.getint(constants.INISECT_INS, "nic_count")):
ndict = {}
for name in list(constants.NICS_PARAMETERS) + ["ip", "mac"]:
v = einfo.get(constants.INISECT_INS, "nic%d_%s" % (idx, name))
ndict[name] = v
nics.append(ndict)
self.op.nics = nics
if (self.op.hypervisor is None and
einfo.has_option(constants.INISECT_INS, "hypervisor")):
self.op.hypervisor = einfo.get(constants.INISECT_INS, "hypervisor")
......
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