Replace marconi by zaqar in heat plugins

Change-Id: I9eb68c27e79782f0da0d9a79bf231e09f2f679bc
This commit is contained in:
Pierre Padrixe 2014-09-02 11:36:08 +02:00
parent 12b3bd4360
commit 8307f1e075
11 changed files with 44 additions and 44 deletions

View File

@ -1 +0,0 @@
python-marconiclient>=0.0.1a1

View File

@ -1,10 +1,10 @@
Marconi plugin for OpenStack Heat
Zaqar plugin for OpenStack Heat
================================
This plugin enable using Marconi queuing service as a resource in a Heat template.
This plugin enable using Zaqar queuing service as a resource in a Heat template.
### 1. Install the Marconi plugin in Heat
### 1. Install the Zaqar plugin in Heat
NOTE: These instructions assume the value of heat.conf plugin_dirs includes the
default directory /usr/lib/heat.

View File

@ -16,20 +16,20 @@ from heat.openstack.common import log as logging
LOG = logging.getLogger(__name__)
try:
from marconiclient.queues.v1 import client as marconiclient
from zaqarclient.queues.v1 import client as zaqarclient
except ImportError:
marconiclient = None
zaqarclient = None
from heat.engine.clients import client_plugin
class MarconiClientPlugin(client_plugin.ClientPlugin):
class ZaqarClientPlugin(client_plugin.ClientPlugin):
def _create(self):
con = self.context
if self.auth_token is None:
LOG.error(_("Marconi connection failed, no auth_token!"))
LOG.error(_("Zaqar connection failed, no auth_token!"))
return None
opts = {
@ -43,6 +43,6 @@ class MarconiClientPlugin(client_plugin.ClientPlugin):
conf = {'auth_opts': auth_opts}
endpoint = self.url_for(service_type='queuing')
client = marconiclient.Client(url=endpoint, conf=conf)
client = zaqarclient.Client(url=endpoint, conf=conf)
return client

View File

@ -19,14 +19,14 @@ from heat.engine import resource
def resource_mapping():
if not clients.has_client('marconi'):
if not clients.has_client('zaqar'):
return {}
return {
'OS::Marconi::Queue': MarconiQueue,
'OS::Zaqar::Queue': ZaqarQueue,
}
class MarconiQueue(resource.Resource):
class ZaqarQueue(resource.Resource):
PROPERTIES = (
NAME, METADATA,
@ -62,17 +62,17 @@ class MarconiQueue(resource.Resource):
),
}
def marconi(self):
return self.clients.client('marconi')
def zaqar(self):
return self.clients.client('zaqar')
def physical_resource_name(self):
return self.properties[self.NAME]
def handle_create(self):
"""Create a marconi message queue."""
"""Create a zaqar message queue."""
queue_name = self.physical_resource_name()
queue = self.marconi().queue(queue_name, auto_create=False)
# Marconi client doesn't report an error if an queue with the same
queue = self.zaqar().queue(queue_name, auto_create=False)
# Zaqar client doesn't report an error if an queue with the same
# id/name already exists, which can cause issue with stack update.
if queue.exists():
raise exception.Error(_('Message queue %s already exists.')
@ -96,20 +96,20 @@ class MarconiQueue(resource.Resource):
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
"""Update queue metadata."""
if 'metadata' in prop_diff:
queue = self.marconi().queue(self.resource_id, auto_create=False)
queue = self.zaqar().queue(self.resource_id, auto_create=False)
metadata = prop_diff['metadata']
queue.metadata(new_meta=metadata)
def handle_delete(self):
"""Delete a marconi message queue."""
"""Delete a zaqar message queue."""
if not self.resource_id:
return
queue = self.marconi().queue(self.resource_id, auto_create=False)
queue = self.zaqar().queue(self.resource_id, auto_create=False)
queue.delete()
def href(self):
api_endpoint = self.marconi().api_url
api_endpoint = self.zaqar().api_url
queue_name = self.physical_resource_name()
if api_endpoint.endswith('/'):
return '%squeues/%s' % (api_endpoint, queue_name)

View File

@ -27,10 +27,10 @@ from ..resources import queue # noqa
wp_template = '''
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "openstack Marconi queue service as a resource",
"Description" : "openstack Zaqar queue service as a resource",
"Resources" : {
"MyQueue2" : {
"Type" : "OS::Marconi::Queue",
"Type" : "OS::Zaqar::Queue",
"Properties" : {
"name": "myqueue",
"metadata": { "key1": { "key2": "value", "key3": [1, 2] } }
@ -70,13 +70,13 @@ class FakeQueue(object):
pass
class MarconiMessageQueueTest(HeatTestCase):
class ZaqarMessageQueueTest(HeatTestCase):
def setUp(self):
super(MarconiMessageQueueTest, self).setUp()
super(ZaqarMessageQueueTest, self).setUp()
self.fc = self.m.CreateMockAnything()
self.ctx = utils.dummy_context()
resource._register_class("OS::Marconi::Queue",
queue.MarconiQueue)
resource._register_class("OS::Zaqar::Queue",
queue.ZaqarQueue)
def parse_stack(self, t):
stack_name = 'test_stack'
@ -90,8 +90,8 @@ class MarconiMessageQueueTest(HeatTestCase):
self.parse_stack(t)
queue = self.stack['MyQueue2']
self.m.StubOutWithMock(queue, 'marconi')
queue.marconi().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(queue, 'zaqar')
queue.zaqar().MultipleTimes().AndReturn(self.fc)
fake_q = FakeQueue(queue.physical_resource_name(), auto_create=False)
self.m.StubOutWithMock(self.fc, 'queue')
@ -120,8 +120,8 @@ class MarconiMessageQueueTest(HeatTestCase):
self.parse_stack(t)
queue = self.stack['MyQueue2']
self.m.StubOutWithMock(queue, 'marconi')
queue.marconi().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(queue, 'zaqar')
queue.zaqar().MultipleTimes().AndReturn(self.fc)
fake_q = FakeQueue("myqueue", auto_create=False)
self.m.StubOutWithMock(self.fc, 'queue')
@ -141,8 +141,8 @@ class MarconiMessageQueueTest(HeatTestCase):
self.parse_stack(t)
queue = self.stack['MyQueue2']
self.m.StubOutWithMock(queue, 'marconi')
queue.marconi().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(queue, 'zaqar')
queue.zaqar().MultipleTimes().AndReturn(self.fc)
fake_q = FakeQueue("myqueue", auto_create=False)
self.m.StubOutWithMock(self.fc, 'queue')
@ -167,8 +167,8 @@ class MarconiMessageQueueTest(HeatTestCase):
queue = self.stack['MyQueue2']
queue.resource_id_set(queue.properties.get('name'))
self.m.StubOutWithMock(queue, 'marconi')
queue.marconi().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(queue, 'zaqar')
queue.zaqar().MultipleTimes().AndReturn(self.fc)
fake_q = FakeQueue("myqueue", auto_create=False)
self.m.StubOutWithMock(self.fc, 'queue')
@ -188,8 +188,8 @@ class MarconiMessageQueueTest(HeatTestCase):
self.parse_stack(t)
queue = self.stack['MyQueue2']
queue.resource_id_set(queue.properties.get('name'))
self.m.StubOutWithMock(queue, 'marconi')
queue.marconi().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(queue, 'zaqar')
queue.zaqar().MultipleTimes().AndReturn(self.fc)
fake_q = FakeQueue('myqueue', auto_create=False)
self.m.StubOutWithMock(self.fc, 'queue')
self.fc.queue('myqueue',
@ -216,8 +216,8 @@ class MarconiMessageQueueTest(HeatTestCase):
self.parse_stack(t)
queue = self.stack['MyQueue2']
queue.resource_id_set(queue.properties.get('name'))
self.m.StubOutWithMock(queue, 'marconi')
queue.marconi().MultipleTimes().AndReturn(self.fc)
self.m.StubOutWithMock(queue, 'zaqar')
queue.zaqar().MultipleTimes().AndReturn(self.fc)
fake_q = FakeQueue('myqueue', auto_create=False)
self.m.StubOutWithMock(self.fc, 'queue')
self.fc.queue('myqueue',

View File

@ -0,0 +1 @@
python-zaqarclient>=0.0.3

View File

@ -1,6 +1,6 @@
[metadata]
name = heat-contrib-marconi
summary = Heat resources for working Marconi queues
name = heat-contrib-zaqar
summary = Heat resources for working Zaqar queues
description-file =
README.md
author = OpenStack
@ -19,14 +19,14 @@ classifier =
[files]
packages =
heat_marconi
heat_zaqar
# Copy to /usr/lib/heat for plugin loading
data_files =
lib/heat/marconi = heat_marconi/resources/*
lib/heat/zaqar = heat_zaqar/resources/*
[entry_points]
heat.clients =
marconi = heat_marconi.client:MarconiClientPlugin
zaqar = heat_zaqar.client:ZaqarClientPlugin
[global]
setup-hooks =