Merge "Add --availability-zone option to container"
This commit is contained in:
@@ -163,6 +163,11 @@ class CreateContainer(command.ShowOne):
|
|||||||
type=int,
|
type=int,
|
||||||
default=None,
|
default=None,
|
||||||
help='The disk size in GiB for per container.')
|
help='The disk size in GiB for per container.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--availability-zone',
|
||||||
|
metavar='<availability_zone>',
|
||||||
|
default=None,
|
||||||
|
help='The availability zone of the container.')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -193,6 +198,7 @@ class CreateContainer(command.ShowOne):
|
|||||||
opts['runtime'] = parsed_args.runtime
|
opts['runtime'] = parsed_args.runtime
|
||||||
opts['hostname'] = parsed_args.hostname
|
opts['hostname'] = parsed_args.hostname
|
||||||
opts['disk'] = parsed_args.disk
|
opts['disk'] = parsed_args.disk
|
||||||
|
opts['availability_zone'] = parsed_args.availability_zone
|
||||||
|
|
||||||
opts = zun_utils.remove_null_parms(**opts)
|
opts = zun_utils.remove_null_parms(**opts)
|
||||||
container = client.containers.create(**opts)
|
container = client.containers.create(**opts)
|
||||||
@@ -723,6 +729,11 @@ class RunContainer(command.ShowOne):
|
|||||||
type=int,
|
type=int,
|
||||||
default=None,
|
default=None,
|
||||||
help='The disk size in GiB for per container.')
|
help='The disk size in GiB for per container.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--availability-zone',
|
||||||
|
metavar='<availability_zone>',
|
||||||
|
default=None,
|
||||||
|
help='The availability zone of the container.')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -753,6 +764,7 @@ class RunContainer(command.ShowOne):
|
|||||||
opts['runtime'] = parsed_args.runtime
|
opts['runtime'] = parsed_args.runtime
|
||||||
opts['hostname'] = parsed_args.hostname
|
opts['hostname'] = parsed_args.hostname
|
||||||
opts['disk'] = parsed_args.disk
|
opts['disk'] = parsed_args.disk
|
||||||
|
opts['availability_zone'] = parsed_args.availability_zone
|
||||||
|
|
||||||
opts = zun_utils.remove_null_parms(**opts)
|
opts = zun_utils.remove_null_parms(**opts)
|
||||||
container = client.containers.run(**opts)
|
container = client.containers.run(**opts)
|
||||||
|
|||||||
@@ -191,6 +191,14 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
|
|||||||
mock_run.assert_called_with(
|
mock_run.assert_called_with(
|
||||||
**_get_container_args(image='x', runtime='runc'))
|
**_get_container_args(image='x', runtime='runc'))
|
||||||
|
|
||||||
|
@mock.patch('zunclient.v1.containers_shell._show_container')
|
||||||
|
@mock.patch('zunclient.v1.containers.ContainerManager.run')
|
||||||
|
def test_zun_container_run_success_with_availability_zone(
|
||||||
|
self, mock_run, mock_show_container):
|
||||||
|
mock_run.return_value = 'container'
|
||||||
|
self._test_arg_success('run --availability-zone nova x')
|
||||||
|
mock_show_container.assert_called_once_with('container')
|
||||||
|
|
||||||
@mock.patch('zunclient.v1.containers_shell._show_container')
|
@mock.patch('zunclient.v1.containers_shell._show_container')
|
||||||
@mock.patch('zunclient.v1.containers.ContainerManager.run')
|
@mock.patch('zunclient.v1.containers.ContainerManager.run')
|
||||||
def test_zun_container_run_with_mount(
|
def test_zun_container_run_with_mount(
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ CREATION_ATTRIBUTES = ['name', 'image', 'command', 'cpu', 'memory',
|
|||||||
'environment', 'workdir', 'labels', 'image_pull_policy',
|
'environment', 'workdir', 'labels', 'image_pull_policy',
|
||||||
'restart_policy', 'interactive', 'image_driver',
|
'restart_policy', 'interactive', 'image_driver',
|
||||||
'security_groups', 'hints', 'nets', 'auto_remove',
|
'security_groups', 'hints', 'nets', 'auto_remove',
|
||||||
'runtime', 'hostname', 'mounts', 'disk']
|
'runtime', 'hostname', 'mounts', 'disk',
|
||||||
|
'availability_zone']
|
||||||
|
|
||||||
|
|
||||||
class Container(base.Resource):
|
class Container(base.Resource):
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ def _show_container(container):
|
|||||||
type=int,
|
type=int,
|
||||||
default=None,
|
default=None,
|
||||||
help='The disk size in GiB for per container.')
|
help='The disk size in GiB for per container.')
|
||||||
|
@utils.arg('--availability-zone',
|
||||||
|
metavar='<availability_zone>',
|
||||||
|
default=None,
|
||||||
|
help='The availability zone of the container.')
|
||||||
def do_create(cs, args):
|
def do_create(cs, args):
|
||||||
"""Create a container."""
|
"""Create a container."""
|
||||||
opts = {}
|
opts = {}
|
||||||
@@ -148,6 +152,7 @@ def do_create(cs, args):
|
|||||||
opts['runtime'] = args.runtime
|
opts['runtime'] = args.runtime
|
||||||
opts['hostname'] = args.hostname
|
opts['hostname'] = args.hostname
|
||||||
opts['disk'] = args.disk
|
opts['disk'] = args.disk
|
||||||
|
opts['availability_zone'] = args.availability_zone
|
||||||
|
|
||||||
if args.security_group:
|
if args.security_group:
|
||||||
opts['security_groups'] = args.security_group
|
opts['security_groups'] = args.security_group
|
||||||
@@ -550,6 +555,10 @@ def do_kill(cs, args):
|
|||||||
type=int,
|
type=int,
|
||||||
default=None,
|
default=None,
|
||||||
help='The disk size in GiB for per container.')
|
help='The disk size in GiB for per container.')
|
||||||
|
@utils.arg('--availability-zone',
|
||||||
|
metavar='<availability_zone>',
|
||||||
|
default=None,
|
||||||
|
help='The availability zone of the container.')
|
||||||
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 = {}
|
||||||
@@ -569,6 +578,7 @@ def do_run(cs, args):
|
|||||||
opts['runtime'] = args.runtime
|
opts['runtime'] = args.runtime
|
||||||
opts['hostname'] = args.hostname
|
opts['hostname'] = args.hostname
|
||||||
opts['disk'] = args.disk
|
opts['disk'] = args.disk
|
||||||
|
opts['availability_zone'] = args.availability_zone
|
||||||
|
|
||||||
if args.security_group:
|
if args.security_group:
|
||||||
opts['security_groups'] = args.security_group
|
opts['security_groups'] = args.security_group
|
||||||
|
|||||||
Reference in New Issue
Block a user