aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/orchestrator
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-18 16:39:17 +0100
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-19 12:03:34 +0100
commit5c8add8e51f3cbc5f6949e890f13785502005576 (patch)
tree566b0cb1943636387c530f668be454c6f1aca802 /yardstick/orchestrator
parent4e058b76a3f9edd26b60f2eeaf4a4ff95e7aa0a6 (diff)
Accept strings and lists as container "args" and "commands"
Accept strings and list of strings as "args" and "commands" in a Kubernetes container. JIRA: YARDSTICK-1329 Change-Id: I56470741072fb7f9a62d695c51fcb0cc3f3ff1b9 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/orchestrator')
-rw-r--r--yardstick/orchestrator/kubernetes.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py
index bee4d4a78..3e2572fcc 100644
--- a/yardstick/orchestrator/kubernetes.py
+++ b/yardstick/orchestrator/kubernetes.py
@@ -11,6 +11,7 @@ import copy
import re
from oslo_serialization import jsonutils
+import six
from yardstick.common import constants
from yardstick.common import exceptions
@@ -22,7 +23,7 @@ class ContainerObject(object):
SSH_MOUNT_PATH = '/tmp/.ssh/'
IMAGE_DEFAULT = 'openretriever/yardstick'
- COMMAND_DEFAULT = '/bin/bash'
+ COMMAND_DEFAULT = ['/bin/bash', '-c']
RESOURCES = ('requests', 'limits')
PORT_OPTIONS = ('containerPort', 'hostIP', 'hostPort', 'name', 'protocol')
IMAGE_PULL_POLICY = ('Always', 'IfNotPresent', 'Never')
@@ -31,8 +32,9 @@ class ContainerObject(object):
self._name = name
self._ssh_key = ssh_key
self._image = kwargs.get('image', self.IMAGE_DEFAULT)
- self._command = [kwargs.get('command', self.COMMAND_DEFAULT)]
- self._args = kwargs.get('args', [])
+ self._command = self._parse_commands(
+ kwargs.get('command', self.COMMAND_DEFAULT))
+ self._args = self._parse_commands(kwargs.get('args', []))
self._volume_mounts = kwargs.get('volumeMounts', [])
self._security_context = kwargs.get('securityContext')
self._env = kwargs.get('env', [])
@@ -40,6 +42,14 @@ class ContainerObject(object):
self._ports = kwargs.get('ports', [])
self._image_pull_policy = kwargs.get('imagePullPolicy')
+ @staticmethod
+ def _parse_commands(command):
+ if isinstance(command, six.string_types):
+ return [command]
+ elif isinstance(command, list):
+ return command
+ raise exceptions.KubernetesContainerCommandType()
+
def _create_volume_mounts(self):
"""Return all "volumeMounts" items per container"""
volume_mounts_items = [self._create_volume_mounts_item(vol)