glanceclient.common.utils module¶
- class glanceclient.common.utils.GeneratorProxy(wrapped)¶
Bases:
ObjectProxy
- next()¶
- property request_ids¶
- property wrapped¶
- class glanceclient.common.utils.RequestIdProxy(wrapped)¶
Bases:
ObjectProxy
- next()¶
- property request_ids¶
- property 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.has_version(client, version)¶
- 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(choices)¶
- glanceclient.common.utils.print_cached_images(cached_images)¶
- glanceclient.common.utils.print_dict(d, max_column_width=80)¶
- glanceclient.common.utils.print_dict_list(objects, fields)¶
- 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)¶
Prints a list of objects.
@param objs: Objects to print @param fields: Fields on each object to be printed @param formatters: Custom field formatters
- 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.serious_integrity_iter(iter, hasher, hash_value)¶
Check image data integrity using the Glance “multihash”.
- Parameters:
iter – iterable containing the image data
hasher – a hashlib object
hash_value – hexdigest of the image data
- Raises:
IOError if the hashdigest of the data is not hash_value
- glanceclient.common.utils.strip_version(endpoint)¶
Strip version from the last component of endpoint if present.