diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 52744bd9ecdbfce2add040e491d5cdc7502208a4..cceb7d7563bf6d36cf2674fc321c7d99b31d3147 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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: