[sdk] creating a blank volume with image properties

Gorka Eguileor geguileo at redhat.com
Thu May 5 08:35:43 UTC 2022


On 03/05, John Ratliff wrote:
> We're standing up a second openstack cluster to do a leapfrog migration
> upgrade. We are using the same ceph storage backend. I need to create
> volumes in the new openstack cluster that use the underlying ceph rbd.
>
> Currently, we are creating a volume in the new openstack cluster, deleting
> the rbd created by openstack, and renaming the original rbd to match the new
> openstack mapping. This process loses the image properties from the original
> volumes. We are using virtio-scsi for the disk block device, and want to
> continue doing that in the new cluster. When we create the server using the
> new volume in the new openstack cluster, it reverts to using virtio-blk
> (/dev/vda).
>
> What can I do to keep using our image properties in the newly created
> volume? I thought I could just pass volume_image_metadata as an argument to
> create_volume(), but it doesn't work. I end up with an image that has no
> image metadata properties.
>
> import openstack
>
> openstack.enable_logging(debug=False)
>
> conn = openstack.connect(cloud="test")
>
> v = conn.create_volume(
>     name="testvol",
>     size=5,
>     wait=True,
>     bootable=True,
>     volume_image_metadata={
>         "hw_scsi_model": "virtio-scsi",
>         "hw_disk_bus": "scsi",
>         "hw_qemu_guest_agent": "yes",
>         "os_require_quiesce": "yes",
>         "hw_rng_model": "virtio",
>         "image_id": "00000000-0000-0000-0000-000000000000",
>     },
> )
>
> What can I do to create this openstack volume while preserving my original
> volume properties?
>
> Since we don't care about the image, I thought about creating a blank image
> that the volume could be based on with those properties, but I'm looking for
> suggestions.
>
> Thanks.
>
> --John
>
>
>

Hi John,

I don't know the OSC counterparts of the cinder client commands, so I'll
only mention the cinder commands here.

I would recommend trying to use the "cinder unmanage" and "cinder
manage" commands (maybe in conjunction with "cinder manageable-list")
instead of modifying image names manually in the Ceph cluster.

There are also snapshot commands "snapshot-unmanage", "snapshot-manage",
and "snapshot-manageable-list".

For the glance image metadata you can use the "cinder image-metadata"
command to set the image metadata values you want.

So the migration script would:

- Get the current glance metadata and volume metadata in the source
  volume.
- Unmanage the source volume from the old Cinder deployment
- Manage the volume in the new Cinder deployment
- Set the glance image metadata

Cheers,
Gorka.




More information about the openstack-discuss mailing list