~ubuntu-branches/ubuntu/vivid/neutron-vpnaas/vivid-proposed

« back to all changes in this revision

Viewing changes to neutron_vpnaas/services/vpn/vyatta_agent.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-03-30 11:20:04 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20150330112004-20hxur2ww41nbvos
Tags: 1:2015.1~b3-0ubuntu1
* New upstream milestone release:
  - d/control: Align version requirements with upstream, add new dependency
    on python-oslo-log.
* Enable unit test suite execution:
  - d/control: Switch BD on python-neutron -> neutron-common.
  - d/rules: Enable execution of unit tests.
* d/control: Add runtime dependency on python-neutron-fwaas.
* d/control: Add runtime dependency on strongswan, with fallback to openswan
  to ensure that any openswan deployments on 14.04 don't get broken during
  upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2015 Brocade Communications System, Inc.
 
2
# All Rights Reserved.
 
3
#
 
4
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
5
#    not use this file except in compliance with the License. You may obtain
 
6
#    a copy of the License at
 
7
#
 
8
#         http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
10
#    Unless required by applicable law or agreed to in writing, software
 
11
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
12
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
13
#    License for the specific language governing permissions and limitations
 
14
#    under the License.
 
15
#
 
16
 
 
17
from networking_brocade.vyatta.common import l3_agent as vyatta_l3
 
18
from neutron.agent import l3_agent as entry
 
19
from oslo_config import cfg
 
20
from oslo_log import log as logging
 
21
 
 
22
from neutron_vpnaas.services.vpn import vyatta_vpn_service
 
23
 
 
24
 
 
25
LOG = logging.getLogger(__name__)
 
26
 
 
27
vpn_agent_opts = [
 
28
    cfg.MultiStrOpt(
 
29
        'vpn_device_driver',
 
30
        default=['neutron_vpnaas.services.vpn.device_drivers.'
 
31
                 'vyatta_ipsec.VyattaIPSecDriver'],
 
32
        help=_("The vpn device drivers Neutron will use")),
 
33
]
 
34
cfg.CONF.register_opts(vpn_agent_opts, 'vpnagent')
 
35
 
 
36
 
 
37
class VyattaVPNAgent(vyatta_l3.L3AgentMiddleware):
 
38
    def __init__(self, host, conf=None):
 
39
        super(VyattaVPNAgent, self).__init__(host, conf)
 
40
        self.service = vyatta_vpn_service.VyattaVPNService(self)
 
41
        self.event_observers.add(self.service)
 
42
        self.devices = self.service.load_device_drivers(host)
 
43
 
 
44
    def _router_added(self, router_id, router):
 
45
        super(VyattaVPNAgent, self)._router_added(router_id, router)
 
46
        for device in self.devices:
 
47
            device.create_router(router_id)
 
48
 
 
49
    def _router_removed(self, router_id):
 
50
        for device in self.devices:
 
51
            device.destroy_router(router_id)
 
52
        super(VyattaVPNAgent, self)._router_removed(router_id)
 
53
 
 
54
    def _process_router_if_compatible(self, router):
 
55
        super(VyattaVPNAgent, self)._process_router_if_compatible(router)
 
56
        for device in self.devices:
 
57
            device.sync(self.context, None)
 
58
 
 
59
 
 
60
def main():
 
61
    entry.main(
 
62
        manager='neutron_vpnaas.services.vpn.vyatta_agent.VyattaVPNAgent')