diff --git a/heat/engine/resources/openstack/zun/container.py b/heat/engine/resources/openstack/zun/container.py index 472a062a84..0265f9d829 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 926fdf2097..393b0506d1 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 0000000000..7ad670b2b3 --- /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.