From a8c2eccc1b30b761741b8c482728840949d09cf8 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Thu, 11 Jul 2019 01:34:39 +0000 Subject: [PATCH] Bump api_version from 1.35 to 1.36 Add support for 'tty' property on creating a container. For backward-compatibility, we assigned 'tty' as 'interactive' if 'interactive' is provided and 'tty' is not provided. Change-Id: Ibd884ec42044a8ab46791e6f3d318f87dc95b10c --- zunclient/api_versions.py | 2 +- zunclient/v1/containers.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/zunclient/api_versions.py b/zunclient/api_versions.py index 4907e9a8..326242e3 100644 --- a/zunclient/api_versions.py +++ b/zunclient/api_versions.py @@ -31,7 +31,7 @@ if not LOG.handlers: HEADER_NAME = "OpenStack-API-Version" SERVICE_TYPE = "container" MIN_API_VERSION = '1.1' -MAX_API_VERSION = '1.35' +MAX_API_VERSION = '1.36' DEFAULT_API_VERSION = '1.latest' _SUBSTITUTIONS = {} diff --git a/zunclient/v1/containers.py b/zunclient/v1/containers.py index 2b8bb02b..14ed1f2b 100644 --- a/zunclient/v1/containers.py +++ b/zunclient/v1/containers.py @@ -26,7 +26,7 @@ CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory', 'security_groups', 'hints', 'nets', 'auto_remove', 'runtime', 'hostname', 'mounts', 'disk', 'availability_zone', 'auto_heal', 'privileged', - 'exposed_ports', 'healthcheck', 'registry'] + 'exposed_ports', 'healthcheck', 'registry', 'tty'] class Container(base.Resource): @@ -97,6 +97,7 @@ class ContainerManager(base.Manager): def create(self, **kwargs): self._process_command(kwargs) self._process_mounts(kwargs) + self._process_tty(kwargs) new = {} for (key, value) in kwargs.items(): @@ -121,6 +122,12 @@ class ContainerManager(base.Manager): if mount.get('type') == 'bind': mount['source'] = utils.encode_file_data(mount['source']) + def _process_tty(self, kwargs): + tty_microversion = api_versions.APIVersion("1.36") + if self.api_version >= tty_microversion: + if 'interactive' in kwargs and 'tty' not in kwargs: + kwargs['tty'] = kwargs['interactive'] + def delete(self, id, **kwargs): return self._delete(self._path(id), qparams=kwargs) @@ -179,6 +186,7 @@ class ContainerManager(base.Manager): def run(self, **kwargs): self._process_command(kwargs) self._process_mounts(kwargs) + self._process_tty(kwargs) if not set(kwargs).issubset(CREATION_ATTRIBUTES): raise exceptions.InvalidAttribute(