summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-09-28 12:29:43 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-09-28 12:29:43 -0700
commitbb1540d7bf2c323d43110738e43e9b99ef49b62c (patch)
tree5588175281a26e774fc580f97f047599455c1373 /nova/db
parentf3698b8da4bd63abfade32c9894ac2095672344e (diff)
parent669cf475d11700064aa16f959077d0512e6b1531 (diff)
downloadnova-bb1540d7bf2c323d43110738e43e9b99ef49b62c.tar.gz
nova-bb1540d7bf2c323d43110738e43e9b99ef49b62c.tar.xz
nova-bb1540d7bf2c323d43110738e43e9b99ef49b62c.zip
merged floating-ips
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py38
-rw-r--r--nova/db/sqlalchemy/api.py27
-rw-r--r--nova/db/sqlalchemy/models.py16
3 files changed, 80 insertions, 1 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index a7dd52473..e9ca3df97 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -458,6 +458,44 @@ def export_device_create(context, values):
###################
+def auth_destroy_token(context, token):
+ """Destroy an auth token"""
+ return IMPL.auth_destroy_token(context, token)
+
+def auth_get_token(context, token_hash):
+ """Retrieves a token given the hash representing it"""
+ return IMPL.auth_get_token(context, token_hash)
+
+def auth_create_token(context, token):
+ """Creates a new token"""
+ return IMPL.auth_create_token(context, token_hash, token)
+
+
+###################
+
+
+def quota_create(context, values):
+ """Create a quota from the values dictionary."""
+ return IMPL.quota_create(context, values)
+
+
+def quota_get(context, project_id):
+ """Retrieve a quota or raise if it does not exist."""
+ return IMPL.quota_get(context, project_id)
+
+
+def quota_update(context, project_id, values):
+ """Update a quota from the values dictionary."""
+ return IMPL.quota_update(context, project_id, values)
+
+
+def quota_destroy(context, project_id):
+ """Destroy the quota or raise if it does not exist."""
+ return IMPL.quota_destroy(context, project_id)
+
+
+###################
+
def quota_create(context, values):
"""Create a quota from the values dictionary."""
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index daa9e991e..ef1741dba 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -19,6 +19,8 @@
Implementation of SQLAlchemy backend
"""
+import sys
+
from nova import db
from nova import exception
from nova import flags
@@ -348,6 +350,7 @@ def fixed_ip_disassociate_all_by_timeout(_context, host, time):
'time': time.isoformat()})
return result.rowcount
+
def fixed_ip_get_by_address(_context, address):
session = get_session()
result = session.query(models.FixedIp
@@ -359,6 +362,7 @@ def fixed_ip_get_by_address(_context, address):
raise exception.NotFound("No model for address %s" % address)
return result
+
def fixed_ip_get_instance(_context, address):
session = get_session()
with session.begin():
@@ -713,6 +717,29 @@ def export_device_create(_context, values):
###################
+def auth_destroy_token(_context, token):
+ session = get_session()
+ session.delete(token)
+
+def auth_get_token(_context, token_hash):
+ session = get_session()
+ tk = session.query(models.AuthToken
+ ).filter_by(token_hash=token_hash)
+ if not tk:
+ raise exception.NotFound('Token %s does not exist' % token_hash)
+ return tk
+
+def auth_create_token(_context, token):
+ tk = models.AuthToken()
+ for k,v in token.iteritems():
+ tk[k] = v
+ tk.save()
+ return tk
+
+
+###################
+
+
def quota_create(_context, values):
quota_ref = models.Quota()
for (key, value) in values.iteritems():
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index f62b79af8..f6ba7953f 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -214,6 +214,7 @@ class Instance(BASE, NovaBase):
image_id = Column(String(255))
kernel_id = Column(String(255))
ramdisk_id = Column(String(255))
+
# image_id = Column(Integer, ForeignKey('images.id'), nullable=True)
# kernel_id = Column(Integer, ForeignKey('images.id'), nullable=True)
# ramdisk_id = Column(Integer, ForeignKey('images.id'), nullable=True)
@@ -396,6 +397,18 @@ class NetworkIndex(BASE, NovaBase):
network = relationship(Network, backref=backref('network_index',
uselist=False))
+class AuthToken(BASE, NovaBase):
+ """Represents an authorization token for all API transactions. Fields
+ are a string representing the actual token and a user id for mapping
+ to the actual user"""
+ __tablename__ = 'auth_tokens'
+ token_hash = Column(String(255), primary_key=True)
+ user_id = Column(Integer)
+ server_manageent_url = Column(String(255))
+ storage_url = Column(String(255))
+ cdn_management_url = Column(String(255))
+
+
# TODO(vish): can these both come from the same baseclass?
class FixedIp(BASE, NovaBase):
@@ -463,7 +476,8 @@ def register_models():
"""Register Models and create metadata"""
from sqlalchemy import create_engine
models = (Service, Instance, Volume, ExportDevice,
- FixedIp, FloatingIp, Network, NetworkIndex) # , Image, Host)
+ FixedIp, FloatingIp, Network, NetworkIndex,
+ AuthToken) # , Image, Host)
engine = create_engine(FLAGS.sql_connection, echo=False)
for model in models:
model.metadata.create_all(engine)