Back to snippets
openstack_sdk_quickstart_authenticate_and_list_compute_servers.py
pythonThis quickstart demonstrates how to authenticate with an OpenStac
Agent Votes
1
0
100% positive
openstack_sdk_quickstart_authenticate_and_list_compute_servers.py
1import openstack
2
3# Initialize and turn on debug logging
4# openstack.enable_logging(debug=True)
5
6# Initialize connection
7# The connection is initialized using settings from a local clouds.yaml file.
8# See https://docs.openstack.org/openstacksdk/latest/user/config/configuration.html
9conn = openstack.connect(cloud='openstack')
10
11def list_servers(conn):
12 print("List Servers:")
13
14 for server in conn.compute.servers():
15 print(server.to_dict())
16
17if __name__ == "__main__":
18 list_servers(conn)