@@ -128,15 +128,15 @@ def init(self, vm_set_name, topo, vm_base, dut_fp_ports, ptf_exists=True):
128128 self .vm_base_index = self .vm_names .index (vm_base )
129129 else :
130130 raise Exception ('VM_base "%s" should be presented in current vm_names: %s' % (vm_base , str (self .vm_names )))
131- for k , v in topo ['VMs' ].iteritems ():
131+ for k , v in topo ['VMs' ].items ():
132132 if self .vm_base_index + v ['vm_offset' ] < len (self .vm_names ):
133133 self .VMs [k ] = v
134134
135- for hostname , attrs in self .VMs .iteritems ():
135+ for hostname , attrs in self .VMs .items ():
136136 vmname = self .vm_names [self .vm_base_index + attrs ['vm_offset' ]]
137137 if len (attrs ['vlans' ]) > len (self .get_bridges (vmname )):
138138 raise Exception ("Wrong vlans parameter for hostname %s, vm %s. Too many vlans. Maximum is %d" % (hostname , vmname , len (self .get_bridges (vmname ))))
139-
139+
140140 if 'host_interfaces' in topo :
141141 self .host_interfaces = topo ['host_interfaces' ]
142142 else :
@@ -180,14 +180,14 @@ def update(self):
180180
181181 def extract_vm_vlans (self ):
182182 vlans = []
183- for attr in self .VMs .itervalues ():
183+ for attr in self .VMs .values ():
184184 vlans .extend (attr ['vlans' ])
185185
186186 return vlans
187187
188188 def create_bridges (self ):
189189 for vm in self .vm_names :
190- for fp_num in xrange (self .max_fp_num ):
190+ for fp_num in range (self .max_fp_num ):
191191 fp_br_name = OVS_FP_BRIDGE_TEMPLATE % (vm , fp_num )
192192 self .create_ovs_bridge (fp_br_name , self .fp_mtu )
193193
@@ -358,7 +358,7 @@ def unbind_mgmt_port(self, mgmt_port):
358358 return
359359
360360 def bind_fp_ports (self , disconnect_vm = False ):
361- for attr in self .VMs .itervalues ():
361+ for attr in self .VMs .values ():
362362 for vlan_num , vlan in enumerate (attr ['vlans' ]):
363363 injected_iface = INJECTED_INTERFACES_TEMPLATE % (self .vm_set_name , vlan )
364364 br_name = OVS_FP_BRIDGE_TEMPLATE % (self .vm_names [self .vm_base_index + attr ['vm_offset' ]], vlan_num )
@@ -368,7 +368,7 @@ def bind_fp_ports(self, disconnect_vm=False):
368368 return
369369
370370 def unbind_fp_ports (self ):
371- for attr in self .VMs .itervalues ():
371+ for attr in self .VMs .values ():
372372 for vlan_num , vlan in enumerate (attr ['vlans' ]):
373373 br_name = OVS_FP_BRIDGE_TEMPLATE % (self .vm_names [self .vm_base_index + attr ['vm_offset' ]], vlan_num )
374374 vm_iface = OVS_FP_TAP_TEMPLATE % (self .vm_names [self .vm_base_index + attr ['vm_offset' ]], vlan_num )
@@ -385,7 +385,7 @@ def bind_vm_backplane(self):
385385
386386 self .update ()
387387
388- for attr in self .VMs .itervalues ():
388+ for attr in self .VMs .values ():
389389 vm_name = self .vm_names [self .vm_base_index + attr ['vm_offset' ]]
390390 bp_port_name = OVS_BP_TAP_TEMPLATE % vm_name
391391
@@ -517,7 +517,7 @@ def cmd(cmdline):
517517
518518 with open (cmd_debug_fname , 'a' ) as fp :
519519 pprint ("OUTPUT: %s" % stdout , fp )
520- return stdout
520+ return stdout . decode ( 'utf-8' )
521521
522522 @staticmethod
523523 def get_ovs_br_ports (bridge ):
@@ -556,7 +556,7 @@ def get_ovs_port_bindings(bridge, vlan_iface = None):
556556 if vlan_iface is None or vlan_iface in result :
557557 return result
558558 time .sleep (2 * retries + 1 )
559- # Flow reaches here when vlan_iface not present in result
559+ # Flow reaches here when vlan_iface not present in result
560560 raise Exception ("Can't find vlan_iface_id" )
561561
562562 @staticmethod
@@ -637,7 +637,7 @@ def check_topo(topo):
637637 if not isinstance (VMs , dict ):
638638 raise Exception ("topo['VMs'] should be a dictionary" )
639639
640- for hostname , attrs in VMs .iteritems ():
640+ for hostname , attrs in VMs .items ():
641641 if 'vlans' not in attrs or not isinstance (attrs ['vlans' ], list ):
642642 raise Exception ("topo['VMs']['%s'] should contain 'vlans' with a list of vlans" % hostname )
643643
0 commit comments