glance.db.sqlalchemy package

Subpackages

Submodules

glance.db.sqlalchemy.api module

Defines interface for DB access.

class glance.db.sqlalchemy.api.DeleteFromSelect(table, select, column)[source]

Bases: sqlalchemy.sql.dml.UpdateBase

glance.db.sqlalchemy.api.artifact_create(context, values, type_name, type_version=None, session=None)[source]
glance.db.sqlalchemy.api.artifact_delete(context, artifact_id, type_name, type_version=None, session=None)[source]
glance.db.sqlalchemy.api.artifact_get(context, artifact_id, type_name=None, type_version=None, show_level=1, session=None)[source]
glance.db.sqlalchemy.api.artifact_get_all(context, marker=None, limit=None, sort_keys=None, sort_dirs=None, filters=None, show_level=0, session=None)[source]
glance.db.sqlalchemy.api.artifact_publish(context, artifact_id, type_name, type_version=None, session=None)[source]
glance.db.sqlalchemy.api.artifact_update(context, values, artifact_id, type_name, type_version=None, session=None)[source]
glance.db.sqlalchemy.api.clear_db_env()[source]

Unset global configuration variables for database.

glance.db.sqlalchemy.api.get_engine()[source]
glance.db.sqlalchemy.api.get_session(autocommit=True, expire_on_commit=False)[source]
glance.db.sqlalchemy.api.image_create(context, values)[source]

Create an image from the values dictionary.

glance.db.sqlalchemy.api.image_destroy(*args, **kw)[source]

Destroy the image or raise if it does not exist.

glance.db.sqlalchemy.api.image_get(context, image_id, session=None, force_show_deleted=False)[source]
glance.db.sqlalchemy.api.image_get_all(context, filters=None, marker=None, limit=None, sort_key=None, sort_dir=None, member_status='accepted', is_public=None, admin_as_user=False, return_tag=False)[source]

Get all images that match zero or more filters.

Parameters:
  • filters – dict of filter keys and values. If a ‘properties’ key is present, it is treated as a dict of key/value filters on the image properties attribute
  • marker – image id after which to start page
  • limit – maximum number of images to return
  • sort_key – list of image attributes by which results should be sorted
  • sort_dir – directions in which results should be sorted (asc, desc)
  • member_status – only return shared images that have this membership status
  • is_public – If true, return only public images. If false, return only private and shared images.
  • admin_as_user – For backwards compatibility. If true, then return to an admin the equivalent set of images which it would see if it was a regular user
  • return_tag – To indicates whether image entry in result includes it relevant tag entries. This could improve upper-layer query performance, to prevent using separated calls
glance.db.sqlalchemy.api.image_location_delete(context, image_id, location_id, status, delete_time=None, session=None)[source]
glance.db.sqlalchemy.api.image_member_count(context, image_id)[source]

Return the number of image members for this image

Parameters:image_id – identifier of image entity
glance.db.sqlalchemy.api.image_member_create(context, values, session=None)[source]

Create an ImageMember object.

glance.db.sqlalchemy.api.image_member_delete(context, memb_id, session=None)[source]

Delete an ImageMember object.

glance.db.sqlalchemy.api.image_member_find(context, image_id=None, member=None, status=None, include_deleted=False)[source]

Find all members that meet the given criteria.

Note, currently include_deleted should be true only when create a new image membership, as there may be a deleted image membership between the same image and tenant, the membership will be reused in this case. It should be false in other cases.

Parameters:
  • image_id – identifier of image entity
  • member – tenant to which membership has been granted
Include_deleted:
 

A boolean indicating whether the result should include the deleted record of image member

glance.db.sqlalchemy.api.image_member_update(context, memb_id, values)[source]

Update an ImageMember object.

glance.db.sqlalchemy.api.image_property_create(context, values, session=None)[source]

Create an ImageProperty object.

glance.db.sqlalchemy.api.image_property_delete(context, prop_ref, image_ref, session=None)[source]

Used internally by image_property_create and image_property_update.

glance.db.sqlalchemy.api.image_tag_delete(context, image_id, value, session=None)[source]

Delete an image tag.

glance.db.sqlalchemy.api.image_tag_get_all(context, image_id, session=None)[source]

Get a list of tags for a specific image.

glance.db.sqlalchemy.api.image_tag_set_all(context, image_id, tags)[source]
glance.db.sqlalchemy.api.image_update(context, image_id, values, purge_props=False, from_state=None)[source]

Set the given properties on an image and update it.

Raises:ImageNotFound if image does not exist.
glance.db.sqlalchemy.api.is_image_mutable(context, image)[source]

Return True if the image is mutable in this context.

glance.db.sqlalchemy.api.is_image_visible(context, image, status=None)[source]

Return True if the image is visible in this context.

glance.db.sqlalchemy.api.metadef_namespace_create(context, values, session=None)[source]

Create a namespace or raise if it already exists.

glance.db.sqlalchemy.api.metadef_namespace_delete(context, namespace_name, session=None)[source]

Delete the namespace and all foreign references

glance.db.sqlalchemy.api.metadef_namespace_get(context, namespace_name, session=None)[source]

Get a namespace or raise if it does not exist or is not visible.

glance.db.sqlalchemy.api.metadef_namespace_get_all(context, marker=None, limit=None, sort_key=None, sort_dir=None, filters=None, session=None)[source]

List all available namespaces.

glance.db.sqlalchemy.api.metadef_namespace_update(context, namespace_id, namespace_dict, session=None)[source]

Update a namespace or raise if it does not exist or not visible

glance.db.sqlalchemy.api.metadef_object_count(context, namespace_name, session=None)[source]

Get count of properties for a namespace, raise if ns doesn’t exist.

glance.db.sqlalchemy.api.metadef_object_create(context, namespace_name, object_dict, session=None)[source]

Create a metadata-schema object or raise if it already exists.

glance.db.sqlalchemy.api.metadef_object_delete(context, namespace_name, object_name, session=None)[source]

Delete an object or raise if namespace or object doesn’t exist.

glance.db.sqlalchemy.api.metadef_object_delete_namespace_content(context, namespace_name, session=None)[source]

Delete an object or raise if namespace or object doesn’t exist.

glance.db.sqlalchemy.api.metadef_object_get(context, namespace_name, object_name, session=None)[source]

Get a metadata-schema object or raise if it does not exist.

glance.db.sqlalchemy.api.metadef_object_get_all(context, namespace_name, session=None)[source]

Get a metadata-schema object or raise if it does not exist.

glance.db.sqlalchemy.api.metadef_object_update(context, namespace_name, object_id, object_dict, session=None)[source]

Update an object or raise if it does not exist or not visible.

glance.db.sqlalchemy.api.metadef_property_count(context, namespace_name, session=None)[source]

Get count of properties for a namespace, raise if ns doesn’t exist.

glance.db.sqlalchemy.api.metadef_property_create(context, namespace_name, property_dict, session=None)[source]

Create a metadef property or raise if it already exists.

glance.db.sqlalchemy.api.metadef_property_delete(context, namespace_name, property_name, session=None)[source]

Delete a property or raise if it or namespace doesn’t exist.

glance.db.sqlalchemy.api.metadef_property_delete_namespace_content(context, namespace_name, session=None)[source]

Delete a property or raise if it or namespace doesn’t exist.

glance.db.sqlalchemy.api.metadef_property_get(context, namespace_name, property_name, session=None)[source]

Get a metadef property or raise if it does not exist.

glance.db.sqlalchemy.api.metadef_property_get_all(context, namespace_name, session=None)[source]

Get a metadef property or raise if it does not exist.

glance.db.sqlalchemy.api.metadef_property_update(context, namespace_name, property_id, property_dict, session=None)[source]

Update an object or raise if it does not exist or not visible.

glance.db.sqlalchemy.api.metadef_resource_type_association_create(context, namespace_name, values, session=None)[source]
glance.db.sqlalchemy.api.metadef_resource_type_association_delete(context, namespace_name, resource_type_name, session=None)[source]
glance.db.sqlalchemy.api.metadef_resource_type_association_get(context, namespace_name, resource_type_name, session=None)[source]
glance.db.sqlalchemy.api.metadef_resource_type_association_get_all_by_namespace(context, namespace_name, session=None)[source]
glance.db.sqlalchemy.api.metadef_resource_type_create(context, values, session=None)[source]

Create a resource_type

glance.db.sqlalchemy.api.metadef_resource_type_delete(context, resource_type_name, session=None)[source]

Get a resource_type

glance.db.sqlalchemy.api.metadef_resource_type_get(context, resource_type_name, session=None)[source]

Get a resource_type

glance.db.sqlalchemy.api.metadef_resource_type_get_all(context, session=None)[source]

list all resource_types

glance.db.sqlalchemy.api.metadef_tag_count(context, namespace_name, session=None)[source]

Get count of tags for a namespace, raise if ns doesn’t exist.

glance.db.sqlalchemy.api.metadef_tag_create(context, namespace_name, tag_dict, session=None)[source]

Create a metadata-schema tag or raise if it already exists.

glance.db.sqlalchemy.api.metadef_tag_create_tags(context, namespace_name, tag_list, session=None)[source]

Create a metadata-schema tag or raise if it already exists.

glance.db.sqlalchemy.api.metadef_tag_delete(context, namespace_name, name, session=None)[source]

Delete an tag or raise if namespace or tag doesn’t exist.

glance.db.sqlalchemy.api.metadef_tag_delete_namespace_content(context, namespace_name, session=None)[source]

Delete an tag or raise if namespace or tag doesn’t exist.

glance.db.sqlalchemy.api.metadef_tag_get(context, namespace_name, name, session=None)[source]

Get a metadata-schema tag or raise if it does not exist.

glance.db.sqlalchemy.api.metadef_tag_get_all(context, namespace_name, filters=None, marker=None, limit=None, sort_key=None, sort_dir=None, session=None)[source]

Get metadata-schema tags or raise if none exist.

glance.db.sqlalchemy.api.metadef_tag_update(context, namespace_name, id, tag_dict, session=None)[source]

Update an tag or raise if it does not exist or not visible.

glance.db.sqlalchemy.api.purge_deleted_rows(context, age_in_days, max_rows, session=None)[source]

Purges soft deleted rows

Deletes rows of table images, table tasks and all dependent tables according to given age for relevant models.

glance.db.sqlalchemy.api.task_create(context, values, session=None)[source]

Create a task object

glance.db.sqlalchemy.api.task_delete(context, task_id, session=None)[source]

Delete a task

glance.db.sqlalchemy.api.task_get(context, task_id, session=None, force_show_deleted=False)[source]

Fetch a task entity by id

glance.db.sqlalchemy.api.task_get_all(context, filters=None, marker=None, limit=None, sort_key='created_at', sort_dir='desc', admin_as_user=False)[source]

Get all tasks that match zero or more filters.

Parameters:
  • filters – dict of filter keys and values.
  • marker – task id after which to start page
  • limit – maximum number of tasks to return
  • sort_key – task attribute by which results should be sorted
  • sort_dir – direction in which results should be sorted (asc, desc)
  • admin_as_user – For backwards compatibility. If true, then return to an admin the equivalent set of tasks which it would see if it were a regular user
Returns:

tasks set

glance.db.sqlalchemy.api.task_update(context, task_id, values, session=None)[source]

Update a task object

glance.db.sqlalchemy.api.user_get_storage_usage(context, owner_id, image_id=None, session=None)[source]
glance.db.sqlalchemy.api.visit_delete_from_select(element, compiler, **kw)[source]

glance.db.sqlalchemy.glare module

class glance.db.sqlalchemy.glare.State[source]

Bases: enum.Enum

ACTIVE = <State.ACTIVE: 'active'>
CREATING = <State.CREATING: 'creating'>
DEACTIVATED = <State.DEACTIVATED: 'deactivated'>
DELETED = <State.DELETED: 'deleted'>
class glance.db.sqlalchemy.glare.Visibility[source]

Bases: enum.Enum

PRIVATE = <Visibility.PRIVATE: 'private'>
PUBLIC = <Visibility.PUBLIC: 'public'>
SHARED = <Visibility.SHARED: 'shared'>
glance.db.sqlalchemy.glare.create(context, values, session, type_name, type_version=None)[source]
glance.db.sqlalchemy.glare.delete(context, artifact_id, session, type_name, type_version=None)[source]
glance.db.sqlalchemy.glare.get(context, artifact_id, session, type_name=None, type_version=None, show_level=1)[source]
glance.db.sqlalchemy.glare.get_all(context, session, marker=None, limit=None, sort_keys=None, sort_dirs=None, filters=None, show_level=0)[source]

List all visible artifacts

glance.db.sqlalchemy.glare.publish(context, artifact_id, session, type_name, type_version=None)[source]

Because transitive dependencies are not initially created it has to be done manually by calling this function. It creates transitive dependencies for the given artifact_id and saves them in DB. :returns: artifact dict with Transitive show level

glance.db.sqlalchemy.glare.update(context, values, artifact_id, session, type_name, type_version=None)[source]

glance.db.sqlalchemy.metadata module

glance.db.sqlalchemy.metadata.db_export_metadefs(engine, metadata_path=None)[source]
glance.db.sqlalchemy.metadata.db_load_metadefs(engine, metadata_path=None, merge=False, prefer_new=False, overwrite=False)[source]
glance.db.sqlalchemy.metadata.db_unload_metadefs(engine)[source]
glance.db.sqlalchemy.metadata.get_metadef_namespace_resource_types_table(meta)[source]
glance.db.sqlalchemy.metadata.get_metadef_namespaces_table(meta)[source]
glance.db.sqlalchemy.metadata.get_metadef_objects_table(meta)[source]
glance.db.sqlalchemy.metadata.get_metadef_properties_table(meta)[source]
glance.db.sqlalchemy.metadata.get_metadef_resource_types_table(meta)[source]
glance.db.sqlalchemy.metadata.get_metadef_tags_table(meta)[source]

glance.db.sqlalchemy.models module

SQLAlchemy models for glance data

class glance.db.sqlalchemy.models.GlanceBase[source]

Bases: oslo_db.sqlalchemy.models.ModelBase, oslo_db.sqlalchemy.models.TimestampMixin

Base class for Glance Models.

created_at = Column(None, DateTime(), table=None, nullable=False, default=ColumnDefault(<function <lambda> at 0x7f9ec5ed4b90>))
delete(session=None)[source]

Delete this object.

deleted = Column(None, Boolean(), table=None, nullable=False, default=ColumnDefault(False))
deleted_at = Column(None, DateTime(), table=None)
items()[source]
keys()[source]
save(session=None)[source]
to_dict()[source]
updated_at = Column(None, DateTime(), table=None, onupdate=ColumnDefault(<function <lambda> at 0x7f9ec5ed4d70>), default=ColumnDefault(<function <lambda> at 0x7f9ec5ed4cf8>))
values()[source]
class glance.db.sqlalchemy.models.Image(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models.GlanceBase

Represents an image in the datastore.

checksum
container_format
created_at
deleted
deleted_at
disk_format
id
is_public
min_disk
min_ram
name
owner
protected
size
status
updated_at
virtual_size
class glance.db.sqlalchemy.models.ImageLocation(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models.GlanceBase

Represents an image location in the datastore.

created_at
deleted
deleted_at
id
image
image_id
meta_data
status
updated_at
value
class glance.db.sqlalchemy.models.ImageMember(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models.GlanceBase

Represents an image members in the datastore.

can_share
created_at
deleted
deleted_at
id
image
image_id
member
status
unique_constraint_key_name = 'image_members_image_id_member_deleted_at_key'
updated_at
class glance.db.sqlalchemy.models.ImageProperty(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models.GlanceBase

Represents an image properties in the datastore.

created_at
deleted
deleted_at
id
image
image_id
name
updated_at
value
class glance.db.sqlalchemy.models.ImageTag(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models.GlanceBase

Represents an image tag in the datastore.

created_at
deleted
deleted_at
id
image
image_id
updated_at
value
class glance.db.sqlalchemy.models.JSONEncodedDict(*args, **kwargs)[source]

Bases: sqlalchemy.sql.type_api.TypeDecorator

Represents an immutable structure as a json-encoded string

impl

alias of Text

process_bind_param(value, dialect)[source]
process_result_value(value, dialect)[source]
class glance.db.sqlalchemy.models.Task(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models.GlanceBase

Represents an task in the datastore

created_at
deleted
deleted_at
expires_at
id
owner
status
type
updated_at
class glance.db.sqlalchemy.models.TaskInfo(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, oslo_db.sqlalchemy.models.ModelBase

Represents task info in the datastore

input
message
result
task
task_id
glance.db.sqlalchemy.models.register_models(engine)[source]

Create database tables for all models with the given engine.

glance.db.sqlalchemy.models.unregister_models(engine)[source]

Drop database tables for all models with the given engine.

glance.db.sqlalchemy.models_glare module

class glance.db.sqlalchemy.models_glare.Artifact(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_glare.ArtifactBase

created_at
deleted_at
description
id
name
owner
published_at
state
to_dict(show_level=1, show_text_properties=True)[source]
type_name
type_version
type_version_meta
type_version_prefix
type_version_suffix
updated_at
version
version_meta
version_prefix
version_suffix
visibility
class glance.db.sqlalchemy.models_glare.ArtifactBase[source]

Bases: oslo_db.sqlalchemy.models.ModelBase, oslo_db.sqlalchemy.models.TimestampMixin

Base class for Artifact Models.

created_at = Column(None, DateTime(), table=None, nullable=False, default=ColumnDefault(<function <lambda> at 0x7f9ec5b4aa28>))
items()[source]
keys()[source]
save(session=None)[source]
to_dict()[source]
updated_at = Column(None, DateTime(), table=None, nullable=False, onupdate=ColumnDefault(<function <lambda> at 0x7f9ec5b4ac08>), default=ColumnDefault(<function <lambda> at 0x7f9ec5b4ab90>))
values()[source]
class glance.db.sqlalchemy.models_glare.ArtifactBlob(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_glare.ArtifactBase

artifact
artifact_id
checksum
created_at
id
item_key
name
position
size
updated_at
class glance.db.sqlalchemy.models_glare.ArtifactBlobLocation(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_glare.ArtifactBase

blob
blob_id
created_at
id
position
status
updated_at
value
class glance.db.sqlalchemy.models_glare.ArtifactDependency(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_glare.ArtifactBase

artifact_dest
artifact_origin
artifact_source
created_at
dest
id
is_direct
name
origin
position
source
updated_at
class glance.db.sqlalchemy.models_glare.ArtifactProperty(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_glare.ArtifactBase

artifact
artifact_id
bool_value
created_at
id
int_value
name
numeric_value
position
string_value
text_value
updated_at
class glance.db.sqlalchemy.models_glare.ArtifactTag(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_glare.ArtifactBase

artifact
artifact_id
created_at
id
updated_at
value
glance.db.sqlalchemy.models_glare.register_models(engine)[source]

Create database tables for all models with the given engine.

glance.db.sqlalchemy.models_glare.unregister_models(engine)[source]

Drop database tables for all models with the given engine.

glance.db.sqlalchemy.models_metadef module

SQLAlchemy models for glance metadata schema

class glance.db.sqlalchemy.models_metadef.DictionaryBase[source]

Bases: oslo_db.sqlalchemy.models.ModelBase

metadata = None
to_dict()[source]
class glance.db.sqlalchemy.models_metadef.GlanceMetadefBase[source]

Bases: oslo_db.sqlalchemy.models.TimestampMixin

Base class for Glance Metadef Models.

created_at = Column(None, DateTime(), table=None, nullable=False, default=ColumnDefault(<function <lambda> at 0x7f9ec5ed47d0>))
updated_at = Column(None, DateTime(), table=None, onupdate=ColumnDefault(<function <lambda> at 0x7f9ec5ed45f0>), default=ColumnDefault(<function <lambda> at 0x7f9ec5ed4500>))
class glance.db.sqlalchemy.models_metadef.MetadefNamespace(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_metadef.GlanceMetadefBase

Represents a metadata-schema namespace in the datastore.

created_at
description
display_name
id
namespace
owner
protected
updated_at
visibility
class glance.db.sqlalchemy.models_metadef.MetadefNamespaceResourceType(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_metadef.GlanceMetadefBase

Represents a metadata-schema namespace-property in the datastore.

created_at
namespace_id
prefix
properties_target
resource_type_id
updated_at
class glance.db.sqlalchemy.models_metadef.MetadefObject(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_metadef.GlanceMetadefBase

Represents a metadata-schema object in the datastore.

created_at
description
id
json_schema
name
namespace_id
required
updated_at
class glance.db.sqlalchemy.models_metadef.MetadefProperty(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_metadef.GlanceMetadefBase

Represents a metadata-schema namespace-property in the datastore.

created_at
id
json_schema
name
namespace_id
updated_at
class glance.db.sqlalchemy.models_metadef.MetadefResourceType(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_metadef.GlanceMetadefBase

Represents a metadata-schema resource type in the datastore.

associations
created_at
id
name
protected
updated_at
class glance.db.sqlalchemy.models_metadef.MetadefTag(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, glance.db.sqlalchemy.models_metadef.GlanceMetadefBase

Represents a metadata-schema tag in the data store.

created_at
id
name
namespace_id
updated_at
glance.db.sqlalchemy.models_metadef.register_models(engine)[source]

Create database tables for all models with the given engine.

glance.db.sqlalchemy.models_metadef.unregister_models(engine)[source]

Drop database tables for all models with the given engine.

Module contents