Added in the guest manager code

* Added the bin script for the guest agent
* Added a sample config file for guest
* Migrated guest-agent to guestagent
* Added a manager and service for the guest
This commit is contained in:
Michael Basnight 2012-03-06 10:30:49 -06:00
parent 37f4936ef0
commit 61b8c85ff6
6 changed files with 233 additions and 0 deletions

57
bin/reddwarf-guestagent Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# 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 eventlet
eventlet.monkey_patch()
import gettext
import optparse
import os
import sys
gettext.install('reddwarf', unicode=1)
# If ../reddwarf/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(possible_topdir, 'reddwarf', '__init__.py')):
sys.path.insert(0, possible_topdir)
from reddwarf import version
from reddwarf.common import config
from reddwarf.common import service
if __name__ == '__main__':
parser = optparse.OptionParser(version="%%prog %s"
% version.version_string())
config.add_common_options(parser)
config.add_log_options(parser)
(options, args) = config.parse_options(parser)
try:
conf, app = config.Config.load_paste_app('reddwarf-guestagent', options, args)
server = service.Service.create(binary='reddwarf-guestagent')
service.serve(server)
service.wait()
except RuntimeError as error:
import traceback
print traceback.format_exc()
sys.exit("ERROR: %s" % error)

View File

@ -0,0 +1,95 @@
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = True
# Show debugging output in logs (sets DEBUG log level output)
debug = True
# Address to bind the API server
bind_host = 0.0.0.0
# Port the bind the API server to
bind_port = 8778
# AMQP Connection info
rabbit_password=f7999d1955c5014aa32c
# SQLAlchemy connection string for the reference implementation
# registry server. Any valid SQLAlchemy connection string is fine.
# See: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/connections.html#sqlalchemy.create_engine
sql_connection = sqlite:///reddwarf_test.sqlite
# sql_connection = mysql://root:root@localhost/reddwarf
#sql_connection = postgresql://reddwarf:reddwarf@localhost/reddwarf
# Period in seconds after which SQLAlchemy should reestablish its connection
# to the database.
#
# MySQL uses a default `wait_timeout` of 8 hours, after which it will drop
# idle connections. This can result in 'MySQL Gone Away' exceptions. If you
# notice this, you can lower this value to ensure that SQLAlchemy reconnects
# before MySQL can drop the connection.
sql_idle_timeout = 3600
#DB Api Implementation
db_api_implementation = "reddwarf.db.sqlalchemy.api"
# Path to the extensions
api_extensions_path = reddwarf/extensions
# Configuration options for talking to nova via the novaclient.
# These options are for an admin user in your keystone config.
# It proxy's the token received from the user to send to nova via this admin users creds,
# basically acting like the client via that proxy token.
reddwarf_proxy_admin_user = admin
reddwarf_proxy_admin_pass = 3de4922d8b6ac5a1aad9
reddwarf_proxy_admin_tenant_name = admin
reddwarf_auth_url = http://0.0.0.0:5000/v2.0
# Manager impl for the taskmanager
guestagent_manager=reddwarf.guestagent.manager.GuestAgent
# ============ notifer queue kombu connection options ========================
notifier_queue_hostname = localhost
notifier_queue_userid = guest
notifier_queue_password = guest
notifier_queue_ssl = False
notifier_queue_port = 5672
notifier_queue_virtual_host = /
notifier_queue_transport = memory
[composite:reddwarf-guestagent]
use = call:reddwarf.common.wsgi:versioned_urlmap
/: versions
/v0.1: reddwarf-guestagent-app
[app:versions]
paste.app_factory = reddwarf.versions:app_factory
[pipeline:reddwarf-guestagent-app]
pipeline = guestagent-app
#pipeline = debug extensions reddwarfapp
[filter:extensions]
paste.filter_factory = reddwarf.common.extensions:factory
[filter:tokenauth]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
service_protocol = http
service_host = 127.0.0.1
service_port = 5000
auth_host = 127.0.0.1
auth_port = 35357
auth_protocol = http
auth_uri = http://127.0.0.1:5000/
admin_token = be19c524ddc92109a224
[filter:authorization]
paste.filter_factory = reddwarf.common.auth:AuthorizationMiddleware.factory
[app:guestagent-app]
paste.app_factory = reddwarf.guestagent.service:app_factory
#Add this filter to log request and response for debugging
[filter:debug]
paste.filter_factory = reddwarf.common.wsgi:Debug

View File

@ -0,0 +1,34 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# 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 logging
LOG = logging.getLogger(__name__)
class GuestAgent(object):
"""Task manager impl"""
def __init__(self, *args, **kwargs):
LOG.info("GuestAgent init %s %s"% (args, kwargs))
def periodic_tasks(self, raise_on_error=False):
LOG.info("Launching a periodic task")
def test_method(self, context):
LOG.info("test_method called with context %s" % context)

View File

@ -0,0 +1,47 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# 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 logging
import routes
import webob.exc
from reddwarf.common import wsgi
from reddwarf import rpc
LOG = logging.getLogger('reddwarf.taskmanager.service')
class Controller(wsgi.Controller):
"""Base controller class."""
pass
class API(wsgi.Router):
"""API"""
def __init__(self):
mapper = routes.Mapper()
super(API, self).__init__(mapper)
self._instance_router(mapper)
def _instance_router(self, mapper):
resource = Controller().create_resource()
path = "/guests"
mapper.resource("guest", path, controller=resource)
def app_factory(global_conf, **local_conf):
return API()