1- #!/usr/bin/python
1+ #!/usr/bin/python3
22# Licensed to the Apache Software Foundation (ASF) under one
33# or more contributor license agreements. See the NOTICE file
44# distributed with this work for additional information
@@ -37,7 +37,7 @@ def setup_ovs_bridge(bridge, key, cs_host_id):
3737 res = lib .check_switch ()
3838 if res != "SUCCESS" :
3939 #return "FAILURE:%s" % res
40- return 'false'
40+ return 'false'
4141
4242 logging .debug ("About to manually create the bridge:%s" % bridge )
4343 #set gre_key to bridge
@@ -50,19 +50,19 @@ def setup_ovs_bridge(bridge, key, cs_host_id):
5050 logging .debug ("Bridge has been manually created:%s" % res )
5151 if res :
5252# result = "FAILURE:%s" % res
53- result = 'false'
53+ result = 'false'
5454 else :
5555 # Verify the bridge actually exists, with the gre_key properly set
5656 res = lib .do_cmd ([lib .VSCTL_PATH , "get" , "bridge" ,
5757 bridge , "other_config:gre_key" ])
58- if key in res :
58+ if key in str ( res ) :
5959# result = "SUCCESS:%s" % bridge
6060 result = 'true'
6161 else :
6262# result = "FAILURE:%s" % res
6363 result = 'false'
6464
65- lib .do_cmd ([lib .VSCTL_PATH , "set" , "bridge" , bridge , "other_config:is-ovs-tun-network=True" ])
65+ lib .do_cmd ([lib .VSCTL_PATH , "set" , "bridge" , bridge , "other_config:is-ovs-tun-network=True" ])
6666 #get list of hosts using this bridge
6767 conf_hosts = lib .do_cmd ([lib .VSCTL_PATH , "get" ,"bridge" , bridge ,"other_config:ovs-host-setup" ])
6868 #add cs_host_id to list of hosts using this bridge
@@ -162,7 +162,7 @@ def create_tunnel(bridge, remote_ip, key, src_host, dst_host):
162162 wait = [lib .VSCTL_PATH , "--timeout=30" , "wait-until" , "bridge" ,
163163 bridge , "--" , "get" , "bridge" , bridge , "name" ]
164164 res = lib .do_cmd (wait )
165- if bridge not in res :
165+ if bridge not in str ( res ) :
166166 logging .debug ("WARNING:Can't find bridge %s for creating " +
167167 "tunnel!" % bridge )
168168# return "FAILURE:NO_BRIDGE"
@@ -185,7 +185,7 @@ def create_tunnel(bridge, remote_ip, key, src_host, dst_host):
185185 # Expecting python-style list as output
186186 iface_list = []
187187 if len (res ) > 2 :
188- iface_list = res .strip ()[1 :- 1 ].split (',' )
188+ iface_list = res .strip ()[1 :- 1 ].split (b ',' )
189189 if len (iface_list ) != 1 :
190190 logging .debug ("WARNING: Unexpected output while verifying " +
191191 "port %s on bridge %s" % (name , bridge ))
@@ -202,7 +202,7 @@ def create_tunnel(bridge, remote_ip, key, src_host, dst_host):
202202 key_validation = lib .do_cmd (verify_interface_key )
203203 ip_validation = lib .do_cmd (verify_interface_ip )
204204
205- if not key in key_validation or not remote_ip in ip_validation :
205+ if not key in str ( key_validation ) or not remote_ip in str ( ip_validation ) :
206206 logging .debug ("WARNING: Unexpected output while verifying " +
207207 "interface %s on bridge %s" % (name , bridge ))
208208# return "FAILURE:VERIFY_INTERFACE_FAILED"
@@ -213,12 +213,18 @@ def create_tunnel(bridge, remote_ip, key, src_host, dst_host):
213213 iface_uuid , "ofport" ]
214214 tun_ofport = lib .do_cmd (cmd_tun_ofport )
215215 # Ensure no trailing LF
216- if tun_ofport .endswith ('\n ' ):
216+ if tun_ofport .endswith (b '\n ' ):
217217 tun_ofport = tun_ofport [:- 1 ]
218218
219- ovs_tunnel_network = lib .do_cmd ([lib .VSCTL_PATH , "get" , "bridge" , bridge , "other_config:is-ovs-tun-network" ])
220- ovs_vpc_distributed_vr_network = lib .do_cmd ([lib .VSCTL_PATH , "get" , "bridge" , bridge ,
221- "other_config:is-ovs_vpc_distributed_vr_network" ])
219+ try :
220+ ovs_tunnel_network = lib .do_cmd ([lib .VSCTL_PATH , "get" , "bridge" , bridge , "other_config:is-ovs-tun-network" ])
221+ except :
222+ ovs_tunnel_network = 'False'
223+ try :
224+ ovs_vpc_distributed_vr_network = lib .do_cmd ([lib .VSCTL_PATH , "get" , "bridge" , bridge ,
225+ "other_config:is-ovs_vpc_distributed_vr_network" ])
226+ except :
227+ ovs_vpc_distributed_vr_network = 'False'
222228
223229 if ovs_tunnel_network == 'True' :
224230 # add flow entryies for dropping broadcast coming in from gre tunnel
0 commit comments