Merge "Minor code style improvements"
This commit is contained in:
commit
f2283541f1
@ -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)
|
||||||
|
|
||||||
|
@ -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],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user