from .interface import TerraformInterface
-__version__ = '1.7.0'
+__version__ = '1.7.1'
LOG = logging.getLogger(__name__)
max_disks = TerraformDisk.max_scsi_disks
+ LOG.debug(_("Evaluating disk data of VM {!r} ...").format(vm.name))
+
if cls.re_key_root_disk.search(key):
if isinstance(value, Mapping):
for (p_key, p_val) in value.items():
return True
if cls.re_key_data_disk.search(key):
- unit_number = cls._get_disk_unit(1)
+ unit_number = vm._get_disk_unit(1)
if isinstance(value, Mapping):
vm._add_data_disk(value, 'disk1', unit_number)
elif value is None:
if total_disks > max_disks:
raise TerraformVmTooManyDisksError(total_disks, max_disks)
- # unit_number = cls._get_disk_unit(current_disk)
+ # unit_number = vm._get_disk_unit(current_disk)
- name = "disk{}".format(current_disk)
for disk_data in value:
- unit_number = cls._get_disk_unit(current_disk)
+ name = "disk{}".format(current_disk)
+ unit_number = vm._get_disk_unit(current_disk)
vm._add_data_disk(disk_data, name, unit_number)
current_disk += 1
elif value is None:
LOG.error(_("Could not evaluate data disks from {!r}.").format(value))
return True
+ LOG.debug(_("The VM {vm!r} has {nrd} disks and {nrc} SCSI controllers.").format(
+ vm=vm.name, nrd=len(vm.disks), nrc=vm.disks.get_ctrlr_count()))
+
return False
# -------------------------------------------------------------------------
disk = TerraformDisk(**params)
disk.initialized = True
if self.verbose > 2:
- LOG.debug(_("Got data disk:") + "\n" + pp(disk.as_dict()))
+ LOG.debug(_("Got data disk {!r}:").format(name) + "\n" + pp(disk.as_dict()))
self.disks[name] = disk
# -------------------------------------------------------------------------
- @classmethod
- def _get_disk_unit(cls, current_disk=0):
+ def _get_disk_unit(self, current_disk_nr=0):
"""Tries to evaluate the disk_unit my the current number in the list."""
disks_per_ctrlr = TerraformDisk.disks_per_scsi_ctrlr
max_scsi_ctrlrs = TerraformDisk.max_scsi_ctrlrs
max_disks = TerraformDisk.max_scsi_disks
- if current_disk >= max_disks:
- raise TerraformVmTooManyDisksError(current_disk + 1, max_disks)
+ if self.verbose > 2:
+ LOG.debug(_("Trying to get unit_id of disk number {}.").format(current_disk_nr))
+
+ if current_disk_nr >= max_disks:
+ raise TerraformVmTooManyDisksError(current_disk_nr + 1, max_disks)
- ctrlr_id = current_disk % max_scsi_ctrlrs
- id_offset = current_disk // max_scsi_ctrlrs
+ ctrlr_id = current_disk_nr % max_scsi_ctrlrs
+ id_offset = current_disk_nr // max_scsi_ctrlrs
unit_id = ctrlr_id * disks_per_ctrlr + id_offset
+ if self.verbose > 1:
+ LOG.debug(_("Got unit_id {id} for disk number {nr} (controller ID {cid}).").format(
+ id=unit_id, nr=current_disk_nr, cid=ctrlr_id))
+
return unit_id