On Fri, 9 Mar 2012 11:50:12 +0900
Isaku Yamahata <[email protected]> wrote:

> On Thu, Mar 08, 2012 at 12:29:38PM +0900, FUJITA Tomonori wrote:
>> On Thu, 8 Mar 2012 09:55:57 +0900
>> FUJITA Tomonori <[email protected]> wrote:
>> 
>> > ryu is a distributed NOS, that is, multiple ryu instances work
>> > together. They need to share some information (e.g. set of ports in a
>> > logically L2 network) by using some kinda storage, KVS, database, NFS,
>> > or something else.
>> > 
>> > This adds the simple memcached server feature to ryu so that you can
>> > develop and test ryu without setting up Memcached.
>> > 
>> > Several NoSQL implementations support Memcached protocol so you can
>> > switch to one of these real NoSQL implementations.
>> > 
>> > Signed-off-by: FUJITA Tomonori <[email protected]>
>> > ---
>> >  bin/ryu-manager           |    6 +++++
>> >  ryu/app/fake_memcached.py |   49 
>> > +++++++++++++++++++++++++++++++++++++++++++++
>> >  2 files changed, 55 insertions(+), 0 deletions(-)
>> >  create mode 100644 ryu/app/fake_memcached.py
>> 
>> On the top of the above patch, I like to convert the simple_isolation
>> stuff to use memcached in the following way.
>> 
>> We need an abstraction layer to hide storage protocols (memcached,
>> rdb, whatever) but I like to start with the straight conversion first.
>> 
>> In addition, we need to think about the data structures of the simple
>> isolation. The current data structures is not ideal for simple storage
>> like KVS. But again, I like to start with the straight conversion.
> 
> Makes sense. 
> Instead of creating client each request, the connection can be passed
> to constructor. something like
> class MacToNetwork(object):
>     def __init__(self, mc)
>         self.mc = mc
> 
> Or if we don't want to change the signature for now,
> 
> class MacToNetwork(object):
>     def __init__(self, nw)
>         self.mc = memcache.Client(['127.0.0.1:11211'])
> 

I go with this since I don't want large changes for this anyway.

>> =
>> >From c9e795088bd3fbe5aced90cb39315785fd3b4e45 Mon Sep 17 00:00:00 2001
>> From: FUJITA Tomonori <[email protected]>
>> Date: Wed, 7 Mar 2012 19:21:36 -0800
>> Subject: [PATCH] convert MacToNetwork to use memcached
>> 
>> Signed-off-by: FUJITA Tomonori <[email protected]>
>> ---
>>  ryu/controller/mac_to_network.py |   18 ++++++++++++------
>>  1 files changed, 12 insertions(+), 6 deletions(-)
>> 
>> diff --git a/ryu/controller/mac_to_network.py 
>> b/ryu/controller/mac_to_network.py
>> index bc18929..4bfe8dc 100644
>> --- a/ryu/controller/mac_to_network.py
>> +++ b/ryu/controller/mac_to_network.py
>> @@ -14,6 +14,7 @@
>>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>>  
>>  import logging
>> +import memcache
>>  
>>  from ryu.exception import MacAddressDuplicated
>>  from ryu.lib.mac import haddr_to_str
>> @@ -24,20 +25,24 @@ LOG = logging.getLogger('ryu.controller.mac_to_network')
>>  class MacToNetwork(object):
>>      def __init__(self, nw):
>>          self.mac_to_net = {}
>> -        self.dpid = {}
>> -        self.nw = nw
> 
> eliminate mac_to_net?

Yeah, right.

>>  
>>      def get_network(self, mac, default=None):
>> -        return self.mac_to_net.get(mac, default)
>> +        mc = memcache.Client(['127.0.0.1:11211'])
>> +        net = mc.get(mac)
>> +        if net:
>> +            return net
>> +        else:
>> +            default
> 
> return default

Oops,

bty, why simple_isolation needs dpset? network moduoles keep the list
of dps, right? Why can't we do something like the following?

Note that it's not tested at all.

diff --git a/ryu/app/simple_isolation.py b/ryu/app/simple_isolation.py
index f547529..1f378a0 100644
--- a/ryu/app/simple_isolation.py
+++ b/ryu/app/simple_isolation.py
@@ -304,8 +304,8 @@ class SimpleIsolation(object):
                 return
 
         for mac_ in self.mac2port.mac_list(datapath_id, port_no):
-            for dp in self.dpset.get_all():
-                if self.mac2port.port_get(dp.id, mac_) is None:
+            for dpid in self.nw.get_dpid_list():
+                if self.mac2port.port_get(dpid, mac_) is None:
                     continue
 
                 wildcards = dp.ofproto.OFPFW_ALL
diff --git a/ryu/controller/network.py b/ryu/controller/network.py
index 0c61ba0..00dabbf 100644
--- a/ryu/controller/network.py
+++ b/ryu/controller/network.py
@@ -139,6 +139,9 @@ class Network(object):
         for port_no in ports:
             self.port_added(datapath, port_no)
 
+    def get_dpid_list(self):
+        return [dpid for dpid, _port in self.dpids.iteritems()]
+
     def port_added(self, datapath, port_no):
         if port_no == 0 or port_no >= datapath.ofproto.OFPP_MAX:
             # skip fake output ports

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to