[sdk] renaming a volume with the SDK

Stephen Finucane stephenfin at redhat.com
Thu Jun 30 15:51:05 UTC 2022


On Tue, 2022-06-28 at 21:22 +0100, Stephen Finucane wrote:
> On Fri, 2022-06-24 at 14:13 -0400, jdratlif at globalnoc.iu.edu wrote:
> > from keystoneauth1.adapter import Adapter
> > adapter = Adapter(conn.session, service_type="block-storage")
> >  
> > Adding this and passing adapter instead of conn.session to the commit call
> > seems to work.
> 
> You can also pass the proxy object itself. For example:
> 
>    cinder: BlockStorageService = conn.block_storage
>    volume: Volume = cinder.get_volume("b3a70014-1cf0-4fd1-bdc4-183dbfd33e79")
>    volume.name = "test_rename"
>    volume.commit(cinder)
> 
> Normally there would be an proxy method for this called 'update_volume' too. For
> some reason this doesn't exist. If it did, you could simply do:
> 
>    cinder: BlockStorageService = conn.block_storage
>    volume: Volume = cinder.get_volume("b3a70014-1cf0-4fd1-bdc4-183dbfd33e79")
>    cinder.update_volume(volume, name="test_rename")
> 
> But someone needs to add that proxy method first.

This is proposed at [1] and will likely form part of a future openstacksdk 1.0
release.

Stephen

[1] https://review.opendev.org/c/openstack/openstacksdk/+/848264/2

> 
> Stephen
> 
> >  
> > ---
> > John Ratliff
> > Systems Automation Engineer 
> > GlobalNOC @ Indiana University
> >  
> > > From: jdratlif at globalnoc.iu.edu <jdratlif at globalnoc.iu.edu> 
> > > Sent: Friday, June 24, 2022 11:44 AM
> > > To: openstack-discuss at lists.openstack.org
> > > Cc: Ratliff, John <jdratlif at iu.edu>
> > > Subject: [sdk] renaming a volume with the SDK
> > >  
> > > I’m trying to set a property on a volume, specifically the name. But when I
> > > try to do this, it tells me the Session object has no default_microversion.
> > > I have all my auth in environment variables. Using TOKEN authentication.
> > >  
> > > What am I doing wrong here?
> > >  
> > > import openstack
> > > from openstack.block_storage.v3._proxy import Proxy as BlockStorageService
> > > from openstack.block_storage.v3.volume import Volume
> > >  
> > > # enable openstack debug logging
> > > openstack.enable_logging(debug=True)
> > >  
> > > conn = openstack.connect()
> > >  
> > > cinder: BlockStorageService = conn.block_storage
> > > volume: Volume = cinder.get_volume("b3a70014-1cf0-4fd1-bdc4-183dbfd33e79")
> > > volume.name = "test_rename"
> > > volume.commit(conn.session)
> > >  
> > >  
> > > Thanks,
> > >  
> > > ---
> > > John Ratliff
> > > Systems Automation Engineer 
> > > GlobalNOC @ Indiana University
> 




More information about the openstack-discuss mailing list