[ovs-discuss] [OVN] [networking-ovn] [networking-sfc] SFC and OVN

John McDowall jmcdowall at paloaltonetworks.com
Wed May 11 17:06:55 UTC 2016


Ryan,

Looks good apart from:

networking_ovn/common/extensions.py

There should be no changes to that file, I removed them as they are from an older prototype.

Regards

John

From: Ryan Moats <rmoats at us.ibm.com<mailto:rmoats at us.ibm.com>>
Date: Wednesday, May 11, 2016 at 9:59 AM
To: John McDowall <jmcdowall at paloaltonetworks.com<mailto:jmcdowall at paloaltonetworks.com>>
Cc: "discuss at openvswitch.org<mailto:discuss at openvswitch.org>" <discuss at openvswitch.org<mailto:discuss at openvswitch.org>>, OpenStack Development Mailing List <openstack-dev at lists.openstack.org<mailto:openstack-dev at lists.openstack.org>>
Subject: Re: [OVN] [networking-ovn] [networking-sfc] SFC and OVN


John McDowall <jmcdowall at paloaltonetworks.com<mailto:jmcdowall at paloaltonetworks.com>> wrote on 05/11/2016 11:30:07 AM:

> From: John McDowall <jmcdowall at paloaltonetworks.com<mailto:jmcdowall at paloaltonetworks.com>>
> To: Ryan Moats/Omaha/IBM at IBMUS
> Cc: "discuss at openvswitch.org<mailto:discuss at openvswitch.org>" <discuss at openvswitch.org<mailto:discuss at openvswitch.org>>, "OpenStack
> Development Mailing List" <openstack-dev at lists.openstack.org<mailto:openstack-dev at lists.openstack.org>>
> Date: 05/11/2016 11:30 AM
> Subject: Re: [OVN] [networking-ovn] [networking-sfc] SFC and OVN
>
> Ryan,
>
> Apologies for missing the _init_.py files – removed them and
> remerged. When I do a compare from my repo to main I see three files
> changed (which I think is correct):
>
> networking_ovn/ovsdb/commands.py
> networking_ovn/ovsdb/impl_idl_ovn.py
> networking_ovn/ovsdb/ovn_api.py
>
> I could be doing something wrong as not an expert at merging repos.
> If I am doing something wrong let me know and I will fix it.
>
> Regards
>
> John

So the change I made to common/extensions.py was to avoid a merge
conflict, and I double checked and yes, the changes I had to
plugin.py are spurious, so here is an updated/corrected patch for
you to check against:

>From eb93dc3984145f1b82be15d204c2f0790c1429bd Mon Sep 17 00:00:00 2001
From: RYAN D. MOATS <rmoats at us.ibm.com<mailto:rmoats at us.ibm.com>>
Date: Wed, 11 May 2016 09:10:18 -0500
Subject: [PATCH] test

Signed-off-by: RYAN D. MOATS <rmoats at us.ibm.com<mailto:rmoats at us.ibm.com>>
---
networking_ovn/common/extensions.py  |    1 +
networking_ovn/ovsdb/commands.py     |   78 ++++++++++++++++++++++++++++++++++
networking_ovn/ovsdb/impl_idl_ovn.py |   18 ++++++++
networking_ovn/ovsdb/ovn_api.py      |   49 +++++++++++++++++++++
4 files changed, 146 insertions(+), 0 deletions(-)

diff --git a/networking_ovn/common/extensions.py b/networking_ovn/common/extensions.py
index c171e11..55fc147 100644
--- a/networking_ovn/common/extensions.py
+++ b/networking_ovn/common/extensions.py
@@ -37,4 +37,5 @@ SUPPORTED_API_EXTENSIONS = [
    'subnet_allocation',
    'port-security',
    'allowed-address-pairs',
+    'sfi',
]
diff --git a/networking_ovn/ovsdb/commands.py b/networking_ovn/ovsdb/commands.py
index 7ea7a6f..68a747f 100644
--- a/networking_ovn/ovsdb/commands.py
+++ b/networking_ovn/ovsdb/commands.py
@@ -164,6 +164,84 @@ class DelLogicalPortCommand(BaseCommand):
        setattr(lswitch, 'ports', ports)
        self.api._tables['Logical_Port'].rows[lport.uuid].delete()

+class AddLogicalServiceCommand(BaseCommand):
+    def __init__(self, api, lservice, lswitch, may_exist, **columns):
+        super(AddLogicalServiceCommand, self).__init__(api)
+        self.lservice = lservice
+        self.lswitch = lswitch
+        self.may_exist = may_exist
+        self.columns = columns
+
+    def run_idl(self, txn):
+        try:
+            lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch',
+                                            'name', self.lswitch)
+            services= getattr(lswitch, 'services', [])
+        except idlutils.RowNotFound:
+            msg = _("Logical Switch %s does not exist") % self.lswitch
+            raise RuntimeError(msg)
+        if self.may_exist:
+            service = idlutils.row_by_value(self.api.idl,
+                                         'Logical_Service', 'name',
+                                         self.lservice, None)
+            if service:
+                return
+
+        lswitch.verify('services')
+
+        service = txn.insert(self.api._tables['Logical_Service'])
+        service.name = self.lservice
+        for col, val in self.columns.items():
+            setattr(service, col, val)
+        # add the newly created service to existing lswitch
+        services.append(service.uuid)
+        setattr(lswitch, 'services', services)
+
+class SetLogicalServiceCommand(BaseCommand):
+    def __init__(self, api, lservice, if_exists, **columns):
+        super(SetLogicalServiceCommand, self).__init__(api)
+        self.lservice = lservice
+        self.columns = columns
+        self.if_exists = if_exists
+
+    def run_idl(self, txn):
+        try:
+            service = idlutils.row_by_value(self.api.idl, 'Logical_Service',
+                                            'name', self.lservice)
+        except idlutils.RowNotFound:
+            if self.if_exists:
+                return
+            msg = _("Logical Service %s does not exist") % self.lservice
+            raise RuntimeError(msg)
+
+        for col, val in self.columns.items():
+            setattr(service, col, val)
+
+class DelLogicalServiceCommand(BaseCommand):
+    def __init__(self, api, lservice, lswitch, if_exists):
+        super(DelLogicalServiceCommand, self).__init__(api)
+        self.lservice = lservice
+        self.lswitch = lswitch
+        self.if_exists = if_exists
+
+    def run_idl(self, txn):
+        try:
+            lservice = idlutils.row_by_value(self.api.idl, 'Logical_Service',
+                                             'name', self.lservice)
+            lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch',
+                                            'name', self.lswitch)
+            services = getattr(lswitch, 'services', [])
+        except idlutils.RowNotFound:
+            if self.if_exists:
+                return
+            msg = _("Service %s does not exist") % self.lservice
+            raise RuntimeError(msg)
+
+        lswitch.verify('services')
+
+        services.remove(lservice)
+        setattr(lswitch, 'services', services)
+        self.api._tables['Logical_Service'].rows[lservice.uuid].delete()

class AddLRouterCommand(BaseCommand):
    def __init__(self, api, name, may_exist, **columns):
diff --git a/networking_ovn/ovsdb/impl_idl_ovn.py b/networking_ovn/ovsdb/impl_idl_ovn.py
index c3411f0..38623ac 100644
--- a/networking_ovn/ovsdb/impl_idl_ovn.py
+++ b/networking_ovn/ovsdb/impl_idl_ovn.py
@@ -77,6 +77,24 @@ class OvsdbOvnIdl(ovn_api.API):
                                               ext_id[0], ext_id[1],
                                               if_exists)

+    def create_lservice(self, lservice_name, lswitch_name, may_exist=True,
+                     **columns):
+        return cmd.AddLogicalServiceCommand(self, lservice_name, lswitch_name,
+                                         may_exist, **columns)
+
+    def set_lservice(self, lservice_name, if_exists=True, **columns):
+        return cmd.SetLogicalServiceCommand(self, lservice_name,
+                                         if_exists, **columns)
+
+    def delete_lservice(self, lservice_name=None, lswitch=None,
+                     ext_id=None, if_exists=True):
+        if lservice_name is not None:
+            return cmd.DelLogicalServiceCommand(self, lservice_name,
+                                             lswitch, if_exists)
+        else:
+            raise RuntimeError(_("Currently only supports "
+                                 "delete by lservice-name"))
+
    def create_lport(self, lport_name, lswitch_name, may_exist=True,
                     **columns):
        return cmd.AddLogicalPortCommand(self, lport_name, lswitch_name,
diff --git a/networking_ovn/ovsdb/ovn_api.py b/networking_ovn/ovsdb/ovn_api.py
index feca916..067488c 100644
--- a/networking_ovn/ovsdb/ovn_api.py
+++ b/networking_ovn/ovsdb/ovn_api.py
@@ -69,6 +69,55 @@ class API(object):
        :returns:         :class:`Command` with no result
        """

+
+
+
+    @abc.abstractmethod
+    def create_lservice(self, name, lswitch_name, may_exist=True, **columns):
+        """Create a command to add an OVN lservice
+
+        :param name:          The name of the lservice
+        :type name:           string
+        :param lswitch_name:  The name of the lswitch the lservice is created on
+        :type lswitch_name:   string
+        :param may_exist:     Do not fail if lservice already exists
+        :type may_exist:      bool
+        :param columns:       Dictionary of service columns
+                              Supported columns: app_port, in_port, out_port
+        :type columns:        dictionary
+        :returns:             :class:`Command` with no result
+        """
+
+    @abc.abstractmethod
+    def set_lservice(self, lservice_name, if_exists=True, **columns):
+        """Create a command to set OVN lservice fields
+
+        :param lservice_name:    The name of the lservice
+        :type lservice_name:     string
+        :param columns:       Dictionary of service columns
+                              Supported columns: app_port, in_port, out_port
+        :param if_exists:     Do not fail if lservice does not exist
+        :type if_exists:      bool
+        :type columns:        dictionary
+        :returns:             :class:`Command` with no result
+        """
+
+    @abc.abstractmethod
+    def delete_lservice(self, name=None, lswitch=None, ext_id=None,
+                     if_exists=True):
+        """Create a command to delete an OVN lservice
+
+        :param name:      The name of the lservice
+        :type name:       string
+        :param lswitch:   The name of the lswitch
+        :type lswitch:    string
+        :param ext_id:    The external id of the lservice
+        :type ext_id:     pair of <ext_id_key ,ext_id_value>
+        :param if_exists: Do not fail if the lservice does not exists
+        :type if_exists:  bool
+        :returns:         :class:`Command` with no result
+        """
+
    @abc.abstractmethod
    def create_lport(self, name, lswitch_name, may_exist=True, **columns):
        """Create a command to add an OVN lport
--
1.7.1



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://openvswitch.org/pipermail/ovs-discuss/attachments/20160511/c7e8dcea/attachment-0002.html>


More information about the discuss mailing list