Merge "zun: add 'tty' property to container"
This commit is contained in:
commit
d33d27af0d
@ -28,9 +28,9 @@ class ZunClientPlugin(client_plugin.ClientPlugin):
|
||||
default_version = '1.12'
|
||||
|
||||
supported_versions = [
|
||||
V1_12, V1_18
|
||||
V1_12, V1_18, V1_36,
|
||||
] = [
|
||||
'1.12', '1.18'
|
||||
'1.12', '1.18', '1.36',
|
||||
]
|
||||
|
||||
def _create(self, version=None):
|
||||
|
@ -39,12 +39,12 @@ class Container(resource.Resource,
|
||||
NAME, IMAGE, COMMAND, CPU, MEMORY,
|
||||
ENVIRONMENT, WORKDIR, LABELS, IMAGE_PULL_POLICY,
|
||||
RESTART_POLICY, INTERACTIVE, IMAGE_DRIVER, HINTS,
|
||||
HOSTNAME, SECURITY_GROUPS, MOUNTS, NETWORKS,
|
||||
HOSTNAME, SECURITY_GROUPS, MOUNTS, NETWORKS, TTY,
|
||||
) = (
|
||||
'name', 'image', 'command', 'cpu', 'memory',
|
||||
'environment', 'workdir', 'labels', 'image_pull_policy',
|
||||
'restart_policy', 'interactive', 'image_driver', 'hints',
|
||||
'hostname', 'security_groups', 'mounts', 'networks',
|
||||
'hostname', 'security_groups', 'mounts', 'networks', 'tty',
|
||||
)
|
||||
|
||||
_NETWORK_KEYS = (
|
||||
@ -129,6 +129,11 @@ class Container(resource.Resource,
|
||||
properties.Schema.BOOLEAN,
|
||||
_('Keep STDIN open even if not attached.'),
|
||||
),
|
||||
TTY: properties.Schema(
|
||||
properties.Schema.BOOLEAN,
|
||||
_('Whether the container allocates a TTY for itself.'),
|
||||
support_status=support.SupportStatus(version='14.0.0'),
|
||||
),
|
||||
IMAGE_DRIVER: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('The image driver to use to pull container image.'),
|
||||
@ -320,7 +325,12 @@ class Container(resource.Resource,
|
||||
command = args.pop(self.COMMAND, None)
|
||||
if command:
|
||||
args['command'] = shlex.split(command)
|
||||
container = self.client().containers.run(**args)
|
||||
|
||||
if self.TTY in args:
|
||||
container = self.client(
|
||||
version=self.client_plugin().V1_36).containers.run(**args)
|
||||
else:
|
||||
container = self.client().containers.run(**args)
|
||||
self.resource_id_set(container.uuid)
|
||||
return container.uuid
|
||||
|
||||
|
@ -48,6 +48,7 @@ resources:
|
||||
image_pull_policy: always
|
||||
restart_policy: on-failure:2
|
||||
interactive: false
|
||||
tty: false
|
||||
image_driver: docker
|
||||
hints:
|
||||
hintkey: hintval
|
||||
@ -108,6 +109,7 @@ class ZunContainerTest(common.HeatTestCase):
|
||||
self.fake_restart_policy = {'MaximumRetryCount': '2',
|
||||
'Name': 'on-failure'}
|
||||
self.fake_interactive = False
|
||||
self.fake_tty = False
|
||||
self.fake_image_driver = 'docker'
|
||||
self.fake_hints = {'hintkey': 'hintval'}
|
||||
self.fake_hostname = 'myhost'
|
||||
@ -194,6 +196,7 @@ class ZunContainerTest(common.HeatTestCase):
|
||||
value.image_pull_policy = self.fake_image_policy
|
||||
value.restart_policy = self.fake_restart_policy
|
||||
value.interactive = self.fake_interactive
|
||||
value.tty = self.fake_tty
|
||||
value.image_driver = self.fake_image_driver
|
||||
value.hints = self.fake_hints
|
||||
value.hostname = self.fake_hostname
|
||||
@ -248,6 +251,9 @@ class ZunContainerTest(common.HeatTestCase):
|
||||
self.assertEqual(
|
||||
self.fake_interactive,
|
||||
c.properties.get(container.Container.INTERACTIVE))
|
||||
self.assertEqual(
|
||||
self.fake_tty,
|
||||
c.properties.get(container.Container.TTY))
|
||||
self.assertEqual(
|
||||
self.fake_image_driver,
|
||||
c.properties.get(container.Container.IMAGE_DRIVER))
|
||||
@ -283,6 +289,7 @@ class ZunContainerTest(common.HeatTestCase):
|
||||
image_pull_policy=self.fake_image_policy,
|
||||
restart_policy=self.fake_restart_policy,
|
||||
interactive=self.fake_interactive,
|
||||
tty=self.fake_tty,
|
||||
image_driver=self.fake_image_driver,
|
||||
hints=self.fake_hints,
|
||||
hostname=self.fake_hostname,
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``tty`` property to ``OS::Zun::Container``.
|
||||
This property allows users to open the TTY of the container.
|
Loading…
x
Reference in New Issue
Block a user