summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoren Hansen <soren.hansen@rackspace.com>2010-10-12 22:18:29 +0200
committerSoren Hansen <soren.hansen@rackspace.com>2010-10-12 22:18:29 +0200
commit84ec303828095fc105b287b2858021604cfcea32 (patch)
tree42cdf8d374ca917854fd279c3f74ab55a91c6e08
parente0dff8694ed11f03760bf4dc251fccc422035acf (diff)
parent4f529fe118283164ccb2756f2001805c69c1cc4a (diff)
Merge trunk (that's 10 times now, count 'em\!)
-rw-r--r--nova/compute/manager.py2
-rw-r--r--nova/db/sqlalchemy/models.py6
-rw-r--r--nova/tests/virt_unittest.py2
-rw-r--r--nova/utils.py4
4 files changed, 6 insertions, 8 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index d9e19ec9e..ef7e9da6f 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -72,7 +72,7 @@ class ComputeManager(manager.Manager):
def run_instance(self, context, instance_id, **_kwargs):
"""Launch a new instance with specified options."""
instance_ref = self.db.instance_get(context, instance_id)
- if instance_ref['internal_id'] in self.driver.list_instances():
+ if instance_ref['name'] in self.driver.list_instances():
raise exception.Error("Instance has already been created")
logging.debug("instance %s: starting...", instance_id)
project_id = instance_ref['project_id']
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 85b7c0aae..7dfc39f6f 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -25,7 +25,7 @@ import datetime
# TODO(vish): clean up these imports
from sqlalchemy.orm import relationship, backref, exc, object_mapper
-from sqlalchemy import Column, Integer, String
+from sqlalchemy import Column, PickleType, Integer, String
from sqlalchemy import ForeignKey, DateTime, Boolean, Text
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.declarative import declarative_base
@@ -152,7 +152,7 @@ class Instance(BASE, NovaBase):
__tablename__ = 'instances'
__prefix__ = 'i'
id = Column(Integer, primary_key=True)
- internal_id = Column(Integer, unique=True)
+ internal_id = Column(PickleType(mutable=False), unique=True)
admin_pass = Column(String(255))
@@ -169,7 +169,7 @@ class Instance(BASE, NovaBase):
@property
def name(self):
- return self.internal_id
+ return "instance-%d" % self.internal_id
image_id = Column(String(255))
kernel_id = Column(String(255))
diff --git a/nova/tests/virt_unittest.py b/nova/tests/virt_unittest.py
index db1541852..684347473 100644
--- a/nova/tests/virt_unittest.py
+++ b/nova/tests/virt_unittest.py
@@ -40,7 +40,7 @@ class LibvirtConnTestCase(test.TrialTestCase):
def test_get_uri_and_template(self):
ip = '10.11.12.13'
- instance = { 'internal_id' : '1',
+ instance = { 'internal_id' : 1,
'memory_kb' : '1024000',
'basepath' : '/some/path',
'bridge_name' : 'br100',
diff --git a/nova/utils.py b/nova/utils.py
index b1699bda8..12afd388f 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -128,9 +128,7 @@ def runthis(prompt, cmd, check_exit_code = True):
def generate_uid(topic, size=8):
if topic == "i":
# Instances have integer internal ids.
- #TODO(gundlach): We should make this more than 32 bits, but we need to
- #figure out how to make the DB happy with 64 bit integers.
- return random.randint(0, 2**32-1)
+ return random.randint(0, 2**64-1)
else:
characters = '01234567890abcdefghijklmnopqrstuvwxyz'
choices = [random.choice(characters) for x in xrange(size)]