Commit 2a518543 authored by Iustin Pop's avatar Iustin Pop
Browse files

Handle errors better for wrong nic_count in export



This fixes an old 'FIXME' entry.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 06fcbaf1
......@@ -6391,8 +6391,12 @@ class LUCreateInstance(LogicalUnit):
self.src_images = disk_images
old_name = export_info.get(constants.INISECT_INS, 'name')
# FIXME: int() here could throw a ValueError on broken exports
exp_nic_count = int(export_info.get(constants.INISECT_INS, 'nic_count'))
try:
exp_nic_count = export_info.getint(constants.INISECT_INS, 'nic_count')
except (TypeError, ValueError), err:
raise errors.OpPrereqError("Invalid export file, nic_count is not"
" an integer: %s" % str(err),
errors.ECODE_STATE)
if self.op.instance_name == old_name:
for idx, nic in enumerate(self.nics):
if nic.mac == constants.VALUE_AUTO and exp_nic_count >= idx:
......
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