def _attach_disks(self, instance, image_meta, vm_ref, name_label, vdis,
                      disk_image_type, network_info, rescue=False,
                      admin_password=None, files=None):
        flavor = instance.get_flavor()

        # Attach (required) root disk
        if disk_image_type == vm_utils.ImageType.DISK_ISO:
            # DISK_ISO needs two VBDs: the ISO disk and a blank RW disk
            root_disk_size = flavor.root_gb
            if root_disk_size > 0:
                vm_utils.generate_iso_blank_root_disk(self._session, instance,
                    vm_ref, DEVICE_ROOT, name_label, root_disk_size)

            cd_vdi = vdis.pop('iso')
            vm_utils.attach_cd(self._session, vm_ref, cd_vdi['ref'],
                               DEVICE_CD)
        else:
            root_vdi = vdis['root']

            auto_disk_config = instance['auto_disk_config']
            # NOTE(tpownall): If rescue mode we need to ensure that we're
            # pulling the auto_disk_config value from the image properties so
            # that we can pull it from the rescue_image_ref.
            if rescue:
                if not image_meta.properties.obj_attr_is_set(
                        "hw_auto_disk_config"):
                    LOG.debug("'hw_auto_disk_config' value not found in"
                              "rescue image_properties. Setting value to %s",
                              auto_disk_config, instance=instance)
                else:
                    auto_disk_config = strutils.bool_from_string(
                        image_meta.properties.hw_auto_disk_config)

            if auto_disk_config:
                LOG.debug("Auto configuring disk, attempting to "
                          "resize root disk...", instance=instance)
                vm_utils.try_auto_configure_disk(self._session,
                                                 root_vdi['ref'],
                                                 flavor.root_gb)

            vm_utils.create_vbd(self._session, vm_ref, root_vdi['ref'],
                                DEVICE_ROOT, bootable=True,
                                osvol=root_vdi.get('osvol'))

        # Attach (optional) additional block-devices
        for type_, vdi_info in vdis.items():
            # Additional block-devices for boot use their device-name as the
            # type.
            if not type_.startswith('/dev'):
                continue

            # Convert device name to user device number, e.g. /dev/xvdb -> 1
            userdevice = ord(block_device.strip_prefix(type_)) - ord('a')
            vm_utils.create_vbd(self._session, vm_ref, vdi_info['ref'],
                                userdevice, bootable=False,
                                osvol=vdi_info.get('osvol'))

        # For rescue, swap and ephemeral disks get attached in
        # _attach_orig_disks

        # Attach (optional) swap disk
        swap_mb = flavor.swap
        if not rescue and swap_mb:
            vm_utils.generate_swap(self._session, instance, vm_ref,
                                   DEVICE_SWAP, name_label, swap_mb)

        ephemeral_gb = flavor.ephemeral_gb
        if not rescue and ephemeral_gb:
            ephemeral_vdis = vdis.get('ephemerals')
            if ephemeral_vdis:
                # attach existing (migrated) ephemeral disks
                for userdevice, ephemeral_vdi in six.iteritems(ephemeral_vdis):
                    vm_utils.create_vbd(self._session, vm_ref,
                                        ephemeral_vdi['ref'],
                                        userdevice, bootable=False)
            else:
                # create specified ephemeral disks
                vm_utils.generate_ephemeral(self._session, instance, vm_ref,
                                            DEVICE_EPHEMERAL, name_label,
                                            ephemeral_gb)

        # Attach (optional) configdrive v2 disk
        if configdrive.required_by(instance):
            vm_utils.generate_configdrive(self._session, instance, vm_ref,
                                          DEVICE_CONFIGDRIVE,
                                          network_info,
                                          admin_password=admin_password,
                                          files=files)
dataset/ETHPy150Open openstack/nova/nova/virt/xenapi/vmops.py/VMOps._attach_disks/original