Skip to content

Instantly share code, notes, and snippets.

@whitekid
Created June 23, 2015 05:01
Show Gist options
  • Save whitekid/58b21cce48d275d5912d to your computer and use it in GitHub Desktop.
Save whitekid/58b21cce48d275d5912d to your computer and use it in GitHub Desktop.
OpenStask python client snippt
import os
import keystoneclient.v2_0.client as kclient
from neutronclient.v2_0 import client as neutronclient
def basic_auth():
keystone = kclient.Client(
auth_url = os.environ.get('OS_AUTH_URL'),
username = os.environ.get('OS_USERNAME'),
tenant_name = os.environ.get('OS_TENANT_NAME'),
password = os.environ.get('OS_PASSWORD'),
region_name = os.environ.get('OS_REGION_NAME'),
)
endpoint_url = keystone.service_catalog.url_for(service_type='network')
assert endpoint_url
token = keystone.auth_token
neutron = neutronclient.Client(endpoint_url = endpoint_url, token=token)
print neutron.list_networks()
if __name__ == '__main__':
basic_auth()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment