Fix ovs_parse_bridge script
- link_state field in interface object is list
- provide compatibility with pike release
Change-Id: Ifd365fcfc4380b950496f5f0bb5148150a1d3b30
Related-bug: PROD-34839
diff --git a/telegraf/files/script/ovs_parse_bridge.py b/telegraf/files/script/ovs_parse_bridge.py
index 1f47aff..e40cded 100644
--- a/telegraf/files/script/ovs_parse_bridge.py
+++ b/telegraf/files/script/ovs_parse_bridge.py
@@ -34,8 +34,7 @@
import sys
from ovsdbapp.backend.ovs_idl import connection
-from ovsdbapp.schema.ovn_northbound import impl_idl
-
+from ovsdbapp.schema.open_vswitch import impl_idl
SOCKET_PATH = 'unix:/run/openvswitch/db.sock'
DB_NAME = 'Open_vSwitch'
@@ -70,9 +69,9 @@
idl = connection.OvsdbIdl.from_server(SOCKET_PATH, DB_NAME)
conn = connection.Connection(idl=idl, timeout=CONN_TIMEOUT)
- api = impl_idl.OvnNbApiIdlImpl(conn)
+ api = impl_idl.OvsdbIdl(conn)
- for br_id, bridge in api.tables['Bridge'].rows.items():
+ for br_id, bridge in api._tables['Bridge'].rows.items():
print(BR_CNT_TMPL.format('ovs_bridge_port',
format_labels(bridge),
@@ -86,7 +85,7 @@
for iface in port.interfaces:
labels = format_labels(bridge, port, iface)
- if iface.link_state == 'up':
+ if len(iface.link_state) == 1 and iface.link_state[0] == 'up':
status = 1
if len(iface.error) > 0:
status = 2