summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorEric Day <eday@oddments.org>2010-12-09 13:59:50 -0800
committerEric Day <eday@oddments.org>2010-12-09 13:59:50 -0800
commit77d7e022fd5f2c8709a6784cc83429494d126a3b (patch)
tree8324cfdbd4ebcb97a89ed23374fad7ed886680fe /nova/compute
parentc5b1fd0424cec19be44751b6f4f2aeec13752733 (diff)
Converted the instance table to use a uuid instead of a auto_increment ID and a random internal_id. I had to use a String(32) column with hex and not a String(16) with bytes because SQLAlchemy doesn't like non-unicode strings going in for String types. We could try another type, but I didn't want a primary_key on blob types.
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 8e0efa4cc..f310c575f 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -36,9 +36,9 @@ from nova.db import base
FLAGS = flags.FLAGS
-def generate_default_hostname(internal_id):
+def generate_default_hostname(instance_id):
"""Default function to generate a hostname given an instance reference."""
- return str(internal_id)
+ return str(instance_id)
class ComputeAPI(base.Base):
@@ -127,7 +127,6 @@ class ComputeAPI(base.Base):
**base_options)
instance = self.db.instance_create(context, instance)
instance_id = instance['id']
- internal_id = instance['internal_id']
elevated = context.elevated()
if not security_groups:
@@ -138,9 +137,9 @@ class ComputeAPI(base.Base):
security_group_id)
# Set sane defaults if not specified
- updates = dict(hostname=generate_hostname(internal_id))
+ updates = dict(hostname=generate_hostname(instance_id))
if 'display_name' not in instance:
- updates['display_name'] = "Server %s" % internal_id
+ updates['display_name'] = "Server %s" % instance_id
instance = self.update_instance(context, instance_id, **updates)
instances.append(instance)
@@ -199,17 +198,16 @@ class ComputeAPI(base.Base):
return self.db.instance_update(context, instance_id, kwargs)
def delete_instance(self, context, instance_id):
- logging.debug("Going to try and terminate %d" % instance_id)
+ logging.debug("Going to try and terminate %s" % instance_id)
try:
- instance = self.db.instance_get_by_internal_id(context,
- instance_id)
+ instance = self.db.instance_get_by_id(context, instance_id)
except exception.NotFound as e:
- logging.warning("Instance %d was not found during terminate",
+ logging.warning("Instance %s was not found during terminate",
instance_id)
raise e
if (instance['state_description'] == 'terminating'):
- logging.warning("Instance %d is already being terminated",
+ logging.warning("Instance %s is already being terminated",
instance_id)
return
@@ -264,11 +262,11 @@ class ComputeAPI(base.Base):
return self.db.instance_get_all(context)
def get_instance(self, context, instance_id):
- return self.db.instance_get_by_internal_id(context, instance_id)
+ return self.db.instance_get_by_id(context, instance_id)
def reboot(self, context, instance_id):
"""Reboot the given instance."""
- instance = self.db.instance_get_by_internal_id(context, instance_id)
+ instance = self.db.instance_get_by_id(context, instance_id)
host = instance['host']
rpc.cast(context,
self.db.queue_get_for(context, FLAGS.compute_topic, host),
@@ -277,7 +275,7 @@ class ComputeAPI(base.Base):
def rescue(self, context, instance_id):
"""Rescue the given instance."""
- instance = self.db.instance_get_by_internal_id(context, instance_id)
+ instance = self.db.instance_get_by_id(context, instance_id)
host = instance['host']
rpc.cast(context,
self.db.queue_get_for(context, FLAGS.compute_topic, host),
@@ -286,7 +284,7 @@ class ComputeAPI(base.Base):
def unrescue(self, context, instance_id):
"""Unrescue the given instance."""
- instance = self.db.instance_get_by_internal_id(context, instance_id)
+ instance = self.db.instance_get_by_id(context, instance_id)
host = instance['host']
rpc.cast(context,
self.db.queue_get_for(context, FLAGS.compute_topic, host),