Minor code style improvements

This is a followup patch to [1] improve code style at multiple places.

1. https://review.openstack.org/#/c/488874

Change-Id: I38a87ecf7215cbf3ff4f94cefedc4f2a297e70f9
This commit is contained in:
Ilya Etingof 2018-06-18 12:24:45 +02:00
parent b3a8a6f532
commit 7149836092
3 changed files with 11 additions and 7 deletions

View File

@ -52,10 +52,14 @@ class ZmqClient(object):
SERVER_TIMEOUT = 5000 # milliseconds
@staticmethod
def to_dict(obj):
return {attr: getattr(obj, attr)
for attr in dir(obj) if not attr.startswith('_')}
def communicate(self, command, args, no_daemon=False):
data_out = {attr: getattr(args, attr)
for attr in dir(args) if not attr.startswith('_')}
data_out = self.to_dict(args)
data_out.update(command=command)

View File

@ -143,14 +143,14 @@ def command_dispatcher(vbmc_manager, data_in):
data_out = [vbmc_manager.delete(domain_name)
for domain_name in data_in['domain_names']]
return {
'rc': max([rc for rc, msg in data_out]),
'rc': max(rc for rc, msg in data_out),
'msg': [msg for rc, msg in data_out if msg],
}
elif command == 'start':
data_out = [vbmc_manager.start(data_in['domain_name'])]
return {
'rc': max([rc for rc, msg in data_out]),
'rc': max(rc for rc, msg in data_out),
'msg': [msg for rc, msg in data_out if msg],
}
@ -158,7 +158,7 @@ def command_dispatcher(vbmc_manager, data_in):
data_out = [vbmc_manager.stop(domain_name)
for domain_name in data_in['domain_names']]
return {
'rc': max([rc for rc, msg in data_out]),
'rc': max(rc for rc, msg in data_out),
'msg': [msg for rc, msg in data_out if msg],
}

View File

@ -76,7 +76,7 @@ class VirtualBMCManager(object):
config = configparser.ConfigParser()
config.add_section(DEFAULT_SECTION)
for option, value in sorted(options.items()):
for option, value in options.items():
if value is not None:
config.set(DEFAULT_SECTION, option, six.text_type(value))
@ -170,7 +170,7 @@ class VirtualBMCManager(object):
if not instance:
instance = multiprocessing.Process(
name='xxx',
name='vbmcd-managing-domain-%s' % domain_name,
target=vbmc_runner,
args=(bmc_config,)
)