Change 'command' type from string to list
This changes the type of command parameter from string to list as changed in server side[1]. [1] https://review.openstack.org/#/c/575709/ Change-Id: I980834cee0031ef12a720d46eebaed33e8cb4c02 Closes-bug: #1780656
This commit is contained in:
committed by
Hongbin Lu
parent
46ee18e0cf
commit
846c8fd60b
@@ -31,7 +31,7 @@ if not LOG.handlers:
|
||||
HEADER_NAME = "OpenStack-API-Version"
|
||||
SERVICE_TYPE = "container"
|
||||
MIN_API_VERSION = '1.1'
|
||||
MAX_API_VERSION = '1.18'
|
||||
MAX_API_VERSION = '1.20'
|
||||
DEFAULT_API_VERSION = MAX_API_VERSION
|
||||
|
||||
_SUBSTITUTIONS = {}
|
||||
|
||||
@@ -194,10 +194,9 @@ class CreateContainer(command.ShowOne):
|
||||
opts['image_pull_policy'] = parsed_args.image_pull_policy
|
||||
opts['image_driver'] = parsed_args.image_driver
|
||||
opts['auto_remove'] = parsed_args.auto_remove
|
||||
opts['command'] = parsed_args.command
|
||||
if parsed_args.security_group:
|
||||
opts['security_groups'] = parsed_args.security_group
|
||||
if parsed_args.command:
|
||||
opts['command'] = zun_utils.parse_command(parsed_args.command)
|
||||
if parsed_args.restart:
|
||||
opts['restart_policy'] = \
|
||||
zun_utils.check_restart_policy(parsed_args.restart)
|
||||
@@ -813,10 +812,9 @@ class RunContainer(command.ShowOne):
|
||||
opts['image_pull_policy'] = parsed_args.image_pull_policy
|
||||
opts['image_driver'] = parsed_args.image_driver
|
||||
opts['auto_remove'] = parsed_args.auto_remove
|
||||
opts['command'] = parsed_args.command
|
||||
if parsed_args.security_group:
|
||||
opts['security_groups'] = parsed_args.security_group
|
||||
if parsed_args.command:
|
||||
opts['command'] = zun_utils.parse_command(parsed_args.command)
|
||||
if parsed_args.restart:
|
||||
opts['restart_policy'] = \
|
||||
zun_utils.check_restart_policy(parsed_args.restart)
|
||||
|
||||
@@ -246,7 +246,7 @@ class ShellTest(utils.TestCase):
|
||||
project_domain_id='', project_domain_name='',
|
||||
user_domain_id='', user_domain_name='', profile=None,
|
||||
endpoint_override=None, insecure=False,
|
||||
version=api_versions.APIVersion('1.18'))
|
||||
version=api_versions.APIVersion('1.20'))
|
||||
|
||||
def test_main_option_region(self):
|
||||
self.make_env()
|
||||
@@ -274,7 +274,7 @@ class ShellTest(utils.TestCase):
|
||||
project_domain_id='', project_domain_name='',
|
||||
user_domain_id='', user_domain_name='', profile=None,
|
||||
endpoint_override=None, insecure=False,
|
||||
version=api_versions.APIVersion('1.18'))
|
||||
version=api_versions.APIVersion('1.20'))
|
||||
|
||||
@mock.patch('zunclient.client.Client')
|
||||
def test_main_endpoint_internal(self, mock_client):
|
||||
@@ -288,7 +288,7 @@ class ShellTest(utils.TestCase):
|
||||
project_domain_id='', project_domain_name='',
|
||||
user_domain_id='', user_domain_name='', profile=None,
|
||||
endpoint_override=None, insecure=False,
|
||||
version=api_versions.APIVersion('1.18'))
|
||||
version=api_versions.APIVersion('1.20'))
|
||||
|
||||
|
||||
class ShellTestKeystoneV3(ShellTest):
|
||||
@@ -319,4 +319,4 @@ class ShellTestKeystoneV3(ShellTest):
|
||||
project_domain_id='', project_domain_name='Default',
|
||||
user_domain_id='', user_domain_name='Default',
|
||||
endpoint_override=None, insecure=False, profile=None,
|
||||
version=api_versions.APIVersion('1.18'))
|
||||
version=api_versions.APIVersion('1.20'))
|
||||
|
||||
@@ -22,6 +22,7 @@ import fixtures
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from zunclient import api_versions
|
||||
from zunclient.common import httpclient as http
|
||||
from zunclient import shell
|
||||
|
||||
@@ -42,6 +43,8 @@ class FakeAPI(object):
|
||||
def __init__(self, responses):
|
||||
self.responses = responses
|
||||
self.calls = []
|
||||
self.api_version = api_versions.APIVersion(
|
||||
api_versions.MAX_API_VERSION)
|
||||
|
||||
def _request(self, method, url, headers=None, body=None):
|
||||
call = (method, url, headers or {}, body)
|
||||
|
||||
@@ -28,6 +28,7 @@ def _get_container_args(**kwargs):
|
||||
'labels': {},
|
||||
'mounts': [],
|
||||
'nets': [],
|
||||
'command': [],
|
||||
}
|
||||
default_args.update(kwargs)
|
||||
return default_args
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from zunclient import api_versions
|
||||
from zunclient.common import base
|
||||
from zunclient.common import utils
|
||||
from zunclient import exceptions
|
||||
@@ -94,6 +95,8 @@ class ContainerManager(base.Manager):
|
||||
return None
|
||||
|
||||
def create(self, **kwargs):
|
||||
self._process_command(kwargs)
|
||||
|
||||
new = {}
|
||||
for (key, value) in kwargs.items():
|
||||
if key in CREATION_ATTRIBUTES:
|
||||
@@ -103,6 +106,13 @@ class ContainerManager(base.Manager):
|
||||
"Key must be in %s" % ','.join(CREATION_ATTRIBUTES))
|
||||
return self._create(self._path(), new)
|
||||
|
||||
def _process_command(self, kwargs):
|
||||
cmd_microversion = api_versions.APIVersion("1.20")
|
||||
if self.api_version < cmd_microversion:
|
||||
command = kwargs.pop('command', None)
|
||||
if command:
|
||||
kwargs['command'] = utils.parse_command(command)
|
||||
|
||||
def delete(self, id, **kwargs):
|
||||
return self._delete(self._path(id),
|
||||
qparams=kwargs)
|
||||
@@ -159,6 +169,8 @@ class ContainerManager(base.Manager):
|
||||
qparams={'signal': signal})[1]
|
||||
|
||||
def run(self, **kwargs):
|
||||
self._process_command(kwargs)
|
||||
|
||||
if not set(kwargs).issubset(CREATION_ATTRIBUTES):
|
||||
raise exceptions.InvalidAttribute(
|
||||
"Key must be in %s" % ','.join(CREATION_ATTRIBUTES))
|
||||
|
||||
@@ -169,11 +169,10 @@ def do_create(cs, args):
|
||||
opts['disk'] = args.disk
|
||||
opts['availability_zone'] = args.availability_zone
|
||||
opts['auto_heal'] = args.auto_heal
|
||||
opts['command'] = args.command
|
||||
|
||||
if args.security_group:
|
||||
opts['security_groups'] = args.security_group
|
||||
if args.command:
|
||||
opts['command'] = zun_utils.parse_command(args.command)
|
||||
if args.restart:
|
||||
opts['restart_policy'] = zun_utils.check_restart_policy(args.restart)
|
||||
if args.interactive:
|
||||
@@ -657,11 +656,10 @@ def do_run(cs, args):
|
||||
opts['disk'] = args.disk
|
||||
opts['availability_zone'] = args.availability_zone
|
||||
opts['auto_heal'] = args.auto_heal
|
||||
opts['command'] = args.command
|
||||
|
||||
if args.security_group:
|
||||
opts['security_groups'] = args.security_group
|
||||
if args.command:
|
||||
opts['command'] = zun_utils.parse_command(args.command)
|
||||
if args.restart:
|
||||
opts['restart_policy'] = zun_utils.check_restart_policy(args.restart)
|
||||
if args.interactive:
|
||||
|
||||
Reference in New Issue
Block a user