From f2212511b83e27815dd4cd5976ac74122d68bec2 Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Tue, 27 Mar 2012 16:46:38 -0500 Subject: [PATCH] Fixing the queues to use uuid. * Added the /etc/guest_info file that has the id of the guest * Passed uuid in as the host flag in the common config code * Removed uuid from the dbaas api/guest prepare call --- bin/reddwarf-guestagent | 6 +++++- reddwarf/guestagent/api.py | 7 ++----- reddwarf/guestagent/dbaas.py | 6 +----- reddwarf/instance/models.py | 10 ++++++---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/bin/reddwarf-guestagent b/bin/reddwarf-guestagent index fd0054c3d8..2e8bff293b 100755 --- a/bin/reddwarf-guestagent +++ b/bin/reddwarf-guestagent @@ -57,9 +57,13 @@ if __name__ == '__main__': conf_loc = '%s/%s' % (config.Config.get('here'), 'conf.d/guest_info') config.Config.append_to_config_values('reddwarf-guestagent', {'config_file': conf_loc}, None) + # Now do the same for the /etc/guest_info file + # that is injected into the VM + config.Config.append_to_config_values('reddwarf-guestagent', + {'config_file': '/etc/guest_info'}, None) db_api.configure_db(conf) server = service.Service.create(binary='reddwarf-guestagent', - host=socket.gethostname()) + host=config.Config.get('guest_id')) service.serve(server) service.wait() except RuntimeError as error: diff --git a/reddwarf/guestagent/api.py b/reddwarf/guestagent/api.py index c322c9d8bc..eb72f169a6 100644 --- a/reddwarf/guestagent/api.py +++ b/reddwarf/guestagent/api.py @@ -39,9 +39,7 @@ class API(object): def _get_routing_key(self, context, id): """Create the routing key based on the container id""" - # TODO(hub-cap): make this work in a real environment with - # more than one guest - return "guestagent.ubuntu" + return "guestagent.%s" % id def create_user(self, context, id, users): """Make an asynchronous call to create a new database user""" @@ -125,8 +123,7 @@ class API(object): rpc.cast_with_consumer(context, self._get_routing_key(context, id), {"method": "prepare", "args": {"databases": databases, - "memory_mb": memory_mb, - "uuid": id} + "memory_mb": memory_mb} }) def restart(self, context, id): diff --git a/reddwarf/guestagent/dbaas.py b/reddwarf/guestagent/dbaas.py index 5c6167ad36..18bb741caa 100644 --- a/reddwarf/guestagent/dbaas.py +++ b/reddwarf/guestagent/dbaas.py @@ -256,7 +256,7 @@ class DBaaSAgent(object): LOG.debug("result = " + str(result)) return result.rowcount != 0 - def prepare(self, databases, memory_mb, uuid): + def prepare(self, databases, memory_mb): """Makes ready DBAAS on a Guest container.""" global PREPARING PREPARING = True @@ -267,10 +267,6 @@ class DBaaSAgent(object): preparer.prepare() self.create_database(databases) PREPARING = False - # Writing the UUID to the guest agent guest_info file - conf_loc = '%s/%s' % (config.Config.get('here'), 'conf.d/guest_info') - config.Config.write_config_values('reddwarf-guestagent', - {'config_file': conf_loc}, None, guest_id=uuid) def update_status(self): """Update the status of the MySQL service""" diff --git a/reddwarf/instance/models.py b/reddwarf/instance/models.py index 8f084a19a0..e543201822 100644 --- a/reddwarf/instance/models.py +++ b/reddwarf/instance/models.py @@ -118,13 +118,15 @@ class Instance(object): @classmethod def create(cls, context, name, flavor_ref, image_id): - client = create_nova_client(context) - server = client.servers.create(name, image_id, flavor_ref) - LOG.debug("Created new compute instance %s." % server.id) db_info = DBInstance.create(name=name, - compute_instance_id=server.id, task_status=InstanceTasks.BUILDING) LOG.debug("Created new Reddwarf instance %s..." % db_info.id) + client = create_nova_client(context) + server = client.servers.create(name, image_id, flavor_ref, + files={"/etc/guest_info":"guest_id=%s" % db_info.id}) + LOG.debug("Created new compute instance %s." % server.id) + db_info.compute_instance_id = server.id + db_info.save() service_status = InstanceServiceStatus.create(instance_id=db_info.id, status=ServiceStatuses.NEW) # Now wait for the response from the create to do additional work