Use isinstance instead of type
With the patch sets of request_ids, the *Manager classes return 'DictWithMeta' or 'ListWithMeta' rather than 'dict' or 'list'. This change adjust conditional statements to use isinstance when comparing variables. Isinstance supports inheritance type checking better than type. The effected subcommands are: evacuate interface-list interface-attach interface-detach Change-Id: I0c1291110c1386d2ff027cb149a5aff20019e6f7 Closes-Bug: 1550870
This commit is contained in:
parent
4e2761d6b9
commit
5c1acb91f7
@ -4698,7 +4698,7 @@ def do_evacuate(cs, args):
|
||||
server = _find_server(cs, args.server)
|
||||
on_shared_storage = getattr(args, 'on_shared_storage', None)
|
||||
res = server.evacuate(args.host, on_shared_storage, args.password)[1]
|
||||
if type(res) is dict:
|
||||
if isinstance(res, dict):
|
||||
utils.print_dict(res)
|
||||
|
||||
|
||||
@ -4723,7 +4723,7 @@ def do_interface_list(cs, args):
|
||||
server = _find_server(cs, args.server)
|
||||
|
||||
res = server.interface_list()
|
||||
if type(res) is list:
|
||||
if isinstance(res, list):
|
||||
_print_interfaces(res)
|
||||
|
||||
|
||||
@ -4748,7 +4748,7 @@ def do_interface_attach(cs, args):
|
||||
server = _find_server(cs, args.server)
|
||||
|
||||
res = server.interface_attach(args.port_id, args.net_id, args.fixed_ip)
|
||||
if type(res) is dict:
|
||||
if isinstance(res, dict):
|
||||
utils.print_dict(res)
|
||||
|
||||
|
||||
@ -4759,7 +4759,7 @@ def do_interface_detach(cs, args):
|
||||
server = _find_server(cs, args.server)
|
||||
|
||||
res = server.interface_detach(args.port_id)
|
||||
if type(res) is dict:
|
||||
if isinstance(res, dict):
|
||||
utils.print_dict(res)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user