From ba68ef4ed66d35b3522b2da65014e687af5a1136 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Tue, 19 Aug 2014 15:17:22 -0600 Subject: [PATCH] orchestration/v1 stack resource Change-Id: I7a93f362d45d4cdb1d7f34f60d95ed552ac8164e --- openstack/orchestration/__init__.py | 0 .../orchestration/orchestration_service.py | 23 ++++++ openstack/orchestration/v1/__init__.py | 0 openstack/orchestration/v1/stack.py | 41 +++++++++++ openstack/tests/orchestration/__init__.py | 0 .../test_orchestration_service.py | 25 +++++++ openstack/tests/orchestration/v1/__init__.py | 0 .../tests/orchestration/v1/test_stack.py | 70 +++++++++++++++++++ 8 files changed, 159 insertions(+) create mode 100644 openstack/orchestration/__init__.py create mode 100644 openstack/orchestration/orchestration_service.py create mode 100644 openstack/orchestration/v1/__init__.py create mode 100644 openstack/orchestration/v1/stack.py create mode 100644 openstack/tests/orchestration/__init__.py create mode 100644 openstack/tests/orchestration/test_orchestration_service.py create mode 100644 openstack/tests/orchestration/v1/__init__.py create mode 100644 openstack/tests/orchestration/v1/test_stack.py diff --git a/openstack/orchestration/__init__.py b/openstack/orchestration/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openstack/orchestration/orchestration_service.py b/openstack/orchestration/orchestration_service.py new file mode 100644 index 000000000..1e581a525 --- /dev/null +++ b/openstack/orchestration/orchestration_service.py @@ -0,0 +1,23 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from openstack.auth import service_filter + + +class OrchestrationService(service_filter.ServiceFilter): + """The orchestration service.""" + + def __init__(self): + """Create an orchestration service.""" + super(OrchestrationService, self).__init__( + service_type='orchestration' + ) diff --git a/openstack/orchestration/v1/__init__.py b/openstack/orchestration/v1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openstack/orchestration/v1/stack.py b/openstack/orchestration/v1/stack.py new file mode 100644 index 000000000..43b2402ac --- /dev/null +++ b/openstack/orchestration/v1/stack.py @@ -0,0 +1,41 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from openstack.orchestration import orchestration_service +from openstack import resource + + +class Stack(resource.Resource): + resource_key = 'stack' + resources_key = 'stacks' + base_path = '/stacks' + service = orchestration_service.OrchestrationService() + + # capabilities + # NOTE(thowe): Special handling for other operations + allow_list = True + + # Properties + capabilities = resource.prop('capabilities') + creation_time = resource.prop('creation_time') + description = resource.prop('description') + disable_rollback = resource.prop('disable_rollback', type=bool) + links = resource.prop('links') + notification_topics = resource.prop('notification_topics') + outputs = resource.prop('outputs') + parameters = resource.prop('parameters', type=dict) + stack_name = resource.prop('stack_name') + stack_status = resource.prop('stack_status') + stack_status_reason = resource.prop('stack_status_reason') + template_description = resource.prop('template_description') + timeout_mins = resource.prop('timeout_mins') + updated_time = resource.prop('updated_time') diff --git a/openstack/tests/orchestration/__init__.py b/openstack/tests/orchestration/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openstack/tests/orchestration/test_orchestration_service.py b/openstack/tests/orchestration/test_orchestration_service.py new file mode 100644 index 000000000..91900d078 --- /dev/null +++ b/openstack/tests/orchestration/test_orchestration_service.py @@ -0,0 +1,25 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import testtools + +from openstack.orchestration import orchestration_service + + +class TestOrchestrationService(testtools.TestCase): + + def test_service(self): + sot = orchestration_service.OrchestrationService() + self.assertEqual('orchestration', sot.service_type) + self.assertEqual('public', sot.visibility) + self.assertIsNone(sot.region) + self.assertIsNone(sot.service_name) diff --git a/openstack/tests/orchestration/v1/__init__.py b/openstack/tests/orchestration/v1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openstack/tests/orchestration/v1/test_stack.py b/openstack/tests/orchestration/v1/test_stack.py new file mode 100644 index 000000000..65817149f --- /dev/null +++ b/openstack/tests/orchestration/v1/test_stack.py @@ -0,0 +1,70 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import testtools + +from openstack.orchestration.v1 import stack + +IDENTIFIER = 'IDENTIFIER' +EXAMPLE = { + 'capabilities': '1', + 'creation_time': '2', + 'description': '3', + 'disable_rollback': True, + 'id': IDENTIFIER, + 'links': '6', + 'notification_topics': '7', + 'outputs': '8', + 'parameters': {'OS::stack_id': '9'}, + 'stack_name': '10', + 'stack_status': '11', + 'stack_status_reason': '12', + 'template_description': '13', + 'timeout_mins': '14', + 'updated_time': '15', +} + + +class TestStack(testtools.TestCase): + + def test_basic(self): + sot = stack.Stack() + self.assertEqual('stack', sot.resource_key) + self.assertEqual('stacks', sot.resources_key) + self.assertEqual('/stacks', sot.base_path) + self.assertEqual('orchestration', sot.service.service_type) + self.assertFalse(sot.allow_create) + self.assertFalse(sot.allow_retrieve) + self.assertFalse(sot.allow_update) + self.assertFalse(sot.allow_delete) + self.assertTrue(sot.allow_list) + + def test_make_it(self): + sot = stack.Stack(EXAMPLE) + self.assertEqual(EXAMPLE['capabilities'], sot.capabilities) + self.assertEqual(EXAMPLE['creation_time'], sot.creation_time) + self.assertEqual(EXAMPLE['description'], sot.description) + self.assertEqual(EXAMPLE['disable_rollback'], sot.disable_rollback) + self.assertEqual(EXAMPLE['id'], sot.id) + self.assertEqual(EXAMPLE['links'], sot.links) + self.assertEqual(EXAMPLE['notification_topics'], + sot.notification_topics) + self.assertEqual(EXAMPLE['outputs'], sot.outputs) + self.assertEqual(EXAMPLE['parameters'], sot.parameters) + self.assertEqual(EXAMPLE['stack_name'], sot.stack_name) + self.assertEqual(EXAMPLE['stack_status'], sot.stack_status) + self.assertEqual(EXAMPLE['stack_status_reason'], + sot.stack_status_reason) + self.assertEqual(EXAMPLE['template_description'], + sot.template_description) + self.assertEqual(EXAMPLE['timeout_mins'], sot.timeout_mins) + self.assertEqual(EXAMPLE['updated_time'], sot.updated_time)