Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
vpn_test_data
from gbpservice.nfp.configurator.agents import vpn
from gbpservice.nfp.configurator.drivers.base import base_driver
from gbpservice.nfp.configurator.drivers.vpn.vyos import (
vyos_vpn_constants as const)
from gbpservice.nfp.configurator.drivers.vpn.vyos import vyos_vpn_driver

from oslo_config import cfg
from oslo_serialization import jsonutils

import json
Expand Down Expand Up @@ -148,12 +152,13 @@ class VpnGenericConfigDriverTestCase(unittest.TestCase):

def __init__(self, *args, **kwargs):
super(VpnGenericConfigDriverTestCase, self).__init__(*args, **kwargs)
self.conf = 'conf'
with mock.patch.object(cfg, 'CONF') as mock_cfg:
mock_cfg.configure_mock()
self.driver = vyos_vpn_driver.VpnaasIpsecDriver(mock_cfg)
self.dict_objects = vpn_test_data.VPNTestData()
self.context = self.dict_objects.make_service_context()
self.plugin_rpc = vpn.VpnaasRpcSender(self.dict_objects.sc)
self.rest_apt = vyos_vpn_driver.RestApi(self.dict_objects.vm_mgmt_ip)
self.driver = vyos_vpn_driver.VpnGenericConfigDriver(self.conf)
self.resp = mock.Mock()
self.fake_resp_dict = {'status': True}
self.kwargs = self.dict_objects.fake_resource_data()
Expand Down Expand Up @@ -308,7 +313,7 @@ def __init__(self, *args, **kwargs):
self.dict_objects = vpn_test_data.VPNTestData()
self.args = {'peer_address': '1.103.2.2'}
self.fake_resp_dict = {'status': None}
self.timeout = 90
self.timeout = const.REST_TIMEOUT
self.data = {'data': 'data'}
self.j_data = jsonutils.dumps(self.data)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
""" Implements fake objects for assertion.

"""
import json

from gbpservice.nfp.configurator.drivers.vpn.vyos import (
vyos_vpn_constants as const)


class VPNTestData(object):
Expand Down Expand Up @@ -76,7 +78,7 @@ def __init__(self):
self.data__ = {"local_cidr": "11.0.6.0/24",
"peer_address": "1.103.2.2",
"peer_cidr": "141.0.0.0/24"}
self.timeout = 90
self.timeout = const.REST_TIMEOUT

self.ipsec_vpn_create = ['fip=192.168.20.75',
'tunnel_local_cidr=11.0.6.0/24',
Expand Down
13 changes: 7 additions & 6 deletions gbpservice/nfp/configurator/agents/vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ def __init__(self, sc, drivers):
self._drivers = drivers
self._plugin_rpc = VpnaasRpcSender(self._sc)

def _get_driver(self):
def _get_driver(self, service_vendor):

driver_id = const.SERVICE_TYPE + const.SERVICE_VENDOR
driver_id = const.SERVICE_TYPE + service_vendor
return self._drivers[driver_id]

def handle_event(self, ev):
Expand All @@ -203,8 +203,10 @@ def handle_event(self, ev):
% (os.getpid(),
ev.id, const.VPN_GENERIC_CONFIG_RPC_TOPIC))
LOG.debug(msg)

driver = self._get_driver()
service_vendor = (
ev.data['context']['agent_info']['service_vendor'])
driver = self._get_driver(service_vendor)
setattr(VPNaasEventHandler, "service_driver", driver)
self._vpnservice_updated(ev, driver)
except Exception as err:
msg = ("Failed to perform the operation: %s. %s"
Expand Down Expand Up @@ -277,9 +279,8 @@ def _sync_ipsec_conns(self, context, svc_context):
Returns: None
"""
try:
self._get_driver()

return self._get_driver().check_status(context, svc_context)
return self.service_driver.check_status(context, svc_context)
except Exception as err:
msg = ("Failed to sync ipsec connection information. %s."
% str(err).capitalize())
Expand Down
2 changes: 1 addition & 1 deletion gbpservice/nfp/configurator/config/asav.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# strictly forbidden unless prior written permission is obtained from
# One Convergence, Inc., USA

[ASAV_FW_CONFIG]
[ASAV_CONFIG]

# Username for ASAv Service VM
mgmt_username = admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def configure_interfaces(self, context, resource_data):
stitching_intf_name = self._get_device_interface_name(
stitching_cidr)

security_level = self.conf.ASAV_FW_CONFIG.security_level
security_level = self.conf.ASAV_CONFIG.security_level

@njagadish njagadish Jun 9, 2016

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if any of the ASAV firewall unit tests will be broken because of this change.

commands = self._get_interface_commands(
provider_intf_name, str(provider_interface_position),
provider_ip, provider_mask, security_level,
Expand Down Expand Up @@ -591,8 +591,8 @@ def __init__(self, conf):
self.timeout = const.REST_TIMEOUT
self.rest_api = RestApi(self.timeout)
self.port = const.CONFIGURATION_SERVER_PORT
self.auth = HTTPBasicAuth(self.conf.ASAV_FW_CONFIG.mgmt_username,
self.conf.ASAV_FW_CONFIG.mgmt_userpass)
self.auth = HTTPBasicAuth(self.conf.ASAV_CONFIG.mgmt_username,
self.conf.ASAV_CONFIG.mgmt_userpass)
super(FwaasDriver, self).__init__()

def register_config_options(self):
Expand All @@ -602,7 +602,7 @@ def register_config_options(self):

"""

self.conf.register_opts(asav_auth_opts, 'ASAV_FW_CONFIG')
self.conf.register_opts(asav_auth_opts, 'ASAV_CONFIG')

def get_rules(self, firewall, interface):
""" Prepares ASAv specific firewall rules from the
Expand Down Expand Up @@ -968,10 +968,10 @@ def _check_for_implicit_deny(self, firewall, interface):
rules = firewall["firewall_rule_list"]
if not rules:
return self._get_deny_rule(interface)
elif (not self.conf.ASAV_FW_CONFIG.scan_all_rule and
elif (not self.conf.ASAV_CONFIG.scan_all_rule and
rules[0]['description'].lower() == const.IMPLICIT_DENY):
return self._get_deny_rule(interface)
elif self.conf.ASAV_FW_CONFIG.scan_all_rule:
elif self.conf.ASAV_CONFIG.scan_all_rule:
for rule in rules:
if rule['description'].lower() == const.IMPLICIT_DENY:
return self._get_deny_rule(interface)
Expand Down
Empty file.
18 changes: 18 additions & 0 deletions gbpservice/nfp/configurator/drivers/vpn/asav/asav_vpn_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


REQUEST_URL = "https://%s%s"
CONFIGURATION_SERVER_PORT = '443'
SERVICE_VENDOR = 'asav'

REST_TIMEOUT = 160
Loading