aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/openstack/neutron/plugin/networking-onos/README.onos29
-rw-r--r--framework/src/openstack/neutron/plugin/networking-onos/__init__.py0
-rw-r--r--framework/src/openstack/neutron/plugin/networking-onos/mech_driver.py133
3 files changed, 162 insertions, 0 deletions
diff --git a/framework/src/openstack/neutron/plugin/networking-onos/README.onos b/framework/src/openstack/neutron/plugin/networking-onos/README.onos
new file mode 100644
index 00000000..667fa36c
--- /dev/null
+++ b/framework/src/openstack/neutron/plugin/networking-onos/README.onos
@@ -0,0 +1,29 @@
+Open Networking Operating System (ONOS) ML2 MechanismDriver
+==========================================================
+ONOS is a carrier grade SDN open operating system designed for
+High Availability, scale-out and better performance.
+
+ http://www.onosproject.org/
+
+Mode of Working:
+================
+The networking-onos project provides a thin layer which makes the
+communication between ONOS and openstack neutron possible via ReST
+call. The driver code can be downloaded from:
+
+ https://git.openstack.org/cgit/openstack/networking-onos
+
+Using ONOS ML2 MechanismDriver
+==============================
+To use ONOS ML2 MechanismDriver one should
+1. Make sure networking-onos code is downloaded and installed. If doing
+ mannually then download the code, go inside networking_onos folder
+ and finally run "sudo python setup.py install" otherwise install
+ using pip.
+
+2. Configure ONOS as the required ML2 "mechanism_drivers" in
+ neutron/plugins/ml2/ml2_conf.ini:
+
+ mechanism_drivers=onos
+
+3. Configure "[ml2_onos]" in networking_onos/etc/ml2_onos_conf.ini \ No newline at end of file
diff --git a/framework/src/openstack/neutron/plugin/networking-onos/__init__.py b/framework/src/openstack/neutron/plugin/networking-onos/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/framework/src/openstack/neutron/plugin/networking-onos/__init__.py
diff --git a/framework/src/openstack/neutron/plugin/networking-onos/mech_driver.py b/framework/src/openstack/neutron/plugin/networking-onos/mech_driver.py
new file mode 100644
index 00000000..207dc699
--- /dev/null
+++ b/framework/src/openstack/neutron/plugin/networking-onos/mech_driver.py
@@ -0,0 +1,133 @@
+# Copyright (c) 2015 Huawei Technologies India Pvt Ltd
+# 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 requests
+
+from oslo_config import cfg
+#from oslo_log import helpers as log_helpers
+from neutron.openstack.common import log as logging
+from neutron.openstack.common import jsonutils
+
+from neutron.plugins.ml2 import driver_api as api
+
+LOG = logging.getLogger(__name__)
+
+ONOS_DRIVER_OPTS = [
+ cfg.StrOpt('path',
+ default='',
+ help=_('ONOS ReST interface URL')),
+ cfg.StrOpt('username',
+ default='',
+ help=_('Username for authentication.')),
+ cfg.StrOpt('password',
+ default='',
+ secret=True, # do not expose value in the logs
+ help=_('Password for authentication.'))
+]
+
+cfg.CONF.register_opts(ONOS_DRIVER_OPTS, "ml2_onos")
+
+
+def send_msg(onos_path, onos_auth, msg_type, entity_path, entity=None):
+ """Send message to the ONOS controller."""
+
+ path = '/'.join([onos_path, entity_path])
+ LOG.debug("Sending MSG (%(msg)) URL (%(path)s) JSON (%(entity)s)",
+ {'msg': msg_type, 'path': path, 'entity': entity})
+ hdr = {'Content-Type': 'application/json'}
+ body = jsonutils.dumps(entity, indent=2) if entity else None
+ req = requests.request(method=msg_type, url=path,
+ headers=hdr, data=body,
+ auth=onos_auth)
+ # Let's raise voice for an error
+ req.raise_for_status()
+
+
+class ONOSMechanismDriver(api.MechanismDriver):
+
+ """Open Networking Operating System ML2 Driver for Neutron.
+
+ Code which makes communication between ONOS and OpenStack Neutron
+ possible.
+ """
+ def __init__(self):
+ conf = cfg.CONF.ml2_onos
+ self.onos_path = conf.url_path
+ self.onos_auth = (conf.username, conf.password)
+
+ def initialize(self):
+ # No action required as of now. Can be extended in
+ # the future if required.
+ pass
+
+ #@log_helpers.log_method_call
+ def create_network_postcommit(self, context):
+ entity_path = 'networks/' + context.current['id']
+ resource = context.current.copy()
+ send_msg(self.onos_path, self.onos_auth, 'post',
+ entity_path, {'network': resource})
+
+ #@log_helpers.log_method_call
+ def update_network_postcommit(self, context):
+ entity_path = 'networks/' + context.current['id']
+ resource = context.current.copy()
+ send_msg(self.onos_path, self.onos_auth, 'put',
+ entity_path, {'network': resource})
+
+ #@log_helpers.log_method_call
+ def delete_network_postcommit(self, context):
+ entity_path = 'networks/' + context.current['id']
+ send_msg(self.onos_path, self.onos_auth, 'delete',
+ entity_path)
+
+ #@log_helpers.log_method_call
+ def create_subnet_postcommit(self, context):
+ entity_path = 'subnets/' + context.current['id']
+ resource = context.current.copy()
+ send_msg(self.onos_path, self.onos_auth, 'post',
+ entity_path, {'subnet': resource})
+
+ #@log_helpers.log_method_call
+ def update_subnet_postcommit(self, context):
+ entity_path = 'subnets/' + context.current['id']
+ resource = context.current.copy()
+ send_msg(self.onos_path, self.onos_auth, 'put',
+ entity_path, {'subnet': resource})
+
+ #@log_helpers.log_method_call
+ def delete_subnet_postcommit(self, context):
+ entity_path = 'subnets/' + context.current['id']
+ send_msg(self.onos_path, self.onos_auth, 'delete',
+ entity_path)
+
+ #@log_helpers.log_method_call
+ def create_port_postcommit(self, context):
+ entity_path = 'ports/' + context.current['id']
+ resource = context.current.copy()
+ send_msg(self.onos_path, self.onos_auth, 'post',
+ entity_path, {'port': resource})
+
+ #@log_helpers.log_method_call
+ def update_port_postcommit(self, context):
+ entity_path = 'ports/' + context.current['id']
+ resource = context.current.copy()
+ send_msg(self.onos_path, self.onos_auth, 'put',
+ entity_path, {'port': resource})
+
+ #@log_helpers.log_method_call
+ def delete_port_postcommit(self, context):
+ entity_path = 'ports/' + context.current['id']
+ send_msg(self.onos_path, self.onos_auth, 'delete',
+ entity_path)