Add db table for Glance Metadata

This commit implements the blueprint
https://blueprints.launchpad.net/cinder/+spec/retain-glance-metadata-for-billing

It creates the new table volume_glance_metadata in the cinder
database, provides the CRUD methods for it, and populates the table
when a volume or snapshot is created from a Glance image.

Patch set 2: remove superflous line

Patch set 3: Fix incorrect column types in sqlalchemy/models.py

Patch set 4: Define exception class GlanceMetadataExists

Change-Id: I8f98f6eaae005a33bfd49cea783774407b7aa120
This commit is contained in:
Ollie Leahy
2012-11-15 11:48:27 +00:00
parent ceee1fdaf2
commit 1a431edff6
7 changed files with 424 additions and 1 deletions

View File

@@ -21,7 +21,7 @@
SQLAlchemy models for cinder data.
"""
from sqlalchemy import Column, Integer, String, schema
from sqlalchemy import Column, Integer, String, Text, schema
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import ForeignKey, DateTime, Boolean
@@ -205,6 +205,16 @@ class VolumeTypeExtraSpecs(BASE, CinderBase):
)
class VolumeGlanceMetadata(BASE, CinderBase):
"""Glance metadata for a bootable volume"""
__tablename__ = 'volume_glance_metadata'
id = Column(Integer, primary_key=True, nullable=False)
volume_id = Column(String(36), ForeignKey('volumes.id'))
snapshot_id = Column(String(36), ForeignKey('snapshots.id'))
key = Column(String(255))
value = Column(Text)
class Quota(BASE, CinderBase):
"""Represents a single quota override for a project.
@@ -378,6 +388,7 @@ def register_models():
VolumeMetadata,
VolumeTypeExtraSpecs,
VolumeTypes,
VolumeGlanceMetadata,
)
engine = create_engine(FLAGS.sql_connection, echo=False)
for model in models: