diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-13 11:10:18 +0100 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-13 16:31:17 +0000 |
commit | f6fa0d7422f0669d049dbf07a51eb39b1dc25830 (patch) | |
tree | 106109341d7cbe1972a99ea1672288cfe1746e7f /yardstick/benchmark/contexts | |
parent | 2429ef152b5503d939022fbfd145b88a1df5c23b (diff) |
Add service NodePort information in server description
Kubernetes context provides a list of NodePort services to each
replication controller. "_get_server" should return this information
in the server description dictionary:
server: { ...
'service_ports': <list of NodePort objects>
}
Relevant NodePort object attributes:
- port
- node_port
- target_port
- protocol
- name
JIRA: YARDSTICK-1313
Change-Id: Ie481cdea4761f162e3b3329e4e2c5a982faea9e9
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/benchmark/contexts')
-rw-r--r-- | yardstick/benchmark/contexts/kubernetes.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/yardstick/benchmark/contexts/kubernetes.py b/yardstick/benchmark/contexts/kubernetes.py index 4ce7cbc55..27a011334 100644 --- a/yardstick/benchmark/contexts/kubernetes.py +++ b/yardstick/benchmark/contexts/kubernetes.py @@ -164,12 +164,8 @@ class KubernetesContext(ctx_base.Context): utils.remove_file(self.public_key_path) def _get_server(self, name): - service_name = '{}-service'.format(name) - service = k8s_utils.get_service_by_name(service_name) - if not service: - raise exceptions.KubernetesServiceObjectNotDefined() - - for sn_port in (sn_port for sn_port in service.ports + node_ports = self._get_service_ports(name) + for sn_port in (sn_port for sn_port in node_ports if sn_port.port == constants.SSH_PORT): node_port = sn_port.node_port break @@ -183,7 +179,8 @@ class KubernetesContext(ctx_base.Context): 'ssh_port': node_port, 'user': 'root', 'key_filename': self.key_path, - 'interfaces': self._get_interfaces(name) + 'interfaces': self._get_interfaces(name), + 'service_ports': node_ports } def _get_network(self, net_name): @@ -221,3 +218,10 @@ class KubernetesContext(ctx_base.Context): def _get_physical_node_for_server(self, server_name): return None + + def _get_service_ports(self, name): + service_name = '{}-service'.format(name) + service = k8s_utils.get_service_by_name(service_name) + if not service: + raise exceptions.KubernetesServiceObjectNotDefined() + return service.ports |