problem with neutronclient example script

asked 2014-10-31 05:05:17 -0600

Gaurav Suryagandh gravatar image

I am a newbie with openstack environment and i am trying my hands on with Openstack API. I am getting following error while executing a basic script to list networks using neutron API.

#!/usr/bin/env python
from neutronclient.v2_0 import client as neutronClient
import os

neutronConnection = neutronClient.Client(
    username=os.environ['OS_USERNAME'],
    password=os.environ['OS_PASSWORD'],
    tenant_name=os.environ['OS_TENANT_NAME'],
    auth_url=os.environ['OS_AUTH_URL']
    )
print neutronConnection
neutronConnection.format = 'json'
neutronConnection.list_networks()

i am getting following error.

neutronConnection.list_networks()
  File "/usr/lib/python2.6/site-packages/neutronclient/v2_0/client.py", line 98, in with_params
    ret = self.function(instance, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/neutronclient/v2_0/client.py", line 339, in list_networks
    **_params)
  File "/usr/lib/python2.6/site-packages/neutronclient/v2_0/client.py", line 1334, in list
    for r in self._pagination(collection, path, **params):
  File "/usr/lib/python2.6/site-packages/neutronclient/v2_0/client.py", line 1347, in _pagination
    res = self.get(path, params=params)
  File "/usr/lib/python2.6/site-packages/neutronclient/v2_0/client.py", line 1320, in get
    headers=headers, params=params)
  File "/usr/lib/python2.6/site-packages/neutronclient/v2_0/client.py", line 1297, in retry_request
    headers=headers, params=params)
  File "/usr/lib/python2.6/site-packages/neutronclient/v2_0/client.py", line 1232, in do_request
    self.httpclient.authenticate_and_fetch_endpoint_url()
  File "/usr/lib/python2.6/site-packages/neutronclient/client.py", line 152, in authenticate_and_fetch_endpoint_url
    self.authenticate()
  File "/usr/lib/python2.6/site-packages/neutronclient/client.py", line 249, in authenticate
    self._authenticate_keystone()
  File "/usr/lib/python2.6/site-packages/neutronclient/client.py", line 228, in _authenticate_keystone
    allow_redirects=True)
  File "/usr/lib/python2.6/site-packages/neutronclient/client.py", line 138, in _cs_request
    raise exceptions.Unauthorized(message=body)
neutronclient.common.exceptions.Unauthorized: {"error": {"message": "Could not find project, ESS.", "code": 401, "title": "Unauthorized"}}

If i do execute neutron net-list from command line .. it works absolutely fine. –

I checked my environment variables its also correct.

edit retag flag offensive close merge delete