This patch is not for merge yet as I haven't tested it yet.
I'll test this patch the next week.

As vxlan support would come, allow more option type in addition to
ofp server address.
This patch is just clean up and n preparation for vxlan.

Signed-off-by: Isaku Yamahata <[email protected]>
---
 quantum/plugins/ryu/agent/ryu_quantum_agent.py |   12 +++++-----
 quantum/plugins/ryu/db/api.py                  |   14 +++++++----
 quantum/plugins/ryu/db/models.py               |   28 +++++++++++++----------
 quantum/plugins/ryu/ryu_quantum_plugin.py      |    4 +-
 4 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/quantum/plugins/ryu/agent/ryu_quantum_agent.py 
b/quantum/plugins/ryu/agent/ryu_quantum_agent.py
index a46ff2b..a15713d 100755
--- a/quantum/plugins/ryu/agent/ryu_quantum_agent.py
+++ b/quantum/plugins/ryu/agent/ryu_quantum_agent.py
@@ -260,17 +260,17 @@ class OVSBridge(object):
 def check_ofp_mode(db):
     LOG.debug("checking db")
 
-    servers = db.ofp_server.all()
+    servers = db.ryu_options.all()
 
     ofp_controller_addr = None
     ofp_rest_api_addr = None
     for serv in servers:
-        if serv.host_type == "REST_API":
-            ofp_rest_api_addr = serv.address
-        elif serv.host_type == "controller":
-            ofp_controller_addr = serv.address
+        if serv.opt_name == "REST_API":
+            ofp_rest_api_addr = serv.value
+        elif serv.opt_name == "controller":
+            ofp_controller_addr = serv.value
         else:
-            LOG.warn("ignoring unknown server type %s", serv)
+            LOG.warn("ignoring unknown option type %s", serv)
 
     LOG.debug("controller %s", ofp_controller_addr)
     LOG.debug("api %s", ofp_rest_api_addr)
diff --git a/quantum/plugins/ryu/db/api.py b/quantum/plugins/ryu/db/api.py
index a0462d5..75162cf 100644
--- a/quantum/plugins/ryu/db/api.py
+++ b/quantum/plugins/ryu/db/api.py
@@ -27,15 +27,19 @@ from quantum.plugins.ryu.db import models
 LOG = logging.getLogger(__name__)
 
 
-def set_ofp_servers(hosts):
+def set_ryu_option(name, value):
     session = db.get_session()
-    session.query(models.OFPServer).delete()
-    for (host_address, host_type) in hosts:
-        host = models.OFPServer(host_address, host_type)
-        session.add(host)
+    session.query(models.RyuOption).filter_by(opt_name=name).delete()
+    opt = models.RyuOption(name, value)
+    session.add(opt)
     session.flush()
 
 
+def set_ofp_servers(hosts):
+    for (opt_name, host_address) in hosts:
+        set_ryu_option(opt_name, host_address)
+
+
 def ovs_node_update(dpid, tunnel_ip):
     session = db.get_session()
     dpid_or_ip = or_(models.OVSNode.dpid == dpid,
diff --git a/quantum/plugins/ryu/db/models.py b/quantum/plugins/ryu/db/models.py
index 87a8ff6..4f88963 100644
--- a/quantum/plugins/ryu/db/models.py
+++ b/quantum/plugins/ryu/db/models.py
@@ -22,24 +22,28 @@ from quantum.db.models import BASE
 from quantum.db.models import QuantumBase
 
 
-class OFPServer(BASE, QuantumBase):
+# RYU REST API location: netloc <host ip address>:<port>
+OPT_REST_API = 'REST_API'
+
+# RYU controller location: netloc <host ip address>:<port>
+OPT_CONTROLLER = 'controller'
+
+
+class RyuOption(BASE, QuantumBase):
     """Openflow Server/API address"""
-    __tablename__ = 'ofp_server'
+    __tablename__ = 'ryu_options'
 
     id = Column(Integer, primary_key=True, autoincrement=True)
-    address = Column(String(255), primary_key=True)  # netloc
-                                                     # <host ip address>:<port>
-    host_type = Column(String(255))     # server type
-                                        # Controller, REST_API
+    opt_name = Column(String(255))
+    value = Column(String(255))
 
-    def __init__(self, address, host_type):
-        super(OFPServer, self).__init__()
-        self.address = address
-        self.host_type = host_type
+    def __init__(self, opt_name, value):
+        super(RyuOption, self).__init__()
+        self.opt_name = opt_name
+        self.value = value
 
     def __repr__(self):
-        return "<OFPServer(%s,%s,%s)>" % (self.id, self.address,
-                                          self.host_type)
+        return "<RyuOption(%s,%s,%s)>" % (self.id, self.opt_name, self.value)
 
 
 class OVSNode(BASE, QuantumBase):
diff --git a/quantum/plugins/ryu/ryu_quantum_plugin.py 
b/quantum/plugins/ryu/ryu_quantum_plugin.py
index b952264..65e5991 100644
--- a/quantum/plugins/ryu/ryu_quantum_plugin.py
+++ b/quantum/plugins/ryu/ryu_quantum_plugin.py
@@ -44,8 +44,8 @@ class 
OFPRyuDriver(ovs_quantum_plugin_base.OVSQuantumPluginDriverBase):
         if ofp_con_host is None or ofp_api_host is None:
             raise q_exc.Invalid("invalid configuration. check ryu.ini")
 
-        hosts = [(ofp_con_host, ofp_service_type.CONTROLLER),
-                 (ofp_api_host, ofp_service_type.REST_API)]
+        hosts = [(ofp_service_type.CONTROLLER, ofp_con_host),
+                 (ofp_service_type.REST_API, ofp_api_host)]
         ryu_db.set_ofp_servers(hosts)
 
         self.client = client.OFPClient(ofp_api_host)
-- 
1.7.4.1



------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to