Replace marconi by zaqar in heat plugins
Change-Id: I9eb68c27e79782f0da0d9a79bf231e09f2f679bc
This commit is contained in:
parent
12b3bd4360
commit
8307f1e075
@ -1 +0,0 @@
|
|||||||
python-marconiclient>=0.0.1a1
|
|
@ -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
|
NOTE: These instructions assume the value of heat.conf plugin_dirs includes the
|
||||||
default directory /usr/lib/heat.
|
default directory /usr/lib/heat.
|
@ -16,20 +16,20 @@ from heat.openstack.common import log as logging
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from marconiclient.queues.v1 import client as marconiclient
|
from zaqarclient.queues.v1 import client as zaqarclient
|
||||||
except ImportError:
|
except ImportError:
|
||||||
marconiclient = None
|
zaqarclient = None
|
||||||
|
|
||||||
from heat.engine.clients import client_plugin
|
from heat.engine.clients import client_plugin
|
||||||
|
|
||||||
|
|
||||||
class MarconiClientPlugin(client_plugin.ClientPlugin):
|
class ZaqarClientPlugin(client_plugin.ClientPlugin):
|
||||||
|
|
||||||
def _create(self):
|
def _create(self):
|
||||||
|
|
||||||
con = self.context
|
con = self.context
|
||||||
if self.auth_token is None:
|
if self.auth_token is None:
|
||||||
LOG.error(_("Marconi connection failed, no auth_token!"))
|
LOG.error(_("Zaqar connection failed, no auth_token!"))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
@ -43,6 +43,6 @@ class MarconiClientPlugin(client_plugin.ClientPlugin):
|
|||||||
conf = {'auth_opts': auth_opts}
|
conf = {'auth_opts': auth_opts}
|
||||||
endpoint = self.url_for(service_type='queuing')
|
endpoint = self.url_for(service_type='queuing')
|
||||||
|
|
||||||
client = marconiclient.Client(url=endpoint, conf=conf)
|
client = zaqarclient.Client(url=endpoint, conf=conf)
|
||||||
|
|
||||||
return client
|
return client
|
@ -19,14 +19,14 @@ from heat.engine import resource
|
|||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
if not clients.has_client('marconi'):
|
if not clients.has_client('zaqar'):
|
||||||
return {}
|
return {}
|
||||||
return {
|
return {
|
||||||
'OS::Marconi::Queue': MarconiQueue,
|
'OS::Zaqar::Queue': ZaqarQueue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MarconiQueue(resource.Resource):
|
class ZaqarQueue(resource.Resource):
|
||||||
|
|
||||||
PROPERTIES = (
|
PROPERTIES = (
|
||||||
NAME, METADATA,
|
NAME, METADATA,
|
||||||
@ -62,17 +62,17 @@ class MarconiQueue(resource.Resource):
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
def marconi(self):
|
def zaqar(self):
|
||||||
return self.clients.client('marconi')
|
return self.clients.client('zaqar')
|
||||||
|
|
||||||
def physical_resource_name(self):
|
def physical_resource_name(self):
|
||||||
return self.properties[self.NAME]
|
return self.properties[self.NAME]
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
"""Create a marconi message queue."""
|
"""Create a zaqar message queue."""
|
||||||
queue_name = self.physical_resource_name()
|
queue_name = self.physical_resource_name()
|
||||||
queue = self.marconi().queue(queue_name, auto_create=False)
|
queue = self.zaqar().queue(queue_name, auto_create=False)
|
||||||
# Marconi client doesn't report an error if an queue with the same
|
# Zaqar client doesn't report an error if an queue with the same
|
||||||
# id/name already exists, which can cause issue with stack update.
|
# id/name already exists, which can cause issue with stack update.
|
||||||
if queue.exists():
|
if queue.exists():
|
||||||
raise exception.Error(_('Message queue %s already 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):
|
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||||
"""Update queue metadata."""
|
"""Update queue metadata."""
|
||||||
if 'metadata' in prop_diff:
|
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']
|
metadata = prop_diff['metadata']
|
||||||
queue.metadata(new_meta=metadata)
|
queue.metadata(new_meta=metadata)
|
||||||
|
|
||||||
def handle_delete(self):
|
def handle_delete(self):
|
||||||
"""Delete a marconi message queue."""
|
"""Delete a zaqar message queue."""
|
||||||
if not self.resource_id:
|
if not self.resource_id:
|
||||||
return
|
return
|
||||||
|
|
||||||
queue = self.marconi().queue(self.resource_id, auto_create=False)
|
queue = self.zaqar().queue(self.resource_id, auto_create=False)
|
||||||
queue.delete()
|
queue.delete()
|
||||||
|
|
||||||
def href(self):
|
def href(self):
|
||||||
api_endpoint = self.marconi().api_url
|
api_endpoint = self.zaqar().api_url
|
||||||
queue_name = self.physical_resource_name()
|
queue_name = self.physical_resource_name()
|
||||||
if api_endpoint.endswith('/'):
|
if api_endpoint.endswith('/'):
|
||||||
return '%squeues/%s' % (api_endpoint, queue_name)
|
return '%squeues/%s' % (api_endpoint, queue_name)
|
@ -27,10 +27,10 @@ from ..resources import queue # noqa
|
|||||||
wp_template = '''
|
wp_template = '''
|
||||||
{
|
{
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
"AWSTemplateFormatVersion" : "2010-09-09",
|
||||||
"Description" : "openstack Marconi queue service as a resource",
|
"Description" : "openstack Zaqar queue service as a resource",
|
||||||
"Resources" : {
|
"Resources" : {
|
||||||
"MyQueue2" : {
|
"MyQueue2" : {
|
||||||
"Type" : "OS::Marconi::Queue",
|
"Type" : "OS::Zaqar::Queue",
|
||||||
"Properties" : {
|
"Properties" : {
|
||||||
"name": "myqueue",
|
"name": "myqueue",
|
||||||
"metadata": { "key1": { "key2": "value", "key3": [1, 2] } }
|
"metadata": { "key1": { "key2": "value", "key3": [1, 2] } }
|
||||||
@ -70,13 +70,13 @@ class FakeQueue(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MarconiMessageQueueTest(HeatTestCase):
|
class ZaqarMessageQueueTest(HeatTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(MarconiMessageQueueTest, self).setUp()
|
super(ZaqarMessageQueueTest, self).setUp()
|
||||||
self.fc = self.m.CreateMockAnything()
|
self.fc = self.m.CreateMockAnything()
|
||||||
self.ctx = utils.dummy_context()
|
self.ctx = utils.dummy_context()
|
||||||
resource._register_class("OS::Marconi::Queue",
|
resource._register_class("OS::Zaqar::Queue",
|
||||||
queue.MarconiQueue)
|
queue.ZaqarQueue)
|
||||||
|
|
||||||
def parse_stack(self, t):
|
def parse_stack(self, t):
|
||||||
stack_name = 'test_stack'
|
stack_name = 'test_stack'
|
||||||
@ -90,8 +90,8 @@ class MarconiMessageQueueTest(HeatTestCase):
|
|||||||
self.parse_stack(t)
|
self.parse_stack(t)
|
||||||
|
|
||||||
queue = self.stack['MyQueue2']
|
queue = self.stack['MyQueue2']
|
||||||
self.m.StubOutWithMock(queue, 'marconi')
|
self.m.StubOutWithMock(queue, 'zaqar')
|
||||||
queue.marconi().MultipleTimes().AndReturn(self.fc)
|
queue.zaqar().MultipleTimes().AndReturn(self.fc)
|
||||||
|
|
||||||
fake_q = FakeQueue(queue.physical_resource_name(), auto_create=False)
|
fake_q = FakeQueue(queue.physical_resource_name(), auto_create=False)
|
||||||
self.m.StubOutWithMock(self.fc, 'queue')
|
self.m.StubOutWithMock(self.fc, 'queue')
|
||||||
@ -120,8 +120,8 @@ class MarconiMessageQueueTest(HeatTestCase):
|
|||||||
self.parse_stack(t)
|
self.parse_stack(t)
|
||||||
|
|
||||||
queue = self.stack['MyQueue2']
|
queue = self.stack['MyQueue2']
|
||||||
self.m.StubOutWithMock(queue, 'marconi')
|
self.m.StubOutWithMock(queue, 'zaqar')
|
||||||
queue.marconi().MultipleTimes().AndReturn(self.fc)
|
queue.zaqar().MultipleTimes().AndReturn(self.fc)
|
||||||
|
|
||||||
fake_q = FakeQueue("myqueue", auto_create=False)
|
fake_q = FakeQueue("myqueue", auto_create=False)
|
||||||
self.m.StubOutWithMock(self.fc, 'queue')
|
self.m.StubOutWithMock(self.fc, 'queue')
|
||||||
@ -141,8 +141,8 @@ class MarconiMessageQueueTest(HeatTestCase):
|
|||||||
self.parse_stack(t)
|
self.parse_stack(t)
|
||||||
|
|
||||||
queue = self.stack['MyQueue2']
|
queue = self.stack['MyQueue2']
|
||||||
self.m.StubOutWithMock(queue, 'marconi')
|
self.m.StubOutWithMock(queue, 'zaqar')
|
||||||
queue.marconi().MultipleTimes().AndReturn(self.fc)
|
queue.zaqar().MultipleTimes().AndReturn(self.fc)
|
||||||
|
|
||||||
fake_q = FakeQueue("myqueue", auto_create=False)
|
fake_q = FakeQueue("myqueue", auto_create=False)
|
||||||
self.m.StubOutWithMock(self.fc, 'queue')
|
self.m.StubOutWithMock(self.fc, 'queue')
|
||||||
@ -167,8 +167,8 @@ class MarconiMessageQueueTest(HeatTestCase):
|
|||||||
|
|
||||||
queue = self.stack['MyQueue2']
|
queue = self.stack['MyQueue2']
|
||||||
queue.resource_id_set(queue.properties.get('name'))
|
queue.resource_id_set(queue.properties.get('name'))
|
||||||
self.m.StubOutWithMock(queue, 'marconi')
|
self.m.StubOutWithMock(queue, 'zaqar')
|
||||||
queue.marconi().MultipleTimes().AndReturn(self.fc)
|
queue.zaqar().MultipleTimes().AndReturn(self.fc)
|
||||||
|
|
||||||
fake_q = FakeQueue("myqueue", auto_create=False)
|
fake_q = FakeQueue("myqueue", auto_create=False)
|
||||||
self.m.StubOutWithMock(self.fc, 'queue')
|
self.m.StubOutWithMock(self.fc, 'queue')
|
||||||
@ -188,8 +188,8 @@ class MarconiMessageQueueTest(HeatTestCase):
|
|||||||
self.parse_stack(t)
|
self.parse_stack(t)
|
||||||
queue = self.stack['MyQueue2']
|
queue = self.stack['MyQueue2']
|
||||||
queue.resource_id_set(queue.properties.get('name'))
|
queue.resource_id_set(queue.properties.get('name'))
|
||||||
self.m.StubOutWithMock(queue, 'marconi')
|
self.m.StubOutWithMock(queue, 'zaqar')
|
||||||
queue.marconi().MultipleTimes().AndReturn(self.fc)
|
queue.zaqar().MultipleTimes().AndReturn(self.fc)
|
||||||
fake_q = FakeQueue('myqueue', auto_create=False)
|
fake_q = FakeQueue('myqueue', auto_create=False)
|
||||||
self.m.StubOutWithMock(self.fc, 'queue')
|
self.m.StubOutWithMock(self.fc, 'queue')
|
||||||
self.fc.queue('myqueue',
|
self.fc.queue('myqueue',
|
||||||
@ -216,8 +216,8 @@ class MarconiMessageQueueTest(HeatTestCase):
|
|||||||
self.parse_stack(t)
|
self.parse_stack(t)
|
||||||
queue = self.stack['MyQueue2']
|
queue = self.stack['MyQueue2']
|
||||||
queue.resource_id_set(queue.properties.get('name'))
|
queue.resource_id_set(queue.properties.get('name'))
|
||||||
self.m.StubOutWithMock(queue, 'marconi')
|
self.m.StubOutWithMock(queue, 'zaqar')
|
||||||
queue.marconi().MultipleTimes().AndReturn(self.fc)
|
queue.zaqar().MultipleTimes().AndReturn(self.fc)
|
||||||
fake_q = FakeQueue('myqueue', auto_create=False)
|
fake_q = FakeQueue('myqueue', auto_create=False)
|
||||||
self.m.StubOutWithMock(self.fc, 'queue')
|
self.m.StubOutWithMock(self.fc, 'queue')
|
||||||
self.fc.queue('myqueue',
|
self.fc.queue('myqueue',
|
1
contrib/heat_zaqar/requirements.txt
Normal file
1
contrib/heat_zaqar/requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
python-zaqarclient>=0.0.3
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = heat-contrib-marconi
|
name = heat-contrib-zaqar
|
||||||
summary = Heat resources for working Marconi queues
|
summary = Heat resources for working Zaqar queues
|
||||||
description-file =
|
description-file =
|
||||||
README.md
|
README.md
|
||||||
author = OpenStack
|
author = OpenStack
|
||||||
@ -19,14 +19,14 @@ classifier =
|
|||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
heat_marconi
|
heat_zaqar
|
||||||
# Copy to /usr/lib/heat for plugin loading
|
# Copy to /usr/lib/heat for plugin loading
|
||||||
data_files =
|
data_files =
|
||||||
lib/heat/marconi = heat_marconi/resources/*
|
lib/heat/zaqar = heat_zaqar/resources/*
|
||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
heat.clients =
|
heat.clients =
|
||||||
marconi = heat_marconi.client:MarconiClientPlugin
|
zaqar = heat_zaqar.client:ZaqarClientPlugin
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
setup-hooks =
|
setup-hooks =
|
Loading…
Reference in New Issue
Block a user