Commit 66f93869 authored by Manuel Franceschini's avatar Manuel Franceschini
Browse files

backend.FinalizeExport: safely initialize some vars

This patch initializes nic_count and disk_count with 0. This prevents
some reference errors if the snap_disks block device list is empty.

Reviewed-by: ultrotter
parent b4de68a9
......@@ -1215,6 +1215,8 @@ def FinalizeExport(instance, snap_disks):
config.set(constants.INISECT_INS, 'memory', '%d' % instance.memory)
config.set(constants.INISECT_INS, 'vcpus', '%d' % instance.vcpus)
config.set(constants.INISECT_INS, 'disk_template', instance.disk_template)
nic_count = 0
for nic_count, nic in enumerate(instance.nics):
config.set(constants.INISECT_INS, 'nic%d_mac' %
nic_count, '%s' % nic.mac)
......@@ -1223,6 +1225,7 @@ def FinalizeExport(instance, snap_disks):
# TODO: redundant: on load can read nics until it doesn't exist
config.set(constants.INISECT_INS, 'nic_count' , '%d' % nic_count)
disk_count = 0
for disk_count, disk in enumerate(snap_disks):
config.set(constants.INISECT_INS, 'disk%d_ivname' % disk_count,
('%s' % disk.iv_name))
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