Merge pull request #27 from hub-cap/fix_amqp
Fixing the server load call and amqp cast_with_consumer.
This commit is contained in:
commit
a5f978bae3
@ -30,6 +30,8 @@ def map(engine, models):
|
||||
orm.mapper(models['instance'], Table('instances', meta, autoload=True))
|
||||
orm.mapper(models['service_image'],
|
||||
Table('service_images', meta, autoload=True))
|
||||
orm.mapper(models['service_statuses'],
|
||||
Table('service_statuses', meta, autoload=True))
|
||||
|
||||
|
||||
def mapping_exists(model):
|
||||
|
@ -78,12 +78,12 @@ class Instance(object):
|
||||
elif uuid is None:
|
||||
raise TypeError("Argument uuid not defined.")
|
||||
client = create_nova_client(context)
|
||||
instance_info = DBInstance.find_by(id=uuid)
|
||||
db_info = DBInstance.find_by(id=uuid)
|
||||
server = load_server_or_raise(client,
|
||||
instance_info.compute_instance_id)
|
||||
task_status = instance_info.task_status
|
||||
db_info.compute_instance_id)
|
||||
task_status = db_info.task_status
|
||||
service_status = InstanceServiceStatus.find_by(instance_id=uuid)
|
||||
return Instance(context, uuid, server, task_status, service_status)
|
||||
return Instance(context, db_info, server, service_status)
|
||||
|
||||
@classmethod
|
||||
def delete(cls, context, uuid):
|
||||
@ -97,10 +97,10 @@ class Instance(object):
|
||||
db_info = DBInstance.create(name=name,
|
||||
compute_instance_id=server.id,
|
||||
task_status=InstanceTasks.BUILDING)
|
||||
service_status = InstanceServiceStatus(instance_id=db_info.id,
|
||||
service_status = InstanceServiceStatus.create(instance_id=db_info.id,
|
||||
status=ServiceStatuses.NEW)
|
||||
# Now wait for the response from the create to do additional work
|
||||
guest_api.API().prepare(context, db_info.id, [], 512)
|
||||
guest_api.API().prepare(context, db_info.id, 512, [])
|
||||
return Instance(context, db_info, server, service_status)
|
||||
|
||||
@property
|
||||
@ -157,12 +157,18 @@ class Instance(object):
|
||||
class Instances(Instance):
|
||||
|
||||
def __init__(self, context):
|
||||
self._data_object = self.get_client(context).servers.list()
|
||||
#TODO(hub-cap): Fix this, this just cant be right
|
||||
client = create_nova_client(context)
|
||||
self._data_object = client.servers.list()
|
||||
|
||||
def __iter__(self):
|
||||
for item in self._data_object:
|
||||
yield item
|
||||
|
||||
@staticmethod
|
||||
def load(context):
|
||||
raise Exception("Implement this!")
|
||||
|
||||
|
||||
class DatabaseModelBase(ModelBase):
|
||||
_auto_generated_attrs = ['id']
|
||||
@ -178,8 +184,6 @@ class DatabaseModelBase(ModelBase):
|
||||
def save(self):
|
||||
if not self.is_valid():
|
||||
raise InvalidModelError(self.errors)
|
||||
# self._convert_columns_to_proper_type()
|
||||
# self._before_save()
|
||||
self['updated_at'] = utils.utcnow()
|
||||
LOG.debug("Saving %s: %s" % (self.__class__.__name__, self.__dict__))
|
||||
return db.db_api.save(self)
|
||||
|
@ -75,14 +75,14 @@ class InstanceController(BaseController):
|
||||
context = rd_context.ReddwarfContext(
|
||||
auth_tok=req.headers["X-Auth-Token"],
|
||||
tenant=tenant_id)
|
||||
servers = models.Instances(context).data()
|
||||
servers = models.Instances.load(context)
|
||||
# TODO(cp16net): need to set the return code correctly
|
||||
return wsgi.Result(views.InstancesView(servers).data(), 201)
|
||||
|
||||
def show(self, req, tenant_id, id):
|
||||
"""Return a single instance."""
|
||||
LOG.info("req : '%s'\n\n" % req)
|
||||
LOG.info("Creating a database instance for tenant '%s'" % tenant_id)
|
||||
LOG.info("Getting a database instance for tenant '%s'" % tenant_id)
|
||||
LOG.info("id : '%s'\n\n" % id)
|
||||
# TODO(hub-cap): turn this into middleware
|
||||
context = rd_context.ReddwarfContext(
|
||||
@ -96,7 +96,7 @@ class InstanceController(BaseController):
|
||||
# this to get the message
|
||||
return wsgi.Result(str(e), 404)
|
||||
# TODO(cp16net): need to set the return code correctly
|
||||
return wsgi.Result(views.InstanceView(server), 201)
|
||||
return wsgi.Result(views.InstanceView(server).data(), 201)
|
||||
|
||||
def delete(self, req, tenant_id, id):
|
||||
"""Delete a single instance."""
|
||||
|
@ -670,7 +670,7 @@ def cast(context, topic, msg):
|
||||
|
||||
def cast_with_consumer(context, topic, msg):
|
||||
"""Sends a message on a topic without waiting for a response."""
|
||||
return rpc_amqp.cast(context, topic, msg, Connection.pool)
|
||||
return rpc_amqp.cast_with_consumer(context, topic, msg, Connection.pool)
|
||||
|
||||
|
||||
def fanout_cast(context, topic, msg):
|
||||
|
Loading…
Reference in New Issue
Block a user