The cinder.volume.drivers.coprhd.helpers.commoncoprhdapi
Module¶
Contains some commonly used utility methods.
-
class
CoprHDResource
(ipaddr, port)¶ Bases:
object
-
exception
CoprHdError
(err_code, msg)¶ Bases:
cinder.exception.VolumeBackendAPIException
Custom exception class used to report logical errors.
- Attributes:
- err_code - String error code msg - String text
-
CMD_LINE_ERR
= 2¶
-
ENTRY_ALREADY_EXISTS_ERR
= 5¶
-
HTTP_ERR
= 3¶
-
MAX_COUNT_REACHED
= 6¶
-
NOT_FOUND_ERR
= 1¶
-
SOS_FAILURE_ERR
= 1¶
-
TIME_OUT
= 7¶
-
VALUE_ERR
= 4¶
-
block_until_complete
(component_type, resource_uri, task_id, ipaddr, port, synctimeout=0)¶
-
format_err_msg_and_raise
(operation_type, component, error_message, error_code)¶ Method to format error message.
Parameters: - operation_type – create, update, add, etc
- component – storagesystem, vpool, etc
- error_code – Error code from the API call
- error_message – Detailed error message
-
format_json_object
(obj)¶ Formats JSON object to make it readable by proper indentation.
Parameters: obj – JSON object Returns: a string of formatted JSON object
-
get_list
(json_object, parent_node_name, child_node_name=None)¶ Returns a list of values from child_node_name.
If child_node is not given, then it will retrieve list from parent node
-
get_node_value
(json_object, parent_node_name, child_node_name=None)¶ Returns value of given child_node.
If child_node is not given, then value of parent node is returned returns None: If json_object or parent_node is not given,
If child_node is not found under parent_node
-
get_parent_child_from_xpath
(name)¶ Returns the parent and child elements from XPath.
-
get_task_by_resourceuri_and_taskId
(component_type, resource_uri, task_id, ipaddr, port)¶ Returns the single task details.
-
is_uri
(name)¶ Checks whether the name is a URI or not.
Parameters: name – Name of the resource Returns: True if name is URI, False otherwise
-
json_decode
(rsp)¶ Used to decode the JSON encoded response.
-
search_by_tag
(resource_search_uri, ipaddr, port)¶ Fetches the list of resources with a given tag.
Parameters: - resource_search_uri – The tag based search uri Example: ‘/block/volumes/search?tag=tagexample1’
- ipaddr – IP address of CoprHD host
- port – Port number
-
service_json_request
(ip_addr, port, http_method, uri, body, contenttype='application/json', customheaders=None)¶ Used to make an HTTP request and get the response.
The message body is encoded in JSON format
Parameters: - ip_addr – IP address or host name of the server
- port – port number of the server on which it is listening to HTTP requests
- http_method – one of GET, POST, PUT, DELETE
- uri – the request URI
- body – the request payload
Returns: a tuple of two elements: (response body, response headers)
Raises: CoprHdError in case of HTTP errors with err_code 3
-
show_task_opid
(taskid, ipaddr, port)¶
-
to_bytes
(in_str)¶ Converts a size to bytes.
Parameters: in_str – a number suffixed with a unit: {number}{unit} units supported: K, KB, k or kb - kilobytes M, MB, m or mb - megabytes G, GB, g or gb - gigabytes T, TB, t or tb - terabytes Returns: number of bytes None; if input is incorrect