Merge "Add scheduler hint for zunclient"

This commit is contained in:
Jenkins
2017-05-29 14:51:21 +00:00
committed by Gerrit Code Review
3 changed files with 42 additions and 1 deletions

View File

@@ -112,6 +112,13 @@ class CreateContainer(command.ShowOne):
metavar='<command>',
nargs=argparse.REMAINDER,
help='Send command to the container')
parser.add_argument(
'--hint',
metavar='key=value',
action='append',
default=[],
help='Container hint key/value pairs for scheduler to select'
' host. May be used multiple times.')
return parser
def take_action(self, parsed_args):
@@ -134,6 +141,9 @@ class CreateContainer(command.ShowOne):
if parsed_args.interactive:
opts['interactive'] = True
hints = zun_utils.format_args(parsed_args.hint)
opts['hint'] = hints
opts = zun_utils.remove_null_parms(**opts)
container = client.containers.create(**opts)
columns = _container_columns(container)
@@ -576,6 +586,13 @@ class RunContainer(command.ShowOne):
metavar='<command>',
nargs=argparse.REMAINDER,
help='Send command to the container')
parser.add_argument(
'--hint',
metavar='key=value',
action='append',
default=[],
help='Container hint key/value pairs for scheduler to select'
' host. May be used multiple times.')
return parser
def take_action(self, parsed_args):
@@ -598,6 +615,9 @@ class RunContainer(command.ShowOne):
if parsed_args.interactive:
opts['interactive'] = True
hints = zun_utils.format_args(parsed_args.hint)
opts['hint'] = hints
opts = zun_utils.remove_null_parms(**opts)
container = client.containers.run(**opts)
columns = _container_columns(container)

View File

@@ -21,7 +21,8 @@ from zunclient import exceptions
CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory',
'environment', 'workdir', 'labels', 'image_pull_policy',
'restart_policy', 'interactive', 'image_driver']
'restart_policy', 'interactive', 'image_driver',
'hint']
class Container(base.Resource):

View File

@@ -85,6 +85,12 @@ def _show_container(container):
metavar='<command>',
nargs=argparse.REMAINDER,
help='Send command to the container')
@utils.arg('--hint',
action='append',
default=[],
metavar='<key=value>',
help='Container hint key/value pairs for scheduler to select'
' host. May be used multiple times.')
def do_create(cs, args):
"""Create a container."""
opts = {}
@@ -97,6 +103,10 @@ def do_create(cs, args):
opts['labels'] = zun_utils.format_args(args.label)
opts['image_pull_policy'] = args.image_pull_policy
opts['image_driver'] = args.image_driver
hints = zun_utils.format_args(args.hint)
opts['hint'] = hints
if args.command:
opts['command'] = ' '.join(args.command)
if args.restart:
@@ -415,6 +425,12 @@ def do_kill(cs, args):
metavar='<command>',
nargs=argparse.REMAINDER,
help='Send command to the container')
@utils.arg('--hint',
action='append',
default=[],
metavar='<key=value>',
help='Container hint key/value pairs for scheduler to select'
' host. May be used multiple times.')
def do_run(cs, args):
"""Run a command in a new container."""
opts = {}
@@ -427,6 +443,10 @@ def do_run(cs, args):
opts['labels'] = zun_utils.format_args(args.label)
opts['image_pull_policy'] = args.image_pull_policy
opts['image_driver'] = args.image_driver
hints = zun_utils.format_args(args.hint)
opts['hint'] = hints
if args.command:
opts['command'] = ' '.join(args.command)
if args.restart: