Skip to content

Commit

Permalink
Authentication token url is added in vnc_api
Browse files Browse the repository at this point in the history
Contrail neutron plugin expects keystone authentication variables
which needs to be updated to support latest SKU's from neutron.
Hence adding auth_token_url in VncApi will rectify this issue.

Changes in contrail neutron plugin to parse and pass auth token
url to VncApi.

Change-Id: Idea3c8a04ad0935cbf50a70733ec96135744316f
Closes-Bug: 1639927
  • Loading branch information
sahilsabharwal committed Nov 29, 2016
1 parent d9213a4 commit ce1e6f7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
3 changes: 3 additions & 0 deletions etc/neutron/plugins/opencontrail/ContrailPlugin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# multi_tenancy =
# Example: multi_tenancy = True

# auth_token_url =
# Example: auth_token_url = http://127.0.0.1:35357/v2.0/tokens

# (ListOpt) list of OpenContrail extensions to be supported.
# OpenContrail extensions are - ipam, policy and route-table.
# By default ipam, policy and route-table extensions are supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def _parse_class_args(cls, cfg_parser):
'api_server_port', '8082')
cls._api_server_use_ssl = _read_cfg(cfg_parser, 'APISERVER',
'use_ssl', False)
cls._auth_token_url = _read_cfg(cfg_parser, 'APISERVER',
'auth_token_url', None)

def __init__(self, conf):
super(ContrailInterfaceDriver, self).__init__(conf)
Expand All @@ -71,7 +73,8 @@ def _connect_to_api_server(self):
try:
client = VncApi(api_server_host=self._api_server_ip,
api_server_port=self._api_server_port,
api_server_use_ssl=self._api_server_use_ssl)
api_server_use_ssl=self._api_server_use_ssl,
auth_token_url=self._auth_token_url)
return client
except:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ def _connect_to_vnc_server(self):
except cfg.NoSuchOptError:
api_server_url = "/"

try:
auth_token_url = cfg.CONF.APISERVER.auth_token_url
except cfg.NoSuchOptError:
auth_token_url = None

# Retry till a api-server is up
connected = False
while not connected:
Expand All @@ -109,7 +114,7 @@ def _connect_to_vnc_server(self):
api_srvr_ip, api_srvr_port, api_server_url,
auth_host=auth_host, auth_port=auth_port,
auth_protocol=auth_protocol, auth_url=auth_url,
auth_type=auth_type)
auth_type=auth_type, auth_token_url=auth_token_url)
connected = True
except requests.exceptions.RequestException:
time.sleep(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def __init__(self):
except cfg.NoSuchOptError:
self.api_server_url = "/"

try:
self.auth_token_url= cfg.CONF.APISERVER.auth_token_url
except cfg.NoSuchOptError:
self.auth_token_url = None

@property
def api(self):
if hasattr(self, '_api'):
Expand All @@ -91,7 +96,8 @@ def api(self):
auth_protocol=self.auth_protocol,
auth_url=self.auth_url, auth_type=self.auth_type,
wait_for_connect=True,
api_server_use_ssl=self.api_srvr_use_ssl)
api_server_use_ssl=self.api_srvr_use_ssl,
auth_token_url=self.auth_token_url)
connected = True
except requests.exceptions.RequestException:
time.sleep(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def __init__(self):
except cfg.NoSuchOptError:
self.api_server_url = "/"

try:
self.auth_token_url = cfg.CONF.APISERVER.auth_token_url
except cfg.NoSuchOptError:
self.auth_token_url = None

@property
def api(self):
if hasattr(self, '_api'):
Expand All @@ -82,7 +87,8 @@ def api(self):
auth_protocol=self.auth_protocol,
auth_url=self.auth_url, auth_type=self.auth_type,
wait_for_connect=True,
api_server_use_ssl=self.api_srvr_use_ssl)
api_server_use_ssl=self.api_srvr_use_ssl,
auth_token_url=self.auth_token_url)
connected = True
except requests.exceptions.RequestException:
time.sleep(3)
Expand Down
9 changes: 8 additions & 1 deletion neutron_plugin_contrail/plugins/opencontrail/quota/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def _get_vnc_conn(cls):
if vnc_conn:
return vnc_conn
# Retry till a api-server is up

try:
auth_token_url= cfg.CONF.APISERVER.auth_token_url
except cfg.NoSuchOptError:
auth_token_url = None

while True:
try:
vnc_conn = vnc_api.VncApi(
Expand All @@ -77,7 +83,8 @@ def _get_vnc_conn(cls):
auth_host=cfg.CONF.keystone_authtoken.auth_host,
auth_port=cfg.CONF.keystone_authtoken.auth_port,
auth_protocol=cfg.CONF.keystone_authtoken.auth_protocol,
api_server_use_ssl=cfg.CONF.APISERVER.use_ssl)
api_server_use_ssl=cfg.CONF.APISERVER.use_ssl,
auth_token_url=auth_token_url)
return vnc_conn
except requests.exceptions.RequestException as e:
time.sleep(3)
Expand Down

0 comments on commit ce1e6f7

Please sign in to comment.