Disconnect from Openstack?

97 Views Asked by At

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?

1

There are 1 best solutions below

2
On BEST ANSWER

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.