Add image_driver option to create and run

The image_driver option has been added in server:
https://review.openstack.org/#/c/423592/
This commit introduces it to client

Change-Id: I544c418369cc632409b0b3343949441554f7c19b
Implements: blueprint allow-specify-image-driver
This commit is contained in:
Hongbin Lu 2017-02-16 16:07:28 -06:00
parent 0ec418dbe6
commit c1b674222e
3 changed files with 31 additions and 1 deletions

View File

@ -107,6 +107,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):
@ -121,6 +128,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)
@ -503,6 +511,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):
@ -517,6 +532,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)

View File

@ -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):

View File

@ -119,6 +119,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 = {}
@ -131,6 +137,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:
@ -395,6 +402,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 = {}
@ -407,6 +420,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: