Fixed Pep8 errors.

This commit is contained in:
Tim Simpson 2012-03-07 13:57:54 -06:00
parent 292410dccb
commit 3e141fd79d
28 changed files with 131 additions and 263 deletions

View File

@ -38,7 +38,7 @@ from nova import utils
from nova import wsgi
from nova.openstack.common import cfg
SERVICE_NAME="reddwarfapi_database"
SERVICE_NAME = "reddwarfapi_database"
reddwarf_opts = [
cfg.StrOpt('reddwarf_api_paste_config',

View File

@ -301,4 +301,3 @@ def main():
if __name__ == '__main__':
main()

View File

@ -38,6 +38,7 @@ from reddwarf.common import config
from reddwarf.common import wsgi
from reddwarf.db import db_api
def create_options(parser):
"""Sets up the CLI and config-file options
@ -69,4 +70,3 @@ if __name__ == '__main__':
import traceback
print traceback.format_exc()
sys.exit("ERROR: %s" % error)

View File

@ -54,4 +54,3 @@ if __name__ == '__main__':
import traceback
print traceback.format_exc()
sys.exit("ERROR: %s" % error)

View File

@ -31,6 +31,7 @@ from nova import log as logging
LOG = logging.getLogger('reddwarf.api.database')
FLAGS = flags.FLAGS
class APIRouter(nova.api.openstack.APIRouter):
"""
Routes requests on the OpenStack API to the appropriate controller
@ -51,5 +52,3 @@ class APIRouter(nova.api.openstack.APIRouter):
controller=self.resources['instances'],
collection={'detail': 'GET'},
member={'action': 'POST'})

View File

@ -22,12 +22,14 @@ from nova import log as logging
LOG = logging.getLogger('reddwarf.api.database.contrib.databases')
class DatabasesController(object):
def index(self, req):
LOG.info("index call databases")
return "This is a index of databases"
class UsersController(object):
def index(self, req):
@ -35,12 +37,6 @@ class UsersController(object):
return "This is a index of users"
#class DatabasesControllerExtension(wsgi.Controller):
# @wsgi.action('test_func')
# def _test_func(self, req, id, body):
#
# return "Test Func called."
class Databases(extensions.ExtensionDescriptor):
"""The Databases Extension"""

View File

@ -30,10 +30,12 @@ reddwarf_opts = [
help='User by which you make proxy requests to the nova api with'),
cfg.StrOpt('reddwarf_proxy_admin_pass',
default='3de4922d8b6ac5a1aad9',
help='Password for the admin user defined in reddwarf_proxy_admin_user'),
help='Password for the admin user defined in '
'reddwarf_proxy_admin_user'),
cfg.StrOpt('reddwarf_proxy_admin_tenant_name',
default='admin',
help='Tenant name fro teh admin user defined in reddwarf_proxy_admin_user'),
help='Tenant name for the admin user defined in '
'reddwarf_proxy_admin_user'),
cfg.StrOpt('reddwarf_auth_url',
default='http://0.0.0.0:5000/v2.0',
help='Auth url for authing against reddwarf_proxy_admin_user'),
@ -52,11 +54,14 @@ class Controller(wsgi.Controller):
def get_client(self, req):
proxy_token = req.headers["X-Auth-Token"]
client = Client(FLAGS.reddwarf_proxy_admin_user, FLAGS.reddwarf_proxy_admin_pass,
FLAGS.reddwarf_proxy_admin_tenant_name, FLAGS.reddwarf_auth_url, token=proxy_token)
client = Client(FLAGS.reddwarf_proxy_admin_user,
FLAGS.reddwarf_proxy_admin_pass,
FLAGS.reddwarf_proxy_admin_tenant_name,
FLAGS.reddwarf_auth_url,
token=proxy_token)
client.authenticate()
return client
def index(self, req):
"""Return all instances."""
servers = self.get_client(req).servers.list()
@ -74,7 +79,8 @@ class Controller(wsgi.Controller):
@wsgi.deserializers(xml=CreateDeserializer)
def create(self, req, body):
"""Creates an instance"""
server = self.get_client(req).servers.create(body['name'], body['image'], body['flavor'])
server = self.get_client(req).servers.create(
body['name'], body['image'], body['flavor'])
LOG.info(server)
robj = wsgi.ResponseObject(server)

View File

@ -43,7 +43,8 @@ class ViewBuilder(object):
"instance": {
"id": instance.id,
"name": instance.name,
"links": self.servers_viewbuilder._get_links(request, instance.id),
"links": self.servers_viewbuilder._get_links(request,
instance.id),
},
}
@ -54,191 +55,13 @@ class ViewBuilder(object):
def _list_view(self, func, request, servers):
"""Provide a view for a list of instances."""
# This is coming back as a server entity but we change it to instances
instance_list = [func(request, instance)["instance"] for instance in servers]
servers_links = self.servers_viewbuilder._get_collection_links(request, servers)
instance_list = [func(request, instance)["instance"]
for instance in servers]
servers_links = self.servers_viewbuilder._get_collection_links(
request, servers)
instances_dict = dict(instances=instance_list)
if servers_links:
instances_dict["servers_links"] = servers_links
return instances_dict
#
#
# def _build_basic(self, server, req, status_lookup):
# """Build the very basic information for an instance"""
# instance = {}
# instance['id'] = server['uuid']
# instance['name'] = server['name']
# instance['status'] = status_lookup.get_status_from_server(server).status
# instance['links'] = self._build_links(req, instance)
# return instance
#
# def _build_detail(self, server, req, instance):
# """Build out a more detailed view of the instance"""
# flavor_view = flavors.ViewBuilder(_base_url(req), _project_id(req))
# instance['flavor'] = server['flavor']
# instance['flavor']['links'] = flavor_view._build_links(instance['flavor'])
# instance['created'] = server['created']
# instance['updated'] = server['updated']
# # Add the hostname
# if 'hostname' in server:
# instance['hostname'] = server['hostname']
#
# # Add volume information
# dbvolume = self.build_volume(server)
# if dbvolume:
# instance['volume'] = dbvolume
# return instance
#
# @staticmethod
# def _build_links(req, instance):
# """Build the links for the instance"""
# base_url = _base_url(req)
# href = os.path.join(base_url, _project_id(req),
# "instances", str(instance['id']))
# bookmark = os.path.join(nova_common.remove_version_from_href(base_url),
# "instances", str(instance['id']))
# links = [
# {
# 'rel': 'self',
# 'href': href
# },
# {
# 'rel': 'bookmark',
# 'href': bookmark
# }
# ]
# return links
#
# def build_index(self, server, req, status_lookup):
# """Build the response for an instance index call"""
# return self._build_basic(server, req, status_lookup)
#
# def build_detail(self, server, req, status_lookup):
# """Build the response for an instance detail call"""
# instance = self._build_basic(server, req, status_lookup)
# instance = self._build_detail(server, req, instance)
# return instance
#
# def build_single(self, server, req, status_lookup, databases=None,
# root_enabled=False, create=False):
# """
# Given a server (obtained from the servers API) returns an instance.
# """
# instance = self._build_basic(server, req, status_lookup)
# instance = self._build_detail(server, req, instance)
# if not create:
# # Add Database and root_enabled
# instance['databases'] = databases
# instance['rootEnabled'] = root_enabled
#
# return instance
#
# @staticmethod
# def build_volume(server):
# """Given a server dict returns the instance volume dict."""
# try:
# volumes = server['volumes']
# volume_dict = volumes[0]
# except (KeyError, IndexError):
# return None
# if len(volumes) > 1:
# error_msg = {'instanceId': server['id'],
# 'msg': "> 1 volumes in the underlying instance!"}
# LOG.error(error_msg)
# notifier.notify(notifier.publisher_id("reddwarf-api"),
# 'reddwarf.instance.list', notifier.ERROR,
# error_msg)
# return {'size': volume_dict['size']}
#
#
#class MgmtViewBuilder(ViewBuilder):
# """Management views for an instance"""
#
# def __init__(self):
# super(MgmtViewBuilder, self).__init__()
#
# def build_mgmt_single(self, server, instance_ref, req, status_lookup):
# """Build out the management view for a single instance"""
# instance = self._build_basic(server, req, status_lookup)
# instance = self._build_detail(server, req, instance)
# instance = self._build_server_details(server, instance)
# instance = self._build_compute_api_details(instance_ref, instance)
# return instance
#
# def build_guest_info(self, instance, status=None, dbs=None, users=None,
# root_enabled=None):
# """Build out all possible information for a guest"""
# instance['guest_status'] = status.get_guest_status()
# instance['databases'] = dbs
# instance['users'] = users
# root_history = self.build_root_history(instance['id'],
# root_enabled)
# instance['root_enabled_at'] = root_history['root_enabled_at']
# instance['root_enabled_by'] = root_history['root_enabled_by']
# return instance
#
# def build_root_history(self, id, root_enabled):
# if root_enabled is not None:
# return {
# 'id': id,
# 'root_enabled_at': root_enabled.created_at,
# 'root_enabled_by': root_enabled.user_id}
# else:
# return {
# 'id': id,
# 'root_enabled_at': 'Never',
# 'root_enabled_by': 'Nobody'
# }
#
# @staticmethod
# def _build_server_details(server, instance):
# """Build more information from the servers api"""
# instance['addresses'] = server['addresses']
# del instance['links']
# return instance
#
# @staticmethod
# def _build_compute_api_details(instance_ref, instance):
# """Build out additional information from the compute api"""
# instance['server_state_description'] = instance_ref['vm_state']
# instance['host'] = instance_ref['host']
# instance['account_id'] = instance_ref['user_id']
# return instance
#
# @staticmethod
# def build_volume(server):
# """Build out a more detailed volumes view"""
# if 'volumes' in server:
# volumes = server['volumes']
# volume_dict = volumes[0]
# else:
# volume_dict = None
# return volume_dict

View File

@ -52,7 +52,8 @@ class AuthorizationMiddleware(wsgi.Middleware):
class TenantBasedAuth(object):
# The paths differ from melange, so the regex must differ as well, reddwarf starts with a tenant_id
# The paths differ from melange, so the regex must differ as well,
# reddwarf starts with a tenant_id
tenant_scoped_url = re.compile("/(?P<tenant_id>.*?)/.*")
def authorize(self, request, tenant_id, roles):
@ -67,4 +68,3 @@ class TenantBasedAuth(object):
return True
raise webob.exc.HTTPForbidden(_("User with tenant id %s cannot "
"access this resource") % tenant_id)

View File

@ -25,6 +25,7 @@ context or provide additional information in their specific WSGI pipeline.
from reddwarf.openstack.common import context
from reddwarf.common import utils
class ReddwarfContext(context.RequestContext):
"""

View File

@ -24,6 +24,7 @@ ProcessExecutionError = openstack_exception.ProcessExecutionError
DatabaseMigrationError = openstack_exception.DatabaseMigrationError
wrap_exception = openstack_exception.wrap_exception
class ReddwarfError(openstack_exception.OpenstackException):
"""Base exception that all custom reddwarf app exceptions inherit from."""
@ -41,6 +42,3 @@ class DBConstraintError(ReddwarfError):
class InvalidRPCConnectionReuse(ReddwarfError):
message = _("Invalid RPC Connection Reuse")

View File

@ -21,6 +21,7 @@ from reddwarf.openstack.common import extensions
ExtensionsDescriptor = extensions.ExtensionDescriptor
ResourceExtension = extensions.ResourceExtension
def factory(global_config, **local_config):
"""Paste factory."""
def _factory(app):
@ -73,4 +74,4 @@ class TenantExtensionsResource(extensions.ExtensionsResource):
return super(TenantExtensionsResource, self).delete(req, id)
def create(self, req, tenant_id):
return super(TenantExtensionsResource, self).create(req)
return super(TenantExtensionsResource, self).create(req)

View File

@ -35,6 +35,7 @@ bool_from_string = openstack_utils.bool_from_string
execute = openstack_utils.execute
isotime = openstack_utils.isotime
def stringify_keys(dictionary):
if dictionary is None:
return None
@ -78,6 +79,7 @@ class cached_property(object):
setattr(obj, self.__name__, value)
return value
class MethodInspector(object):
def __init__(self, func):

View File

@ -83,7 +83,8 @@ class Request(openstack_wsgi.Request):
if format in ['json', 'xml']:
return 'application/{0}'.format(parts[1])
ctypes = {'application/vnd.openstack.reddwarf+json': "application/json",
ctypes = {'application/vnd.openstack.reddwarf+json':
"application/json",
'application/vnd.openstack.reddwarf+xml': "application/xml",
'application/json': "application/json",
'application/xml': "application/xml"}
@ -254,4 +255,4 @@ class Fault(webob.exc.HTTPException):
self.wrapped_exc.body = serializer.serialize(fault_data, content_type)
self.wrapped_exc.content_type = content_type
return self.wrapped_exc
return self.wrapped_exc

View File

@ -27,13 +27,18 @@ from reddwarf.common import exception
from reddwarf.common import utils
from novaclient.v1_1.client import Client
CONFIG = config.Config
LOG = logging.getLogger('reddwarf.database.models')
PROXY_ADMIN_USER = config.Config.get('reddwarf_proxy_admin_user', 'admin')
PROXY_ADMIN_PASS = config.Config.get('reddwarf_proxy_admin_pass', '3de4922d8b6ac5a1aad9')
PROXY_ADMIN_TENANT_NAME = config.Config.get('reddwarf_proxy_admin_tenant_name', 'admin')
PROXY_AUTH_URL = config.Config.get('reddwarf_auth_url', 'http://0.0.0.0:5000/v2.0')
PROXY_TENANT_ID = config.Config.get('reddwarf_tenant_id', 'f5f71240a97c411e977452370422d7cc')
PROXY_ADMIN_USER = CONFIG.get('reddwarf_proxy_admin_user', 'admin')
PROXY_ADMIN_PASS = CONFIG.get('reddwarf_proxy_admin_pass',
'3de4922d8b6ac5a1aad9')
PROXY_ADMIN_TENANT_NAME = CONFIG.get('reddwarf_proxy_admin_tenant_name',
'admin')
PROXY_AUTH_URL = CONFIG.get('reddwarf_auth_url', 'http://0.0.0.0:5000/v2.0')
PROXY_TENANT_ID = CONFIG.get('reddwarf_tenant_id',
'f5f71240a97c411e977452370422d7cc')
class ModelBase(object):
@ -92,7 +97,8 @@ class RemoteModelBase(ModelBase):
def data_item(self, data_object):
data_fields = self._data_fields + self._auto_generated_attrs
return dict([(field, getattr(data_object,field)) for field in data_fields])
return dict([(field, getattr(data_object, field))
for field in data_fields])
# data magic that will allow for a list of _data_object or a single item
# if the object is a list, it will turn it into a list of hash's again
@ -104,6 +110,7 @@ class RemoteModelBase(ModelBase):
else:
return self.data_item(self._data_object)
class Instance(RemoteModelBase):
_data_fields = ['name', 'status', 'updated', 'id', 'flavor']
@ -115,6 +122,7 @@ class Instance(RemoteModelBase):
def delete(cls, proxy_token, uuid):
return cls.get_client(proxy_token).servers.delete(uuid)
class Instances(Instance):
def __init__(self, proxy_token):
@ -174,15 +182,18 @@ class DatabaseModelBase(ModelBase):
class DBInstance(DatabaseModelBase):
_data_fields = ['name', 'status']
class ServiceImage(DatabaseModelBase):
_data_fields = ['service_name', 'image_id']
def persisted_models():
return {
'instance': DBInstance,
'service_image': ServiceImage,
}
class InvalidModelError(exception.ReddwarfError):
message = _("The following values are invalid: %(errors)s")

View File

@ -27,6 +27,7 @@ from reddwarf.database import views
from reddwarf.common import context
from reddwarf import rpc
CONFIG = config.Config
LOG = logging.getLogger('reddwarf.database.service')
@ -34,10 +35,14 @@ class BaseController(wsgi.Controller):
"""Base controller class."""
def __init__(self):
self.proxy_admin_user = config.Config.get('reddwarf_proxy_admin_user', 'admin')
self.proxy_admin_pass = config.Config.get('reddwarf_proxy_admin_pass', '3de4922d8b6ac5a1aad9')
self.proxy_admin_tenant_name = config.Config.get('reddwarf_proxy_admin_tenant_name', 'admin')
self.auth_url = config.Config.get('reddwarf_auth_url', 'http://0.0.0.0:5000/v2.0')
self.proxy_admin_user = CONFIG.get('reddwarf_proxy_admin_user',
'admin')
self.proxy_admin_pass = CONFIG.get('reddwarf_proxy_admin_pass',
'3de4922d8b6ac5a1aad9')
self.proxy_admin_tenant_name = CONFIG.get(
'reddwarf_proxy_admin_tenant_name', 'admin')
self.auth_url = CONFIG.get('reddwarf_auth_url',
'http://0.0.0.0:5000/v2.0')
def get_client(self, req):
proxy_token = req.headers["X-Auth-Token"]
@ -46,6 +51,7 @@ class BaseController(wsgi.Controller):
client.authenticate()
return client
class InstanceController(BaseController):
"""Controller for instance functionality"""
@ -53,7 +59,8 @@ class InstanceController(BaseController):
"""Return all instances."""
servers = models.Instances(req.headers["X-Auth-Token"]).data()
#TODO(hub-cap): Remove this, this is only for testing communication between services
rpc.cast(context.ReddwarfContext(), "taskmanager.None", {"method":"test_method", "BARRRR":"ARGGGGG"})
rpc.cast(context.ReddwarfContext(), "taskmanager.None",
{"method": "test_method", "BARRRR": "ARGGGGG"})
return wsgi.Result(views.InstancesView(servers).data(), 201)
@ -70,17 +77,21 @@ class InstanceController(BaseController):
return wsgi.Result(202)
def create(self, req, body, tenant_id):
# find the service id (cant be done yet at startup due to inconsitencies w/ the load app paste
# find the service id (cant be done yet at startup due to
# inconsitencies w/ the load app paste
# TODO(hub-cap): figure out how to get this to work in __init__ time
# TODO(hub-cap): The problem with this in __init__ is that the paste config
# is generated w/ the same config file as the db flags that are needed
# for init. These need to be split so the db can be init'd w/o the paste
# stuff. Since the paste stuff inits the database.service module, it
# is a chicken before the egg problem. Simple refactor will fix it and
# we can move this into the __init__ code. Or maybe we shouldnt due to
# the nature of changing images. This needs discussion.
image_id = models.ServiceImage.find_by(service_name="database")['image_id']
server = self.get_client(req).servers.create(body['name'], image_id, body['flavor'])
# TODO(hub-cap): The problem with this in __init__ is that the paste
# config is generated w/ the same config file as the db flags that
# are needed for init. These need to be split so the db can be init'd
# w/o the paste stuff. Since the paste stuff inits the
# database.service module, it is a chicken before the egg problem.
# Simple refactor will fix it and we can move this into the __init__
# code. Or maybe we shouldnt due to the nature of changing images.
# This needs discussion.
database = models.ServiceImage.find_by(service_name="database")
image_id = database['image_id']
server = self.get_client(req).servers.create(body['name'], image_id,
body['flavor'])
# Now wait for the response from the create to do additional work
return "server created %s" % server.__dict__

View File

@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
class InstanceView(object):
def __init__(self, instance):
@ -30,6 +31,7 @@ class InstanceView(object):
},
}
class InstancesView(object):
def __init__(self, instances):
@ -41,4 +43,4 @@ class InstancesView(object):
for instance in self.instances:
data.append(InstanceView(instance).data())
return data
return data

View File

@ -28,7 +28,9 @@ def map(engine, models):
return
orm.mapper(models['instance'], Table('instances', meta, autoload=True))
orm.mapper(models['service_image'], Table('service_images', meta, autoload=True))
orm.mapper(models['service_image'],
Table('service_images', meta, autoload=True))
def mapping_exists(model):
try:

View File

@ -40,9 +40,9 @@ instances = Table('instances', meta,
def upgrade(migrate_engine):
meta.bind = migrate_engine
create_tables([instances,])
create_tables([instances, ])
def downgrade(migrate_engine):
meta.bind = migrate_engine
drop_tables([instances,])
drop_tables([instances, ])

View File

@ -40,9 +40,9 @@ service_images = Table('service_images', meta,
def upgrade(migrate_engine):
meta.bind = migrate_engine
create_tables([service_images,])
create_tables([service_images, ])
def downgrade(migrate_engine):
meta.bind = migrate_engine
drop_tables([service_images,])
drop_tables([service_images, ])

View File

@ -21,6 +21,8 @@ from novaclient.v1_1.client import Client
from reddwarf.common import config
from reddwarf.common import extensions
CONFIG = config.Config
LOG = logging.getLogger('reddwarf.extensions.mysql')
@ -28,11 +30,14 @@ class BaseController(object):
"""Base controller class."""
def __init__(self):
self.proxy_admin_user = config.Config.get('reddwarf_proxy_admin_user', 'admin')
self.proxy_admin_pass = config.Config.get('reddwarf_proxy_admin_pass', '3de4922d8b6ac5a1aad9')
self.proxy_admin_tenant_name = config.Config.get('reddwarf_proxy_admin_tenant_name', 'admin')
self.auth_url = config.Config.get('reddwarf_auth_url', 'http://0.0.0.0:5000/v2.0')
self.proxy_admin_user = CONFIG.get('reddwarf_proxy_admin_user',
'admin')
self.proxy_admin_pass = CONFIG.get('reddwarf_proxy_admin_pass',
'3de4922d8b6ac5a1aad9')
self.proxy_admin_tenant_name = CONFIG.get(
'reddwarf_proxy_admin_tenant_name', 'admin')
self.auth_url = CONFIG.get('reddwarf_auth_url',
'http://0.0.0.0:5000/v2.0')
def get_client(self, req):
proxy_token = req.headers["X-Auth-Token"]
@ -41,6 +46,7 @@ class BaseController(object):
client.authenticate()
return client
class UserController(BaseController):
"""Controller for instance functionality"""
@ -83,4 +89,4 @@ class Mysql(extensions.ExtensionsDescriptor):
UserController())
resources.append(resource)
return resources
return resources

View File

@ -24,7 +24,8 @@ from reddwarf.common import config
LOG = logging.getLogger(__name__)
rpc_backend_opt = config.Config.get('rpc_backend','reddwarf.rpc.impl_kombu')
rpc_backend_opt = config.Config.get('rpc_backend', 'reddwarf.rpc.impl_kombu')
def create_connection(new=True):
"""Create a connection to the message bus used for rpc.

View File

@ -43,11 +43,13 @@ from reddwarf.common import context
LOG = logging.getLogger(__name__)
class Pool(pools.Pool):
"""Class that implements a Pool of Connections."""
def __init__(self, *args, **kwargs):
self.connection_cls = kwargs.pop("connection_cls", None)
kwargs.setdefault("max_size", config.Config.get('rpc_conn_pool_size', 30))
kwargs.setdefault("max_size",
config.Config.get('rpc_conn_pool_size', 30))
kwargs.setdefault("order_as_stack", True)
super(Pool, self).__init__(*args, **kwargs)
@ -205,7 +207,8 @@ class ProxyCallback(object):
def __init__(self, proxy, connection_pool):
self.proxy = proxy
self.pool = greenpool.GreenPool(config.Config.get('rpc_thread_pool_size',1024))
self.pool = greenpool.GreenPool(
config.Config.get('rpc_thread_pool_size', 1024))
self.connection_pool = connection_pool
def __call__(self, message_data):
@ -265,8 +268,8 @@ class ProxyCallback(object):
class MulticallWaiter(object):
def __init__(self, connection, timeout):
self._connection = connection
self._iterator = connection.iterconsume(
timeout=timeout or config.Config.get('rpc_response_timeout', 3600))
timeout = timeout or config.Config.get('rpc_response_timeout', 3600)
self._iterator = connection.iterconsume(timeout)
self._result = None
self._done = False
self._got_ending = False

View File

@ -26,6 +26,7 @@ from reddwarf.common import exception
LOG = logging.getLogger(__name__)
class RemoteError(exception.ReddwarfError):
"""Signifies that a remote class has raised an exception.

View File

@ -36,6 +36,7 @@ from reddwarf.rpc import common as rpc_common
LOG = logging.getLogger(__name__)
SSL_VERSION = "SSLv2"
class ConsumerBase(object):
"""Consumer base class."""
@ -149,7 +150,8 @@ class TopicConsumer(ConsumerBase):
Other kombu options may be passed
"""
# Default options
options = {'durable': config.Config.get('rabbit_durable_queues', False),
options = {'durable': config.Config.get('rabbit_durable_queues',
False),
'auto_delete': False,
'exclusive': False}
options.update(kwargs)
@ -255,9 +257,10 @@ class TopicPublisher(Publisher):
Kombu options may be passed as keyword args to override defaults
"""
options = {'durable': config.Config.get('rabbit_durable_queues', False),
'auto_delete': False,
'exclusive': False}
options = {'durable': config.Config.get('rabbit_durable_queues',
False),
'auto_delete': False,
'exclusive': False }
options.update(kwargs)
super(TopicPublisher, self).__init__(channel,
config.Config.get('control_exchange', 'reddwarf'),
@ -288,7 +291,8 @@ class NotifyPublisher(TopicPublisher):
"""Publisher class for 'notify'"""
def __init__(self, *args, **kwargs):
self.durable = kwargs.pop('durable', config.Config.get('rabbit_durable_queues', False))
default = config.Config.get('rabbit_durable_queues', False)
self.durable = kwargs.pop('durable', default)
super(NotifyPublisher, self).__init__(*args, **kwargs)
def reconnect(self, channel):
@ -315,7 +319,7 @@ class Connection(object):
# Try forever?
if self.max_retries <= 0:
self.max_retries = None
self.interval_start = config.Config.get('rabbit_retry_interval',1)
self.interval_start = config.Config.get('rabbit_retry_interval', 1)
self.interval_stepping = config.Config.get('rabbit_retry_backoff', 2)
# max retry-interval = 30 seconds
self.interval_max = 30
@ -332,15 +336,19 @@ class Connection(object):
p_key = server_params_to_kombu_params.get(sp_key, sp_key)
params[p_key] = value
params.setdefault('hostname', config.Config.get('rabbit_host','127.0.0.1'))
params.setdefault('port', config.Config.get('rabbit_port',5672))
params.setdefault('userid', config.Config.get('rabbit_userid','guest'))
params.setdefault('password', config.Config.get('rabbit_password','f7999d1955c5014aa32c'))
params.setdefault('virtual_host', config.Config.get('rabbit_virtual_host','/'))
params.setdefault('hostname', config.Config.get('rabbit_host',
'127.0.0.1'))
params.setdefault('port', config.Config.get('rabbit_port', 5672))
params.setdefault('userid',
config.Config.get('rabbit_userid', 'guest'))
params.setdefault('password',
config.Config.get('rabbit_password', 'guest'))
params.setdefault('virtual_host',
config.Config.get('rabbit_virtual_host', '/'))
self.params = params
if config.Config.get('fake_rabbit',False):
if config.Config.get('fake_rabbit', False):
self.params['transport'] = 'memory'
self.memory_transport = True
else:
@ -570,7 +578,8 @@ class Connection(object):
def _publish():
publisher = cls(self.channel, topic, **kwargs)
LOG.info("_publish info%s %s %s %s" % (self.channel, topic, kwargs,publisher))
LOG.info("_publish info%s %s %s %s" % (self.channel, topic,
kwargs, publisher))
publisher.send(msg)
self.ensure(_error_callback, _publish)

View File

@ -74,4 +74,3 @@ class API(wsgi.Router):
def app_factory(global_conf, **local_conf):
return API()

View File

@ -19,7 +19,6 @@
# The code below enables nosetests to work with i18n _() blocks
import __builtin__
setattr(__builtin__, '_', lambda x: x)

View File

@ -45,4 +45,3 @@ def vcs_version_string():
def version_string_with_vcs():
return "%s-%s" % (canonical_version_string(), vcs_version_string())