Added Higgins conductor service and API

This patch adds code for Higgins conductor and API.
Only default handler is added as of now. We can add
the handlers later as we proceed on.

Change-Id: I9761204bc2b4aadd11f7f6f9be468a6ec94162a3
This commit is contained in:
Vivek Jain 2016-05-19 00:39:55 +05:30
parent 429942ce55
commit 8652e66fed
7 changed files with 134 additions and 0 deletions

48
higgins/cmd/conductor.py Normal file
View File

@ -0,0 +1,48 @@
# 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 Higgins conductor service."""
import os
import sys
from oslo_config import cfg
from oslo_log import log as logging
from oslo_service import service
from higgins.common import rpc_service
from higgins.common import service as higgins_service
from higgins.common import short_id
from higgins.conductor.handlers import default as default_handler
from higgins.i18n import _LI
LOG = logging.getLogger(__name__)
def main():
higgins_service.prepare_service(sys.argv)
LOG.info(_LI('Starting server in PID %s'), os.getpid())
cfg.CONF.log_opt_values(LOG, logging.DEBUG)
cfg.CONF.import_opt('topic', 'higgins.conductor.config', group='conductor')
conductor_id = short_id.generate_id()
endpoints = [
default_handler.Handler(),
]
server = rpc_service.Service.create(cfg.CONF.conductor.topic,
conductor_id, endpoints,
binary='higgins-conductor')
launcher = service.launch(cfg.CONF, server)
launcher.wait()

View File

33
higgins/conductor/api.py Normal file
View File

@ -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.
"""API for interfacing with Higgins Backend."""
from oslo_config import cfg
from higgins.common import rpc_service
# The Backend API class serves as a AMQP client for communicating
# on a topic exchange specific to the conductors. This allows the ReST
# API to trigger operations on the conductors
class API(rpc_service.API):
def __init__(self, transport=None, context=None, topic=None):
if topic is None:
cfg.CONF.import_opt('topic', 'higgins.conductor.config',
group='conductor')
super(API, self).__init__(transport, context,
topic=cfg.CONF.conductor.topic)
# NOTE(vivek): Add all APIs here
def container_get(self, uuid):
return self._call('container_get', uuid=uuid)

View File

@ -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.
"""Config options for Higgins Backend service."""
from oslo_config import cfg
SERVICE_OPTS = [
cfg.StrOpt('topic',
default='higgins-conductor',
help='The queue to add conductor tasks to.'),
]
opt_group = cfg.OptGroup(
name='conductor',
title='Options for the higgins-conductor service')
cfg.CONF.register_group(opt_group)
cfg.CONF.register_opts(SERVICE_OPTS, opt_group)

View File

View File

@ -0,0 +1,24 @@
# 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.
"""Higgins Conductor default handler."""
# These are the database operations - They are executed by the conductor
# service. API calls via AMQP trigger the handlers to be called.
class Handler(object):
def __init__(self):
super(Handler, self).__init__()
def container_get(uuid):
pass

View File

@ -47,6 +47,7 @@ output_file = higgins/locale/higgins.pot
[entry_points]
console_scripts =
higgins-api = higgins.cmd.api:main
higgins-conductor = higgins.cmd.conductor:main
oslo.config.opts =
higgins = higgins.opts:list_opts