diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-11 17:32:44 +0100 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-13 17:30:51 +0100 |
commit | 2429ef152b5503d939022fbfd145b88a1df5c23b (patch) | |
tree | 2096853bd15d7e7d347834e9e419030733cba1d7 /yardstick/benchmark | |
parent | 0ca0696d0a22daca831daa8f9815bdeaea29aea1 (diff) |
Add interface and network information to Kubernetes context
Add to "Kubernetes" context the "interfaces" information when retrieving
a server. This information is needed for NSPerf test cases.
The interface information comes from the resource controller network list.
Each replication controller will have one port per network defined.
JIRA: YARDSTICK-1303
Change-Id: Ifb0e17df295c042a643128c705a93876af999bad
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/benchmark')
-rw-r--r-- | yardstick/benchmark/contexts/kubernetes.py | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/yardstick/benchmark/contexts/kubernetes.py b/yardstick/benchmark/contexts/kubernetes.py index a6b3ebad8..4ce7cbc55 100644 --- a/yardstick/benchmark/contexts/kubernetes.py +++ b/yardstick/benchmark/contexts/kubernetes.py @@ -7,25 +7,28 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import collections import logging -import time import pkg_resources +import time import paramiko from yardstick.benchmark import contexts -from yardstick.benchmark.contexts.base import Context -from yardstick.orchestrator import kubernetes +from yardstick.benchmark.contexts import base as ctx_base +from yardstick.benchmark.contexts import model from yardstick.common import constants from yardstick.common import exceptions from yardstick.common import kubernetes_utils as k8s_utils from yardstick.common import utils +from yardstick.orchestrator import kubernetes + LOG = logging.getLogger(__name__) BITS_LENGTH = 2048 -class KubernetesContext(Context): +class KubernetesContext(ctx_base.Context): """Class that handle nodes info""" __context_type__ = contexts.CONTEXT_KUBERNETES @@ -40,10 +43,14 @@ class KubernetesContext(Context): def init(self, attrs): super(KubernetesContext, self).init(attrs) + networks = attrs.get('networks', {}) self.template = kubernetes.KubernetesTemplate(self.name, attrs) self.ssh_key = '{}-key'.format(self.name) self.key_path = self._get_key_path() self.public_key_path = '{}.pub'.format(self.key_path) + self._networks = collections.OrderedDict( + (net_name, model.Network(net_name, self, network)) + for net_name, network in networks.items()) def deploy(self): LOG.info('Creating ssh key') @@ -92,7 +99,7 @@ class KubernetesContext(Context): obj.delete() def _create_rcs(self): - for obj in self.template.k8s_objs: + for obj in self.template.rc_objs: self._create_rc(obj.get_template()) def _create_rc(self, template): @@ -175,15 +182,40 @@ class KubernetesContext(Context): 'private_ip': k8s_utils.get_pod_by_name(name).status.pod_ip, 'ssh_port': node_port, 'user': 'root', - 'key_filename': self.key_path + 'key_filename': self.key_path, + 'interfaces': self._get_interfaces(name) } + def _get_network(self, net_name): + """Retrieves the network object, searching by name + + :param net_name: (str) replication controller name + :return: (dict) network information (name) + """ + network = self._networks.get(net_name) + if not network: + return + return {'name': net_name} + + def _get_interfaces(self, rc_name): + """Retrieves the network list of a replication controller + + :param rc_name: (str) replication controller name + :return: (dict) names and information of the networks used in this + replication controller; those networks must be defined in the + Kubernetes cluster + """ + rc = self.template.get_rc_by_name(rc_name) + if not rc: + return {} + return {name: {'network_name': name, + 'local_mac': None, + 'local_ip': None} + for name in rc.networks} + def _get_node_ip(self): return k8s_utils.get_node_list().items[0].status.addresses[0].address - def _get_network(self, attr_name): - return None - def _get_physical_nodes(self): return None |