]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
bug #891267 : for XS, grab iface-id from XAPI directly if needed.
authorDan Wendlandt <dan@nicira.com>
Wed, 16 Nov 2011 18:07:03 +0000 (10:07 -0800)
committerDan Wendlandt <dan@nicira.com>
Wed, 16 Nov 2011 18:07:03 +0000 (10:07 -0800)
The version of OVS that ships with XenServer by default does not include
the script to automatically sync the XAPI other_config:nicira-iface-id
field of a VIF with the external_ids:iface-id in the OVS interfaces table.
Thus, make the agent grab the value directly from XAPI if iface-id is
not already populated.

Change-Id: Id01d9da1761016bcd983ad06621c62e94b2445c1

plugins/openvswitch-plugin/lib/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py

index 2d5376f5196dad4b38687369c18c8256da96eff9..398b8b9947c479d1f63d101edbbcd6cb79f2cebb 100755 (executable)
@@ -130,17 +130,34 @@ class OVSBridge:
     def get_port_stats(self, port_name):
         return self.db_get_map("Interface", port_name, "statistics")
 
+    def get_xapi_iface_id(self, xs_vif_uuid):
+        return self.run_cmd(
+                        ["xe",
+                        "vif-param-get",
+                        "param-name=other-config",
+                        "param-key=nicira-iface-id",
+                        "uuid=%s" % xs_vif_uuid]).strip()
+
     # returns a VIF object for each VIF port
     def get_vif_ports(self):
         edge_ports = []
         port_names = self.get_port_name_list()
         for name in port_names:
             external_ids = self.db_get_map("Interface", name, "external_ids")
+            ofport = self.db_get_val("Interface", name, "ofport")
             if "iface-id" in external_ids and "attached-mac" in external_ids:
-                ofport = self.db_get_val("Interface", name, "ofport")
                 p = VifPort(name, ofport, external_ids["iface-id"],
                             external_ids["attached-mac"], self)
                 edge_ports.append(p)
+            elif "xs-vif-uuid" in external_ids and \
+                 "attached-mac" in external_ids:
+                # if this is a xenserver and iface-id is not automatically
+                # synced to OVS from XAPI, we grab it from XAPI directly
+                iface_id = self.get_xapi_iface_id(external_ids["xs-vif-uuid"])
+                p = VifPort(name, ofport, iface_id,
+                            external_ids["attached-mac"], self)
+                edge_ports.append(p)
+
         return edge_ports