Merge "Minor code style improvements"

This commit is contained in:
Zuul 2018-06-20 10:59:59 +00:00 committed by Gerrit Code Review
commit f2283541f1
3 changed files with 11 additions and 7 deletions

View File

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

View File

@ -143,7 +143,7 @@ def command_dispatcher(vbmc_manager, data_in):
data_out = [vbmc_manager.delete(domain_name) data_out = [vbmc_manager.delete(domain_name)
for domain_name in set(data_in['domain_names'])] for domain_name in set(data_in['domain_names'])]
return { 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], 'msg': [msg for rc, msg in data_out if msg],
} }
@ -151,7 +151,7 @@ def command_dispatcher(vbmc_manager, data_in):
data_out = [vbmc_manager.start(domain_name) data_out = [vbmc_manager.start(domain_name)
for domain_name in set(data_in['domain_names'])] for domain_name in set(data_in['domain_names'])]
return { 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], 'msg': [msg for rc, msg in data_out if msg],
} }
@ -159,7 +159,7 @@ def command_dispatcher(vbmc_manager, data_in):
data_out = [vbmc_manager.stop(domain_name) data_out = [vbmc_manager.stop(domain_name)
for domain_name in set(data_in['domain_names'])] for domain_name in set(data_in['domain_names'])]
return { 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], 'msg': [msg for rc, msg in data_out if msg],
} }

View File

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