diff options
| author | Soren Hansen <soren.hansen@rackspace.com> | 2010-09-24 10:25:29 +0200 |
|---|---|---|
| committer | Soren Hansen <soren.hansen@rackspace.com> | 2010-09-24 10:25:29 +0200 |
| commit | 3e8c19c42bd56dfc1cb428f3a39d0f102c65a4ac (patch) | |
| tree | 142d3d6cad7d1156db67c8ef3eed8e6a502417c0 /nova/db | |
| parent | fed57c47da49a0457fce8fec3b59c9142e62785e (diff) | |
| parent | cb311a3deb42094261b91467b7717f4eb3e9eaba (diff) | |
| download | nova-3e8c19c42bd56dfc1cb428f3a39d0f102c65a4ac.tar.gz nova-3e8c19c42bd56dfc1cb428f3a39d0f102c65a4ac.tar.xz nova-3e8c19c42bd56dfc1cb428f3a39d0f102c65a4ac.zip | |
Merge trunk
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/api.py | 15 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 23 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/models.py | 17 |
3 files changed, 53 insertions, 2 deletions
diff --git a/nova/db/api.py b/nova/db/api.py index 2393e692a..602c3cf09 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -453,6 +453,21 @@ 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.""" diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index df66560a7..d2847506e 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -693,6 +693,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 69cff5c44..9ce146f1d 100644 --- a/nova/db/sqlalchemy/models.py +++ b/nova/db/sqlalchemy/models.py @@ -218,6 +218,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) @@ -451,6 +452,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): @@ -518,8 +531,8 @@ def register_models(): """Register Models and create metadata""" from sqlalchemy import create_engine models = (Service, Instance, Volume, ExportDevice, FixedIp, FloatingIp, - Network, NetworkIndex, SecurityGroup, SecurityGroupIngressRule) - # , Image, Host + Network, NetworkIndex, SecurityGroup, SecurityGroupIngressRule, + AuthToken) # , Image, Host engine = create_engine(FLAGS.sql_connection, echo=False) for model in models: model.metadata.create_all(engine) |
