glare package

Subpackages

Submodules

glare.engine module

class glare.engine.Engine[source]

Bases: object

Engine is responsible for executing different helper operations when processing incoming requests from Glare API.

Engine receives incoming data and does the following:
  • check basic policy permissions;
  • requests artifact definition from artifact type registry;
  • check access permission(ro, rw);
  • lock artifact for update if needed;
  • pass data to base artifact type to execute all business logic operations with database;
  • check quotas during upload;
  • call operations pre- and post- hooks;
  • notify other users about finished operation.

Engine should not include any business logic and validation related to artifacts types. Engine should not know any internal details of artifact type, because this part of the work is done by Base artifact type.

add_blob_location(context, type_name, artifact_id, field_name, location, blob_meta, blob_key=None)[source]

Add external/internal location to blob.

Parameters:
  • context – user context
  • type_name – name of artifact type
  • artifact_id – id of the artifact to be updated
  • field_name – name of blob or blob dict field
  • location – blob url
  • blob_meta – dictionary containing blob metadata like md5 checksum
  • blob_key – if field_name is blob dict it specifies key in this dict
Returns:

dict representation of updated artifact

create(context, type_name, values)[source]

Create artifact record in Glare.

Parameters:
  • context – user context
  • type_name – artifact type name
  • values – dict with artifact fields
Returns:

dict representation of created artifact

delete(context, type_name, artifact_id)[source]

Delete artifact from Glare.

Parameters:
  • context – User context
  • type_name – Artifact type name
  • artifact_id – id of artifact to delete
delete_external_blob(context, type_name, artifact_id, field_name, blob_key=None)[source]

Delete artifact blob with external location.

Parameters:
  • context – user context
  • type_name – name of artifact type
  • artifact_id – id of artifact with the blob to delete
  • field_name – name of blob or blob dict field
  • blob_key – if field_name is blob dict it specifies key in this dictionary
download_blob(context, type_name, artifact_id, field_name, blob_key=None)[source]

Download binary data from Glare Artifact.

Parameters:
  • context – user context
  • type_name – name of artifact type
  • artifact_id – id of the artifact to be updated
  • field_name – name of blob or blob dict field
  • blob_key – if field_name is blob dict it specifies key in this dict
Returns:

file iterator for requested file

static list(context, type_name, filters, marker=None, limit=None, sort=None, latest=False)[source]

Return list of artifacts requested by user.

Parameters:
  • context – user context
  • type_name – Artifact type name
  • filters – filters that need to be applied to artifact
  • marker – the artifact that considered as begin of the list so all artifacts before marker (including marker itself) will not be added to artifact list
  • limit – maximum number of items in list
  • sort – sorting options
  • latest – flag that indicates, that only artifacts with highest versions should be returned in output
Returns:

list of artifact definitions

list_all_quotas(context)[source]

Get detailed info about all available quotas.

Parameters:context – user request context
Returns:dict with definitions of redefined quotas for all projects and global defaults
list_project_quotas(context, project_id=None)[source]

Get detailed info about project quotas.

Parameters:
  • context – user request context
  • project_id – id of the project for which to show quotas
Returns:

definition of requested quotas for the project

lock_engine = <glare.locking.LockEngine object>
save(context, type_name, artifact_id, patch)[source]

Update artifact with json patch.

Apply patch to artifact and validate artifact before updating it in database. If there is request for visibility or status change then call specific method for that.

Parameters:
  • context – user context
  • type_name – name of artifact type
  • artifact_id – id of the artifact to be updated
  • patch – json patch object
Returns:

dict representation of updated artifact

static set_quotas(context, values)[source]

Set quota records in Glare.

Parameters:
  • context – user request context
  • values – dict with quota values to set
show(context, type_name, artifact_id)[source]

Show detailed artifact info.

Parameters:
  • context – user context
  • type_name – Artifact type name
  • artifact_id – id of artifact to show
Returns:

definition of requested artifact

show_type_schemas(context, type_name=None)[source]
upload_blob(context, type_name, artifact_id, field_name, fd, content_type, content_length=None, blob_key=None)[source]

Upload Artifact blob.

Parameters:
  • context – user context
  • type_name – name of artifact type
  • artifact_id – id of the artifact to be updated
  • field_name – name of blob or blob dict field
  • fd – file descriptor that Glare uses to upload the file
  • content_type – data content-type
  • content_length – amount of data user wants to upload
  • blob_key – if field_name is blob dict it specifies key in this dictionary
Returns:

dict representation of updated artifact

glare.i18n module

glare.locking module

class glare.locking.Lock(context, lock_id, lock_key, release_method)[source]

Bases: object

Object that stores lock context for users. This class is internal and used only in lock engine, so users shouldn’t use this class directly.

class glare.locking.LockApiBase[source]

Bases: object

Lock Api Base class that responsible for acquiring/releasing locks.

create_lock(context, lock_key)[source]

Acquire lock for current user.

Parameters:
  • context – user context
  • lock_key – unique lock identifier that defines lock scope
Returns:

lock internal identifier

delete_lock(context, lock_id)[source]

Delete acquired user lock.

Parameters:
  • context – user context
  • lock_id – lock internal identifier
class glare.locking.LockEngine(lock_api)[source]

Bases: object

Glare lock engine.

Defines how artifact updates must be synchronized with each other. When some user obtains a lock for the same artifact then other user cannot request that lock and gets a Conflict error.

MAX_LOCK_LENGTH = 255
acquire(context, lock_key)[source]

Acquire lock for artifact.

If there is some other lock with the same key then raise Conflict Error.

Parameters:
  • context – user context
  • lock_key – lock key
Returns:

lock definition

release(lock)[source]

Release lock for artifact.

Parameters:lock – Lock object

glare.notification module

class glare.notification.Notifier[source]

Bases: object

Simple interface to receive Glare notifier.

GLARE_NOTIFIER = None
SERVICE_NAME = 'artifact'
classmethod notify(context, event_type, body, level='INFO')[source]

Notify Glare listeners with some useful info.

Parameters:
  • context – User request context
  • event_type – type of event
  • body – notification payload
  • level – notification level (“INFO”, “WARN”, “ERROR”, etc)
glare.notification.get_transport()[source]
glare.notification.set_defaults(control_exchange='glare')[source]

glare.opts module

glare.opts.list_artifacts_opts()[source]

Return a list of oslo_config options available in Glare

glare.quota module

glare.quota.list_quotas(project_id=None)[source]
glare.quota.set_quotas(values)[source]
glare.quota.verify_artifact_count(context, type_name)[source]

Verify if user can upload data based on his quota limits.

Parameters:
  • context – user context
  • type_name – name of artifact type
glare.quota.verify_uploaded_data_amount(context, type_name, data_amount=None)[source]

Verify if user can upload data based on his quota limits.

Parameters:
  • context – user context
  • type_name – name of artifact type
  • data_amount – number of bytes user wants to upload. Value None means that user hasn’t specified data amount. In this case don’t raise an exception, but just return the amount of data he is able to upload.
Returns:

number of bytes user can upload if data_amount isn’t specified

glare.scrubber module

class glare.scrubber.Daemon(wakeup_time=300, threads=100)[source]

Bases: object

start(application)[source]
wait()[source]
class glare.scrubber.Scrubber[source]

Bases: object

run(event=None)[source]

glare.version module

glare.wsgi module

Module contents