glance.cmd package

Submodules

glance.cmd.api module

Glance API Server

glance.cmd.api.fail(e)[source]
glance.cmd.api.main()[source]

glance.cmd.cache_cleaner module

Glance Image Cache Invalid Cache Entry and Stalled Image cleaner

This is meant to be run as a periodic task from cron.

If something goes wrong while we’re caching an image (for example the fetch times out, or an exception is raised), we create an ‘invalid’ entry. These entires are left around for debugging purposes. However, after some period of time, we want to clean these up.

Also, if an incomplete image hangs around past the image_cache_stall_time period, we automatically sweep it up.

glance.cmd.cache_cleaner.main()[source]

glance.cmd.cache_manage module

A simple cache management utility for Glance.

glance.cmd.cache_manage.catch_error(action)[source]

Decorator to provide sensible default error handling for actions.

glance.cmd.cache_manage.create_options(parser)[source]

Set up the CLI and config-file options that may be parsed and program commands.

Parameters:parser – The option parser
glance.cmd.cache_manage.delete_all_cached_images(*args, **kwargs)[source]

%(prog)s delete-all-cached-images [options]

Remove all images from the cache.

glance.cmd.cache_manage.delete_all_queued_images(*args, **kwargs)[source]

%(prog)s delete-all-queued-images [options]

Remove all images from the cache queue.

glance.cmd.cache_manage.delete_cached_image(*args, **kwargs)[source]

%(prog)s delete-cached-image <IMAGE_ID> [options]

Deletes an image from the cache

glance.cmd.cache_manage.delete_queued_image(*args, **kwargs)[source]

%(prog)s delete-queued-image <IMAGE_ID> [options]

Deletes an image from the cache

glance.cmd.cache_manage.env(*vars, **kwargs)[source]

Search for the first defined of possibly many env vars.

Returns the first environment variable defined in vars, or returns the default defined in kwargs.

glance.cmd.cache_manage.get_client(options)[source]

Return a new client object to a Glance server.

specified by the –host and –port options supplied to the CLI

glance.cmd.cache_manage.list_cached(*args, **kwargs)[source]

%(prog)s list-cached [options]

List all images currently cached.

glance.cmd.cache_manage.list_queued(*args, **kwargs)[source]

%(prog)s list-queued [options]

List all images currently queued for caching.

glance.cmd.cache_manage.lookup_command(parser, command_name)[source]
glance.cmd.cache_manage.main()[source]
glance.cmd.cache_manage.parse_options(parser, cli_args)[source]

Returns the parsed CLI options, command to run and its arguments, merged with any same-named options found in a configuration file

Parameters:parser – The option parser
glance.cmd.cache_manage.print_help(options, args)[source]

Print help specific to a command

glance.cmd.cache_manage.queue_image(*args, **kwargs)[source]

%(prog)s queue-image <IMAGE_ID> [options]

Queues an image for caching

glance.cmd.cache_manage.user_confirm(prompt, default=False)[source]

Yes/No question dialog with user.

Parameters:
  • prompt – question/statement to present to user (string)
  • default – boolean value to return if empty string is received as response to prompt

glance.cmd.cache_prefetcher module

Glance Image Cache Pre-fetcher

This is meant to be run from the command line after queueing images to be pretched.

glance.cmd.cache_prefetcher.main()[source]

glance.cmd.cache_pruner module

Glance Image Cache Pruner

This is meant to be run as a periodic task, perhaps every half-hour.

glance.cmd.cache_pruner.main()[source]

glance.cmd.control module

Helper script for starting/stopping/reloading Glance server programs. Thanks for some of the code, Swifties ;)

glance.cmd.control.add_command_parsers(subparsers)[source]
glance.cmd.control.do_check_status(pid_file, server)[source]
glance.cmd.control.do_reload(pid_file, server)[source]
glance.cmd.control.do_start(verb, pid_file, server, args)[source]
glance.cmd.control.do_stop(server, args, graceful=False)[source]
glance.cmd.control.gated_by(predicate)[source]
glance.cmd.control.get_pid_file(server, pid_file)[source]
glance.cmd.control.main()[source]
glance.cmd.control.pid_files(server, pid_file)[source]

glance.cmd.glare module

Glare (Glance Artifact Repository) API service

glance.cmd.glare.fail(e)[source]
glance.cmd.glare.main()[source]

glance.cmd.manage module

Glance Management Utility

class glance.cmd.manage.DbCommands[source]

Bases: object

Class for managing the db

downgrade(version=None)[source]

Downgrade the database’s migration level

export_metadefs(path=None)[source]

Export metadefinitions data from database to files

load_metadefs(path=None, merge=False, prefer_new=False, overwrite=False)[source]

Load metadefinition json files to database

purge(age_in_days=30, max_rows=100)[source]

Purge deleted rows older than a given age from glance tables.

sync(version=None, current_version=None)[source]

Place a database under migration control and upgrade/downgrade it, creating first if necessary.

unload_metadefs()[source]

Unload metadefinitions from database

upgrade(version=None)[source]

Upgrade the database’s migration level

version()[source]

Print database’s current migration level

version_control(version=None)[source]

Place a database under migration control

class glance.cmd.manage.DbLegacyCommands(command_object)[source]

Bases: object

Class for managing the db using legacy commands

downgrade(version=None)[source]
export_metadefs(path=None)[source]
load_metadefs(path=None, merge=False, prefer_new=False, overwrite=False)[source]
sync(version=None, current_version=None)[source]
unload_metadefs()[source]
upgrade(version=None)[source]
version()[source]
version_control(version=None)[source]
glance.cmd.manage.add_command_parsers(subparsers)[source]
glance.cmd.manage.add_legacy_command_parsers(command_object, subparsers)[source]
glance.cmd.manage.args(*args, **kwargs)[source]
glance.cmd.manage.main()[source]
glance.cmd.manage.methods_of(obj)[source]

Get all callable methods of an object that don’t start with underscore

returns a list of tuples of the form (method_name, method)

glance.cmd.registry module

Reference implementation server for Glance Registry

glance.cmd.registry.main()[source]

glance.cmd.replicator module

class glance.cmd.replicator.ImageService(conn, auth_token)[source]

Bases: object

add_image(image_meta, image_data)[source]

Upload an image.

image_meta: image metadata as a dictionary image_data: image data as a object with a read() method

Returns: a tuple of (http response headers, http response body)

add_image_meta(image_meta)[source]

Update image metadata.

image_meta: image metadata as a dictionary

Returns: a tuple of (http response headers, http response body)

get_image(image_uuid)[source]

Fetch image data from glance.

image_uuid: the id of an image

Returns: a http_client Response object where the body is the image.

get_image_meta(image_uuid)[source]

Return the metadata for a single image.

image_uuid: the id of an image

Returns: image metadata as a dictionary

get_images()[source]

Return a detailed list of images.

Yields a series of images as dicts containing metadata.

glance.cmd.replicator.get_image_service()[source]

Get a copy of the image service.

This is done like this to make it easier to mock out ImageService.

glance.cmd.replicator.lookup_command(command_name)[source]

Lookup a command.

command_name: the command name

Returns: a method which implements that command

glance.cmd.replicator.main()[source]

The main function.

glance.cmd.replicator.print_help(options, args)[source]

Print help specific to a command.

options: the parsed command line options args: the command line

glance.cmd.replicator.replication_compare(options, args)[source]

%(prog)s compare <fromserver:port> <toserver:port>

Compare the contents of fromserver with those of toserver.

fromserver:port: the location of the master glance instance. toserver:port: the location of the slave glance instance.

glance.cmd.replicator.replication_dump(options, args)[source]

%(prog)s dump <server:port> <path>

Dump the contents of a glance instance to local disk.

server:port: the location of the glance instance. path: a directory on disk to contain the data.

glance.cmd.replicator.replication_livecopy(options, args)[source]

%(prog)s livecopy <fromserver:port> <toserver:port>

Load the contents of one glance instance into another.

fromserver:port: the location of the master glance instance. toserver:port: the location of the slave glance instance.

glance.cmd.replicator.replication_load(options, args)[source]

%(prog)s load <server:port> <path>

Load the contents of a local directory into glance.

server:port: the location of the glance instance. path: a directory on disk containing the data.

glance.cmd.replicator.replication_size(options, args)[source]

%(prog)s size <server:port>

Determine the size of a glance instance if dumped to disk.

server:port: the location of the glance instance.

glance.cmd.scrubber module

Glance Scrub Service

glance.cmd.scrubber.main()[source]

Module contents

glance.cmd.fix_greendns_ipv6()[source]