summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Lucio <rlucio@internap.com>2010-12-03 13:50:30 -0800
committerRyan Lucio <rlucio@internap.com>2010-12-03 13:50:30 -0800
commit4f2a8c5398d4d4848f441e366e8bcc5e97a0b34f (patch)
tree498dc9e29789cc3d09eb0660f8c3f4633cbb08bf
parent108bab90cb70798151b8e6a09d2176a3eb120380 (diff)
Decreased the maximum value for instance-id generation from uint32 to int32 to avoid truncation when being entered into the instance table. Reverted fix to make internal_id column a uint
-rw-r--r--nova/db/sqlalchemy/api.py2
-rw-r--r--nova/db/sqlalchemy/models.py3
-rw-r--r--nova/image/local.py2
3 files changed, 3 insertions, 4 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index dd9649054..2dc140274 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -543,7 +543,7 @@ def instance_create(context, values):
with session.begin():
while instance_ref.internal_id == None:
# Instances have integer internal ids.
- internal_id = random.randint(0, 2 ** 32 - 1)
+ internal_id = random.randint(0, 2 ** 31 - 1)
if not instance_internal_id_exists(context, internal_id,
session=session):
instance_ref.internal_id = internal_id
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index 18ba80caf..fe0a9a921 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -27,7 +27,6 @@ from sqlalchemy import ForeignKey, DateTime, Boolean, Text
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.schema import ForeignKeyConstraint
-from sqlalchemy.databases import mysql
from nova.db.sqlalchemy.session import get_session
@@ -156,7 +155,7 @@ class Instance(BASE, NovaBase):
"""Represents a guest vm."""
__tablename__ = 'instances'
id = Column(Integer, primary_key=True)
- internal_id = Column(mysql.MSInteger(unsigned=True), unique=True)
+ internal_id = Column(Integer, unique=True)
admin_pass = Column(String(255))
diff --git a/nova/image/local.py b/nova/image/local.py
index 9b0cdcc50..b44593221 100644
--- a/nova/image/local.py
+++ b/nova/image/local.py
@@ -59,7 +59,7 @@ class LocalImageService(service.BaseImageService):
"""
Store the image data and return the new image id.
"""
- id = random.randint(0, 2 ** 32 - 1)
+ id = random.randint(0, 2 ** 31 - 1)
data['id'] = id
self.update(context, id, data)
return id