Ask Your Question

novaclient Python API not working

asked 2015-11-12 12:51:03 -0500

Vini.g.fer gravatar image

Trying to follow a simple tutorial for the python API found at ( but doesn't seem to be working. When I try to run




on python interpreter, I get following error:

  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/novaclient/v2/", line 617, in list
    return self._list("/servers%s%s" % (detail, query_string), "servers")
  File "/usr/lib/python2.7/dist-packages/novaclient/", line 64, in _list
    _resp, body = self.api.client.get(url)
  File "/usr/lib/python2.7/dist-packages/novaclient/", line 440, in get
    return self._cs_request(url, 'GET', **kwargs)
  File "/usr/lib/python2.7/dist-packages/novaclient/", line 399, in _cs_request
  File "/usr/lib/python2.7/dist-packages/novaclient/", line 569, in authenticate
  File "/usr/lib/python2.7/dist-packages/novaclient/", line 634, in _v2_auth
    return self._authenticate(url, body)
  File "/usr/lib/python2.7/dist-packages/novaclient/", line 647, in _authenticate
  File "/usr/lib/python2.7/dist-packages/novaclient/", line 392, in _time_request
    resp, body = self.request(url, method, **kwargs)
  File "/usr/lib/python2.7/dist-packages/novaclient/", line 386, in request
    raise exceptions.from_response(resp, body, url, method)
novaclient.exceptions.NotFound: The resource could not be found. (HTTP 404)

I'm using the same credentials as, which works. Can't figure out what might be the problem.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-02-01 12:52:10 -0500

dbaxps gravatar image

updated 2016-02-02 14:30:57 -0500

Code bellow works for me
[root@ip-192-169-142-127 ~(keystone_demo)]# cat

#!/usr/bin/env python
import os
import time
import novaclient.v2  as nvclient
from credentials import get_nova_creds

def get_keystone_creds():
    d = {}
    d['username'] = os.environ['OS_USERNAME']
    d['password'] = os.environ['OS_PASSWORD']
    d['auth_url'] = os.environ['OS_AUTH_URL']
    d['tenant_name'] = os.environ['OS_TENANT_NAME']
    return d

def get_nova_creds():
    d = {}
    d['username'] = os.environ['OS_USERNAME']
    d['api_key'] = os.environ['OS_PASSWORD']
    d['auth_url'] = os.environ['OS_AUTH_URL']
    d['project_id'] = os.environ['OS_TENANT_NAME']
    return d

creds = get_nova_creds()
nova = nvclient.client.Client(**creds)
if not nova.keypairs.findall(name="oskeydvr3node"):
    with open(os.path.expanduser('~/.ssh/')) as fpubkey:
image = nova.images.find(name="cirros")
flavor = nova.flavors.find(name="m1.small")

network = nova.networks.find(label="demo_network1")
nics = [{'net-id':}]

block_dev_mapping = {'vda': '10451763-d614-437e-937b-59002603af1c' }

instance = nova.servers.create(name="UbuntuWereWolf", image='', flavor=flavor, key_name="oskeydvr3node", nics=nics, block_device_mapping=block_dev_mapping)

# Poll at 5 second intervals, until the status is no longer 'BUILD'
status = instance.status
while status == 'BUILD':
    # Retrieve the instance again so the status field updates
    instance = nova.servers.get(
    status = instance.status
print "status: %s" % status


[root@ip-192-169-142-127 ~(keystone_demo)]# python
/usr/lib/python2.7/site-packages/novaclient/v2/ UserWarning: 'novaclient.v2.client.Client' is not designed to be initialized directly. It is inner class of novaclient. Please, use 'novaclient.client.Client' instead. Related lp bug-report: 1493576
  _LW("'novaclient.v2.client.Client' is not designed to be "
status: ACTIVE

If per
is already in current directory, there is no need to redefine get_nova_creds() due to

from credentials import get_nova_creds
edit flag offensive delete link more

answered 2016-02-01 19:19:05 -0500

Mohit gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-11-12 12:51:03 -0500

Seen: 1,843 times

Last updated: Feb 02 '16