Created
March 1, 2016 11:10
-
-
Save djoreilly/888abbfc3425e54fa290 to your computer and use it in GitHub Desktop.
Howto use the python-novaclient and python-neutronclient with Keystone V3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://docs.openstack.org/developer/keystoneauth/index.html | |
# http://www.jamielennox.net/blog/2014/09/15/how-to-use-keystoneclient-sessions/ | |
# In iPython: execfile('path/to/this/file') | |
import os | |
import logging | |
from keystoneauth1.identity import v3 | |
from keystoneauth1 import session | |
import requests | |
# suppress warning | |
requests.packages.urllib3.disable_warnings() | |
# logging.basicConfig(level=logging.DEBUG) | |
logging.basicConfig(level=logging.INFO) | |
LOG = logging.getLogger(__name__) | |
if os.environ.get('http_proxy') or os.environ.get('https_proxy'): | |
LOG.WARN("Proxy env vars set") | |
# TODO howto pass internalURL | |
auth = v3.Password(auth_url=os.environ['OS_AUTH_URL'], | |
username=os.environ['OS_USERNAME'], | |
password=os.environ['OS_PASSWORD'], | |
project_name=os.environ['OS_PROJECT_NAME'], | |
user_domain_id=os.environ['OS_USER_DOMAIN_NAME'], | |
project_domain_name=os.environ['OS_PROJECT_DOMAIN_NAME']) | |
# sess = session.Session(auth=auth, verify='/path/to/ca.cert') | |
sess = session.Session(auth=auth, verify=False) | |
import novaclient.client | |
novac = novaclient.client.Client(2, session=sess) | |
novac.servers.list() | |
import neutronclient.neutron.client | |
neutc = neutronclient.neutron.client.Client('2.0', session=sess) | |
neutc.list_networks() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For me, changing
user_domain_id
at Line#29 touser_domain_name
did the trick.