summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongbin Lu <hongbin.lu@huawei.com>2018-01-10 03:47:04 +0000
committerHongbin Lu <hongbin034@gmail.com>2018-01-27 18:17:47 +0000
commit1617aadf5f7969820443c0a702ed2cf5ee2c07aa (patch)
tree3413c233ea2049bf52c4313eaff488cb0492d975
parentfea2a2aca09ce0adb0c3cbe296503ce4d58b5bfb (diff)
downloadheat-1617aadf5f7969820443c0a702ed2cf5ee2c07aa.tar.gz
zun: add hostname, hints and security_groups
Add three properties to the container resource: hostname, hints and security_groups. The 'hostname' is the hostname of the container. The 'hints' is a set of key-value pair passed to the scheduler. The 'security_groups' is a list of neutron security groups. Change-Id: I518e37c9907350e364fa9a16b25013e68cc60fa9
-rw-r--r--heat/engine/resources/openstack/zun/container.py22
-rw-r--r--heat/tests/openstack/zun/test_container.py26
-rw-r--r--releasenotes/notes/add-hostname-hints-security_groups-to-container-d3b69ae4b6f71fc7.yaml5
3 files changed, 50 insertions, 3 deletions
diff --git a/heat/engine/resources/openstack/zun/container.py b/heat/engine/resources/openstack/zun/container.py
index 472a062a8..0265f9d82 100644
--- a/heat/engine/resources/openstack/zun/container.py
+++ b/heat/engine/resources/openstack/zun/container.py
@@ -33,11 +33,13 @@ class Container(resource.Resource):
PROPERTIES = (
NAME, IMAGE, COMMAND, CPU, MEMORY,
ENVIRONMENT, WORKDIR, LABELS, IMAGE_PULL_POLICY,
- RESTART_POLICY, INTERACTIVE, IMAGE_DRIVER
+ RESTART_POLICY, INTERACTIVE, IMAGE_DRIVER, HINTS,
+ HOSTNAME, SECURITY_GROUPS,
) = (
'name', 'image', 'command', 'cpu', 'memory',
'environment', 'workdir', 'labels', 'image_pull_policy',
- 'restart_policy', 'interactive', 'image_driver'
+ 'restart_policy', 'interactive', 'image_driver', 'hints',
+ 'hostname', 'security_groups',
)
ATTRIBUTES = (
@@ -110,6 +112,22 @@ class Container(resource.Resource):
constraints.AllowedValues(['docker', 'glance']),
]
),
+ HINTS: properties.Schema(
+ properties.Schema.MAP,
+ _('Arbitrary key-value pairs for scheduler to select host.'),
+ support_status=support.SupportStatus(version='10.0.0'),
+ ),
+ HOSTNAME: properties.Schema(
+ properties.Schema.STRING,
+ _('The hostname of the container.'),
+ support_status=support.SupportStatus(version='10.0.0'),
+ ),
+ SECURITY_GROUPS: properties.Schema(
+ properties.Schema.LIST,
+ _('List of security group names or IDs.'),
+ support_status=support.SupportStatus(version='10.0.0'),
+ default=[]
+ ),
}
attributes_schema = {
diff --git a/heat/tests/openstack/zun/test_container.py b/heat/tests/openstack/zun/test_container.py
index 926fdf209..393b0506d 100644
--- a/heat/tests/openstack/zun/test_container.py
+++ b/heat/tests/openstack/zun/test_container.py
@@ -47,6 +47,11 @@ resources:
restart_policy: on-failure:2
interactive: false
image_driver: docker
+ hints:
+ hintkey: hintval
+ hostname: myhost
+ security_groups:
+ - my_seg
'''
@@ -69,6 +74,10 @@ class ZunContainerTest(common.HeatTestCase):
'Name': 'on-failure'}
self.fake_interactive = False
self.fake_image_driver = 'docker'
+ self.fake_hints = {'hintkey': 'hintval'}
+ self.fake_hostname = 'myhost'
+ self.fake_security_groups = ['my_seg']
+
self.fake_network_id = '9c11d847-99ce-4a83-82da-9827362a68e8'
self.fake_network_name = 'private'
self.fake_networks = {
@@ -117,6 +126,9 @@ class ZunContainerTest(common.HeatTestCase):
value.restart_policy = self.fake_restart_policy
value.interactive = self.fake_interactive
value.image_driver = self.fake_image_driver
+ value.hints = self.fake_hints
+ value.hostname = self.fake_hostname
+ value.security_groups = self.fake_security_groups
value.addresses = self.fake_addresses
value.to_dict.return_value = value.__dict__
@@ -170,6 +182,15 @@ class ZunContainerTest(common.HeatTestCase):
self.assertEqual(
self.fake_image_driver,
c.properties.get(container.Container.IMAGE_DRIVER))
+ self.assertEqual(
+ self.fake_hints,
+ c.properties.get(container.Container.HINTS))
+ self.assertEqual(
+ self.fake_hostname,
+ c.properties.get(container.Container.HOSTNAME))
+ self.assertEqual(
+ self.fake_security_groups,
+ c.properties.get(container.Container.SECURITY_GROUPS))
scheduler.TaskRunner(c.create)()
self.assertEqual(self.resource_id, c.resource_id)
@@ -187,7 +208,10 @@ class ZunContainerTest(common.HeatTestCase):
image_pull_policy=self.fake_image_policy,
restart_policy=self.fake_restart_policy,
interactive=self.fake_interactive,
- image_driver=self.fake_image_driver
+ image_driver=self.fake_image_driver,
+ hints=self.fake_hints,
+ hostname=self.fake_hostname,
+ security_groups=self.fake_security_groups,
)
def test_container_create_failed(self):
diff --git a/releasenotes/notes/add-hostname-hints-security_groups-to-container-d3b69ae4b6f71fc7.yaml b/releasenotes/notes/add-hostname-hints-security_groups-to-container-d3b69ae4b6f71fc7.yaml
new file mode 100644
index 000000000..7ad670b2b
--- /dev/null
+++ b/releasenotes/notes/add-hostname-hints-security_groups-to-container-d3b69ae4b6f71fc7.yaml
@@ -0,0 +1,5 @@
+---
+features:
+ - |
+ Add properties hostname, hints, security_groups to Zun's container
+ resource.