The glanceclient.common.utils Module

The glanceclient.common.utils Module

class glanceclient.common.utils.GeneratorProxy(wrapped)

Bases: ObjectProxy

next()
request_ids
wrapped
class glanceclient.common.utils.IterableWithLength(iterable, length)

Bases: object

next()
class glanceclient.common.utils.RequestIdProxy(wrapped)

Bases: ObjectProxy

next()
request_ids
wrapped
glanceclient.common.utils.add_req_id_to_generator()
glanceclient.common.utils.add_req_id_to_object()
glanceclient.common.utils.arg(*args, **kwargs)
glanceclient.common.utils.debug_enabled(argv)
glanceclient.common.utils.endpoint_version_from_url(endpoint, default_version=None)
glanceclient.common.utils.env(*vars, **kwargs)

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.

glanceclient.common.utils.exit(msg='', exit_code=1)
glanceclient.common.utils.find_resource(manager, name_or_id)

Helper for the _find_* methods.

glanceclient.common.utils.get_data_file(args)
glanceclient.common.utils.get_file_size(file_obj)

Analyze file-like object and attempt to determine its size.

Parameters:file_obj – file-like object.
Retval:The file’s size or None if it cannot be determined.
glanceclient.common.utils.integrity_iter(iter, checksum)

Check image data integrity.

Raises:IOError
glanceclient.common.utils.make_size_human_readable(size)
glanceclient.common.utils.memoized_property(fn)
glanceclient.common.utils.on_data_require_fields(data_fields, required=('disk_format', 'container_format'))

Decorator to check commands’ validity

This decorator checks that required fields are present when image data has been supplied via command line arguments or via stdin

On error throws CommandError exception with meaningful message.

Parameters:
  • data_fields (iter) – Which fields’ presence imply image data
  • required (iter) – Required fields
Returns:

function decorator

glanceclient.common.utils.pretty_choice_list(l)
glanceclient.common.utils.print_dict(d, max_column_width=80)
glanceclient.common.utils.print_err(msg)
glanceclient.common.utils.print_image(image_obj, human_readable=False, max_col_width=None)
glanceclient.common.utils.print_list(objs, fields, formatters=None, field_settings=None)
glanceclient.common.utils.safe_header(name, value)
glanceclient.common.utils.save_image(data, path)

Save an image to the specified path.

Parameters:
  • data – binary data of the image
  • path – path to save the image to
glanceclient.common.utils.schema_args(schema_getter, omit=None)
glanceclient.common.utils.strip_version(endpoint)

Strip version from the last component of endpoint if present.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.