Added common RPC service and API classes

Also added skeletons of three services

Co-Authored-by:  Angus Salkeld <angus.salkeld@rackspace.com>
Change-Id: I21ff5e71273c421803fca917e5ee6294600879e4
This commit is contained in:
Ed Cranford 2014-03-18 13:41:14 +10:00 committed by Angus Salkeld
parent e259479c00
commit 03e7549ebc
38 changed files with 879 additions and 5 deletions

View File

@ -6,11 +6,15 @@ To install::
$ cp lib/solum ${DEVSTACK_DIR}/lib
$ cp extras.d/70-solum.sh ${DEVSTACK_DIR}/extras.d
To configure devstack to run solum::
Add the following to your local.conf::
$ cd ${DEVSTACK_DIR}
$ echo "enable_service solum" >> localrc
enable_service solum
enable_service solum-api
enable_service solum-conductor
enable_service solum-deployer
enable_service solum-worker
Run devstack as normal::
$ cd ${DEVSTACK_DIR}
$ ./stack.sh

View File

@ -98,6 +98,14 @@ function configure_solum() {
# configure the api servers to listen on 0.0.0.0
iniset $SOLUM_CONF_DIR/$SOLUM_CONF_FILE api host 0.0.0.0
iniset $SOLUM_CONF_DIR/$SOLUM_CONF_FILE builder host 0.0.0.0
# common rpc settings
iniset_rpc_backend solum $SOLUM_CONF_DIR/$SOLUM_CONF_FILE DEFAULT
# service rpc settings
iniset $SOLUM_CONF_DIR/$SOLUM_CONF_FILE conductor topic solum-conductor
iniset $SOLUM_CONF_DIR/$SOLUM_CONF_FILE deployer topic solum-deployer
iniset $SOLUM_CONF_DIR/$SOLUM_CONF_FILE worker topic solum-worker
}
#register solum user in Keystone
@ -139,13 +147,19 @@ function install_solum() {
# start_solum() - Start running processes, including screen
function start_solum() {
screen_it solum "cd $SOLUM_DIR && $SOLUM_BIN_DIR/solum-api --config-file $SOLUM_CONF_DIR/$SOLUM_CONF_FILE"
screen_it solum-api "cd $SOLUM_DIR && $SOLUM_BIN_DIR/solum-api --config-file $SOLUM_CONF_DIR/$SOLUM_CONF_FILE"
screen_it solum-conductor "cd $SOLUM_DIR && $SOLUM_BIN_DIR/solum-conductor --config-file $SOLUM_CONF_DIR/$SOLUM_CONF_FILE"
screen_it solum-deployer "cd $SOLUM_DIR && $SOLUM_BIN_DIR/solum-deployer --config-file $SOLUM_CONF_DIR/$SOLUM_CONF_FILE"
screen_it solum-worker "cd $SOLUM_DIR && $SOLUM_BIN_DIR/solum-worker --config-file $SOLUM_CONF_DIR/$SOLUM_CONF_FILE"
}
# stop_solum() - Stop running processes
function stop_solum() {
# Kill the solum screen windows
screen -S $SCREEN_NAME -p solum -X kill
screen -S $SCREEN_NAME -p solum-api -X kill
screen -S $SCREEN_NAME -p solum-conductor -X kill
screen -S $SCREEN_NAME -p solum-deployer -X kill
screen -S $SCREEN_NAME -p solum-worker -X kill
}
# Restore xtrace

View File

@ -1,5 +1,199 @@
[DEFAULT]
#
# Options defined in oslo.messaging
#
# Use durable queues in amqp. (boolean value)
# Deprecated group/name - [DEFAULT]/rabbit_durable_queues
#amqp_durable_queues=false
# Auto-delete queues in amqp. (boolean value)
#amqp_auto_delete=false
# Size of RPC connection pool. (integer value)
#rpc_conn_pool_size=30
# Modules of exceptions that are permitted to be recreated
# upon receiving exception data from an rpc call. (list value)
#allowed_rpc_exception_modules=oslo.messaging.exceptions,nova.exception,cinder.exception,exceptions
# Qpid broker hostname. (string value)
#qpid_hostname=localhost
# Qpid broker port. (integer value)
#qpid_port=5672
# Qpid HA cluster host:port pairs. (list value)
#qpid_hosts=$qpid_hostname:$qpid_port
# Username for Qpid connection. (string value)
#qpid_username=
# Password for Qpid connection. (string value)
#qpid_password=
# Space separated list of SASL mechanisms to use for auth.
# (string value)
#qpid_sasl_mechanisms=
# Seconds between connection keepalive heartbeats. (integer
# value)
#qpid_heartbeat=60
# Transport to use, either 'tcp' or 'ssl'. (string value)
#qpid_protocol=tcp
# Whether to disable the Nagle algorithm. (boolean value)
#qpid_tcp_nodelay=true
# The qpid topology version to use. Version 1 is what was
# originally used by impl_qpid. Version 2 includes some
# backwards-incompatible changes that allow broker federation
# to work. Users should update to version 2 when they are
# able to take everything down, as it requires a clean break.
# (integer value)
#qpid_topology_version=1
# SSL version to use (valid only if SSL enabled). valid values
# are TLSv1, SSLv23 and SSLv3. SSLv2 may be available on some
# distributions. (string value)
#kombu_ssl_version=
# SSL key file (valid only if SSL enabled). (string value)
#kombu_ssl_keyfile=
# SSL cert file (valid only if SSL enabled). (string value)
#kombu_ssl_certfile=
# SSL certification authority file (valid only if SSL
# enabled). (string value)
#kombu_ssl_ca_certs=
# How long to wait before reconnecting in response to an AMQP
# consumer cancel notification. (floating point value)
#kombu_reconnect_delay=1.0
# The RabbitMQ broker address where a single node is used.
# (string value)
#rabbit_host=localhost
# The RabbitMQ broker port where a single node is used.
# (integer value)
#rabbit_port=5672
# RabbitMQ HA cluster host:port pairs. (list value)
#rabbit_hosts=$rabbit_host:$rabbit_port
# Connect over SSL for RabbitMQ. (boolean value)
#rabbit_use_ssl=false
# The RabbitMQ userid. (string value)
#rabbit_userid=guest
# The RabbitMQ password. (string value)
#rabbit_password=guest
# the RabbitMQ login method (string value)
#rabbit_login_method=AMQPLAIN
# The RabbitMQ virtual host. (string value)
#rabbit_virtual_host=/
# How frequently to retry connecting with RabbitMQ. (integer
# value)
#rabbit_retry_interval=1
# How long to backoff for between retries when connecting to
# RabbitMQ. (integer value)
#rabbit_retry_backoff=2
# Maximum number of RabbitMQ connection retries. Default is 0
# (infinite retry count). (integer value)
#rabbit_max_retries=0
# Use HA queues in RabbitMQ (x-ha-policy: all). If you change
# this option, you must wipe the RabbitMQ database. (boolean
# value)
#rabbit_ha_queues=false
# If passed, use a fake RabbitMQ provider. (boolean value)
#fake_rabbit=false
# ZeroMQ bind address. Should be a wildcard (*), an ethernet
# interface, or IP. The "host" option should point or resolve
# to this address. (string value)
#rpc_zmq_bind_address=*
# MatchMaker driver. (string value)
#rpc_zmq_matchmaker=oslo.messaging._drivers.matchmaker.MatchMakerLocalhost
# ZeroMQ receiver listening port. (integer value)
#rpc_zmq_port=9501
# Number of ZeroMQ contexts, defaults to 1. (integer value)
#rpc_zmq_contexts=1
# Maximum number of ingress messages to locally buffer per
# topic. Default is unlimited. (integer value)
#rpc_zmq_topic_backlog=<None>
# Directory for holding IPC sockets. (string value)
#rpc_zmq_ipc_dir=/var/run/openstack
# Name of this node. Must be a valid hostname, FQDN, or IP
# address. Must match "host" option, if running Nova. (string
# value)
#rpc_zmq_host=solum
# Seconds to wait before a cast expires (TTL). Only supported
# by impl_zmq. (integer value)
#rpc_cast_timeout=30
# Heartbeat frequency. (integer value)
#matchmaker_heartbeat_freq=300
# Heartbeat time-to-live. (integer value)
#matchmaker_heartbeat_ttl=600
# Host to locate redis. (string value)
#host=127.0.0.1
# Use this port to connect to redis host. (integer value)
#port=6379
# Password for Redis server (optional). (string value)
#password=<None>
# Size of RPC greenthread pool. (integer value)
#rpc_thread_pool_size=64
# Driver or drivers to handle sending notifications. (multi
# valued)
#notification_driver=
# AMQP topic used for OpenStack notifications. (list value)
# Deprecated group/name - [rpc_notifier2]/topics
#notification_topics=notifications
# Seconds to wait for a response from a call. (integer value)
#rpc_response_timeout=60
# A URL representing the messaging driver to use and its full
# configuration. If not set, we fall back to the rpc_backend
# option and driver specific configuration. (string value)
#transport_url=<None>
# The messaging driver to use, defaults to rabbit. Other
# drivers include qpid and zmq. (string value)
#rpc_backend=rabbit
# The default exchange under which topics are scoped. May be
# overridden by an exchange name specified in the
# transport_url option. (string value)
#control_exchange=openstack
#
# Options defined in solum.api.auth
#
@ -158,6 +352,19 @@
#host=127.0.0.1
[conductor]
#
# Options defined in solum.conductor.config
#
# The queue to add conductor tasks to (string value)
#topic=solum-conductor
# The location of the conductor rpc queue (string value)
#host=localhost
[database]
#
@ -246,6 +453,19 @@
#pool_timeout=<None>
[deployer]
#
# Options defined in solum.deployer.config
#
# The queue to add deployer tasks to (string value)
#topic=solum-deployer
# The location of the deployer rpc queue (string value)
#host=localhost
[heat_client]
#
@ -404,3 +624,27 @@
#enforce_token_bind=permissive
[matchmaker_ring]
#
# Options defined in oslo.messaging
#
# Matchmaker ring file (JSON). (string value)
# Deprecated group/name - [DEFAULT]/matchmaker_ringfile
#ringfile=/etc/oslo/matchmaker_ring.json
[worker]
#
# Options defined in solum.worker.config
#
# The queue to add build tasks to (string value)
#topic=solum-worker
# The location of the build rpc queue (string value)
#host=localhost

View File

@ -1,8 +1,10 @@
alembic>=0.4.1
Babel>=1.3
iso8601>=0.1.9
kombu>=2.4.8
netaddr>=0.7.6
oslo.config>=1.2.0
oslo.messaging>=1.3.0a4
pbr>=0.6,<1.0
pecan>=0.4.5
python-heatclient>=0.2.3

View File

@ -50,7 +50,10 @@ output_file = solum/locale/solum.pot
console_scripts =
solum-api = solum.cmd.api:main
solum-builder-api = solum.cmd.builder:main
solum-conductor = solum.cmd.conductor:main
solum-db-manage = solum.cmd.db_manage:main
solum-deployer = solum.cmd.deployer:main
solum-worker = solum.cmd.worker:main
solum.openstack.common.migration =
alembic = solum.openstack.common.db.sqlalchemy.migration_cli.ext_alembic:AlembicExtension

46
solum/cmd/conductor.py Normal file
View File

@ -0,0 +1,46 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Starter script for the Solum Conductor service."""
import logging as std_logging
import os
import sys
from oslo.config import cfg
from solum.common.rpc import service
from solum.conductor.handlers import default as default_handler
from solum.openstack.common.gettextutils import _
from solum.openstack.common import log as logging
LOG = logging.getLogger(__name__)
def main():
cfg.CONF(sys.argv[1:], project='solum')
logging.setup('solum')
LOG.info(_('Starting server in PID %s') % os.getpid())
LOG.debug(_("Configuration:"))
cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
cfg.CONF.import_opt('topic', 'solum.conductor.config', group='conductor')
cfg.CONF.import_opt('host', 'solum.conductor.config', group='conductor')
endpoints = [
default_handler.Handler(),
]
server = service.Service(cfg.CONF.conductor.topic,
cfg.CONF.conductor.host, endpoints)
server.serve()

46
solum/cmd/deployer.py Normal file
View File

@ -0,0 +1,46 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Starter script for the Solum Deployer service."""
import logging as std_logging
import os
import sys
from oslo.config import cfg
from solum.common.rpc import service
from solum.deployer.handlers import default as default_handler
from solum.openstack.common.gettextutils import _
from solum.openstack.common import log as logging
LOG = logging.getLogger(__name__)
def main():
cfg.CONF(sys.argv[1:], project='solum')
logging.setup('solum')
LOG.info(_('Starting server in PID %s') % os.getpid())
LOG.debug(_("Configuration:"))
cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
cfg.CONF.import_opt('topic', 'solum.deployer.config', group='deployer')
cfg.CONF.import_opt('host', 'solum.deployer.config', group='deployer')
endpoints = [
default_handler.Handler(),
]
server = service.Service(cfg.CONF.deployer.topic,
cfg.CONF.deployer.host, endpoints)
server.serve()

46
solum/cmd/worker.py Normal file
View File

@ -0,0 +1,46 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Starter script for the Solum Worker service."""
import logging as std_logging
import os
import sys
from oslo.config import cfg
from solum.common.rpc import service
from solum.openstack.common.gettextutils import _
from solum.openstack.common import log as logging
from solum.worker.handlers import subprocess as subprocess_handler
LOG = logging.getLogger(__name__)
def main():
cfg.CONF(sys.argv[1:], project='solum')
logging.setup('solum')
LOG.info(_('Starting server in PID %s') % os.getpid())
LOG.debug(_("Configuration:"))
cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
cfg.CONF.import_opt('topic', 'solum.worker.config', group='worker')
cfg.CONF.import_opt('host', 'solum.worker.config', group='worker')
endpoints = [
subprocess_handler.Handler(),
]
server = service.Service(cfg.CONF.worker.topic,
cfg.CONF.worker.host, endpoints)
server.serve()

View File

View File

@ -0,0 +1,63 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Common RPC service and API tools for Solum."""
from oslo.config import cfg
from oslo import messaging
# NOTE(asalkeld):
# The solum.openstack.common.rpc entries are for compatability
# with devstack rpc_backend configuration values.
TRANSPORT_ALIASES = {
'solum.openstack.common.rpc.impl_kombu': 'rabbit',
'solum.openstack.common.rpc.impl_qpid': 'qpid',
'solum.openstack.common.rpc.impl_zmq': 'zmq',
}
class Service(object):
_server = None
def __init__(self, topic, server, handlers):
transport = messaging.get_transport(cfg.CONF,
aliases=TRANSPORT_ALIASES)
# TODO(asalkeld) add support for version='x.y'
target = messaging.Target(topic=topic, server=server)
self._server = messaging.get_rpc_server(transport, target, handlers)
def serve(self):
self._server.start()
self._server.wait()
class API(object):
def __init__(self, transport=None, context=None, topic=None):
if transport is None:
transport = messaging.get_transport(cfg.CONF,
aliases=TRANSPORT_ALIASES)
self._context = context
if topic is None:
topic = ''
target = messaging.Target(topic=topic)
self._client = messaging.RPCClient(transport, target)
def _call(self, method, *args, **kwargs):
return self._client.call(self._context, method, *args, **kwargs)
def _cast(self, method, *args, **kwargs):
self._client.cast(self._context, method, *args, **kwargs)
def echo(self, message):
self._cast('echo', message=message)

View File

26
solum/conductor/api.py Normal file
View File

@ -0,0 +1,26 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""API for interfacing with Solum Conductor."""
from oslo.config import cfg
from solum.common.rpc import service
class API(service.API):
def __init__(self, transport=None, context=None):
cfg.CONF.import_opt('topic', 'solum.conductor.config',
group='conductor')
super(API, self).__init__(transport, context,
topic=cfg.CONF.conductor.topic)

33
solum/conductor/config.py Normal file
View File

@ -0,0 +1,33 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Config options for Solum Conductor service."""
from oslo.config import cfg
SERVICE_OPTS = [
cfg.StrOpt('topic',
default='solum-conductor',
help='The queue to add conductor tasks to'),
cfg.StrOpt('host',
default='localhost',
help='The location of the conductor rpc queue'),
]
opt_group = cfg.OptGroup(
name='conductor',
title='Options for the solum-conductor service')
cfg.CONF.register_group(opt_group)
cfg.CONF.register_opts(SERVICE_OPTS, opt_group)

View File

View File

@ -0,0 +1,25 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Solum Conductor default handler."""
from solum.openstack.common.gettextutils import _
from solum.openstack.common import log as logging
LOG = logging.getLogger(__name__)
class Handler(object):
def echo(self, ctxt, message):
LOG.debug(_("%s") % message)

View File

26
solum/deployer/api.py Normal file
View File

@ -0,0 +1,26 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""API for interfacing with Solum Deployer."""
from oslo.config import cfg
from solum.common.rpc import service
class API(service.API):
def __init__(self, transport=None, context=None):
cfg.CONF.import_opt('topic', 'solum.deployer.config',
group='deployer')
super(API, self).__init__(transport, context,
topic=cfg.CONF.deployer.topic)

33
solum/deployer/config.py Normal file
View File

@ -0,0 +1,33 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Config options for Solum Deployer service."""
from oslo.config import cfg
SERVICE_OPTS = [
cfg.StrOpt('topic',
default='solum-deployer',
help='The queue to add deployer tasks to'),
cfg.StrOpt('host',
default='localhost',
help='The location of the deployer rpc queue'),
]
opt_group = cfg.OptGroup(
name='deployer',
title='Options for the solum-deployer service')
cfg.CONF.register_group(opt_group)
cfg.CONF.register_opts(SERVICE_OPTS, opt_group)

View File

View File

@ -0,0 +1,25 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Solum Deployer default handler."""
from solum.openstack.common.gettextutils import _
from solum.openstack.common import log as logging
LOG = logging.getLogger(__name__)
class Handler(object):
def echo(self, ctxt, message):
LOG.debug(_("%s") % message)

View File

View File

@ -0,0 +1,41 @@
# Copyright 2014 - Rackspace Hosting
#
# 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
from solum.common.rpc import service
from solum.tests import base
class ServiceTest(base.BaseTestCase):
def test_create(self):
topic, server, handlers = 'fake_topic', 'fake_host', []
rpc_service = service.Service(topic, server, handlers)
self.assertIsNotNone(rpc_service._server)
class APITest(base.BaseTestCase):
def test_create(self):
topic = 'fake_topic'
rpc_api = service.API(context={}, topic=topic)
self.assertIsNotNone(rpc_api._client)
def test_cast(self):
topic = 'fake_topic'
rpc_api = service.API(context={}, topic=topic)
rpc_api._cast = mock.MagicMock()
rpc_api.echo('foo')
rpc_api._cast.assert_called_once_with('echo', message='foo')

View File

View File

@ -0,0 +1,27 @@
# Copyright 2014 - Rackspace Hosting
#
# 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
from solum.deployer.handlers import default
from solum.tests import base
class HandlerTest(base.BaseTestCase):
def test_create(self):
handler = default.Handler()
handler.echo = mock.MagicMock()
handler.echo({}, 'foo')
handler.echo.assert_called_once_with({}, 'foo')

View File

View File

@ -0,0 +1,27 @@
# Copyright 2014 - Rackspace Hosting
#
# 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
from solum.deployer.handlers import default
from solum.tests import base
class HandlerTest(base.BaseTestCase):
def test_create(self):
handler = default.Handler()
handler.echo = mock.MagicMock()
handler.echo({}, 'foo')
handler.echo.assert_called_once_with({}, 'foo')

View File

View File

View File

@ -0,0 +1,27 @@
# Copyright 2014 - Rackspace Hosting
#
# 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
from solum.tests import base
from solum.worker.handlers import subprocess
class HandlerTest(base.BaseTestCase):
def test_create(self):
handler = subprocess.Handler()
handler.echo = mock.MagicMock()
handler.echo({}, 'foo')
handler.echo.assert_called_once_with({}, 'foo')

0
solum/worker/__init__.py Normal file
View File

26
solum/worker/api.py Normal file
View File

@ -0,0 +1,26 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""API for interfacing with Solum Worker."""
from oslo.config import cfg
from solum.common.rpc import service
class API(service.API):
def __init__(self, transport=None, context=None):
cfg.CONF.import_opt('topic', 'solum.worker.config',
group='worker')
super(API, self).__init__(transport, context,
topic=cfg.CONF.worker.topic)

33
solum/worker/config.py Normal file
View File

@ -0,0 +1,33 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Config options for Solum Worker service."""
from oslo.config import cfg
SERVICE_OPTS = [
cfg.StrOpt('topic',
default='solum-worker',
help='The queue to add build tasks to'),
cfg.StrOpt('host',
default='localhost',
help='The location of the build rpc queue'),
]
opt_group = cfg.OptGroup(
name='worker',
title='Options for the solum-worker service')
cfg.CONF.register_group(opt_group)
cfg.CONF.register_opts(SERVICE_OPTS, opt_group)

View File

View File

@ -0,0 +1,25 @@
# Copyright 2014 - Rackspace Hosting
#
# 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.
"""Solum Worker subprocess handler."""
from solum.openstack.common.gettextutils import _
from solum.openstack.common import log as logging
LOG = logging.getLogger(__name__)
class Handler(object):
def echo(self, ctxt, message):
LOG.debug(_("%s") % message)

View File

@ -1 +1,2 @@
SOLUM_CONFIG_GENERATOR_EXTRA_LIBRARIES=oslo.messaging
SOLUM_CONFIG_GENERATOR_EXTRA_MODULES=keystoneclient.middleware.auth_token

31
tools/send-echo-to-worker.py Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python
# Copyright 2014 - Rackspace Hosting
#
# 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 sys
from oslo.config import cfg
from solum.openstack.common import log as logging
from solum.worker import api
LOG = logging.getLogger(__name__)
if __name__ == '__main__':
conf_files = ['--config-file=/etc/solum/solum.conf']
cfg.CONF(conf_files, project='solum')
message = ' '.join(sys.argv[1:])
api.API(context={}).echo(message)