Merge "Add image_driver option to create and run"
This commit is contained in:
commit
4507d6b43e
@ -108,6 +108,13 @@ class CreateContainer(command.ShowOne):
|
||||
metavar='<restart>',
|
||||
help='Restart policy to apply when a container exits'
|
||||
'(no, on-failure[:max-retry], always, unless-stopped)')
|
||||
parser.add_argument(
|
||||
'--image-driver',
|
||||
metavar='<image_driver>',
|
||||
help='The image driver to use to pull container image. '
|
||||
'It can have following values: '
|
||||
'"docker": pull the image from Docker Hub. '
|
||||
'"glance": pull the image from Glance. ')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -122,6 +129,7 @@ class CreateContainer(command.ShowOne):
|
||||
opts['workdir'] = parsed_args.workdir
|
||||
opts['labels'] = zun_utils.format_args(parsed_args.label)
|
||||
opts['image_pull_policy'] = parsed_args.image_pull_policy
|
||||
opts['image_driver'] = parsed_args.image_driver
|
||||
if parsed_args.restart:
|
||||
opts['restart_policy'] = _check_restart_policy(parsed_args.restart)
|
||||
|
||||
@ -514,6 +522,13 @@ class RunContainer(command.ShowOne):
|
||||
metavar='<restart>',
|
||||
help='Restart policy to apply when a container exits'
|
||||
'(no, on-failure[:max-retry], always, unless-stopped)')
|
||||
parser.add_argument(
|
||||
'--image-driver',
|
||||
metavar='<image_driver>',
|
||||
help='The image driver to use to pull container image. '
|
||||
'It can have following values: '
|
||||
'"docker": pull the image from Docker Hub. '
|
||||
'"glance": pull the image from Glance. ')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -528,6 +543,7 @@ class RunContainer(command.ShowOne):
|
||||
opts['workdir'] = parsed_args.workdir
|
||||
opts['labels'] = zun_utils.format_args(parsed_args.label)
|
||||
opts['image_pull_policy'] = parsed_args.image_pull_policy
|
||||
opts['image_driver'] = parsed_args.image_driver
|
||||
if parsed_args.restart:
|
||||
opts['restart_policy'] = _check_restart_policy(parsed_args.restart)
|
||||
|
||||
|
@ -21,7 +21,7 @@ from zunclient import exceptions
|
||||
|
||||
CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory',
|
||||
'environment', 'workdir', 'labels', 'image_pull_policy',
|
||||
'restart_policy', 'tty', 'stdin_open']
|
||||
'restart_policy', 'tty', 'stdin_open', 'image_driver']
|
||||
|
||||
|
||||
class Container(base.Resource):
|
||||
|
@ -120,6 +120,12 @@ def _remove_null_parms(**kwargs):
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Keep STDIN open even if not attached')
|
||||
@utils.arg('--image-driver',
|
||||
metavar='<image_driver>',
|
||||
help='The image driver to use to pull container image. '
|
||||
'It can have following values: '
|
||||
'"docker": pull the image from Docker Hub. '
|
||||
'"glance": pull the image from Glance. ')
|
||||
def do_create(cs, args):
|
||||
"""Create a container."""
|
||||
opts = {}
|
||||
@ -132,6 +138,7 @@ def do_create(cs, args):
|
||||
opts['workdir'] = args.workdir
|
||||
opts['labels'] = zun_utils.format_args(args.label)
|
||||
opts['image_pull_policy'] = args.image_pull_policy
|
||||
opts['image_driver'] = args.image_driver
|
||||
if args.restart:
|
||||
opts['restart_policy'] = _check_restart_policy(args.restart)
|
||||
if args.tty:
|
||||
@ -402,6 +409,12 @@ def do_kill(cs, args):
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Keep STDIN open even if not attached')
|
||||
@utils.arg('--image-driver',
|
||||
metavar='<image_driver>',
|
||||
help='The image driver to use to pull container image. '
|
||||
'It can have following values: '
|
||||
'"docker": pull the image from Docker Hub. '
|
||||
'"glance": pull the image from Glance. ')
|
||||
def do_run(cs, args):
|
||||
"""Run a command in a new container"""
|
||||
opts = {}
|
||||
@ -414,6 +427,7 @@ def do_run(cs, args):
|
||||
opts['workdir'] = args.workdir
|
||||
opts['labels'] = zun_utils.format_args(args.label)
|
||||
opts['image_pull_policy'] = args.image_pull_policy
|
||||
opts['image_driver'] = args.image_driver
|
||||
if args.restart:
|
||||
opts['restart_policy'] = _check_restart_policy(args.restart)
|
||||
if args.tty:
|
||||
|
Loading…
Reference in New Issue
Block a user