Example #1
0
def init_agent(cm, sc, conf):
    """Loads the drivers and registers the agents.
    Loads the dynamicaaly both the drivers and agents, registers the agents
    with their service types.

    :prarm cm: Configurator module's object to communicate back and forth
    :param sc: Object of the Service Controller class from core
    service controller.
    :param conf: Object of oslo configurator passed from the core service
    controller

    Returns: None

    """
    try:
        drivers = load_drivers(sc, conf)
    except Exception as err:
        msg = ("VPNaas failed to load drivers. %s"
               % (str(err).capitalize()))
        LOG.error(msg)
        raise err
    else:
        msg = "VPNaas loaded drivers successfully."
        LOG.debug(msg)

    try:
        events_init(sc, drivers)
    except Exception as err:
        msg = ("VPNaas Events initialization unsuccessful. %s"
               % (str(err).capitalize()))
        LOG.error(msg)
        raise err
    else:
        msg = "VPNaas Events initialization successful."
        LOG.debug(msg)

    try:
        register_service_agent(cm, sc, conf)
        bdobj = base_driver.BaseDriver(conf)
        bdobj.register_agent_object_with_driver('agent', VpnaasRpcSender(sc))
    except Exception as err:
        msg = ("VPNaas service agent registration unsuccessful. %s"
               % (str(err).capitalize()))
        LOG.error(msg)
        raise err
    else:
        msg = "VPNaas service agent registration successful."
        LOG.debug(msg)

    msg = "VPN as a Service Module Initialized."
    LOG.info(msg)
import json

import mock
from neutron.tests import base
from oslo_serialization import jsonutils
import requests
import six

from gbpservice.contrib.nfp.configurator.agents import vpn
from gbpservice.contrib.nfp.configurator.drivers.base import base_driver
from gbpservice.contrib.nfp.configurator.drivers.vpn.vyos import (
    vyos_vpn_driver)
from gbpservice.contrib.tests.unit.nfp.configurator.test_data import (
    vpn_test_data)

bdobj = base_driver.BaseDriver('conf')
bdobj.register_agent_object_with_driver(
    'agent', vpn.VpnaasRpcSender(vpn_test_data.VPNTestData().sc))


class VpnaasIpsecDriverTestCase(base.BaseTestCase):
    """
    Implements test cases for driver methods
    of vpn.

    """
    def __init__(self, *args, **kwargs):
        super(VpnaasIpsecDriverTestCase, self).__init__(*args, **kwargs)
        self.conf = 'conf'
        self.test_dict = vpn_test_data.VPNTestData()
        self.context = self.test_dict.make_service_context()