def parse_json(self):
data = self._get_config_data()
try:
json_data = json.loads(data.value) # pylint: disable=no-member
except ValueError:
raise InvokeError('Failed to parse JSON data')
# simple ordered dict
command_execution_pairs = [
('ab', ApacheBenchExecution),
('nginx', NginxExecution),
('netperf', NetperfExecution),
('iperf', IperfExecution),
]
for command_type, exec_class in command_execution_pairs:
with suppress(KeyError):
return exec_class(json_data[command_type], self)
raise InvokeError('No command found to parse')
评论列表
文章目录