Add support for requested host
Depends-On: https://review.opendev.org/#/c/711864/ Change-Id: Ie370f352c9f996c4f1953787b1d5b24bd723c6cc
This commit is contained in:
@@ -31,7 +31,7 @@ if not LOG.handlers:
|
|||||||
HEADER_NAME = "OpenStack-API-Version"
|
HEADER_NAME = "OpenStack-API-Version"
|
||||||
SERVICE_TYPE = "container"
|
SERVICE_TYPE = "container"
|
||||||
MIN_API_VERSION = '1.1'
|
MIN_API_VERSION = '1.1'
|
||||||
MAX_API_VERSION = '1.38'
|
MAX_API_VERSION = '1.39'
|
||||||
DEFAULT_API_VERSION = '1.latest'
|
DEFAULT_API_VERSION = '1.latest'
|
||||||
|
|
||||||
_SUBSTITUTIONS = {}
|
_SUBSTITUTIONS = {}
|
||||||
|
@@ -214,6 +214,12 @@ class CreateContainer(command.ShowOne):
|
|||||||
'--registry',
|
'--registry',
|
||||||
metavar='<registry>',
|
metavar='<registry>',
|
||||||
help='The container image registry ID or name.')
|
help='The container image registry ID or name.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--host',
|
||||||
|
metavar='<host>',
|
||||||
|
help='Requested host to create containers. Admin only by '
|
||||||
|
'default. (supported by --os-container-api-version 1.39 '
|
||||||
|
'or above')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -231,6 +237,7 @@ class CreateContainer(command.ShowOne):
|
|||||||
opts['auto_remove'] = parsed_args.auto_remove
|
opts['auto_remove'] = parsed_args.auto_remove
|
||||||
opts['command'] = parsed_args.command
|
opts['command'] = parsed_args.command
|
||||||
opts['registry'] = parsed_args.registry
|
opts['registry'] = parsed_args.registry
|
||||||
|
opts['host'] = parsed_args.host
|
||||||
if parsed_args.security_group:
|
if parsed_args.security_group:
|
||||||
opts['security_groups'] = parsed_args.security_group
|
opts['security_groups'] = parsed_args.security_group
|
||||||
if parsed_args.expose_port:
|
if parsed_args.expose_port:
|
||||||
@@ -904,6 +911,12 @@ class RunContainer(command.ShowOne):
|
|||||||
'--registry',
|
'--registry',
|
||||||
metavar='<registry>',
|
metavar='<registry>',
|
||||||
help='The container image registry ID or name.')
|
help='The container image registry ID or name.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--host',
|
||||||
|
metavar='<host>',
|
||||||
|
help='Requested host to run containers. Admin only by '
|
||||||
|
'default. (supported by --os-container-api-version 1.39 '
|
||||||
|
'or above')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -921,6 +934,7 @@ class RunContainer(command.ShowOne):
|
|||||||
opts['auto_remove'] = parsed_args.auto_remove
|
opts['auto_remove'] = parsed_args.auto_remove
|
||||||
opts['command'] = parsed_args.command
|
opts['command'] = parsed_args.command
|
||||||
opts['registry'] = parsed_args.registry
|
opts['registry'] = parsed_args.registry
|
||||||
|
opts['host'] = parsed_args.host
|
||||||
if parsed_args.security_group:
|
if parsed_args.security_group:
|
||||||
opts['security_groups'] = parsed_args.security_group
|
opts['security_groups'] = parsed_args.security_group
|
||||||
if parsed_args.expose_port:
|
if parsed_args.expose_port:
|
||||||
|
@@ -26,7 +26,8 @@ CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory',
|
|||||||
'security_groups', 'hints', 'nets', 'auto_remove',
|
'security_groups', 'hints', 'nets', 'auto_remove',
|
||||||
'runtime', 'hostname', 'mounts', 'disk',
|
'runtime', 'hostname', 'mounts', 'disk',
|
||||||
'availability_zone', 'auto_heal', 'privileged',
|
'availability_zone', 'auto_heal', 'privileged',
|
||||||
'exposed_ports', 'healthcheck', 'registry', 'tty']
|
'exposed_ports', 'healthcheck', 'registry', 'tty',
|
||||||
|
'host']
|
||||||
|
|
||||||
|
|
||||||
class Container(base.Resource):
|
class Container(base.Resource):
|
||||||
|
@@ -184,6 +184,10 @@ def _show_container(container):
|
|||||||
@utils.arg('--registry',
|
@utils.arg('--registry',
|
||||||
metavar='<registry>',
|
metavar='<registry>',
|
||||||
help='The container image registry ID or name')
|
help='The container image registry ID or name')
|
||||||
|
@utils.arg('--host',
|
||||||
|
metavar='<host>',
|
||||||
|
help='Requested host to create containers. Admin only by default.'
|
||||||
|
'(Supported by API versions 1.39 or above)')
|
||||||
def do_create(cs, args):
|
def do_create(cs, args):
|
||||||
"""Create a container."""
|
"""Create a container."""
|
||||||
opts = {}
|
opts = {}
|
||||||
@@ -206,6 +210,7 @@ def do_create(cs, args):
|
|||||||
opts['availability_zone'] = args.availability_zone
|
opts['availability_zone'] = args.availability_zone
|
||||||
opts['command'] = args.command
|
opts['command'] = args.command
|
||||||
opts['registry'] = args.registry
|
opts['registry'] = args.registry
|
||||||
|
opts['host'] = args.host
|
||||||
if args.healthcheck:
|
if args.healthcheck:
|
||||||
opts['healthcheck'] = zun_utils.parse_health(args.healthcheck)
|
opts['healthcheck'] = zun_utils.parse_health(args.healthcheck)
|
||||||
|
|
||||||
@@ -708,6 +713,10 @@ def do_kill(cs, args):
|
|||||||
@utils.arg('--registry',
|
@utils.arg('--registry',
|
||||||
metavar='<registry>',
|
metavar='<registry>',
|
||||||
help='The container image registry ID or name')
|
help='The container image registry ID or name')
|
||||||
|
@utils.arg('--host',
|
||||||
|
metavar='<host>',
|
||||||
|
help='Requested host to run containers. Admin only by default.'
|
||||||
|
'(Supported by API versions 1.39 or above)')
|
||||||
def do_run(cs, args):
|
def do_run(cs, args):
|
||||||
"""Run a command in a new container."""
|
"""Run a command in a new container."""
|
||||||
opts = {}
|
opts = {}
|
||||||
@@ -730,6 +739,7 @@ def do_run(cs, args):
|
|||||||
opts['availability_zone'] = args.availability_zone
|
opts['availability_zone'] = args.availability_zone
|
||||||
opts['command'] = args.command
|
opts['command'] = args.command
|
||||||
opts['registry'] = args.registry
|
opts['registry'] = args.registry
|
||||||
|
opts['host'] = args.host
|
||||||
if args.healthcheck:
|
if args.healthcheck:
|
||||||
opts['healthcheck'] = zun_utils.parse_health(args.healthcheck)
|
opts['healthcheck'] = zun_utils.parse_health(args.healthcheck)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user