aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-12 16:17:33 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-07-12 16:17:33 +0000
commit2a286049b340801cff37329921f2ecca8a33c3fa (patch)
treea0ea69875c45adc054b2ced6daa71a2e9afdda5b /yardstick/benchmark
parent5e531e1e38da7670a1226aec4c664ef96a77335e (diff)
parent8da1feb7267f4b04e543b2e2e6590e2de8c31237 (diff)
Merge "Improve "get_server" function in Kubernetes context"
Diffstat (limited to 'yardstick/benchmark')
-rw-r--r--yardstick/benchmark/contexts/kubernetes.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/yardstick/benchmark/contexts/kubernetes.py b/yardstick/benchmark/contexts/kubernetes.py
index 52d17df4d..a6b3ebad8 100644
--- a/yardstick/benchmark/contexts/kubernetes.py
+++ b/yardstick/benchmark/contexts/kubernetes.py
@@ -16,6 +16,8 @@ import paramiko
from yardstick.benchmark import contexts
from yardstick.benchmark.contexts.base import Context
from yardstick.orchestrator import kubernetes
+from yardstick.common import constants
+from yardstick.common import exceptions
from yardstick.common import kubernetes_utils as k8s_utils
from yardstick.common import utils
@@ -156,19 +158,26 @@ class KubernetesContext(Context):
def _get_server(self, name):
service_name = '{}-service'.format(name)
- service = k8s_utils.get_service_by_name(service_name).ports[0]
-
- host = {
- 'name': service.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
+ if sn_port.port == constants.SSH_PORT):
+ node_port = sn_port.node_port
+ break
+ else:
+ raise exceptions.KubernetesSSHPortNotDefined()
+
+ return {
+ 'name': name,
'ip': self._get_node_ip(),
'private_ip': k8s_utils.get_pod_by_name(name).status.pod_ip,
- 'ssh_port': service.node_port,
+ 'ssh_port': node_port,
'user': 'root',
- 'key_filename': self.key_path,
+ 'key_filename': self.key_path
}
- return host
-
def _get_node_ip(self):
return k8s_utils.get_node_list().items[0].status.addresses[0].address