Skip to content

Commit

Permalink
VPNaaS Cisco REST client enhance CSR create
Browse files Browse the repository at this point in the history
For the create of the REST client object that represents a Cisco CSR,
all of the info needed were passed in as separate parameters. This
change just uses a dict instead, so that additional parameters can
be added w/o changing the API.

Updated the currently unused UT module, just so that it can be used
locally and stays up-to-date until it can be converted to use the
new requests-mock package.

Change-Id: I5d4f439cc7ffe125cea9ed3407b70645587a739a
Closes-Bug: 1336478
  • Loading branch information
Paul Michali committed Jul 16, 2014
1 parent fb6e065 commit 787fecb
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 208 deletions.
10 changes: 5 additions & 5 deletions neutron/services/vpn/device_drivers/cisco_csr_rest_client.py
Expand Up @@ -44,13 +44,13 @@ class CsrRestClient(object):

"""REST CsrRestClient for accessing the Cisco Cloud Services Router."""

def __init__(self, host, tunnel_ip, username, password, timeout=None):
self.host = host
self.tunnel_ip = tunnel_ip
self.auth = (username, password)
def __init__(self, settings):
self.host = settings['rest_mgmt']
self.tunnel_ip = settings['tunnel_ip']
self.auth = (settings['username'], settings['password'])
self.token = None
self.status = requests.codes.OK
self.timeout = timeout
self.timeout = settings.get('timeout')
self.max_tries = 5
self.session = requests.Session()

Expand Down
6 changes: 1 addition & 5 deletions neutron/services/vpn/device_drivers/cisco_ipsec.py
Expand Up @@ -216,11 +216,7 @@ def __init__(self, agent, host):
else:
raise SystemExit(_('No Cisco CSR configurations found in: %s') %
cfg.CONF.config_file)
self.csrs = dict([(k, csr_client.CsrRestClient(v['rest_mgmt'],
v['tunnel_ip'],
v['username'],
v['password'],
v['timeout']))
self.csrs = dict([(k, csr_client.CsrRestClient(v))
for k, v in csrs_found.items()])

def vpnservice_updated(self, context, **kwargs):
Expand Down
10 changes: 5 additions & 5 deletions neutron/tests/unit/services/vpn/device_drivers/cisco_csr_mock.py
Expand Up @@ -19,19 +19,19 @@
import re

import functools
# import httmock
# TODO(pcm): Remove when switch to requests-mock package. Comment out, if use
# local copy of httmock.py source. Needed for PEP8.
import httmock
import requests
from requests import exceptions as r_exc

from neutron.openstack.common import log as logging
# TODO(pcm) Remove once httmock package is added to test-requirements. For
# now, uncomment and include httmock source to UT
from neutron.tests.unit.services.vpn import device_drivers
# now, uncomment and include httmock source to unit test.
# from neutron.tests.unit.services.vpn.device_drivers import httmock

LOG = logging.getLogger(__name__)

httmock = device_drivers.httmock


def repeat(n):
"""Decorator to limit the number of times a handler is called.
Expand Down

0 comments on commit 787fecb

Please sign in to comment.