Comment 39 for bug 1560965

Revision history for this message
eblock@nde.ag (eblock) wrote :

Ok, after some trial & error it seems like this works for volume -> volume:

---cut here---
    function setFinalSpecBootFromVolumeDevice(finalSpec, sourceType) {
      var deviceName = finalSpec.vol_device_name ? finalSpec.vol_device_name : null;
      if (finalSpec.vol_device_name==='NOTSET'){
        finalSpec.block_device_mapping_v2 = [];
        finalSpec.block_device_mapping_v2.push(
          {
            'source_type': bootSourceTypes.VOLUME,
            'destination_type': bootSourceTypes.VOLUME,
            'delete_on_termination': finalSpec.vol_delete_on_instance_delete,
            'uuid': finalSpec.source_id,
            'boot_index': '0'
          }
        );
      }
      else {
        finalSpec.block_device_mapping = {};
        finalSpec.block_device_mapping[finalSpec.vol_device_name] = [
          finalSpec.source_id,
          ':',
          sourceType,
          '::',
          finalSpec.vol_delete_on_instance_delete
        ].join('');
      }
      finalSpec.source_id = '';
    }
---cut here---

In case there is a device name provided it will use the legacy bdm, but if the default is "NOTSET" it will create a new bdm. I'm not sure about the legacy part, which consequences there could be, I just tried it without changing that part.
Maybe it should be changed to bdm_v2, too. Anyway, with these changes I could launch an instance from volume with a non-default device name (/dev/sda), also attaching another volume results in a correct device name in horizon/cinder and from within the VM (/dev/sdb).