Volume-related Utilities and helpers.
append_host
(host, pool)¶Encode pool into host info.
check_already_managed_volume
(vol_id)¶Check cinder db for already managed volume.
vol_id – volume id parameter
bool – return True, if db entry with specified volume id exists, otherwise return False
check_encryption_provider
(db, volume, context)¶Check that this is a LUKS encryption provider.
encryption dict
check_for_odirect_support
(src, dest, flag='oflag=direct')¶check_image_metadata
(image_meta, vol_size)¶Validates the image metadata.
clear_volume
(volume_size, volume_path, volume_clear=None, volume_clear_size=None, volume_clear_ionice=None, throttle=None)¶Unprovision old volumes to prevent data leaking between users.
clone_encryption_key
(context, key_manager, encryption_key_id)¶convert_config_string_to_dict
(config_string)¶Convert config file replication string to a dict.
The only supported form is as follows: “{‘key-1’=’val-1’ ‘key-2’=’val-2’…}”
config_string – Properly formatted string to convert to dict.
dict of string values
copy_image_to_volume
(driver, context, volume, image_meta, image_location, image_service)¶Downloads Glance image to the specified volume.
copy_volume
(src, dest, size_in_m, blocksize, sync=False, execute=<function execute>, ionice=None, throttle=None, sparse=False)¶Copy data from the source volume to the destination volume.
The parameters ‘src’ and ‘dest’ are both typically of type str, which represents the path to each volume on the filesystem. Connectors can optionally return a volume handle of type RawIOBase for volumes that are not available on the local filesystem for open/close operations.
If either ‘src’ or ‘dest’ are not of type str, then they are assumed to be of type RawIOBase or any derivative that supports file operations such as read and write. In this case, the handles are treated as file handles instead of file paths and, at present moment, throttling is unavailable.
create_encryption_key
(context, key_manager, volume_type_id)¶delete_encryption_key
(context, key_manager, encryption_key_id)¶enable_bootable_flag
(volume)¶extract_availability_zones_from_volume_type
(volume_type)¶extract_host
(host, level='backend', default_pool_name=False)¶Extract Host, Backend or Pool information from host string.
host – String for host, which could include host@backend#pool info
level – Indicate which level of information should be extracted from host string. Level can be ‘host’, ‘backend’ or ‘pool’, default value is ‘backend’
default_pool_name – this flag specify what to do if level == ‘pool’ and there is no ‘pool’ info encoded in host string. default_pool_name=True will return DEFAULT_POOL_NAME, otherwise we return None. Default value of this parameter is False.
expected information, string or None
exception.InvalidVolume
host = ‘HostA@BackendB#PoolC’ ret = extract_host(host, ‘host’) # ret is ‘HostA’ ret = extract_host(host, ‘backend’) # ret is ‘HostA@BackendB’ ret = extract_host(host, ‘pool’) # ret is ‘PoolC’
host = ‘HostX@BackendY’ ret = extract_host(host, ‘pool’) # ret is None ret = extract_host(host, ‘pool’, True) # ret is ‘_pool0’
extract_id_from_snapshot_name
(snap_name)¶Return a snapshot’s ID from its name on the backend.
extract_id_from_volume_name
(vol_name)¶generate_password
(length=16, symbolgroups=('23456789', 'ABCDEFGHJKLMNPQRSTUVWXYZ', 'abcdefghijkmnopqrstuvwxyz'))¶Generate a random password from the supplied symbol groups.
At least one symbol from each group will be included. Unpredictable results if length is less than the number of symbol groups.
Believed to be reasonably secure (with a reasonable password length!)
generate_username
(length=20, symbolgroups=('23456789', 'ABCDEFGHJKLMNPQRSTUVWXYZ', 'abcdefghijkmnopqrstuvwxyz'))¶get_all_physical_volumes
(vg_name=None)¶get_all_volume_groups
(vg_name=None)¶get_base_image_ref
(volume)¶get_max_over_subscription_ratio
(str_value, supports_auto=False)¶Get the max_over_subscription_ratio from a string
As some drivers need to do some calculations with the value and we are now receiving a string value in the conf, this converts the value to float when appropriate.
str_value – Configuration object
supports_auto – Tell if the calling driver supports auto MOSR.
value of mosr
get_volume_image_metadata
(image_id, image_meta)¶group_get_by_id
(group_id)¶hosts_are_equivalent
(host_1, host_2)¶image_conversion_dir
()¶is_boolean_str
(str)¶is_group_a_cg_snapshot_type
(group_or_snap)¶is_group_a_type
(group, key)¶is_multiattach_spec
(extra_specs)¶is_replicated_spec
(extra_specs)¶make_initiator_target_all2all_map
(initiator_wwpns, target_wwpns)¶Build a simplistic all-to-all mapping.
matching_backend_name
(src_volume_type, volume_type)¶notify_about_backup_usage
(context, backup, event_suffix, extra_usage_info=None, host=None)¶notify_about_capacity_usage
(context, capacity, suffix, extra_usage_info=None, host=None)¶notify_about_cgsnapshot_usage
(context, cgsnapshot, event_suffix, extra_usage_info=None, host=None)¶notify_about_consistencygroup_usage
(context, group, event_suffix, extra_usage_info=None, host=None)¶notify_about_group_snapshot_usage
(context, group_snapshot, event_suffix, extra_usage_info=None, host=None)¶notify_about_group_usage
(context, group, event_suffix, extra_usage_info=None, host=None)¶notify_about_replication_error
(context, volume, suffix, extra_error_info=None, host=None)¶notify_about_replication_usage
(context, volume, suffix, extra_usage_info=None, host=None)¶notify_about_snapshot_usage
(context, snapshot, event_suffix, extra_usage_info=None, host=None)¶notify_about_volume_usage
(context, volume, event_suffix, extra_usage_info=None, host=None)¶null_safe_str
(s)¶paginate_entries_list
(entries, marker, limit, offset, sort_keys, sort_dirs)¶Paginate a list of entries.
entries – list of dictionaries
The last element previously returned
The maximum number of items to return
The number of items to skip from the marker or from the first element.
A list of keys in the dictionaries to sort by
A list of sort directions, where each is either ‘asc’ or ‘dec’
read_proc_mounts
()¶Read the /proc/mounts file.
It’s a dummy function but it eases the writing of unit tests as mocking __builtin__open() for a specific file only is not trivial.
resolve_hostname
(hostname)¶Resolves host name to IP address.
Resolves a host name (my.data.point.com) to an IP address (10.12.143.11). This routine also works if the data passed in hostname is already an IP. In this case, the same IP address will be returned.
hostname – Host name to resolve.
IP Address for Host name.
sanitize_host
(host)¶Ensure IPv6 addresses are enclosed in [] for iSCSI portals.
sanitize_hostname
(hostname)¶Return a hostname which conforms to RFC-952 and RFC-1123 specs.
supports_thin_provisioning
()¶update_backup_error
(backup, err, status='error')¶upload_volume
(context, image_service, image_meta, volume_path, volume, volume_format='raw', run_as_root=True, compress=True)¶Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.