diff --git a/zunclient/api_versions.py b/zunclient/api_versions.py index f9f85d0b..2fa7e4ac 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.39' +MAX_API_VERSION = '1.40' DEFAULT_API_VERSION = '1.latest' _SUBSTITUTIONS = {} diff --git a/zunclient/common/utils.py b/zunclient/common/utils.py index 9ad66096..1ee1de51 100644 --- a/zunclient/common/utils.py +++ b/zunclient/common/utils.py @@ -18,6 +18,7 @@ import base64 import binascii import os import re +import shlex from oslo_serialization import jsonutils from oslo_utils import netutils @@ -211,6 +212,10 @@ def parse_command(command): return " ".join(output) +def parse_entrypoint(entrypoint): + return shlex.split(entrypoint) + + def parse_mounts(mounts): err_msg = ("Invalid mounts argument '%s'. mounts arguments must be of " "the form --mount source=,destination=, " diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index 29957b70..9b38b369 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -220,6 +220,11 @@ class CreateContainer(command.ShowOne): help='Requested host to create containers. Admin only by ' 'default. (supported by --os-container-api-version 1.39 ' 'or above') + parser.add_argument( + '--entrypoint', + metavar='', + help='The entrypoint which overwrites the default ENTRYPOINT ' + 'of the image.') return parser def take_action(self, parsed_args): @@ -238,6 +243,7 @@ class CreateContainer(command.ShowOne): opts['command'] = parsed_args.command opts['registry'] = parsed_args.registry opts['host'] = parsed_args.host + opts['entrypoint'] = zun_utils.parse_entrypoint(parsed_args.entrypoint) if parsed_args.security_group: opts['security_groups'] = parsed_args.security_group if parsed_args.expose_port: @@ -917,6 +923,11 @@ class RunContainer(command.ShowOne): help='Requested host to run containers. Admin only by ' 'default. (supported by --os-container-api-version 1.39 ' 'or above') + parser.add_argument( + '--entrypoint', + metavar='', + help='The entrypoint which overwrites the default ENTRYPOINT ' + 'of the image.') return parser def take_action(self, parsed_args): @@ -935,6 +946,7 @@ class RunContainer(command.ShowOne): opts['command'] = parsed_args.command opts['registry'] = parsed_args.registry opts['host'] = parsed_args.host + opts['entrypoint'] = zun_utils.parse_entrypoint(parsed_args.entrypoint) if parsed_args.security_group: opts['security_groups'] = parsed_args.security_group if parsed_args.expose_port: diff --git a/zunclient/tests/unit/v1/test_containers_shell.py b/zunclient/tests/unit/v1/test_containers_shell.py index c35274b7..205522df 100644 --- a/zunclient/tests/unit/v1/test_containers_shell.py +++ b/zunclient/tests/unit/v1/test_containers_shell.py @@ -28,6 +28,7 @@ def _get_container_args(**kwargs): 'mounts': [], 'nets': [], 'command': [], + 'entrypoint': [], } default_args.update(kwargs) return default_args diff --git a/zunclient/v1/containers.py b/zunclient/v1/containers.py index 04c0f86e..75bf4c20 100644 --- a/zunclient/v1/containers.py +++ b/zunclient/v1/containers.py @@ -27,7 +27,7 @@ CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory', 'runtime', 'hostname', 'mounts', 'disk', 'availability_zone', 'auto_heal', 'privileged', 'exposed_ports', 'healthcheck', 'registry', 'tty', - 'host'] + 'host', 'entrypoint'] class Container(base.Resource): diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index 2380a8f0..72c09323 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -188,6 +188,10 @@ def _show_container(container): metavar='', help='Requested host to create containers. Admin only by default.' '(Supported by API versions 1.39 or above)') +@utils.arg('--entrypoint', + metavar='', + help='The entrypoint which overwrites the default ENTRYPOINT ' + 'of the image. (Supported by API versions 1.40 or above)') def do_create(cs, args): """Create a container.""" opts = {} @@ -211,6 +215,7 @@ def do_create(cs, args): opts['command'] = args.command opts['registry'] = args.registry opts['host'] = args.host + opts['entrypoint'] = zun_utils.parse_entrypoint(args.entrypoint) if args.healthcheck: opts['healthcheck'] = zun_utils.parse_health(args.healthcheck) @@ -717,6 +722,10 @@ def do_kill(cs, args): metavar='', help='Requested host to run containers. Admin only by default.' '(Supported by API versions 1.39 or above)') +@utils.arg('--entrypoint', + metavar='', + help='The entrypoint which overwrites the default ENTRYPOINT ' + 'of the image. (Supported by API versions 1.40 or above)') def do_run(cs, args): """Run a command in a new container.""" opts = {} @@ -740,6 +749,7 @@ def do_run(cs, args): opts['command'] = args.command opts['registry'] = args.registry opts['host'] = args.host + opts['entrypoint'] = zun_utils.parse_entrypoint(args.entrypoint) if args.healthcheck: opts['healthcheck'] = zun_utils.parse_health(args.healthcheck)