glance.common.scripts.utils module¶
- class glance.common.scripts.utils.SafeRedirectHandler[source]¶
Bases:
HTTPRedirectHandlerHTTP redirect handler that validates redirect destinations.
- redirect_request(req, fp, code, msg, headers, newurl)[source]¶
Return a Request or None in response to a redirect.
This is called by the http_error_30x methods when a redirection response is received. If a redirection should take place, return a new Request to allow http_error_30x to perform the redirect. Otherwise, raise HTTPError if no-one else should try to handle this url. Return None if you can’t but another Handler might.
- glance.common.scripts.utils.get_image_data_iter(uri)[source]¶
Returns iterable object either for local file or uri
- Parameters:
uri – uri (remote or local) to the datasource we want to iterate
Remote HTTP(S) URIs are validated and resolved at fetch time. The connection is pinned to the validated destination address to close the DNS rebinding window between API validation and worker download.
- glance.common.scripts.utils.get_task(task_repo, task_id)[source]¶
Gets a TaskProxy object.
- Parameters:
task_repo – TaskRepo object used to perform DB operations
task_id – ID of the Task
- glance.common.scripts.utils.open_external_uri(uri_or_request)[source]¶
Open an external URL string or Request with validation and IP pinning.
The destination is re-checked at fetch time and the TCP connection is pinned to the validated address so DNS cannot rebind mid-download. Suitable for import downloads and other outbound HTTP(S) fetches that need the same host filtering protections.
- glance.common.scripts.utils.set_base_image_properties(properties=None)[source]¶
Sets optional base properties for creating Image.
- Parameters:
properties – Input dict to set some base properties
- glance.common.scripts.utils.unpack_task_input(task)[source]¶
Verifies and returns valid task input dictionary.
- Parameters:
task – Task domain object