aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/contexts
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/contexts')
-rw-r--r--yardstick/benchmark/contexts/__init__.py20
-rw-r--r--yardstick/benchmark/contexts/dummy.py7
-rw-r--r--yardstick/benchmark/contexts/heat.py3
-rw-r--r--yardstick/benchmark/contexts/kubernetes.py29
-rw-r--r--yardstick/benchmark/contexts/node.py4
-rw-r--r--yardstick/benchmark/contexts/standalone/ovs_dpdk.py9
-rw-r--r--yardstick/benchmark/contexts/standalone/sriov.py9
7 files changed, 57 insertions, 24 deletions
diff --git a/yardstick/benchmark/contexts/__init__.py b/yardstick/benchmark/contexts/__init__.py
index e69de29bb..d50f08cc3 100644
--- a/yardstick/benchmark/contexts/__init__.py
+++ b/yardstick/benchmark/contexts/__init__.py
@@ -0,0 +1,20 @@
+# Copyright (c) 2016-2017 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+CONTEXT_DUMMY = "Dummy"
+CONTEXT_HEAT = "Heat"
+CONTEXT_KUBERNETES = "Kubernetes"
+CONTEXT_NODE = "Node"
+CONTEXT_STANDALONEOVSDPDK = "StandaloneOvsDpdk"
+CONTEXT_STANDALONESRIOV = "StandaloneSriov"
diff --git a/yardstick/benchmark/contexts/dummy.py b/yardstick/benchmark/contexts/dummy.py
index 36e8854e8..9faca4c63 100644
--- a/yardstick/benchmark/contexts/dummy.py
+++ b/yardstick/benchmark/contexts/dummy.py
@@ -7,17 +7,18 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from yardstick.benchmark.contexts.base import Context
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base
-class DummyContext(Context):
+class DummyContext(base.Context):
"""Class that handle dummy info.
This class is also used to test the abstract class Context because it
provides a minimal concrete implementation of a subclass.
"""
- __context_type__ = "Dummy"
+ __context_type__ = contexts.CONTEXT_DUMMY
def deploy(self):
"""Don't need to deploy"""
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index ac85b6ffe..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
@@ -47,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
diff --git a/yardstick/benchmark/contexts/kubernetes.py b/yardstick/benchmark/contexts/kubernetes.py
index 4ba9eee36..a6b3ebad8 100644
--- a/yardstick/benchmark/contexts/kubernetes.py
+++ b/yardstick/benchmark/contexts/kubernetes.py
@@ -7,15 +7,17 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import absolute_import
import logging
import time
import pkg_resources
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
@@ -26,7 +28,7 @@ BITS_LENGTH = 2048
class KubernetesContext(Context):
"""Class that handle nodes info"""
- __context_type__ = "Kubernetes"
+ __context_type__ = contexts.CONTEXT_KUBERNETES
def __init__(self):
self.ssh_key = ''
@@ -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
diff --git a/yardstick/benchmark/contexts/node.py b/yardstick/benchmark/contexts/node.py
index d3af98920..d233e02ae 100644
--- a/yardstick/benchmark/contexts/node.py
+++ b/yardstick/benchmark/contexts/node.py
@@ -7,7 +7,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import absolute_import
import subprocess
import os
import collections
@@ -18,6 +17,7 @@ import six
import pkg_resources
from yardstick import ssh
+from yardstick.benchmark import contexts
from yardstick.benchmark.contexts.base import Context
from yardstick.common.constants import ANSIBLE_DIR, YARDSTICK_ROOT_PATH
from yardstick.common.ansible_common import AnsibleCommon
@@ -31,7 +31,7 @@ DEFAULT_DISPATCH = 'script'
class NodeContext(Context):
"""Class that handle nodes info"""
- __context_type__ = "Node"
+ __context_type__ = contexts.CONTEXT_NODE
def __init__(self):
self.file_path = None
diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
index e6a6f99e4..88ad598c3 100644
--- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
+++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
@@ -20,11 +20,12 @@ import re
import time
from yardstick import ssh
-from yardstick.network_services.utils import get_nsb_option
-from yardstick.benchmark.contexts.base import Context
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
from yardstick.common import exceptions
from yardstick.network_services import utils
+from yardstick.network_services.utils import get_nsb_option
LOG = logging.getLogger(__name__)
@@ -32,12 +33,12 @@ LOG = logging.getLogger(__name__)
MAIN_BRIDGE = 'br0'
-class OvsDpdkContext(Context):
+class OvsDpdkContext(base.Context):
""" This class handles OVS standalone nodes - VM running on Non-Managed NFVi
Configuration: ovs_dpdk
"""
- __context_type__ = "StandaloneOvsDpdk"
+ __context_type__ = contexts.CONTEXT_STANDALONEOVSDPDK
SUPPORTED_OVS_TO_DPDK_MAP = {
'2.6.0': '16.07.1',
diff --git a/yardstick/benchmark/contexts/standalone/sriov.py b/yardstick/benchmark/contexts/standalone/sriov.py
index 05fac0218..3da12a9a8 100644
--- a/yardstick/benchmark/contexts/standalone/sriov.py
+++ b/yardstick/benchmark/contexts/standalone/sriov.py
@@ -18,20 +18,21 @@ import logging
import collections
from yardstick import ssh
-from yardstick.network_services.utils import get_nsb_option
-from yardstick.benchmark.contexts.base import Context
+from yardstick.benchmark import contexts
+from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts.standalone import model
+from yardstick.network_services.utils import get_nsb_option
from yardstick.network_services.utils import PciAddress
LOG = logging.getLogger(__name__)
-class SriovContext(Context):
+class SriovContext(base.Context):
""" This class handles SRIOV standalone nodes - VM running on Non-Managed NFVi
Configuration: sr-iov
"""
- __context_type__ = "StandaloneSriov"
+ __context_type__ = contexts.CONTEXT_STANDALONESRIOV
def __init__(self):
self.file_path = None