aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/contexts/heat.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/contexts/heat.py')
-rw-r--r--yardstick/benchmark/contexts/heat.py47
1 files changed, 45 insertions, 2 deletions
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index 82861829e..f118ffc32 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -16,6 +16,7 @@ from collections import OrderedDict
import ipaddress
import pkg_resources
+from yardstick.benchmark import contexts
from yardstick.benchmark.contexts.base import Context
from yardstick.benchmark.contexts.model import Network
from yardstick.benchmark.contexts.model import PlacementGroup, ServerGroup
@@ -29,6 +30,7 @@ from yardstick.common import constants as consts
from yardstick.common import utils
from yardstick.common.utils import source_env
from yardstick.ssh import SSH
+from yardstick.common import openstack_utils
LOG = logging.getLogger(__name__)
@@ -46,7 +48,7 @@ def h_join(*args):
class HeatContext(Context):
"""Class that represents a context in the logical model"""
- __context_type__ = "Heat"
+ __context_type__ = contexts.CONTEXT_HEAT
def __init__(self):
self.stack = None
@@ -68,6 +70,12 @@ class HeatContext(Context):
self.shade_client = None
self.heat_timeout = None
self.key_filename = None
+ self.shade_client = None
+ self.operator_client = None
+ self.nodes = []
+ self.controllers = []
+ self.computes = []
+ self.baremetals = []
super(HeatContext, self).__init__()
@staticmethod
@@ -96,6 +104,14 @@ class HeatContext(Context):
self.template_file = attrs.get("heat_template")
+ self.shade_client = openstack_utils.get_shade_client()
+ self.operator_client = openstack_utils.get_shade_operator_client()
+
+ try:
+ self.read_pod_file(attrs)
+ except IOError:
+ LOG.warning("No pod file specified. NVFi metrics will be disabled")
+
self.heat_timeout = attrs.get("timeout", DEFAULT_HEAT_TIMEOUT)
if self.template_file:
self.heat_parameters = attrs.get("heat_parameters")
@@ -465,7 +481,7 @@ class HeatContext(Context):
with attribute name mapping when using external heat templates
"""
if isinstance(attr_name, collections.Mapping):
- node_name, cname = self.split_name(attr_name['name'])
+ node_name, cname = self.split_host_name(attr_name['name'])
if cname is None or cname != self.name:
return None
@@ -528,3 +544,30 @@ class HeatContext(Context):
"physical_network": network.physical_network,
}
return result
+
+ def _get_physical_nodes(self):
+ return self.nodes
+
+ def _get_physical_node_for_server(self, server_name):
+ node_name, ctx_name = self.split_host_name(server_name)
+ if ctx_name is None or self.name != ctx_name:
+ return None
+
+ matching_nodes = [s for s in self.servers if s.name == node_name]
+ if len(matching_nodes) == 0:
+ return None
+
+ server = openstack_utils.get_server(self.shade_client,
+ name_or_id=server_name)
+
+ if server:
+ server = server.toDict()
+ list_hypervisors = self.operator_client.list_hypervisors()
+
+ for hypervisor in list_hypervisors:
+ if hypervisor.hypervisor_hostname == server['OS-EXT-SRV-ATTR:hypervisor_hostname']:
+ for node in self.nodes:
+ if node['ip'] == hypervisor.host_ip:
+ return "{}.{}".format(node['name'], self._name)
+
+ return None