hpOneView.resources package¶
Subpackages¶
- hpOneView.resources.activity package
- hpOneView.resources.data_services package
- hpOneView.resources.facilities package
- hpOneView.resources.fc_sans package
- hpOneView.resources.networking package
- Submodules
- hpOneView.resources.networking.connection_templates module
- hpOneView.resources.networking.ethernet_networks module
- hpOneView.resources.networking.fabrics module
- hpOneView.resources.networking.fc_networks module
- hpOneView.resources.networking.fcoe_networks module
- hpOneView.resources.networking.interconnect_link_topologies module
- hpOneView.resources.networking.interconnect_types module
- hpOneView.resources.networking.interconnects module
- hpOneView.resources.networking.internal_link_sets module
- hpOneView.resources.networking.logical_downlinks module
- hpOneView.resources.networking.logical_interconnect_groups module
- hpOneView.resources.networking.logical_interconnects module
- hpOneView.resources.networking.logical_switch_groups module
- hpOneView.resources.networking.logical_switches module
- hpOneView.resources.networking.network_sets module
- hpOneView.resources.networking.sas_interconnect_types module
- hpOneView.resources.networking.sas_interconnects module
- hpOneView.resources.networking.sas_logical_interconnect_groups module
- hpOneView.resources.networking.sas_logical_interconnects module
- hpOneView.resources.networking.switch_types module
- hpOneView.resources.networking.switches module
- hpOneView.resources.networking.uplink_sets module
- Module contents
- hpOneView.resources.search package
- hpOneView.resources.security package
- hpOneView.resources.servers package
- Submodules
- hpOneView.resources.servers.connections module
- hpOneView.resources.servers.enclosure_groups module
- hpOneView.resources.servers.enclosures module
- hpOneView.resources.servers.id_pools module
- hpOneView.resources.servers.id_pools_ipv4_ranges module
- hpOneView.resources.servers.id_pools_ipv4_subnets module
- hpOneView.resources.servers.id_pools_ranges module
- hpOneView.resources.servers.logical_enclosures module
- hpOneView.resources.servers.migratable_vc_domains module
- hpOneView.resources.servers.server_hardware module
- hpOneView.resources.servers.server_hardware_types module
- hpOneView.resources.servers.server_profile_templates module
- hpOneView.resources.servers.server_profiles module
- Module contents
- hpOneView.resources.settings package
- Submodules
- hpOneView.resources.settings.appliance_device_read_community module
- hpOneView.resources.settings.appliance_device_snmp_v1_trap_destinations module
- hpOneView.resources.settings.appliance_device_snmp_v3_trap_destinations module
- hpOneView.resources.settings.appliance_device_snmp_v3_users module
- hpOneView.resources.settings.appliance_node_information module
- hpOneView.resources.settings.appliance_time_and_locale_configuration module
- hpOneView.resources.settings.backups module
- hpOneView.resources.settings.firmware_bundles module
- hpOneView.resources.settings.firmware_drivers module
- hpOneView.resources.settings.licenses module
- hpOneView.resources.settings.restores module
- hpOneView.resources.settings.scopes module
- hpOneView.resources.settings.versions module
- Module contents
- hpOneView.resources.storage package
- Submodules
- hpOneView.resources.storage.drive_enclosures module
- hpOneView.resources.storage.sas_logical_jbod_attachments module
- hpOneView.resources.storage.sas_logical_jbods module
- hpOneView.resources.storage.storage_pools module
- hpOneView.resources.storage.storage_systems module
- hpOneView.resources.storage.storage_volume_attachments module
- hpOneView.resources.storage.storage_volume_templates module
- hpOneView.resources.storage.volumes module
- Module contents
- hpOneView.resources.uncategorized package
Submodules¶
hpOneView.resources.resource module¶
-
class
hpOneView.resources.resource.
EnsureResourceClient
(method=None, update_data=False)[source]¶ Bases:
object
Decorator class to update the resource data.
-
class
hpOneView.resources.resource.
Resource
(connection, data=None)[source]¶ Bases:
object
Base class for OneView resources.
Parameters: - connection – OneView connection object
- data – Resource data
-
DEFAULT_VALUES
= {}¶
-
UNIQUE_IDENTIFIERS
= [u'uri', u'name']¶
-
URI
= u'/rest'¶
-
create
(data=None, uri=None, timeout=-1, custom_headers=None, force=False)[source]¶ Makes a POST request to create a resource when a request body is required.
Parameters: - data – Additional fields can be passed to create the resource.
- uri – Resouce uri
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows set specific HTTP headers.
Returns: Created resource.
-
delete
= <functools.partial object>¶
-
ensure_resource_data
(update_data=False)[source]¶ Retrieves data from OneView and updates resource object.
Parameters: update_data – Flag to update resource data when it is required.
-
get_all
(start=0, count=-1, filter=u'', sort=u'')[source]¶ Gets all items according with the given arguments.
Parameters: - start – The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item.
- count – The number of resources to return. A count of -1 requests all items (default).
- filter (list or str) – A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned.
- sort – The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first.
Returns: A list of items matching the specified filter.
Return type: list
-
get_by
(field, value)[source]¶ Get the resource by passing a field and its value.
Note
This function uses get_all passing a filter.The search is case-insensitive.
Parameters: - field – Field name to filter.
- value – Value to filter.
Returns: dict
-
get_by_name
(name)[source]¶ Retrieves a resource by its name.
Parameters: name – Resource name. Returns: Resource object or None if resource does not exist.
-
get_by_uri
(uri)[source]¶ Retrieves a resource by its URI
Parameters: uri – URI of the resource Returns: Resource object
-
refresh
= <functools.partial object>¶
-
class
hpOneView.resources.resource.
ResourceClient
(con, uri)[source]¶ Bases:
object
This class implements common functions for HpOneView API rest
-
build_query_uri
(start=0, count=-1, filter=u'', query=u'', sort=u'', view=u'', fields=u'', uri=None, scope_uris=u'')[source]¶ Builds the URI given the parameters.
More than one request can be send to get the items, regardless the query parameter ‘count’, because the actual number of items in the response might differ from the requested count. Some types of resource have a limited number of items returned on each call. For those resources, additional calls are made to the API to retrieve any other items matching the given filter. The actual number of items can also differ from the requested call if the requested number of items would take too long.
The use of optional parameters for OneView 2.0 is described at: http://h17007.www1.hpe.com/docs/enterprise/servers/oneview2.0/cic-api/en/api-docs/current/index.html
Note
Single quote - “’” - inside a query parameter is not supported by OneView API.
Parameters: - start – The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item.
- count – The number of resources to return. A count of -1 requests all items (default).
- filter (list or str) – A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned.
- query – A single query parameter can do what would take multiple parameters or multiple GET requests using filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0.
- sort – The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first.
- view – Returns a specific subset of the attributes of the resource or collection by specifying the name of a predefined view. The default view is expand (show all attributes of the resource and all elements of the collections or resources).
- fields – Name of the fields.
- uri – A specific URI (optional)
- scope_uris – An expression to restrict the resources returned according to the scopes to which they are assigned.
Returns: The complete uri
Return type: uri
-
build_subresource_uri
(resource_id_or_uri=None, subresource_id_or_uri=None, subresource_path=u'')[source]¶
-
create
(resource, uri=None, timeout=-1, custom_headers=None, default_values={})[source]¶ Makes a POST request to create a resource when a request body is required.
Parameters: - resource – OneView resource dictionary.
- uri – Can be either the resource ID or the resource URI.
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows set specific HTTP headers.
- default_values –
Dictionary with default values grouped by OneView API version. This dictionary will be be merged with the resource dictionary only if the dictionary does not contain the keys. This argument is optional and the default value is an empty dictionary. Ex.:
- default_values = {
- ‘200’: {“type”: “logical-switch-group”}, ‘300’: {“type”: “logical-switch-groupV300”}
}
Returns: Created resource.
-
create_report
(uri, timeout=-1)[source]¶ Creates a report and returns the output.
Parameters: - uri – URI
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
Returns: Return type: list
-
create_with_zero_body
(uri=None, timeout=-1, custom_headers=None)[source]¶ Makes a POST request to create a resource when no request body is required.
Parameters: - uri – Can be either the resource ID or the resource URI.
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows set specific HTTP headers.
Returns: Created resource.
-
delete_all
(filter, force=False, timeout=-1)[source]¶ Deletes all resources from the appliance that match the provided filter.
Parameters: - filter – A general filter/query string to narrow the list of items deleted.
- force – If set to true, the operation completes despite any problems with network connectivity or errors on the resource itself. The default is false.
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
Returns: Indicates if the resources were successfully deleted.
Return type: bool
-
download
(uri, file_path)[source]¶ Downloads the contents of the requested URI to a stream.
Parameters: - uri – URI
- file_path – File path destination
Returns: Indicates if the file was successfully downloaded.
Return type: bool
-
get
(id_or_uri)[source]¶ Parameters: id_or_uri – Can be either the resource ID or the resource URI. Returns: The requested resource.
-
get_all
(start=0, count=-1, filter=u'', query=u'', sort=u'', view=u'', fields=u'', uri=None, scope_uris=u'')[source]¶ Gets all items according with the given arguments.
Parameters: - start – The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item.
- count – The number of resources to return. A count of -1 requests all items (default).
- filter (list or str) – A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned.
- query – A single query parameter can do what would take multiple parameters or multiple GET requests using filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0.
- sort – The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first.
- view – Returns a specific subset of the attributes of the resource or collection by specifying the name of a predefined view. The default view is expand (show all attributes of the resource and all elements of the collections or resources).
- fields – Name of the fields.
- uri – A specific URI (optional)
- scope_uris – An expression to restrict the resources returned according to the scopes to which they are assigned.
Returns: A list of items matching the specified filter.
Return type: list
-
get_by
(field, value, uri=None)[source]¶ This function uses get_all passing a filter.
The search is case-insensitive.
Parameters: - field – Field name to filter.
- value – Value to filter.
- uri – Resource uri.
Returns: dict
-
get_by_name
(name)[source]¶ Retrieve a resource by its name.
Parameters: name – Resource name. Returns: dict
-
get_collection
(id_or_uri, filter=u'')[source]¶ Retrieves a collection of resources.
Use this function when the ‘start’ and ‘count’ parameters are not allowed in the GET call. Otherwise, use get_all instead.
Optional filtering criteria may be specified.
Parameters: - id_or_uri – Can be either the resource ID or the resource URI.
- filter (list or str) – General filter/query string.
Returns: Collection of the requested resource.
-
get_utilization
(id_or_uri, fields=None, filter=None, refresh=False, view=None)[source]¶ Retrieves historical utilization data for the specified resource, metrics, and time span.
Parameters: - id_or_uri – Resource identification
- fields – Name of the supported metric(s) to be retrieved in the format METRIC[,METRIC]… If unspecified, all metrics supported are returned.
- filter (list or str) –
Filters should be in the format FILTER_NAME=VALUE[,FILTER_NAME=VALUE]… E.g.: ‘startDate=2016-05-30T11:20:44.541Z,endDate=2016-05-30T19:20:44.541Z’
- startDate
- Start date of requested starting time range in ISO 8601 format. If omitted, the startDate is determined by the endDate minus 24 hours.
- endDate
- End date of requested starting time range in ISO 8601 format. When omitted, the endDate includes the latest data sample available.
If an excessive number of samples would otherwise be returned, the results will be segmented. The caller is responsible for comparing the returned sliceStartTime with the requested startTime in the response. If the sliceStartTime is greater than the oldestSampleTime and the requested start time, the caller is responsible for repeating the request with endTime set to sliceStartTime to obtain the next segment. This process is repeated until the full data set is retrieved.
If the resource has no data, the UtilizationData is still returned but will contain no samples and sliceStartTime/sliceEndTime will be equal. oldestSampleTime/newestSampleTime will still be set appropriately (null if no data is available). If the filter does not happen to overlap the data that a resource has, then the metric history service will return null sample values for any missing samples.
- refresh – Specifies that if necessary, an additional request will be queued to obtain the most recent utilization data from the iLO. The response will not include any refreshed data. To track the availability of the newly collected data, monitor the TaskResource identified by the refreshTaskUri property in the response. If null, no refresh was queued.
- view –
Specifies the resolution interval length of the samples to be retrieved. This is reflected in the resolution in the returned response. Utilization data is automatically purged to stay within storage space constraints. Supported views are listed below:
- native
- Resolution of the samples returned will be one sample for each 5-minute time period. This is the default view and matches the resolution of the data returned by the iLO. Samples at this resolution are retained up to one year.
- hour
- Resolution of the samples returned will be one sample for each 60-minute time period. Samples are calculated by averaging the available 5-minute data samples that occurred within the hour, except for PeakPower which is calculated by reporting the peak observed 5-minute sample value data during the hour. Samples at this resolution are retained up to three years.
- day
- Resolution of the samples returned will be one sample for each 24-hour time period. One day is a 24-hour period that starts at midnight GMT regardless of the time zone in which the appliance or client is located. Samples are calculated by averaging the available 5-minute data samples that occurred during the day, except for PeakPower which is calculated by reporting the peak observed 5-minute sample value data during the day. Samples at this resolution are retained up to three years.
Returns: dict
-
patch
(id_or_uri, operation, path, value, timeout=-1, custom_headers=None)[source]¶ Uses the PATCH to update a resource.
Only one operation can be performed in each PATCH call.
Parameters: - id_or_uri – Can be either the resource ID or the resource URI.
- operation – Patch operation
- path – Path
- value – Value
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
Returns: Updated resource.
-
patch_request
(id_or_uri, body, timeout=-1, custom_headers=None)[source]¶ Uses the PATCH to update a resource.
Only one operation can be performed in each PATCH call.
Parameters: - id_or_uri – Can be either the resource ID or the resource URI.
- body – Patch request body
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
Returns: Updated resource.
-
update
(resource, uri=None, force=False, timeout=-1, custom_headers=None, default_values={})[source]¶ Makes a PUT request to update a resource when a request body is required.
Parameters: - resource – OneView resource dictionary.
- uri – Can be either the resource ID or the resource URI.
- force – If set to true, the operation completes despite any problems with network connectivity or errors on the resource itself. The default is false.
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows set specific HTTP headers.
- default_values –
Dictionary with default values grouped by OneView API version. This dictionary will be be merged with the resource dictionary only if the dictionary does not contain the keys. This argument is optional and the default value is an empty dictionary. Ex.:
- default_values = {
- ‘200’: {“type”: “logical-switch-group”}, ‘300’: {“type”: “logical-switch-groupV300”}
}
Returns: Updated resource.
-
update_with_zero_body
(uri, timeout=-1, custom_headers=None)[source]¶ Makes a PUT request to update a resource when no request body is required.
Parameters: - uri – Can be either the resource ID or the resource URI.
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows set specific HTTP headers.
Returns: Updated resource.
-
upload
(file_path, uri=None, timeout=-1)[source]¶ Makes a multipart request.
Parameters: - file_path – File to upload.
- uri – A specific URI (optional).
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
Returns: Response body.
Return type: dict
-
-
class
hpOneView.resources.resource.
ResourceFileHandlerMixin
[source]¶ Bases:
object
-
download
(uri, file_path)[source]¶ Downloads the contents of the requested URI to a stream.
Parameters: - uri – URI
- file_path – File path destination
Returns: Indicates if the file was successfully downloaded.
Return type: bool
-
upload
(file_path, uri=None, timeout=-1)[source]¶ Makes a multipart request.
Parameters: - file_path – File to upload.
- uri – A specific URI (optional).
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
Returns: Response body.
Return type: dict
-
-
class
hpOneView.resources.resource.
ResourceHelper
(base_uri, connection, task_monitor)[source]¶ Bases:
object
-
add_new_fields
(data_to_add)[source]¶ Update resource data with new fields.
Parameters: - data – resource data
- data_to_update – dict of data to update resource data
- Returnes:
- Returnes dict
-
build_query_uri
(uri=None, start=0, count=-1, filter=u'', query=u'', sort=u'', view=u'', fields=u'', scope_uris=u'')[source]¶ Builds the URI from given parameters.
More than one request can be send to get the items, regardless the query parameter ‘count’, because the actual number of items in the response might differ from the requested count. Some types of resource have a limited number of items returned on each call. For those resources, additional calls are made to the API to retrieve any other items matching the given filter. The actual number of items can also differ from the requested call if the requested number of items would take too long.
The use of optional parameters for OneView 2.0 is described at: http://h17007.www1.hpe.com/docs/enterprise/servers/oneview2.0/cic-api/en/api-docs/current/index.html
Note
Single quote - “’” - inside a query parameter is not supported by OneView API.
Parameters: - start – The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item.
- count – The number of resources to return. A count of -1 requests all items (default).
- filter (list or str) – A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned.
- query – A single query parameter can do what would take multiple parameters or multiple GET requests using filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0.
- sort – The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first.
- view – Returns a specific subset of the attributes of the resource or collection by specifying the name of a predefined view. The default view is expand (show all attributes of the resource and all elements of the collections or resources).
- fields – Name of the fields.
- uri – A specific URI (optional)
- scope_uris – An expression to restrict the resources returned according to the scopes to which they are assigned.
Returns: The complete uri
Return type: uri
-
build_subresource_uri
(resource_id_or_uri=None, subresource_id_or_uri=None, subresource_path=u'')[source]¶ Helps to build a URI with resource path and its sub resource path.
Parameters: - resoure_id_or_uri – ID/URI of the main resource.
- subresource_id__or_uri – ID/URI of the sub resource.
- subresource_path – Sub resource path to be added with the URI.
Returns: Returns URI
-
build_uri
(id_or_uri)[source]¶ Helps to build the URI from resource id and validate the URI.
Parameters: id_or_uri – ID/URI of the resource. Returns: Returns a valid resource URI
-
create
(data=None, uri=None, timeout=-1, custom_headers=None, force=False)[source]¶ Makes a POST request to create a resource when a request body is required.
Parameters: - data – Additional fields can be passed to create the resource.
- uri – Resouce uri
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows set specific HTTP headers.
Returns: Created resource.
-
create_report
(uri, timeout=-1)[source]¶ Creates a report and returns the output.
Parameters: - uri – URI
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
Returns: Return type: list
-
delete
(uri, force=False, timeout=-1, custom_headers=None)[source]¶ Deletes current resource.
Parameters: - force – Flag to delete the resource forcefully, default is False.
- timeout – Timeout in seconds.
- custom_headers – Allows to set custom http headers.
-
delete_all
(filter, force=False, timeout=-1)[source]¶ Deletes all resources from the appliance that match the provided filter.
Parameters: - filter – A general filter/query string to narrow the list of items deleted.
- force – If set to true, the operation completes despite any problems with network connectivity or errors on the resource itself. The default is false.
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
Returns: Indicates if the resources were successfully deleted.
Return type: bool
-
do_get
(uri)[source]¶ Helps to make get requests
Parameters: uri – URI of the resource Returns: Returns the resource data Return type: Returns
-
do_post
(uri, resource, timeout, custom_headers)[source]¶ Helps to make post requests.
Parameters: - uri – URI of the resource.
- resource – Resource data to post.
- timeout – Time out for the request in seconds.
- cutom_headers – Allows to add custom http headers.
Returns: Retunrs Task object.
-
do_put
(uri, resource, timeout, custom_headers)[source]¶ Helps to make put requests.
Parameters: - uri – URI of the resource
- timeout – Time out for the request in seconds.
- custom_headers – Allows to set custom http headers.
- Retuns:
- Returns Task object
-
do_requests_to_getall
(uri, requested_count)[source]¶ Helps to make http request for get_all method.
Note
This method will be checking for the pagination URI in the response and make request to pagination URI to get all the resources.
-
get_all
(start=0, count=-1, filter=u'', query=u'', sort=u'', view=u'', fields=u'', uri=None, scope_uris=u'')[source]¶ Gets all items according with the given arguments.
Parameters: - start – The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the first available item.
- count – The number of resources to return. A count of -1 requests all items (default).
- filter (list or str) – A general filter/query string to narrow the list of items returned. The default is no filter; all resources are returned.
- query – A single query parameter can do what would take multiple parameters or multiple GET requests using filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0.
- sort – The sort order of the returned data set. By default, the sort order is based on create time with the oldest entry first.
- view – Returns a specific subset of the attributes of the resource or collection by specifying the name of a predefined view. The default view is expand (show all attributes of the resource and all elements of the collections or resources).
- fields – Name of the fields.
- uri – A specific URI (optional)
- scope_uris – An expression to restrict the resources returned according to the scopes to which they are assigned.
Returns: A list of items matching the specified filter.
Return type: list
-
get_collection
(uri=None, filter=u'', path=u'')[source]¶ Retrieves a collection of resources.
Use this function when the ‘start’ and ‘count’ parameters are not allowed in the GET call. Otherwise, use get_all instead.
Optional filtering criteria may be specified.
Parameters: - filter (list or str) – General filter/query string.
- path (str) – path to be added with base URI
Returns: Collection of the requested resource.
-
update
(resource, uri=None, force=False, timeout=-1, custom_headers=None)[source]¶ Makes a PUT request to update a resource when a request body is required.
Parameters: - resource – Data to update the resource.
- uri – Resource uri
- force – If set to true, the operation completes despite any problems with network connectivity or errors on the resource itself. The default is false.
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows to add custom HTTP headers.
Returns: A dict with the updated resource data.
-
-
class
hpOneView.resources.resource.
ResourcePatchMixin
[source]¶ Bases:
object
-
patch
= <functools.partial object>¶
-
patch_request
(uri, body, custom_headers=None, timeout=-1)[source]¶ Uses the PATCH to update a resource.
Only one operation can be performed in each PATCH call.
Parameters: - body (list) – Patch request body
- timeout (int) – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers (dict) – Allows to add custom http headers.
Returns: Updated resource.
-
-
class
hpOneView.resources.resource.
ResourceUtilizationMixin
[source]¶ Bases:
object
-
get_utilization
(fields=None, filter=None, refresh=False, view=None)[source]¶ Retrieves historical utilization data for the specified resource, metrics, and time span.
Parameters: - fields – Name of the supported metric(s) to be retrieved in the format METRIC[,METRIC]… If unspecified, all metrics supported are returned.
- filter (list or str) –
Filters should be in the format FILTER_NAME=VALUE[,FILTER_NAME=VALUE]… E.g.: ‘startDate=2016-05-30T11:20:44.541Z,endDate=2016-05-30T19:20:44.541Z’
- startDate
- Start date of requested starting time range in ISO 8601 format. If omitted, the startDate is determined by the endDate minus 24 hours.
- endDate
- End date of requested starting time range in ISO 8601 format. When omitted, the endDate includes the latest data sample available.
If an excessive number of samples would otherwise be returned, the results will be segmented. The caller is responsible for comparing the returned sliceStartTime with the requested startTime in the response. If the sliceStartTime is greater than the oldestSampleTime and the requested start time, the caller is responsible for repeating the request with endTime set to sliceStartTime to obtain the next segment. This process is repeated until the full data set is retrieved.
If the resource has no data, the UtilizationData is still returned but will contain no samples and sliceStartTime/sliceEndTime will be equal. oldestSampleTime/newestSampleTime will still be set appropriately (null if no data is available). If the filter does not happen to overlap the data that a resource has, then the metric history service will return null sample values for any missing samples.
- refresh – Specifies that if necessary, an additional request will be queued to obtain the most recent utilization data from the iLO. The response will not include any refreshed data. To track the availability of the newly collected data, monitor the TaskResource identified by the refreshTaskUri property in the response. If null, no refresh was queued.
- view –
Specifies the resolution interval length of the samples to be retrieved. This is reflected in the resolution in the returned response. Utilization data is automatically purged to stay within storage space constraints. Supported views are listed below:
- native
- Resolution of the samples returned will be one sample for each 5-minute time period. This is the default view and matches the resolution of the data returned by the iLO. Samples at this resolution are retained up to one year.
- hour
- Resolution of the samples returned will be one sample for each 60-minute time period. Samples are calculated by averaging the available 5-minute data samples that occurred within the hour, except for PeakPower which is calculated by reporting the peak observed 5-minute sample value data during the hour. Samples at this resolution are retained up to three years.
- day
- Resolution of the samples returned will be one sample for each 24-hour time period. One day is a 24-hour period that starts at midnight GMT regardless of the time zone in which the appliance or client is located. Samples are calculated by averaging the available 5-minute data samples that occurred during the day, except for PeakPower which is calculated by reporting the peak observed 5-minute sample value data during the day. Samples at this resolution are retained up to three years.
Returns: dict
-
-
class
hpOneView.resources.resource.
ResourceZeroBodyMixin
[source]¶ Bases:
object
-
create_with_zero_body
(uri=None, timeout=-1, custom_headers=None)[source]¶ Makes a POST request to create a resource when no request body is required.
Parameters: - timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows set specific HTTP headers.
Returns: Created resource.
-
update_with_zero_body
(uri=None, timeout=-1, custom_headers=None)[source]¶ Makes a PUT request to update a resource when no request body is required.
Parameters: - uri – Allows to use a different URI other than resource URI
- timeout – Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in OneView; it just stops waiting for its completion.
- custom_headers – Allows to set custom HTTP headers.
Returns: A dict with updated resource data.
-
-
hpOneView.resources.resource.
ensure_resource_client
¶
-
hpOneView.resources.resource.
extract_id_from_uri
(id_or_uri)[source]¶ Extract ID from the end of the URI
Parameters: id_or_uri – ID or URI of the OneView resources. Returns: The string founded after the last “/” Return type: str
-
hpOneView.resources.resource.
merge_default_values
(resource_list, default_values)[source]¶ Generate a new list where each item of original resource_list will be merged with the default_values.
Parameters: - resource_list – list with items to be merged
- default_values – properties to be merged with each item list. If the item already contains some property the original value will be maintained.
Returns: list containing each item merged with default_values
Return type: list
-
hpOneView.resources.resource.
merge_resources
(resource1, resource2)[source]¶ Updates a copy of resource1 with resource2 values and returns the merged dictionary.
Parameters: - resource1 – original resource
- resource2 – resource to update resource1
Returns: merged resource
Return type: dict
-
hpOneView.resources.resource.
transform_list_to_dict
(list)[source]¶ - Transforms a list into a dictionary, putting values as keys
Parameters: id – Returns: dictionary built Return type: dict
Raise an exception if method is not available for the resource.
hpOneView.resources.task_monitor module¶
-
class
hpOneView.resources.task_monitor.
TaskMonitor
(con)[source]¶ Bases:
object
-
CONNECTION_FAILURE_ERROR_NUMBERS
= [8, 22, 101, 110, 104, 103, 101, 100, 111]¶
-
CONNECTION_FAILURE_TIMEOUT
= 90¶
-
get
(task)[source]¶ Retrieve a task by its uri.
Parameters: task – task dict, must have ‘uri’ key. Returns: task dict
-
get_associated_resource
(task)[source]¶ Retrieve a resource associated with a task.
Parameters: task – task dict Returns: task (updated), the entity found (dict) Return type: tuple
-
get_completed_task
(task, timeout=-1)[source]¶ Waits until the task is completed and returns the task resource.
Parameters: - task – TaskResource
- timeout – Timeout in seconds
Returns: TaskResource
Return type: dict
-
is_task_running
(task, connection_failure_control=None)[source]¶ Check if a task is running according to: TASK_PENDING_STATES [‘New’, ‘Starting’, ‘Pending’, ‘Running’, ‘Suspended’, ‘Stopping’]
Parameters: - task (dict) – OneView Task resource.
- connection_failure_control (dict) – A dictionary instance that contains last_success for error tolerance control.
Examples
>>> connection_failure_control = dict(last_success=int(time.time())) >>> while self.is_task_running(task, connection_failure_control): >>> pass
Returns: True when in TASK_PENDING_STATES; False when not.
-