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
4 changes: 2 additions & 2 deletions devstack/lib/nfp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ function create_ep_and_nsp {
gbp external-segment-create --ip-version 4 --cidr $EXT_NET_CIDR/$EXT_NET_MASK --external-route destination=0.0.0.0/0,nexthop= --shared True --subnet_id=$subnet_id default
gbp nat-pool-create --ip-version 4 --ip-pool $EXT_NET_CIDR/$EXT_NET_MASK --external-segment default --shared True default

gbp ep-create --external-segments default ext_connect
gbp nsp-create --network-service-params type=ip_pool,name=vip_ip,value=nat_pool svc_mgmt_fip_policy
}

Expand All @@ -301,10 +300,11 @@ function create_nfp_gbp_resources {
gbp service-profile-create --servicetype LOADBALANCER --insertion-mode l3 --shared True --service-flavor service_vendor=haproxy,device_type=nova --vendor NFP lb_profile
gbp service-profile-create --shared True --vendor NFP --servicetype LOADBALANCERV2 --service-flavor service_vendor=haproxy_lbaasv2,device_type=nova,flavor=m1.small --insertion-mode l3 lbv2_profile
gbp service-profile-create --servicetype FIREWALL --insertion-mode l3 --shared True --service-flavor service_vendor=vyos,device_type=nova --vendor NFP vyos_fw_profile
gbp service-profile-create --servicetype VPN --insertion-mode l3 --shared True --service-flavor service_vendor=vyos,device_type=nova --vendor NFP vpn_profile
gbp service-profile-create --servicetype VPN --insertion-mode l3 --shared True --service-flavor service_vendor=vyos,device_type=nova --vendor NFP vyos_vpn_profile

if [[ $DEVSTACK_MODE = enterprise ]]; then
gbp service-profile-create --servicetype FIREWALL --insertion-mode l3 --shared True --service-flavor service_vendor=asav,device_type=nova --vendor NFP asav_fw_profile
gbp service-profile-create --servicetype VPN --insertion-mode l3 --shared True --service-flavor service_vendor=asav,device_type=nova --vendor NFP asav_vpn_profile
fi
create_ext_net
create_ep_and_nsp
Expand Down
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
22 changes: 11 additions & 11 deletions gbpservice/nfp/configurator/agents/vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
from gbpservice.nfp.configurator.lib import data_filter
from gbpservice.nfp.configurator.lib import utils
from gbpservice.nfp.configurator.lib import vpn_constants as const
from gbpservice.nfp.core import controller as main
from gbpservice.nfp.core.event import Event
from gbpservice.nfp.core import module as nfp_api
from gbpservice.nfp.core import event as main
from gbpservice.nfp.core import log as nfp_logging
from gbpservice.nfp.core import module as nfp_api

import oslo_messaging as messaging

Expand Down Expand Up @@ -181,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 @@ -204,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 @@ -278,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 Expand Up @@ -316,9 +316,9 @@ def events_init(sc, drivers):
Returns: None
"""
evs = [
Event(id='VPNSERVICE_UPDATED',
main.Event(id='VPNSERVICE_UPDATED',
handler=VPNaasEventHandler(sc, drivers)),
Event(id='VPN_SYNC',
main.Event(id='VPN_SYNC',
handler=VPNaasEventHandler(sc, drivers))]

sc.register_events(evs)
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
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