Volume-related Utilities and helpers.
Encode pool into host info.
Check cinder db for already managed volume.
Parameters: | vol_id – volume id parameter |
---|---|
Returns: | bool – return True, if db entry with specified volume id exists, otherwise return False |
Unprovision old volumes to prevent data leaking between users.
Convert config file replication string to a dict.
The only supported form is as follows: “{‘key-1’=’val-1’ ‘key-2’=’val-2’...}”
Parameters: | config_string – Properly formatted string to convert to dict. |
---|---|
Response: | dict of string values |
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.
Extract Host, Backend or Pool information from host string.
Parameters: |
|
---|---|
Returns: | expected level of information |
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’
Return a snapshot’s ID from its name on the backend.
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!)
Paginate a list of entries.
Parameters: | entries – list of dictionaries |
---|---|
Marker: | The last element previously returned |
Limit: | The maximum number of items to return |
Offset: | The number of items to skip from the marker or from the first element. |
Sort_keys: | A list of keys in the dictionaries to sort by |
Sort_dirs: | A list of sort directions, where each is either ‘asc’ or ‘dec’ |
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.