diff --git a/doc/source/contributors/local.conf b/doc/source/contributors/local.conf index 862bea84..6a56eb20 100644 --- a/doc/source/contributors/local.conf +++ b/doc/source/contributors/local.conf @@ -19,6 +19,7 @@ KEYSTONE_BRANCH=stable/OPENSTACK_VERSION NEUTRON_BRANCH=stable/OPENSTACK_VERSION NOVA_BRANCH=stable/OPENSTACK_VERSION SWIFT_BRANCH=stable/OPENSTACK_VERSION +ZAQAR_BRANCH=stable/OPENSTACK_VERSION # Enable Swift enable_service s-proxy @@ -44,6 +45,10 @@ enable_service ceilometer-alarm-evaluator enable_service ceilometer-alarm-notifier enable_service ceilometer-api +# Enable Zaqar +enable_plugin zaqar https://github.com/openstack/zaqar +enable_service zaqar-server + # Automatically download and register a VM image that Heat can launch # For more information on Heat and DevStack see # http://docs.openstack.org/developer/heat/getting_started/on_devstack.html diff --git a/openstack/messaging/__init__.py b/openstack/messaging/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/openstack/messaging/messaging_service.py b/openstack/messaging/messaging_service.py new file mode 100644 index 00000000..a42306e8 --- /dev/null +++ b/openstack/messaging/messaging_service.py @@ -0,0 +1,26 @@ +# 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 MessagingService(service_filter.ServiceFilter): + """The messaging service.""" + + valid_versions = [service_filter.ValidVersion('v1')] + + def __init__(self, version=None): + """Create an messaging service.""" + super(MessagingService, self).__init__( + service_type='messaging', + version=version + ) diff --git a/openstack/messaging/v1/__init__.py b/openstack/messaging/v1/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/openstack/messaging/v1/_proxy.py b/openstack/messaging/v1/_proxy.py new file mode 100644 index 00000000..1d72970e --- /dev/null +++ b/openstack/messaging/v1/_proxy.py @@ -0,0 +1,29 @@ +# 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.messaging.v1 import queue +from openstack import proxy + + +class Proxy(proxy.BaseProxy): + + def create_queue(self, **attrs): + """Create a new queue from attributes + + :param dict attrs: Keyword arguments which will be used to create + a :class:`~openstack.messaging.v1.queue.Queue`, + comprised of the properties on the Queue class. + + :returns: The results of queue creation + :rtype: :class:`~openstack.messaging.v1.queue.Queue` + """ + return self._create(queue.Queue, **attrs) diff --git a/openstack/messaging/v1/queue.py b/openstack/messaging/v1/queue.py new file mode 100644 index 00000000..7ea67775 --- /dev/null +++ b/openstack/messaging/v1/queue.py @@ -0,0 +1,33 @@ +# 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.messaging import messaging_service +from openstack import resource + + +class Queue(resource.Resource): + id_attribute = 'name' + resources_key = 'queues' + base_path = '/queues' + service = messaging_service.MessagingService() + + # capabilities + allow_create = True + allow_list = False + allow_retrieve = False + allow_delete = False + + @classmethod + def create_by_id(cls, session, attrs, resource_id=None, path_args=None): + url = cls._get_url(path_args, resource_id) + session.put(url, service=cls.service, accept=None) + return {cls.id_attribute: resource_id} diff --git a/openstack/messaging/version.py b/openstack/messaging/version.py new file mode 100644 index 00000000..b43c0f0a --- /dev/null +++ b/openstack/messaging/version.py @@ -0,0 +1,30 @@ +# 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.messaging import messaging_service +from openstack import resource + + +class Version(resource.Resource): + resource_key = 'version' + resources_key = 'versions' + base_path = '/' + service = messaging_service.MessagingService( + version=messaging_service.MessagingService.UNVERSIONED + ) + + # capabilities + allow_list = True + + # Properties + links = resource.prop('links') + status = resource.prop('status') diff --git a/openstack/profile.py b/openstack/profile.py index 20b37943..34dd6d79 100644 --- a/openstack/profile.py +++ b/openstack/profile.py @@ -59,6 +59,7 @@ from openstack import exceptions from openstack.identity import identity_service from openstack.image import image_service from openstack.keystore import keystore_service +from openstack.messaging import messaging_service from openstack.metric import metric_service from openstack.network import network_service from openstack.object_store import object_store_service @@ -120,6 +121,9 @@ class Profile(object): serv = volume_service.VolumeService() serv.set_visibility(None) self._services[serv.service_type] = serv + serv = messaging_service.MessagingService() + serv.set_visibility(None) + self._services[serv.service_type] = serv self.service_names = sorted(self._services.keys()) diff --git a/openstack/tests/unit/messaging/__init__.py b/openstack/tests/unit/messaging/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/openstack/tests/unit/messaging/test_messaging_service.py b/openstack/tests/unit/messaging/test_messaging_service.py new file mode 100644 index 00000000..76e3a404 --- /dev/null +++ b/openstack/tests/unit/messaging/test_messaging_service.py @@ -0,0 +1,28 @@ +# 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.messaging import messaging_service + + +class TestOrchestrationService(testtools.TestCase): + + def test_service(self): + sot = messaging_service.MessagingService() + self.assertEqual('messaging', sot.service_type) + self.assertEqual('public', sot.visibility) + self.assertIsNone(sot.region) + self.assertIsNone(sot.service_name) + self.assertEqual(1, len(sot.valid_versions)) + self.assertEqual('v1', sot.valid_versions[0].module) + self.assertEqual('v1', sot.valid_versions[0].path) diff --git a/openstack/tests/unit/messaging/test_version.py b/openstack/tests/unit/messaging/test_version.py new file mode 100644 index 00000000..777d4483 --- /dev/null +++ b/openstack/tests/unit/messaging/test_version.py @@ -0,0 +1,43 @@ +# 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.messaging import version + +IDENTIFIER = 'IDENTIFIER' +EXAMPLE = { + 'id': IDENTIFIER, + 'links': '2', + 'status': '3', +} + + +class TestVersion(testtools.TestCase): + + def test_basic(self): + sot = version.Version() + self.assertEqual('version', sot.resource_key) + self.assertEqual('versions', sot.resources_key) + self.assertEqual('/', sot.base_path) + self.assertEqual('messaging', 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 = version.Version(EXAMPLE) + self.assertEqual(EXAMPLE['id'], sot.id) + self.assertEqual(EXAMPLE['links'], sot.links) + self.assertEqual(EXAMPLE['status'], sot.status) diff --git a/openstack/tests/unit/messaging/v1/__init__.py b/openstack/tests/unit/messaging/v1/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/openstack/tests/unit/messaging/v1/test_proxy.py b/openstack/tests/unit/messaging/v1/test_proxy.py new file mode 100644 index 00000000..0b4315ec --- /dev/null +++ b/openstack/tests/unit/messaging/v1/test_proxy.py @@ -0,0 +1,29 @@ +# 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.messaging.v1 import _proxy +from openstack.messaging.v1 import queue +from openstack.tests.unit import test_proxy_base + + +class TestMessagingProxy(test_proxy_base.TestProxyBase): + def setUp(self): + super(TestMessagingProxy, self).setUp() + self.proxy = _proxy.Proxy(self.session) + + def test_queue_create_attrs(self): + kwargs = {"x": 1, "y": 2, "z": 3} + self.verify_create2('openstack.proxy.BaseProxy._create', + self.proxy.create_queue, + method_kwargs=kwargs, + expected_args=[queue.Queue], + expected_kwargs=kwargs) diff --git a/openstack/tests/unit/messaging/v1/test_queue.py b/openstack/tests/unit/messaging/v1/test_queue.py new file mode 100644 index 00000000..2b0095a2 --- /dev/null +++ b/openstack/tests/unit/messaging/v1/test_queue.py @@ -0,0 +1,53 @@ +# 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 mock +import testtools + +from openstack.messaging.v1 import queue + + +FAKE_NAME = 'test_queue' +FAKE = { + 'name': FAKE_NAME, +} + + +class TestStack(testtools.TestCase): + + def test_basic(self): + sot = queue.Queue() + self.assertEqual('queues', sot.resources_key) + self.assertEqual('/queues', sot.base_path) + self.assertEqual('messaging', sot.service.service_type) + self.assertTrue(sot.allow_create) + self.assertFalse(sot.allow_retrieve) + self.assertFalse(sot.allow_update) + self.assertFalse(sot.allow_delete) + self.assertFalse(sot.allow_list) + + def test_make_it(self): + sot = queue.Queue(FAKE) + self.assertEqual(FAKE['name'], sot.name) + + def test_create(self): + sess = mock.Mock() + sess.put = mock.Mock() + sess.put.return_value = mock.Mock() + sot = queue.Queue(FAKE) + + sot.create(sess) + + url = 'queues/%s' % FAKE_NAME + sess.put.assert_called_with(url, service=sot.service, accept=None) + self.assertEqual(FAKE_NAME, sot.id) + self.assertEqual(FAKE_NAME, sot.name) diff --git a/openstack/tests/unit/test_profile.py b/openstack/tests/unit/test_profile.py index e9948ee8..c07ae735 100644 --- a/openstack/tests/unit/test_profile.py +++ b/openstack/tests/unit/test_profile.py @@ -24,6 +24,7 @@ class TestProfile(base.TestCase): 'identity', 'image', 'keystore', + 'messaging', 'metering', 'metric', 'network',