1

I am writing python code on top of the openstack shade library.

Connecting to a stack is pretty straight forward:

return shade.openstack_cloud(cloud='mycloud', **auth_data)

Now I am simply wondering: is there a canonical way to disconnect when I am done?

Or is the assumption that my script ending will do a "graceful" shutdown of that connection; not leaving anything behind?

GhostCat
  • 137,827
  • 25
  • 176
  • 248

1 Answers1

2

OpenStack works on a RESTful api model. This means the connections are stateless, i.e. it makes a HTTP connection when you do your request, and closes that connection when the request is finished.

The above code simply initialises things by reading your config, authentication data, etc. A connection is not made until you do something with that object, e.g. create an image:

image = cloud.create_image( 'ubuntu-trusty', filename='ubuntu-trusty.qcow2', wait=True)

In summary, no, you don't need to disconnect, shade's underlying code will take care of closing connections.

brk3
  • 1,524
  • 2
  • 19
  • 31
  • Well, so, just to be sure: the API "revoke" for tokens is thus not some regular "disconnect" thing? Beyond that: is there anything I could do to make my question upvote-worthy in your eyes? – GhostCat Apr 13 '17 at 11:08
  • Revoking tokens is a different concept, this is used by admins to remove access from users or services from accessing the cloud. This link might be of use to you https://docs.openstack.org/security-guide/identity/tokens.html – brk3 Apr 13 '17 at 11:30