From 71900afd5d8ba89db92e641fdd9c9e57d2b180b3 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Sun, 7 Apr 2019 03:07:35 +0000 Subject: [PATCH] Add '--registry' option on running container This is the client side implementation for: https://review.openstack.org/#/c/628787/ Change-Id: I6792912ddaf4ab3156ab6945286edf29f3286a05 Related-Bug: #1702830 --- zunclient/api_versions.py | 2 +- zunclient/osc/v1/containers.py | 10 ++++++++++ zunclient/v1/containers.py | 2 +- zunclient/v1/containers_shell.py | 8 ++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/zunclient/api_versions.py b/zunclient/api_versions.py index 983d4347..46b6142f 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.30' +MAX_API_VERSION = '1.31' DEFAULT_API_VERSION = '1.latest' _SUBSTITUTIONS = {} diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index ecc2f054..ba71b31d 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -210,6 +210,10 @@ class CreateContainer(command.ShowOne): '--wait', action='store_true', help='Wait for create to complete') + parser.add_argument( + '--registry', + metavar='', + help='The container image registry ID or name.') return parser def take_action(self, parsed_args): @@ -226,6 +230,7 @@ class CreateContainer(command.ShowOne): opts['image_driver'] = parsed_args.image_driver opts['auto_remove'] = parsed_args.auto_remove opts['command'] = parsed_args.command + opts['registry'] = parsed_args.registry if parsed_args.security_group: opts['security_groups'] = parsed_args.security_group if parsed_args.expose_port: @@ -895,6 +900,10 @@ class RunContainer(command.ShowOne): '--wait', action='store_true', help='Wait for run to complete') + parser.add_argument( + '--registry', + metavar='', + help='The container image registry ID or name.') return parser def take_action(self, parsed_args): @@ -911,6 +920,7 @@ class RunContainer(command.ShowOne): opts['image_driver'] = parsed_args.image_driver opts['auto_remove'] = parsed_args.auto_remove opts['command'] = parsed_args.command + opts['registry'] = parsed_args.registry if parsed_args.security_group: opts['security_groups'] = parsed_args.security_group if parsed_args.expose_port: diff --git a/zunclient/v1/containers.py b/zunclient/v1/containers.py index 3e6cc6ad..2b8bb02b 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'] + 'exposed_ports', 'healthcheck', 'registry'] class Container(base.Resource): diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index f8ffead4..340fcef4 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -181,6 +181,9 @@ def _show_container(container): 'retries: Consecutive failures needed to report unhealthy. ' 'timeout: Maximum time to allow one check to run (s|m|h)' ' (default 0s).') +@utils.arg('--registry', + metavar='', + help='The container image registry ID or name') def do_create(cs, args): """Create a container.""" opts = {} @@ -202,6 +205,7 @@ def do_create(cs, args): opts['disk'] = args.disk opts['availability_zone'] = args.availability_zone opts['command'] = args.command + opts['registry'] = args.registry if args.healthcheck: opts['healthcheck'] = zun_utils.parse_health(args.healthcheck) @@ -701,6 +705,9 @@ def do_kill(cs, args): 'retries: Consecutive failures needed to report unhealthy. ' 'timeout: Maximum time to allow one check to run (s|m|h)' ' (default 0s).') +@utils.arg('--registry', + metavar='', + help='The container image registry ID or name') def do_run(cs, args): """Run a command in a new container.""" opts = {} @@ -722,6 +729,7 @@ def do_run(cs, args): opts['disk'] = args.disk opts['availability_zone'] = args.availability_zone opts['command'] = args.command + opts['registry'] = args.registry if args.healthcheck: opts['healthcheck'] = zun_utils.parse_health(args.healthcheck)