L2 gateway basic agent side implementation

This is the first change in a series of changes to support the L2
Gateway API on top of ovsdb.
L2 gateway agent files are submitted.

Change-Id: Id564c869546e3d3b95501f201184b5f4c633f1ac
stable/ocata
Maruti 8 years ago
parent 8227bcc52a
commit 536ec3ec1c
  1. 36
      etc/l2gateway_agent.ini
  2. 0
      networking_l2gw/services/__init__.py
  3. 0
      networking_l2gw/services/l2gateway/__init__.py
  4. 0
      networking_l2gw/services/l2gateway/agent/__init__.py
  5. 36
      networking_l2gw/services/l2gateway/agent/agent_api.py
  6. 37
      networking_l2gw/services/l2gateway/agent/l2gateway_config.py
  7. 0
      networking_l2gw/services/l2gateway/common/__init__.py
  8. 85
      networking_l2gw/services/l2gateway/common/ovsdb_schema.py
  9. 23
      networking_l2gw/tests/base.py
  10. 28
      networking_l2gw/tests/test_networking_l2gw.py
  11. 0
      networking_l2gw/tests/unit/__init__.py
  12. 0
      networking_l2gw/tests/unit/services/__init__.py
  13. 0
      networking_l2gw/tests/unit/services/l2gateway/__init__.py
  14. 0
      networking_l2gw/tests/unit/services/l2gateway/agent/__init__.py
  15. 41
      networking_l2gw/tests/unit/services/l2gateway/agent/test_agent_api.py

@ -0,0 +1,36 @@
[DEFAULT]
# Show debugging output in log (sets DEBUG log level output)
# debug = False
[ovsdb]
# (StrOpt) OVSDB server tuples in the format
# <ovsdb_name>:<ip address>:<port>[,<ovsdb_name>:<ip address>:<port>]
# - ovsdb_name: a symbolic name that helps identifies keys and certificate files
# - ip address: the address or dns name for the ovsdb server
# - port: the port (ssl is supported)
# ovsdb_hosts =
# Example: ovsdb_hosts = 'ovsdb1:16.95.16.1:6632,ovsdb2:16.95.16.2:6632'
# (StrOpt) Base path to private key file(s).
# Agent will find key file named
# $l2_gw_agent_priv_key_base_path/$ovsdb_name.key
# l2_gw_agent_priv_key_base_path =
# Example: l2_gw_agent_priv_key_base_path = '/home/someuser/keys'
# (StrOpt) Base path to cert file(s).
# Agent will find cert file named
# $l2_gw_agent_cert_base_path/$ovsdb_name.cert
# l2_gw_agent_cert_base_path =
# Example: l2_gw_agent_cert_base_path = '/home/someuser/certs'
# (StrOpt) Base path to ca cert file(s).
# Agent will find ca cert file named
# $l2_gw_agent_ca_cert_base_path/$ovsdb_name.ca_cert
# l2_gw_agent_ca_cert_base_path =
# Example: l2_gw_agent_ca_cert_base_path = '/home/someuser/ca_certs'
# (IntOpt) The L2 gateway agent checks connection state with the OVSDB
# servers.
# The interval is number of seconds between attempts.
# periodic_interval =
# Example: periodic_interval = 20

@ -0,0 +1,36 @@
# Copyright (c) 2015 OpenStack Foundation.
# All Rights Reserved.
#
# 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.
from neutron.common import rpc as n_rpc
from oslo import messaging
class L2GatewayAgentApi(object):
"""Agent side of the Agent to Plugin RPC API."""
API_VERSION = '1.0'
def __init__(self, topic, context, host):
self.context = context
self.host = host
target = messaging.Target(topic=topic, version=self.API_VERSION)
self.client = n_rpc.get_client(target)
def update_ovsdb_changes(self, ovsdb_data):
cctxt = self.client.prepare()
return cctxt.call(self.context,
'update_ovsdb_changes',
ovsdb_data=ovsdb_data)

@ -0,0 +1,37 @@
# Copyright (c) 2015 OpenStack Foundation.
# All Rights Reserved.
#
# 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.
OVSDB_IDENTIFIER = 'ovsdb_identifier'
OVSDB_IP = 'ovsdb_ip'
OVSDB_PORT = 'ovsdb_port'
PRIVATE_KEY = 'private_key'
USE_SSL = 'use_ssl'
CERTIFICATE = 'certificate'
CA_CERT = 'ca_cert'
class L2GatewayConfig(object):
def __init__(self, ovsdb_config):
self.use_ssl = False
if ovsdb_config.get(USE_SSL, None):
self.use_ssl = ovsdb_config[USE_SSL]
self.private_key = ovsdb_config[PRIVATE_KEY]
self.certificate = ovsdb_config[CERTIFICATE]
self.ca_cert = ovsdb_config[CA_CERT]
self.ovsdb_identifier = ovsdb_config[OVSDB_IDENTIFIER]
self.ovsdb_ip = ovsdb_config[OVSDB_IP]
self.ovsdb_port = ovsdb_config[OVSDB_PORT]
self.ovsdb_fd = None

@ -0,0 +1,85 @@
# Copyright (c) 2015 OpenStack Foundation.
# All Rights Reserved.
#
# 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.
class PhysicalLocator(object):
def __init__(self, uuid, dst_ip):
self.uuid = uuid
self.dst_ip = dst_ip
class PhysicalSwitch(object):
def __init__(self, uuid, name, tunnel_ip):
self.uuid = uuid
self.name = name
self.tunnel_ip = tunnel_ip
class PhysicalPort(object):
def __init__(self, uuid, name, phys_switch_id):
self.uuid = uuid
self.name = name
self.physical_switch_id = phys_switch_id
self.vlan_bindings = None
class LogicalSwitch(object):
def __init__(self, uuid, name, key):
self.uuid = uuid
self.name = name
self.key = key
class UcastMacsLocal(object):
def __init__(self, uuid, mac, logical_switch_id, physical_locator_id,
ip_address):
self.uuid = uuid
self.mac = mac
self.logical_switch_id = logical_switch_id
self.physical_locator_id = physical_locator_id
self.ip_address = ip_address
class UcastMacsRemote(object):
def __init__(self, uuid, mac, logical_switch_id, physical_locator_id,
ip_address):
self.uuid = uuid
self.mac = mac
self.logical_switch_id = logical_switch_id
self.physical_locator_id = physical_locator_id
self.ip_address = ip_address
class VlanBinding(object):
def __init__(self, vlan, logical_switch_uuid):
self.vlan = vlan
self.logical_switch_uuid = logical_switch_uuid
class McastMacsLocal(object):
def __init__(self, uuid, mac, logical_switch, locator_set,
ip_address):
self.uuid = uuid
self.mac = mac
self.logical_switch_id = logical_switch
self.locator_set = locator_set
self.ip_address = ip_address
class PhysicalLocatorSet(object):
def __init__(self, uuid, locators):
self.uuid = uuid
self.locators = self.locators

@ -1,23 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2010-2011 OpenStack Foundation
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# 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.
from oslotest import base
class TestCase(base.BaseTestCase):
"""Test case base class for all unit tests."""

@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
# 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.
"""
test_networking_l2gw
----------------------------------
Tests for `networking_l2gw` module.
"""
from networking_l2gw.tests import base
class TestNetworking_l2gw(base.TestCase):
def test_something(self):
pass

@ -0,0 +1,41 @@
# Copyright (c) 2015 OpenStack Foundation.
# All Rights Reserved.
#
# 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.
import mock
from neutron.tests import base
from networking_l2gw.services.l2gateway.agent import agent_api
class L2GatewayAgentApiTestCase(base.BaseTestCase):
def setUp(self):
self.client_mock_p = mock.patch.object(agent_api.n_rpc, 'get_client')
self.client_mock = self.client_mock_p.start()
self.ctxt = mock.ANY
self.topic = 'foo_topic'
self.host = 'foo_host'
self.agent_rpc = agent_api.L2GatewayAgentApi(
self.topic, self.ctxt, self.host)
super(L2GatewayAgentApiTestCase, self).setUp()
def test_update_ovsdb_changes(self):
cctxt = mock.Mock()
self.agent_rpc.client.prepare.return_value = cctxt
self.agent_rpc.update_ovsdb_changes(mock.ANY)
cctxt.call.assert_called_with(
self.ctxt, 'update_ovsdb_changes', ovsdb_data=mock.ANY)
Loading…
Cancel
Save