1
- #!/usr/bin/python
1
+ #!/usr/bin/python3
2
2
3
3
# Copyright (c) 2005-2022 Citrix Systems Inc.
4
4
# Copyright (c) 2022-12-01 Cloud Software Group Holdings, Inc.
38
38
import utils
39
39
import sys
40
40
import os
41
- import ConfigParser
41
+ import configparser
42
42
43
43
import testbase
44
44
import inspect
51
51
import test_report
52
52
import test_runner
53
53
from optparse import OptionParser
54
- from exceptions import *
54
+ import builtins as exceptions
55
55
56
56
MIN_VLAN = 0
57
57
MAX_VLAN = 4096
@@ -140,7 +140,7 @@ def parse_cmd_args():
140
140
141
141
if options .optionstr :
142
142
kvp_rec = kvp_string_to_rec (options .optionstr )
143
- for k , v in kvp_rec .iteritems ():
143
+ for k , v in kvp_rec .items ():
144
144
config [k ] = v
145
145
146
146
check_files (config )
@@ -155,7 +155,7 @@ def check_files(config):
155
155
if opt in config .keys ():
156
156
assert_file_exists (os .path .join (INSTALL_DIR , config [opt ]), label )
157
157
158
- for key , value in config ['netconf' ].iteritems ():
158
+ for key , value in config ['netconf' ].items ():
159
159
if key .startswith ('eth' ):
160
160
vf_driver_pkg = value ['vf_driver_pkg' ]
161
161
if vf_driver_pkg :
@@ -196,7 +196,7 @@ def parse_netconf_file(filename):
196
196
"""
197
197
utils .log .debug ("Parse network config file: %s" % filename )
198
198
199
- cp = ConfigParser .ConfigParser ()
199
+ cp = configparser .ConfigParser ()
200
200
cp .read (filename )
201
201
rec = {}
202
202
for section in cp .sections ():
@@ -282,7 +282,7 @@ def parse_section_static_net(cp, rec, section):
282
282
'should be in format of "static_<network_id>_<vlan_id>"' )
283
283
net = arr [1 ]
284
284
vlan = arr [2 ]
285
- if not unicode (net .strip ()).isdecimal () or not unicode (vlan .strip ()).isdecimal ():
285
+ if not str (net .strip ()).isdecimal () or not str (vlan .strip ()).isdecimal ():
286
286
raise utils .InvalidArgument ('static addressing section' , section ,
287
287
'should be valid network and/or vlan to determine' )
288
288
rec [section ] = parse_static_config (cp , section )
@@ -461,7 +461,7 @@ def pre_flight_checks(session, config):
461
461
# Check that we have at least two network adaptors, on the same network
462
462
recs = config ['netconf' ]
463
463
ifaces = {}
464
- for k , v in recs .iteritems ():
464
+ for k , v in recs .items ():
465
465
if k .startswith ('eth' ):
466
466
ifaces [k ] = v ['network_id' ]
467
467
@@ -479,8 +479,8 @@ def pre_flight_checks(session, config):
479
479
len (ifaces .keys ()), ifaces .keys ()))
480
480
481
481
# If less than 2 interfaces share the same network, raise an exception
482
- for k , v in ifaces .iteritems ():
483
- if ifaces .values ().count (v ) < 2 :
482
+ for k , v in ifaces .items ():
483
+ if list ( ifaces .values () ).count (v ) < 2 :
484
484
raise Exception ("Error: ethernet device %s on network %s is defined in the network config but does not have a matching partner. \
485
485
Please review the nework configuration and minumum requirements of this kit." % (k , v ))
486
486
0 commit comments