Contrail

How-To: Make Contrail Python API Library Work Without Authentication

By p.k posted 12-16-2015 09:28

  

Symptoms

Examples provided in Contrail Configuration API server documentation at

http://www.juniper.net/techpubs/en_US/release-independent/contrail/information-products/pathway-pages/api-server/index.html

assume no authentication of the incoming API connection. However recent versions of Contrail (such as 2.21) require authentication of API requests by default.

Diagnosis

By default, API calls require authentication. For the sake of lab testing, it is possible to disable this authentication.

 

root@openstack:~# cat /etc/contrail/contrail-api.conf | grep auth

auth = keystone

Solution

Replace "keystone" with "none" and restart.

 

Here is an example Python session that no longer requires authentication:

 

root@openstack:~# python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from vnc_api import vnc_api
>>> vnc_lib = vnc_api.VncApi()
>>> print(vnc_lib.virtual_networks_list())
{u'virtual-networks': [{u'href': u'http://127.0.0.1:8082/virtual-network/a3169c4b-ebb9-4b45-8452-9ad6a4de3c9f', u'fq_name': [u'default-domain', u'default-project', u'__link_local__'], u'uuid': u'a3169c4b-ebb9-4b45-8452-9ad6a4de3c9f'}, {u'href': u'http://127.0.0.1:8082/virtual-network/ab93c42b-f24d-4b1f-9cd9-5306b5bda0bd', u'fq_name': [u'default-domain', u'demo', u'VN-B'], u'uuid': u'ab93c42b-f24d-4b1f-9cd9-5306b5bda0bd'}, {u'href': u'http://127.0.0.1:8082/virtual-network/0719a959-c0a2-4264-a67d-8a30a9eb8628', u'fq_name': [u'default-domain', u'demo', u'svc-vn-left'], u'uuid': u'0719a959-c0a2-4264-a67d-8a30a9eb8628'}, {u'href': u'http://127.0.0.1:8082/virtual-network/ce2439e9-9aca-4de0-b1e0-088bd42dbec1', u'fq_name': [u'default-domain', u'default-project', u'ip-fabric'], u'uuid': u'ce2439e9-9aca-4de0-b1e0-088bd42dbec1'}, {u'href': u'http://127.0.0.1:8082/virtual-network/00105e7a-8b23-4333-afb4-d83d508cf5cd', u'fq_name': [u'default-domain', u'demo', u'VN-A'], u'uuid': u'00105e7a-8b23-4333-afb4-d83d508cf5cd'}, {u'href': u'http://127.0.0.1:8082/virtual-network/bf5d86d4-12dd-49e4-bee2-3cb906b9c942', u'fq_name': [u'default-domain', u'default-project', u'default-virtual-network'], u'uuid': u'bf5d86d4-12dd-49e4-bee2-3cb906b9c942'}, {u'href': u'http://127.0.0.1:8082/virtual-network/f63f3f86-8d41-4d08-9892-bb4dfca85c29', u'fq_name': [u'default-domain', u'demo', u'Ext'], u'uuid': u'f63f3f86-8d41-4d08-9892-bb4dfca85c29'}]}


#How-To
#Python
#Contrail
0 comments
0 views

Permalink