+ # Add data disks if they are provided
+ if disk_list:
+ data_disks = []
+ for lun_name, disk in enumerate(disk_list):
+ self.logger.debug("add disk size: %s, image: %s", disk.get("size"), disk.get("image_id"))
+ if not disk.get("image_id"):
+ data_disks.append({
+ 'lun': lun_name, # You choose the value, depending of what is available for you
+ 'name': vm_name + "_data_disk-" + str(lun_name),
+ 'create_option': DiskCreateOption.empty,
+ 'disk_size_gb': disk.get("size")
+ })
+ else:
+ # self.logger.debug("currently not able to create data disks from image for azure, ignoring")
+ data_disks.append({
+ 'lun': lun_name, # You choose the value, depending of what is available for you
+ 'name': vm_name + "_data_disk-" + str(lun_name),
+ 'create_option': 'Attach',
+ 'disk_size_gb': disk.get("size"),
+ 'managed_disk': {
+ 'id': disk.get("image_id")
+ }
+ })
+
+ if data_disks:
+ vm_parameters["storage_profile"]["data_disks"] = data_disks
+
+ # If the machine has several networks one must be marked as primary
+ # As it is not indicated in the interface the first interface will be marked as primary
+ if len(vm_nics) > 1:
+ for idx, vm_nic in enumerate(vm_nics):
+ if idx == 0:
+ vm_nics[0]['Primary'] = True
+ else:
+ vm_nics[idx]['Primary'] = False
+
+ vm_parameters['network_profile'] = {'network_interfaces': vm_nics}
+
+ self.logger.debug("create vm name: %s", vm_name)