1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 from __future__ import print_function
11 from __future__ import absolute_import
15 from yardstick.benchmark.scenarios import base
17 LOG = logging.getLogger(__name__)
20 class GetServerIp(base.Scenario):
21 """Get a server by name"""
23 __scenario_type__ = "GetServerIp"
25 def __init__(self, scenario_cfg, context_cfg):
26 self.scenario_cfg = scenario_cfg
27 self.context_cfg = context_cfg
28 self.options = self.scenario_cfg.get('options', {})
29 self.ip_type = self.options.get('ip_type', "floating")
31 def run(self, result):
32 server = self.options.get('server', {})
33 ip = next(n['addr'] for k, v in server['addresses'].items()
34 for n in v if n['OS-EXT-IPS:type'] == self.ip_type)
36 keys = self.scenario_cfg.get('output', '').split()
38 return self._push_to_outputs(keys, values)