Fix: "tuple_params" issue for Python 2/3 compatible code
change "lambda (i, x): i - x" to "lambda i_x: i_x[0] - i_x[1]" change "def func((tuple))" to "def func(params): (tup_params) = params" Story: 2002909 Task: 24568 Change-Id: I071be0ab525a580fe6ef201c4f71fa92e8b8b09b Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
fc9b6f94a8
commit
4d9e712c78
@ -482,7 +482,7 @@ def list_to_range(L=[]):
|
|||||||
""" Convert a list into a string of comma separate ranges.
|
""" Convert a list into a string of comma separate ranges.
|
||||||
E.g., [1,2,3,8,9,15] is converted to '1-3,8-9,15'
|
E.g., [1,2,3,8,9,15] is converted to '1-3,8-9,15'
|
||||||
"""
|
"""
|
||||||
G = (list(x) for _, x in groupby(enumerate(L), lambda (i, x): i - x))
|
G = (list(x) for _, x in groupby(enumerate(L), lambda i_x: i_x[0] - i_x[1]))
|
||||||
return ",".join(
|
return ",".join(
|
||||||
"-".join(map(str, (g[0][1], g[-1][1])[:len(g)])) for g in G)
|
"-".join(map(str, (g[0][1], g[-1][1])[:len(g)])) for g in G)
|
||||||
|
|
||||||
@ -505,7 +505,8 @@ def timeout_handler(signum, frame):
|
|||||||
raise TimeoutError('timeout')
|
raise TimeoutError('timeout')
|
||||||
|
|
||||||
|
|
||||||
def libvirt_domain_info_worker((host)):
|
def libvirt_domain_info_worker(tuple_hosts):
|
||||||
|
(host) = tuple_hosts
|
||||||
pid = os.getpid()
|
pid = os.getpid()
|
||||||
active_pids.update({pid: (host, time.time())})
|
active_pids.update({pid: (host, time.time())})
|
||||||
error = None
|
error = None
|
||||||
@ -519,11 +520,12 @@ def libvirt_domain_info_worker((host)):
|
|||||||
return (host, domain, topology, time.time(), error)
|
return (host, domain, topology, time.time(), error)
|
||||||
|
|
||||||
|
|
||||||
def do_libvirt_domain_info((host)):
|
def do_libvirt_domain_info(tuple_hosts):
|
||||||
"""
|
"""
|
||||||
Connect to libvirt for specified host, and retrieve per-domain information
|
Connect to libvirt for specified host, and retrieve per-domain information
|
||||||
including cpu affinity per vcpu.
|
including cpu affinity per vcpu.
|
||||||
"""
|
"""
|
||||||
|
(host) = tuple_hosts
|
||||||
domains = {}
|
domains = {}
|
||||||
topology = {}
|
topology = {}
|
||||||
if not host:
|
if not host:
|
||||||
@ -899,7 +901,7 @@ def print_all_tables(tenants=None,
|
|||||||
'memory', 'U:memory', 'A:mem_4K', 'A:mem_2M', 'A:mem_1G']:
|
'memory', 'U:memory', 'A:mem_4K', 'A:mem_2M', 'A:mem_1G']:
|
||||||
pt.align[C] = 'r'
|
pt.align[C] = 'r'
|
||||||
for host_name, H in sorted(hypervisors.items(),
|
for host_name, H in sorted(hypervisors.items(),
|
||||||
key=lambda (k, v): (natural_keys(k))):
|
key=lambda k_v1: (natural_keys(k_v1[0]))):
|
||||||
A = list(agg_h[host_name].keys())
|
A = list(agg_h[host_name].keys())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1020,7 +1022,7 @@ def print_all_tables(tenants=None,
|
|||||||
print
|
print
|
||||||
print('LOGICAL CPU TOPOLOGY (compute hosts):')
|
print('LOGICAL CPU TOPOLOGY (compute hosts):')
|
||||||
for host_name, topology in sorted(topologies.items(),
|
for host_name, topology in sorted(topologies.items(),
|
||||||
key=lambda (k, v): (natural_keys(k))):
|
key=lambda k_v2: (natural_keys(k_v2[0]))):
|
||||||
H = hypervisors[host_name]
|
H = hypervisors[host_name]
|
||||||
try:
|
try:
|
||||||
topology_idx = topologies_idx[host_name]
|
topology_idx = topologies_idx[host_name]
|
||||||
@ -1084,7 +1086,7 @@ def print_all_tables(tenants=None,
|
|||||||
print
|
print
|
||||||
print('LOGICAL CPU TOPOLOGY (compute hosts):')
|
print('LOGICAL CPU TOPOLOGY (compute hosts):')
|
||||||
for host_name, topology in sorted(topologies.items(),
|
for host_name, topology in sorted(topologies.items(),
|
||||||
key=lambda (k, v): (natural_keys(k))):
|
key=lambda k_v3: (natural_keys(k_v3[0]))):
|
||||||
H = hypervisors[host_name]
|
H = hypervisors[host_name]
|
||||||
try:
|
try:
|
||||||
topology_idx = topologies_idx[host_name]
|
topology_idx = topologies_idx[host_name]
|
||||||
@ -1161,10 +1163,10 @@ def print_all_tables(tenants=None,
|
|||||||
for C in ['in_libvirt']:
|
for C in ['in_libvirt']:
|
||||||
pt.align[C] = 'c'
|
pt.align[C] = 'c'
|
||||||
for _, S in sorted(servers.items(),
|
for _, S in sorted(servers.items(),
|
||||||
key=lambda (k, v): (natural_keys(v.host),
|
key=lambda k_v4: (natural_keys(k_v4[1].host),
|
||||||
v.server_group,
|
k_v4[1].server_group,
|
||||||
v.instance_name)
|
k_v4[1].instance_name)
|
||||||
if (v.host is not None) else 'None'
|
if (k_v4[1].host is not None) else 'None'
|
||||||
):
|
):
|
||||||
if S.server_group is not None and S.server_group:
|
if S.server_group is not None and S.server_group:
|
||||||
match = re_server_group.search(S.server_group)
|
match = re_server_group.search(S.server_group)
|
||||||
@ -1257,9 +1259,9 @@ def print_all_tables(tenants=None,
|
|||||||
for C in ['in_nova']:
|
for C in ['in_nova']:
|
||||||
pt.align[C] = 'c'
|
pt.align[C] = 'c'
|
||||||
for host, D in sorted(domains.items(),
|
for host, D in sorted(domains.items(),
|
||||||
key=lambda (k, v): (natural_keys(k))):
|
key=lambda k_v5: (natural_keys(k_v5[0]))):
|
||||||
for _, S in sorted(D.items(),
|
for _, S in sorted(D.items(),
|
||||||
key=lambda (k, v): (v['name'])):
|
key=lambda k_v: (k_v[1]['name'])):
|
||||||
in_nova = True if S['uuid'] in servers else False
|
in_nova = True if S['uuid'] in servers else False
|
||||||
pt.add_row(
|
pt.add_row(
|
||||||
[S['uuid'],
|
[S['uuid'],
|
||||||
@ -1292,7 +1294,7 @@ def print_all_tables(tenants=None,
|
|||||||
])
|
])
|
||||||
pt.align = 'l'
|
pt.align = 'l'
|
||||||
for _, M in sorted(migrations.items(),
|
for _, M in sorted(migrations.items(),
|
||||||
key=lambda (k, v): (k)):
|
key=lambda k_v6: (k_v6[0])):
|
||||||
pt.add_row(
|
pt.add_row(
|
||||||
[M.instance_uuid,
|
[M.instance_uuid,
|
||||||
M.status,
|
M.status,
|
||||||
@ -1328,7 +1330,7 @@ def print_all_tables(tenants=None,
|
|||||||
'rxtx_factor']:
|
'rxtx_factor']:
|
||||||
pt.align[C] = 'r'
|
pt.align[C] = 'r'
|
||||||
for _, F in sorted(flavors.items(),
|
for _, F in sorted(flavors.items(),
|
||||||
key=lambda (k, v): (k)):
|
key=lambda k_v7: (k_v7[0])):
|
||||||
if F.id in flavors_in_use:
|
if F.id in flavors_in_use:
|
||||||
pt.add_row(
|
pt.add_row(
|
||||||
[F.id,
|
[F.id,
|
||||||
@ -1362,7 +1364,7 @@ def print_all_tables(tenants=None,
|
|||||||
for C in ['id', 'min_disk', 'min_ram', 'status']:
|
for C in ['id', 'min_disk', 'min_ram', 'status']:
|
||||||
pt.align[C] = 'r'
|
pt.align[C] = 'r'
|
||||||
for _, I in sorted(images.items(),
|
for _, I in sorted(images.items(),
|
||||||
key=lambda (k, v): (k)):
|
key=lambda k_v8: (k_v8[0])):
|
||||||
if I.id in images_in_use:
|
if I.id in images_in_use:
|
||||||
pt.add_row(
|
pt.add_row(
|
||||||
[I.id,
|
[I.id,
|
||||||
@ -1388,7 +1390,7 @@ def print_all_tables(tenants=None,
|
|||||||
])
|
])
|
||||||
pt.align = 'l'
|
pt.align = 'l'
|
||||||
for _, S in sorted(server_groups.items(),
|
for _, S in sorted(server_groups.items(),
|
||||||
key=lambda (k, v): (k)):
|
key=lambda k_v9: (k_v9[0])):
|
||||||
if S.id in server_groups_in_use:
|
if S.id in server_groups_in_use:
|
||||||
tenant = tenants[S.project_id].name
|
tenant = tenants[S.project_id].name
|
||||||
pt.add_row(
|
pt.add_row(
|
||||||
|
Loading…
Reference in New Issue
Block a user