Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def get_environmental_configuration(self, id_or_uri): uri = self._client.build_uri(id_or_uri) + "/environmentalConfiguration" return self._client.get(uri)
[ "\n Returns a description of the environmental configuration (supported feature set, calibrated minimum & maximum\n power, location & dimensions, ...) of the resource.\n\n Args:\n id_or_uri:\n Can be either the Unmanaged Device id or the uri\n\n Returns:\n dict:\n EnvironmentalConfiguration\n " ]
Please provide a description of the function:def get_script(self): uri = "{}/script".format(self.data["uri"]) return self._helper.do_get(uri)
[ "\n Gets the configuration script of the logical enclosure by ID or URI.\n\n Return:\n str: Configuration script.\n " ]
Please provide a description of the function:def update_script(self, information, timeout=-1): uri = "{}/script".format(self.data["uri"]) return self._helper.update(information, uri=uri, timeout=timeout)
[ "\n Updates the configuration script of the logical enclosure and on all enclosures in the logical enclosure with\n the specified ID.\n\n Args:\n information: Updated script.\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Return:\n Configuration script.\n " ]
Please provide a description of the function:def generate_support_dump(self, information, timeout=-1): uri = "{}/support-dumps".format(self.data["uri"]) return self._helper.create(information, uri=uri, timeout=timeout)
[ "\n Generates a support dump for the logical enclosure with the specified ID. A logical enclosure support dump\n includes content for logical interconnects associated with that logical enclosure. By default, it also contains\n appliance support dump content.\n\n Args:\n information (dict): Information to generate support dump.\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n dict: Support dump.\n " ]
Please provide a description of the function:def update_from_group(self, data=None, timeout=-1): uri = "{}/updateFromGroup".format(self.data["uri"]) return self._helper.update(data, uri, timeout=timeout)
[ "\n Use this action to make a logical enclosure consistent with the enclosure group when the logical enclosure is\n in the Inconsistent state.\n\n Args:\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n dict: Logical enclosure.\n " ]
Please provide a description of the function:def create_bulk(self, resource, timeout=-1): uri = self.URI + '/bulk' default_values = self._get_default_values(self.BULK_DEFAULT_VALUES) updated_data = self._helper.update_resource_fields(resource, default_values) self._helper.create(updated_data, uri=uri, timeout=timeout) return self.get_range(resource['namePrefix'], resource['vlanIdRange'])
[ "\n Creates bulk Ethernet networks.\n\n Args:\n resource (dict): Specifications to create in bulk.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n list: List of created Ethernet Networks.\n\n " ]
Please provide a description of the function:def get_range(self, name_prefix, vlan_id_range): filter = '"\'name\' matches \'{}\_%\'"'.format(name_prefix) ethernet_networks = self.get_all(filter=filter, sort='vlanId:ascending') vlan_ids = self.dissociate_values_or_ranges(vlan_id_range) for net in ethernet_networks[:]: if int(net['vlanId']) not in vlan_ids: ethernet_networks.remove(net) return ethernet_networks
[ "\n Gets a list of Ethernet Networks that match the 'given name_prefix' and the 'vlan_id_range'.\n\n Examples:\n >>> enet.get_range('Enet_name', '1-2,5')\n # The result contains the ethernet network with names:\n ['Enet_name_1', 'Enet_name_2', 'Enet_name_5']\n\n >>> enet.get_range('Enet_name', '2')\n # The result contains the ethernet network with names:\n ['Enet_name_1', 'Enet_name_2']\n\n Args:\n name_prefix: The Ethernet Network prefix\n vlan_id_range: A combination of values or ranges to be retrieved. For example, '1-10,50,51,500-700'.\n\n Returns:\n list: A list of Ethernet Networks.\n\n " ]
Please provide a description of the function:def dissociate_values_or_ranges(self, vlan_id_range): values_or_ranges = vlan_id_range.split(',') vlan_ids = [] # The expected result is different if the vlan_id_range contains only one value if len(values_or_ranges) == 1 and '-' not in values_or_ranges[0]: vlan_ids = list(range(1, int(values_or_ranges[0]) + 1)) else: for value_or_range in values_or_ranges: value_or_range.strip() if '-' not in value_or_range: vlan_ids.append(int(value_or_range)) else: start, end = value_or_range.split('-') range_ids = range(int(start), int(end) + 1) vlan_ids.extend(range_ids) return vlan_ids
[ "\n Build a list of vlan ids given a combination of ranges and/or values\n\n Examples:\n >>> enet.dissociate_values_or_ranges('1-2,5')\n [1, 2, 5]\n\n >>> enet.dissociate_values_or_ranges('5')\n [1, 2, 3, 4, 5]\n\n >>> enet.dissociate_values_or_ranges('4-5,7-8')\n [4, 5, 7, 8]\n\n Args:\n vlan_id_range: A combination of values or ranges. For example, '1-10,50,51,500-700'.\n\n Returns:\n list: vlan ids\n " ]
Please provide a description of the function:def get_associated_profiles(self): uri = "{}/associatedProfiles".format(self.data['uri']) return self._helper.do_get(uri)
[ "\n Gets the URIs of profiles which are using an Ethernet network.\n\n Args:\n id_or_uri: Can be either the logical interconnect group id or the logical interconnect group uri\n\n Returns:\n list: URIs of the associated profiles.\n\n " ]
Please provide a description of the function:def get_associated_uplink_groups(self): uri = "{}/associatedUplinkGroups".format(self.data['uri']) return self._helper.do_get(uri)
[ "\n Gets the uplink sets which are using an Ethernet network.\n\n Returns:\n list: URIs of the associated uplink sets.\n\n " ]
Please provide a description of the function:def merge_resources(resource1, resource2): merged = resource1.copy() merged.update(resource2) return merged
[ "\n Updates a copy of resource1 with resource2 values and returns the merged dictionary.\n\n Args:\n resource1: original resource\n resource2: resource to update resource1\n\n Returns:\n dict: merged resource\n " ]
Please provide a description of the function:def merge_default_values(resource_list, default_values): def merge_item(resource): return merge_resources(default_values, resource) return lmap(merge_item, resource_list)
[ "\n Generate a new list where each item of original resource_list will be merged with the default_values.\n\n Args:\n resource_list: list with items to be merged\n default_values: properties to be merged with each item list. If the item already contains some property\n the original value will be maintained.\n\n Returns:\n list: list containing each item merged with default_values\n " ]
Please provide a description of the function:def transform_list_to_dict(list): ret = {} for value in list: if isinstance(value, dict): ret.update(value) else: ret[str(value)] = True return ret
[ "\n Transforms a list into a dictionary, putting values as keys\n Args:\n id:\n Returns:\n dict: dictionary built\n " ]
Please provide a description of the function:def ensure_resource_data(self, update_data=False): # Check for unique identifier in the resource data if not any(key in self.data for key in self.UNIQUE_IDENTIFIERS): raise exceptions.HPOneViewMissingUniqueIdentifiers(MISSING_UNIQUE_IDENTIFIERS) # Returns if data update is not required if not update_data: return resource_data = None if 'uri' in self.UNIQUE_IDENTIFIERS and self.data.get('uri'): resource_data = self._helper.do_get(self.data['uri']) else: for identifier in self.UNIQUE_IDENTIFIERS: identifier_value = self.data.get(identifier) if identifier_value: result = self.get_by(identifier, identifier_value) if result and isinstance(result, list): resource_data = result[0] break if resource_data: self.data.update(resource_data) else: raise exceptions.HPOneViewResourceNotFound(RESOURCE_DOES_NOT_EXIST)
[ "Retrieves data from OneView and updates resource object.\n\n Args:\n update_data: Flag to update resource data when it is required.\n " ]
Please provide a description of the function:def create(self, data=None, uri=None, timeout=-1, custom_headers=None, force=False): if not data: data = {} default_values = self._get_default_values() data = self._helper.update_resource_fields(data, default_values) logger.debug('Create (uri = %s, resource = %s)' % (uri, str(data))) resource_data = self._helper.create(data, uri, timeout, custom_headers, force) new_resource = self.new(self._connection, resource_data) return new_resource
[ "Makes a POST request to create a resource when a request body is required.\n\n Args:\n data: Additional fields can be passed to create the resource.\n uri: Resouce uri\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers: Allows set specific HTTP headers.\n Returns:\n Created resource.\n " ]
Please provide a description of the function:def delete(self, timeout=-1, custom_headers=None, force=False): uri = self.data['uri'] logger.debug("Delete resource (uri = %s)" % (str(uri))) return self._helper.delete(uri, timeout=timeout, custom_headers=custom_headers, force=force)
[ "Deletes current resource.\n\n Args:\n timeout: Timeout in seconds.\n custom_headers: Allows to set custom http headers.\n force: Flag to force the operation.\n " ]
Please provide a description of the function:def update(self, data=None, timeout=-1, custom_headers=None, force=False): uri = self.data['uri'] resource = deepcopy(self.data) resource.update(data) logger.debug('Update async (uri = %s, resource = %s)' % (uri, str(resource))) self.data = self._helper.update(resource, uri, force, timeout, custom_headers) return self
[ "Makes a PUT request to update a resource when a request body is required.\n\n Args:\n data: Data to update the resource.\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers: Allows to add custom HTTP headers.\n force: Force the update operation.\n\n Returns:\n A dict with the updated resource data.\n " ]
Please provide a description of the function:def get_by(self, field, value): if not field: logger.exception(RESOURCE_CLIENT_INVALID_FIELD) raise ValueError(RESOURCE_CLIENT_INVALID_FIELD) filter = "\"{0}='{1}'\"".format(field, value) results = self.get_all(filter=filter) # Workaround when the OneView filter does not work, it will filter again if "." not in field: # This filter only work for the first level results = [item for item in results if str(item.get(field, "")).lower() == value.lower()] return results
[ "Get the resource by passing a field and its value.\n\n Note:\n This function uses get_all passing a filter.The search is case-insensitive.\n\n Args:\n field: Field name to filter.\n value: Value to filter.\n\n Returns:\n dict\n " ]
Please provide a description of the function:def get_by_name(self, name): result = self.get_by("name", name) if result: data = result[0] new_resource = self.new(self._connection, data) else: new_resource = None return new_resource
[ "Retrieves a resource by its name.\n\n Args:\n name: Resource name.\n\n Returns:\n Resource object or None if resource does not exist.\n " ]
Please provide a description of the function:def get_by_uri(self, uri): self._helper.validate_resource_uri(uri) data = self._helper.do_get(uri) if data: new_resource = self.new(self._connection, data) else: new_resource = None return new_resource
[ "Retrieves a resource by its URI\n\n Args:\n uri: URI of the resource\n\n Returns:\n Resource object\n " ]
Please provide a description of the function:def _get_default_values(self, default_values=None): if not default_values: default_values = self.DEFAULT_VALUES if default_values: api_version = str(self._connection._apiVersion) values = default_values.get(api_version, {}).copy() else: values = {} return values
[ "Gets the default values set for a resource" ]
Please provide a description of the function:def _merge_default_values(self): values = self._get_default_values() for key, value in values.items(): if not self.data.get(key): self.data[key] = value
[ "Merge default values with resource data." ]
Please provide a description of the function:def get_all(self, start=0, count=-1, filter='', query='', sort='', view='', fields='', uri=None, scope_uris=''): if not uri: uri = self._base_uri uri = self.build_query_uri(uri=uri, start=start, count=count, filter=filter, query=query, sort=sort, view=view, fields=fields, scope_uris=scope_uris) logger.debug('Getting all resources with uri: {0}'.format(uri)) return self.do_requests_to_getall(uri, count)
[ "Gets all items according with the given arguments.\n\n Args:\n start: The first item to return, using 0-based indexing.\n If not specified, the default is 0 - start with the first available item.\n count: The number of resources to return. A count of -1 requests all items (default).\n filter (list or str): A general filter/query string to narrow the list of items returned. The default is no\n filter; all resources are returned.\n query: A single query parameter can do what would take multiple parameters or multiple GET requests using\n filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0.\n sort: The sort order of the returned data set. By default, the sort order is based on create time with the\n oldest entry first.\n view:\n Returns a specific subset of the attributes of the resource or collection by specifying the name of a\n predefined view. The default view is expand (show all attributes of the resource and all elements of\n the collections or resources).\n fields:\n Name of the fields.\n uri:\n A specific URI (optional)\n scope_uris:\n An expression to restrict the resources returned according to the scopes to\n which they are assigned.\n\n Returns:\n list: A list of items matching the specified filter.\n " ]
Please provide a description of the function:def delete_all(self, filter, force=False, timeout=-1): uri = "{}?filter={}&force={}".format(self._base_uri, quote(filter), force) logger.debug("Delete all resources (uri = %s)" % uri) return self.delete(uri)
[ "\n Deletes all resources from the appliance that match the provided filter.\n\n Args:\n filter:\n A general filter/query string to narrow the list of items deleted.\n force:\n If set to true, the operation completes despite any problems with network connectivity or errors\n on the resource itself. The default is false.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n bool: Indicates if the resources were successfully deleted.\n " ]
Please provide a description of the function:def create(self, data=None, uri=None, timeout=-1, custom_headers=None, force=False): if not uri: uri = self._base_uri if force: uri += '?force={}'.format(force) logger.debug('Create (uri = %s, resource = %s)' % (uri, str(data))) return self.do_post(uri, data, timeout, custom_headers)
[ "Makes a POST request to create a resource when a request body is required.\n\n Args:\n data: Additional fields can be passed to create the resource.\n uri: Resouce uri\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers: Allows set specific HTTP headers.\n Returns:\n Created resource.\n " ]
Please provide a description of the function:def delete(self, uri, force=False, timeout=-1, custom_headers=None): if force: uri += '?force=True' logger.debug("Delete resource (uri = %s)" % (str(uri))) task, body = self._connection.delete(uri, custom_headers=custom_headers) if not task: # 204 NO CONTENT # Successful return from a synchronous delete operation. return True task = self._task_monitor.wait_for_task(task, timeout=timeout) return task
[ "Deletes current resource.\n\n Args:\n force: Flag to delete the resource forcefully, default is False.\n timeout: Timeout in seconds.\n custom_headers: Allows to set custom http headers.\n " ]
Please provide a description of the function:def update(self, resource, uri=None, force=False, timeout=-1, custom_headers=None): logger.debug('Update async (uri = %s, resource = %s)' % (uri, str(resource))) if not uri: uri = resource['uri'] if force: uri += '?force=True' return self.do_put(uri, resource, timeout, custom_headers)
[ "Makes a PUT request to update a resource when a request body is required.\n\n Args:\n resource: Data to update the resource.\n uri: Resource uri\n force: If set to true, the operation completes despite any problems\n with network connectivity or errors on the resource itself. The default is false.\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers: Allows to add custom HTTP headers.\n\n Returns:\n A dict with the updated resource data.\n " ]
Please provide a description of the function:def create_report(self, uri, timeout=-1): logger.debug('Creating Report (uri = %s)'.format(uri)) task, _ = self._connection.post(uri, {}) if not task: raise exceptions.HPOneViewException(RESOURCE_CLIENT_TASK_EXPECTED) task = self._task_monitor.get_completed_task(task, timeout) return task['taskOutput']
[ "\n Creates a report and returns the output.\n\n Args:\n uri: URI\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n list:\n " ]
Please provide a description of the function:def get_collection(self, uri=None, filter='', path=''): if not uri: uri = self._base_uri if filter: filter = self.make_query_filter(filter) filter = "?" + filter[1:] uri = "{uri}{path}{filter}".format(uri=uri, path=path, filter=filter) logger.debug('Get resource collection (uri = %s)' % uri) response = self._connection.get(uri) return self.get_members(response)
[ "Retrieves a collection of resources.\n\n Use this function when the 'start' and 'count' parameters are not allowed in the GET call.\n Otherwise, use get_all instead.\n\n Optional filtering criteria may be specified.\n\n Args:\n filter (list or str): General filter/query string.\n path (str): path to be added with base URI\n\n Returns:\n Collection of the requested resource.\n " ]
Please provide a description of the function:def build_query_uri(self, uri=None, start=0, count=-1, filter='', query='', sort='', view='', fields='', scope_uris=''): if filter: filter = self.make_query_filter(filter) if query: query = "&query=" + quote(query) if sort: sort = "&sort=" + quote(sort) if view: view = "&view=" + quote(view) if fields: fields = "&fields=" + quote(fields) if scope_uris: scope_uris = "&scopeUris=" + quote(scope_uris) path = uri if uri else self._base_uri self.validate_resource_uri(path) symbol = '?' if '?' not in path else '&' uri = "{0}{1}start={2}&count={3}{4}{5}{6}{7}{8}{9}".format(path, symbol, start, count, filter, query, sort, view, fields, scope_uris) return uri
[ "Builds the URI from given parameters.\n\n More than one request can be send to get the items, regardless the query parameter 'count', because the actual\n number of items in the response might differ from the requested count. Some types of resource have a limited\n number of items returned on each call. For those resources, additional calls are made to the API to retrieve\n any other items matching the given filter. The actual number of items can also differ from the requested call\n if the requested number of items would take too long.\n\n The use of optional parameters for OneView 2.0 is described at:\n http://h17007.www1.hpe.com/docs/enterprise/servers/oneview2.0/cic-api/en/api-docs/current/index.html\n\n Note:\n Single quote - \"'\" - inside a query parameter is not supported by OneView API.\n\n Args:\n start: The first item to return, using 0-based indexing.\n If not specified, the default is 0 - start with the first available item.\n count: The number of resources to return. A count of -1 requests all items (default).\n filter (list or str): A general filter/query string to narrow the list of items returned. The default is no\n filter; all resources are returned.\n query: A single query parameter can do what would take multiple parameters or multiple GET requests using\n filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0.\n sort: The sort order of the returned data set. By default, the sort order is based on create time with the\n oldest entry first.\n view: Returns a specific subset of the attributes of the resource or collection by specifying the name of a\n predefined view. The default view is expand (show all attributes of the resource and all elements of\n the collections or resources).\n fields: Name of the fields.\n uri: A specific URI (optional)\n scope_uris: An expression to restrict the resources returned according to the scopes to\n which they are assigned.\n\n Returns:\n uri: The complete uri\n " ]
Please provide a description of the function:def build_uri(self, id_or_uri): if not id_or_uri: logger.exception(RESOURCE_CLIENT_INVALID_ID) raise ValueError(RESOURCE_CLIENT_INVALID_ID) if "/" in id_or_uri: self.validate_resource_uri(id_or_uri) return id_or_uri else: return self._base_uri + "/" + id_or_uri
[ "Helps to build the URI from resource id and validate the URI.\n\n Args:\n id_or_uri: ID/URI of the resource.\n\n Returns:\n Returns a valid resource URI\n " ]
Please provide a description of the function:def build_subresource_uri(self, resource_id_or_uri=None, subresource_id_or_uri=None, subresource_path=''): if subresource_id_or_uri and "/" in subresource_id_or_uri: return subresource_id_or_uri else: if not resource_id_or_uri: raise exceptions.HPOneViewValueError(RESOURCE_ID_OR_URI_REQUIRED) resource_uri = self.build_uri(resource_id_or_uri) uri = "{}/{}/{}".format(resource_uri, subresource_path, str(subresource_id_or_uri or '')) uri = uri.replace("//", "/") if uri.endswith("/"): uri = uri[:-1] return uri
[ "Helps to build a URI with resource path and its sub resource path.\n\n Args:\n resoure_id_or_uri: ID/URI of the main resource.\n subresource_id__or_uri: ID/URI of the sub resource.\n subresource_path: Sub resource path to be added with the URI.\n\n Returns:\n Returns URI\n " ]
Please provide a description of the function:def validate_resource_uri(self, path): if self._base_uri not in path: logger.exception('Get by uri : unrecognized uri: (%s)' % path) raise exceptions.HPOneViewUnknownType(UNRECOGNIZED_URI)
[ "Helper method to validate URI of the resource." ]
Please provide a description of the function:def update_resource_fields(self, data, data_to_add): for key, value in data_to_add.items(): if not data.get(key): data[key] = value return data
[ "Update resource data with new fields.\n\n Args:\n data: resource data\n data_to_update: dict of data to update resource data\n\n Returnes:\n Returnes dict\n " ]
Please provide a description of the function:def do_requests_to_getall(self, uri, requested_count): items = [] while uri: logger.debug('Making HTTP request to get all resources. Uri: {0}'.format(uri)) response = self._connection.get(uri) members = self.get_members(response) items += members logger.debug("Response getAll: nextPageUri = {0}, members list length: {1}".format(uri, str(len(members)))) uri = self.get_next_page(response, items, requested_count) logger.debug('Total # of members found = {0}'.format(str(len(items)))) return items
[ "Helps to make http request for get_all method.\n\n Note:\n This method will be checking for the pagination URI in the response\n and make request to pagination URI to get all the resources.\n " ]
Please provide a description of the function:def do_get(self, uri): self.validate_resource_uri(uri) return self._connection.get(uri)
[ "Helps to make get requests\n\n Args:\n uri: URI of the resource\n\n Returns:\n Returns: Returns the resource data\n " ]
Please provide a description of the function:def do_post(self, uri, resource, timeout, custom_headers): self.validate_resource_uri(uri) task, entity = self._connection.post(uri, resource, custom_headers=custom_headers) if not task: return entity return self._task_monitor.wait_for_task(task, timeout)
[ "Helps to make post requests.\n\n Args:\n uri: URI of the resource.\n resource: Resource data to post.\n timeout: Time out for the request in seconds.\n cutom_headers: Allows to add custom http headers.\n\n Returns:\n Retunrs Task object.\n " ]
Please provide a description of the function:def do_put(self, uri, resource, timeout, custom_headers): self.validate_resource_uri(uri) task, body = self._connection.put(uri, resource, custom_headers=custom_headers) if not task: return body return self._task_monitor.wait_for_task(task, timeout)
[ "Helps to make put requests.\n\n Args:\n uri: URI of the resource\n timeout: Time out for the request in seconds.\n custom_headers: Allows to set custom http headers.\n\n Retuns:\n Returns Task object\n " ]
Please provide a description of the function:def add_new_fields(data, data_to_add): for key, value in data_to_add.items(): if not data.get(key): data[key] = value return data
[ "Update resource data with new fields.\n\n Args:\n data: resource data\n data_to_update: dict of data to update resource data\n\n Returnes:\n Returnes dict\n " ]
Please provide a description of the function:def patch(self, operation, path, value, custom_headers=None, timeout=-1): patch_request_body = [{'op': operation, 'path': path, 'value': value}] resource_uri = self.data['uri'] self.data = self.patch_request(resource_uri, body=patch_request_body, custom_headers=custom_headers, timeout=timeout) return self
[ "Uses the PATCH to update a resource.\n\n Only one operation can be performed in each PATCH call.\n\n Args\n operation: Patch operation\n path: Path\n value: Value\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers: Allows to add custom http headers.\n\n Returns:\n Updated resource.\n " ]
Please provide a description of the function:def patch_request(self, uri, body, custom_headers=None, timeout=-1): logger.debug('Patch resource (uri = %s, data = %s)' % (uri, body)) if not custom_headers: custom_headers = {} if self._connection._apiVersion >= 300 and 'Content-Type' not in custom_headers: custom_headers['Content-Type'] = 'application/json-patch+json' task, entity = self._connection.patch(uri, body, custom_headers=custom_headers) if not task: return entity return self._task_monitor.wait_for_task(task, timeout)
[ "Uses the PATCH to update a resource.\n\n Only one operation can be performed in each PATCH call.\n\n Args:\n body (list): Patch request body\n timeout (int): Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers (dict): Allows to add custom http headers.\n\n Returns:\n Updated resource.\n " ]
Please provide a description of the function:def download(self, uri, file_path): with open(file_path, 'wb') as file: return self._connection.download_to_stream(file, uri)
[ "Downloads the contents of the requested URI to a stream.\n\n Args:\n uri: URI\n file_path: File path destination\n\n Returns:\n bool: Indicates if the file was successfully downloaded.\n " ]
Please provide a description of the function:def get_utilization(self, fields=None, filter=None, refresh=False, view=None): resource_uri = self.data['uri'] query = '' if filter: query += self._helper.make_query_filter(filter) if fields: query += "&fields=" + quote(fields) if refresh: query += "&refresh=true" if view: query += "&view=" + quote(view) if query: query = "?" + query[1:] uri = "{0}/utilization{1}".format(self._helper.build_uri(resource_uri), query) return self._helper.do_get(uri)
[ "Retrieves historical utilization data for the specified resource, metrics, and time span.\n\n Args:\n fields: Name of the supported metric(s) to be retrieved in the format METRIC[,METRIC]...\n If unspecified, all metrics supported are returned.\n\n filter (list or str): Filters should be in the format FILTER_NAME=VALUE[,FILTER_NAME=VALUE]...\n E.g.: 'startDate=2016-05-30T11:20:44.541Z,endDate=2016-05-30T19:20:44.541Z'\n\n startDate\n Start date of requested starting time range in ISO 8601 format. If omitted, the startDate is\n determined by the endDate minus 24 hours.\n endDate\n End date of requested starting time range in ISO 8601 format. When omitted, the endDate includes\n the latest data sample available.\n\n If an excessive number of samples would otherwise be returned, the results will be segmented. The\n caller is responsible for comparing the returned sliceStartTime with the requested startTime in the\n response. If the sliceStartTime is greater than the oldestSampleTime and the requested start time,\n the caller is responsible for repeating the request with endTime set to sliceStartTime to obtain the\n next segment. This process is repeated until the full data set is retrieved.\n\n If the resource has no data, the UtilizationData is still returned but will contain no samples and\n sliceStartTime/sliceEndTime will be equal. oldestSampleTime/newestSampleTime will still be set\n appropriately (null if no data is available). If the filter does not happen to overlap the data\n that a resource has, then the metric history service will return null sample values for any\n missing samples.\n\n refresh: Specifies that if necessary, an additional request will be queued to obtain the most recent\n utilization data from the iLO. The response will not include any refreshed data. To track the\n availability of the newly collected data, monitor the TaskResource identified by the refreshTaskUri\n property in the response. If null, no refresh was queued.\n\n view: Specifies the resolution interval length of the samples to be retrieved. This is reflected in the\n resolution in the returned response. Utilization data is automatically purged to stay within storage\n space constraints. Supported views are listed below:\n\n native\n Resolution of the samples returned will be one sample for each 5-minute time period. This is the\n default view and matches the resolution of the data returned by the iLO. Samples at this resolution\n are retained up to one year.\n hour\n Resolution of the samples returned will be one sample for each 60-minute time period. Samples are\n calculated by averaging the available 5-minute data samples that occurred within the hour, except\n for PeakPower which is calculated by reporting the peak observed 5-minute sample value data during\n the hour. Samples at this resolution are retained up to three years.\n day\n Resolution of the samples returned will be one sample for each 24-hour time period. One day is a\n 24-hour period that starts at midnight GMT regardless of the time zone in which the appliance or\n client is located. Samples are calculated by averaging the available 5-minute data samples that\n occurred during the day, except for PeakPower which is calculated by reporting the peak observed\n 5-minute sample value data during the day. Samples at this resolution are retained up to three\n years.\n\n Returns:\n dict\n " ]
Please provide a description of the function:def create_with_zero_body(self, uri=None, timeout=-1, custom_headers=None): if not uri: uri = self.URI logger.debug('Create with zero body (uri = %s)' % uri) resource_data = self._helper.do_post(uri, {}, timeout, custom_headers) return resource_data
[ "Makes a POST request to create a resource when no request body is required.\n\n Args:\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers: Allows set specific HTTP headers.\n\n Returns:\n Created resource.\n " ]
Please provide a description of the function:def update_with_zero_body(self, uri=None, timeout=-1, custom_headers=None): if not uri: uri = self.data['uri'] logger.debug('Update with zero length body (uri = %s)' % uri) resource_data = self._helper.do_put(uri, None, timeout, custom_headers) return resource_data
[ "Makes a PUT request to update a resource when no request body is required.\n\n Args:\n uri: Allows to use a different URI other than resource URI\n timeout: Timeout in seconds. Wait for task completion by default.\n The timeout does not abort the operation in OneView; it just stops waiting for its completion.\n custom_headers: Allows to set custom HTTP headers.\n\n Returns:\n A dict with updated resource data.\n " ]
Please provide a description of the function:def build_query_uri(self, start=0, count=-1, filter='', query='', sort='', view='', fields='', uri=None, scope_uris=''): if filter: filter = self.__make_query_filter(filter) if query: query = "&query=" + quote(query) if sort: sort = "&sort=" + quote(sort) if view: view = "&view=" + quote(view) if fields: fields = "&fields=" + quote(fields) if scope_uris: scope_uris = "&scopeUris=" + quote(scope_uris) path = uri if uri else self._uri self.__validate_resource_uri(path) symbol = '?' if '?' not in path else '&' uri = "{0}{1}start={2}&count={3}{4}{5}{6}{7}{8}{9}".format(path, symbol, start, count, filter, query, sort, view, fields, scope_uris) return uri
[ "\n Builds the URI given the parameters.\n\n More than one request can be send to get the items, regardless the query parameter 'count', because the actual\n number of items in the response might differ from the requested count. Some types of resource have a limited\n number of items returned on each call. For those resources, additional calls are made to the API to retrieve\n any other items matching the given filter. The actual number of items can also differ from the requested call\n if the requested number of items would take too long.\n\n The use of optional parameters for OneView 2.0 is described at:\n http://h17007.www1.hpe.com/docs/enterprise/servers/oneview2.0/cic-api/en/api-docs/current/index.html\n\n Note:\n Single quote - \"'\" - inside a query parameter is not supported by OneView API.\n\n Args:\n start:\n The first item to return, using 0-based indexing.\n If not specified, the default is 0 - start with the first available item.\n count:\n The number of resources to return. A count of -1 requests all items (default).\n filter (list or str):\n A general filter/query string to narrow the list of items returned. The default is no\n filter; all resources are returned.\n query:\n A single query parameter can do what would take multiple parameters or multiple GET requests using\n filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0.\n sort:\n The sort order of the returned data set. By default, the sort order is based on create time with the\n oldest entry first.\n view:\n Returns a specific subset of the attributes of the resource or collection by specifying the name of a\n predefined view. The default view is expand (show all attributes of the resource and all elements of\n the collections or resources).\n fields:\n Name of the fields.\n uri:\n A specific URI (optional)\n scope_uris:\n An expression to restrict the resources returned according to the scopes to\n which they are assigned.\n\n Returns:\n uri: The complete uri\n " ]
Please provide a description of the function:def get_all(self, start=0, count=-1, filter='', query='', sort='', view='', fields='', uri=None, scope_uris=''): uri = self.build_query_uri(start=start, count=count, filter=filter, query=query, sort=sort, view=view, fields=fields, uri=uri, scope_uris=scope_uris) logger.debug('Getting all resources with uri: {0}'.format(uri)) result = self.__do_requests_to_getall(uri, count) return result
[ "\n Gets all items according with the given arguments.\n\n Args:\n start:\n The first item to return, using 0-based indexing.\n If not specified, the default is 0 - start with the first available item.\n count:\n The number of resources to return. A count of -1 requests all items (default).\n filter (list or str):\n A general filter/query string to narrow the list of items returned. The default is no\n filter; all resources are returned.\n query:\n A single query parameter can do what would take multiple parameters or multiple GET requests using\n filter. Use query for more complex queries. NOTE: This parameter is experimental for OneView 2.0.\n sort:\n The sort order of the returned data set. By default, the sort order is based on create time with the\n oldest entry first.\n view:\n Returns a specific subset of the attributes of the resource or collection by specifying the name of a\n predefined view. The default view is expand (show all attributes of the resource and all elements of\n the collections or resources).\n fields:\n Name of the fields.\n uri:\n A specific URI (optional)\n scope_uris:\n An expression to restrict the resources returned according to the scopes to\n which they are assigned.\n\n Returns:\n list: A list of items matching the specified filter.\n " ]
Please provide a description of the function:def delete_all(self, filter, force=False, timeout=-1): uri = "{}?filter={}&force={}".format(self._uri, quote(filter), force) logger.debug("Delete all resources (uri = %s)" % uri) task, body = self._connection.delete(uri) if not task: # 204 NO CONTENT # Successful return from a synchronous delete operation. return True return self._task_monitor.wait_for_task(task, timeout=timeout)
[ "\n Deletes all resources from the appliance that match the provided filter.\n\n Args:\n filter:\n A general filter/query string to narrow the list of items deleted.\n force:\n If set to true, the operation completes despite any problems with network connectivity or errors\n on the resource itself. The default is false.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n bool: Indicates if the resources were successfully deleted.\n " ]
Please provide a description of the function:def get(self, id_or_uri): uri = self.build_uri(id_or_uri) logger.debug('Get resource (uri = %s, ID = %s)' % (uri, str(id_or_uri))) return self._connection.get(uri)
[ "\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n\n Returns:\n The requested resource.\n " ]
Please provide a description of the function:def get_collection(self, id_or_uri, filter=''): if filter: filter = self.__make_query_filter(filter) filter = "?" + filter[1:] uri = "{uri}{filter}".format(uri=self.build_uri(id_or_uri), filter=filter) logger.debug('Get resource collection (uri = %s)' % uri) response = self._connection.get(uri) return self.__get_members(response)
[ "\n Retrieves a collection of resources.\n\n Use this function when the 'start' and 'count' parameters are not allowed in the GET call.\n Otherwise, use get_all instead.\n\n Optional filtering criteria may be specified.\n\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n filter (list or str): General filter/query string.\n\n Returns:\n Collection of the requested resource.\n " ]
Please provide a description of the function:def update_with_zero_body(self, uri, timeout=-1, custom_headers=None): logger.debug('Update with zero length body (uri = %s)' % uri) return self.__do_put(uri, None, timeout, custom_headers)
[ "\n Makes a PUT request to update a resource when no request body is required.\n\n Args:\n uri:\n Can be either the resource ID or the resource URI.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers:\n Allows set specific HTTP headers.\n\n Returns:\n Updated resource.\n " ]
Please provide a description of the function:def update(self, resource, uri=None, force=False, timeout=-1, custom_headers=None, default_values={}): if not resource: logger.exception(RESOURCE_CLIENT_RESOURCE_WAS_NOT_PROVIDED) raise ValueError(RESOURCE_CLIENT_RESOURCE_WAS_NOT_PROVIDED) logger.debug('Update async (uri = %s, resource = %s)' % (self._uri, str(resource))) if not uri: uri = resource['uri'] if force: uri += '?force=True' resource = self.merge_default_values(resource, default_values) return self.__do_put(uri, resource, timeout, custom_headers)
[ "\n Makes a PUT request to update a resource when a request body is required.\n\n Args:\n resource:\n OneView resource dictionary.\n uri:\n Can be either the resource ID or the resource URI.\n force:\n If set to true, the operation completes despite any problems with network connectivity or errors\n on the resource itself. The default is false.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers:\n Allows set specific HTTP headers.\n default_values:\n Dictionary with default values grouped by OneView API version. This dictionary will be be merged with\n the resource dictionary only if the dictionary does not contain the keys.\n This argument is optional and the default value is an empty dictionary.\n Ex.:\n default_values = {\n '200': {\"type\": \"logical-switch-group\"},\n '300': {\"type\": \"logical-switch-groupV300\"}\n }\n\n Returns:\n Updated resource.\n " ]
Please provide a description of the function:def create_with_zero_body(self, uri=None, timeout=-1, custom_headers=None): if not uri: uri = self._uri logger.debug('Create with zero body (uri = %s)' % uri) return self.__do_post(uri, {}, timeout, custom_headers)
[ "\n Makes a POST request to create a resource when no request body is required.\n\n Args:\n uri:\n Can be either the resource ID or the resource URI.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers:\n Allows set specific HTTP headers.\n\n Returns:\n Created resource.\n " ]
Please provide a description of the function:def create(self, resource, uri=None, timeout=-1, custom_headers=None, default_values={}): if not resource: logger.exception(RESOURCE_CLIENT_RESOURCE_WAS_NOT_PROVIDED) raise ValueError(RESOURCE_CLIENT_RESOURCE_WAS_NOT_PROVIDED) if not uri: uri = self._uri logger.debug('Create (uri = %s, resource = %s)' % (uri, str(resource))) resource = self.merge_default_values(resource, default_values) return self.__do_post(uri, resource, timeout, custom_headers)
[ "\n Makes a POST request to create a resource when a request body is required.\n\n Args:\n resource:\n OneView resource dictionary.\n uri:\n Can be either the resource ID or the resource URI.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n custom_headers:\n Allows set specific HTTP headers.\n default_values:\n Dictionary with default values grouped by OneView API version. This dictionary will be be merged with\n the resource dictionary only if the dictionary does not contain the keys.\n This argument is optional and the default value is an empty dictionary.\n Ex.:\n default_values = {\n '200': {\"type\": \"logical-switch-group\"},\n '300': {\"type\": \"logical-switch-groupV300\"}\n }\n\n Returns:\n Created resource.\n " ]
Please provide a description of the function:def upload(self, file_path, uri=None, timeout=-1): if not uri: uri = self._uri upload_file_name = os.path.basename(file_path) task, entity = self._connection.post_multipart_with_response_handling(uri, file_path, upload_file_name) if not task: return entity return self._task_monitor.wait_for_task(task, timeout)
[ "\n Makes a multipart request.\n\n Args:\n file_path:\n File to upload.\n uri:\n A specific URI (optional).\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n dict: Response body.\n " ]
Please provide a description of the function:def patch(self, id_or_uri, operation, path, value, timeout=-1, custom_headers=None): patch_request_body = [{'op': operation, 'path': path, 'value': value}] return self.patch_request(id_or_uri=id_or_uri, body=patch_request_body, timeout=timeout, custom_headers=custom_headers)
[ "\n Uses the PATCH to update a resource.\n\n Only one operation can be performed in each PATCH call.\n\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n operation: Patch operation\n path: Path\n value: Value\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n Updated resource.\n " ]
Please provide a description of the function:def patch_request(self, id_or_uri, body, timeout=-1, custom_headers=None): uri = self.build_uri(id_or_uri) logger.debug('Patch resource (uri = %s, data = %s)' % (uri, body)) custom_headers_copy = custom_headers.copy() if custom_headers else {} if self._connection._apiVersion >= 300 and 'Content-Type' not in custom_headers_copy: custom_headers_copy['Content-Type'] = 'application/json-patch+json' task, entity = self._connection.patch(uri, body, custom_headers=custom_headers_copy) if not task: return entity return self._task_monitor.wait_for_task(task, timeout)
[ "\n Uses the PATCH to update a resource.\n\n Only one operation can be performed in each PATCH call.\n\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n body: Patch request body\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n Updated resource.\n " ]
Please provide a description of the function:def get_by(self, field, value, uri=None): if not field: logger.exception(RESOURCE_CLIENT_INVALID_FIELD) raise ValueError(RESOURCE_CLIENT_INVALID_FIELD) if not uri: uri = self._uri self.__validate_resource_uri(uri) logger.debug('Get by (uri = %s, field = %s, value = %s)' % (uri, field, str(value))) filter = "\"{0}='{1}'\"".format(field, value) results = self.get_all(filter=filter, uri=uri) # Workaround when the OneView filter does not work, it will filter again if "." not in field: # This filter only work for the first level results = [item for item in results if str(item.get(field, '')).lower() == value.lower()] return results
[ "\n This function uses get_all passing a filter.\n\n The search is case-insensitive.\n\n Args:\n field: Field name to filter.\n value: Value to filter.\n uri: Resource uri.\n\n Returns:\n dict\n " ]
Please provide a description of the function:def get_utilization(self, id_or_uri, fields=None, filter=None, refresh=False, view=None): if not id_or_uri: raise ValueError(RESOURCE_CLIENT_INVALID_ID) query = '' if filter: query += self.__make_query_filter(filter) if fields: query += "&fields=" + quote(fields) if refresh: query += "&refresh=true" if view: query += "&view=" + quote(view) if query: query = "?" + query[1:] uri = "{0}/utilization{1}".format(self.build_uri(id_or_uri), query) return self._connection.get(uri)
[ "\n Retrieves historical utilization data for the specified resource, metrics, and time span.\n\n Args:\n id_or_uri:\n Resource identification\n fields:\n Name of the supported metric(s) to be retrieved in the format METRIC[,METRIC]...\n If unspecified, all metrics supported are returned.\n\n filter (list or str):\n Filters should be in the format FILTER_NAME=VALUE[,FILTER_NAME=VALUE]...\n E.g.: 'startDate=2016-05-30T11:20:44.541Z,endDate=2016-05-30T19:20:44.541Z'\n\n startDate\n Start date of requested starting time range in ISO 8601 format. If omitted, the startDate is\n determined by the endDate minus 24 hours.\n endDate\n End date of requested starting time range in ISO 8601 format. When omitted, the endDate includes\n the latest data sample available.\n\n If an excessive number of samples would otherwise be returned, the results will be segmented. The\n caller is responsible for comparing the returned sliceStartTime with the requested startTime in the\n response. If the sliceStartTime is greater than the oldestSampleTime and the requested start time,\n the caller is responsible for repeating the request with endTime set to sliceStartTime to obtain the\n next segment. This process is repeated until the full data set is retrieved.\n\n If the resource has no data, the UtilizationData is still returned but will contain no samples and\n sliceStartTime/sliceEndTime will be equal. oldestSampleTime/newestSampleTime will still be set\n appropriately (null if no data is available). If the filter does not happen to overlap the data\n that a resource has, then the metric history service will return null sample values for any\n missing samples.\n\n refresh:\n Specifies that if necessary, an additional request will be queued to obtain the most recent\n utilization data from the iLO. The response will not include any refreshed data. To track the\n availability of the newly collected data, monitor the TaskResource identified by the refreshTaskUri\n property in the response. If null, no refresh was queued.\n\n view:\n Specifies the resolution interval length of the samples to be retrieved. This is reflected in the\n resolution in the returned response. Utilization data is automatically purged to stay within storage\n space constraints. Supported views are listed below:\n\n native\n Resolution of the samples returned will be one sample for each 5-minute time period. This is the\n default view and matches the resolution of the data returned by the iLO. Samples at this resolution\n are retained up to one year.\n hour\n Resolution of the samples returned will be one sample for each 60-minute time period. Samples are\n calculated by averaging the available 5-minute data samples that occurred within the hour, except\n for PeakPower which is calculated by reporting the peak observed 5-minute sample value data during\n the hour. Samples at this resolution are retained up to three years.\n day\n Resolution of the samples returned will be one sample for each 24-hour time period. One day is a\n 24-hour period that starts at midnight GMT regardless of the time zone in which the appliance or\n client is located. Samples are calculated by averaging the available 5-minute data samples that\n occurred during the day, except for PeakPower which is calculated by reporting the peak observed\n 5-minute sample value data during the day. Samples at this resolution are retained up to three\n years.\n\n Returns:\n dict\n " ]
Please provide a description of the function:def get_by(self, field, value): firmwares = self.get_all() matches = [] for item in firmwares: if item.get(field) == value: matches.append(item) return matches
[ "\n Gets the list of firmware baseline resources managed by the appliance. Optional parameters can be used to\n filter the list of resources returned.\n\n The search is case-insensitive.\n\n Args:\n field: Field name to filter.\n value: Value to filter.\n\n Returns:\n list: List of firmware baseline resources.\n " ]
Please provide a description of the function:def update(self, data, timeout=-1, force=False): uri = self.data["uri"] self.data = self._helper.update(data, uri=uri, timeout=timeout, force=force) return self
[ "\n Updates one or more attributes for a server hardware type resource.\n Args:\n data (dict): Object to update.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n force: Flag to force the operation.\n Returns:\n dict: Updated server hardware type.\n " ]
Please provide a description of the function:def get_statistics(self, id_or_uri, port_name=''): uri = self._client.build_uri(id_or_uri) + "/statistics" if port_name: uri = uri + "/" + port_name return self._client.get(uri)
[ "\n Gets the statistics from an interconnect.\n\n Args:\n id_or_uri: Can be either the interconnect id or the interconnect uri.\n port_name (str): A specific port name of an interconnect.\n\n Returns:\n dict: The statistics for the interconnect that matches id.\n " ]
Please provide a description of the function:def get_subport_statistics(self, id_or_uri, port_name, subport_number): uri = self._client.build_uri(id_or_uri) + "/statistics/{0}/subport/{1}".format(port_name, subport_number) return self._client.get(uri)
[ "\n Gets the subport statistics on an interconnect.\n\n Args:\n id_or_uri: Can be either the interconnect id or the interconnect uri.\n port_name (str): A specific port name of an interconnect.\n subport_number (int): The subport.\n\n Returns:\n dict: The statistics for the interconnect that matches id, port_name, and subport_number.\n " ]
Please provide a description of the function:def get_name_servers(self, id_or_uri): uri = self._client.build_uri(id_or_uri) + "/nameServers" return self._client.get(uri)
[ "\n Gets the named servers for an interconnect.\n\n Args:\n id_or_uri: Can be either the interconnect id or the interconnect uri.\n\n Returns:\n dict: the name servers for an interconnect.\n " ]
Please provide a description of the function:def update_port(self, port_information, id_or_uri, timeout=-1): uri = self._client.build_uri(id_or_uri) + "/ports" return self._client.update(port_information, uri, timeout)
[ "\n Updates an interconnect port.\n\n Args:\n id_or_uri: Can be either the interconnect id or the interconnect uri.\n port_information (dict): object to update\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n dict: The interconnect.\n\n " ]
Please provide a description of the function:def update_ports(self, ports, id_or_uri, timeout=-1): resources = merge_default_values(ports, {'type': 'port'}) uri = self._client.build_uri(id_or_uri) + "/update-ports" return self._client.update(resources, uri, timeout)
[ "\n Updates the interconnect ports.\n\n Args:\n id_or_uri: Can be either the interconnect id or the interconnect uri.\n ports (list): Ports to update.\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n dict: The interconnect.\n\n " ]
Please provide a description of the function:def reset_port_protection(self, id_or_uri, timeout=-1): uri = self._client.build_uri(id_or_uri) + "/resetportprotection" return self._client.update_with_zero_body(uri, timeout)
[ "\n Triggers a reset of port protection.\n\n Cause port protection to be reset on all the interconnects of the logical interconnect that matches ID.\n\n Args:\n id_or_uri: Can be either the interconnect id or the interconnect uri.\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n dict: The interconnect.\n\n " ]
Please provide a description of the function:def get_ports(self, id_or_uri, start=0, count=-1): uri = self._client.build_subresource_uri(resource_id_or_uri=id_or_uri, subresource_path="ports") return self._client.get_all(start, count, uri=uri)
[ "\n Gets all interconnect ports.\n\n Args:\n id_or_uri: Can be either the interconnect id or the interconnect uri.\n start:\n The first item to return, using 0-based indexing.\n If not specified, the default is 0 - start with the first available item.\n count:\n The number of resources to return. A count of -1 requests all items.\n The actual number of items in the response might differ from the requested\n count if the sum of start and count exceeds the total number of items.\n\n Returns:\n list: All interconnect ports.\n " ]
Please provide a description of the function:def get_port(self, id_or_uri, port_id_or_uri): uri = self._client.build_subresource_uri(id_or_uri, port_id_or_uri, "ports") return self._client.get(uri)
[ "\n Gets an interconnect port.\n\n Args:\n id_or_uri: Can be either the interconnect id or uri.\n port_id_or_uri: The interconnect port id or uri.\n\n Returns:\n dict: The interconnect port.\n " ]
Please provide a description of the function:def get_pluggable_module_information(self, id_or_uri): uri = self._client.build_uri(id_or_uri) + "/pluggableModuleInformation" return self._client.get(uri)
[ "\n Gets all the pluggable module information.\n\n Args:\n id_or_uri: Can be either the interconnect id or uri.\n\n Returns:\n array: dicts of the pluggable module information.\n " ]
Please provide a description of the function:def update_configuration(self, id_or_uri, timeout=-1): uri = self._client.build_uri(id_or_uri) + "/configuration" return self._client.update_with_zero_body(uri, timeout=timeout)
[ "\n Reapplies the appliance's configuration on the interconnect. This includes running the same configure steps\n that were performed as part of the interconnect add by the enclosure.\n\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n timeout: Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView; it just stops waiting for its completion.\n\n Returns:\n Interconnect\n " ]
Please provide a description of the function:def update(self, resource, id_or_uri): return self._client.update(resource=resource, uri=id_or_uri)
[ "\n Updates a registered Device Manager.\n\n Args:\n resource (dict): Object to update.\n id_or_uri: Can be either the Device manager ID or URI.\n\n Returns:\n dict: The device manager resource.\n " ]
Please provide a description of the function:def add(self, resource, provider_uri_or_id, timeout=-1): uri = self._provider_client.build_uri(provider_uri_or_id) + "/device-managers" return self._client.create(resource=resource, uri=uri, timeout=timeout)
[ "\n Adds a Device Manager under the specified provider.\n\n Args:\n resource (dict): Object to add.\n provider_uri_or_id: ID or URI of provider.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation\n in OneView, just stop waiting for its completion.\n\n Returns:\n dict: Added SAN Manager.\n " ]
Please provide a description of the function:def get_provider_uri(self, provider_display_name): providers = self._provider_client.get_by('displayName', provider_display_name) return providers[0]['uri'] if providers else None
[ "\n Gets uri for a specific provider.\n\n Args:\n provider_display_name: Display name of the provider.\n\n Returns:\n uri\n " ]
Please provide a description of the function:def get_default_connection_info(self, provider_name): provider = self._provider_client.get_by_name(provider_name) if provider: return provider['defaultConnectionInfo'] else: return {}
[ "\n Gets default connection info for a specific provider.\n\n Args:\n provider_name: Name of the provider.\n\n Returns:\n dict: Default connection information.\n " ]
Please provide a description of the function:def get_by_name(self, name): san_managers = self._client.get_all() result = [x for x in san_managers if x['name'] == name] return result[0] if result else None
[ "\n Gets a SAN Manager by name.\n\n Args:\n name: Name of the SAN Manager\n\n Returns:\n dict: SAN Manager.\n " ]
Please provide a description of the function:def get_by_provider_display_name(self, provider_display_name): san_managers = self._client.get_all() result = [x for x in san_managers if x['providerDisplayName'] == provider_display_name] return result[0] if result else None
[ "\n Gets a SAN Manager by provider display name.\n\n Args:\n provider_display_name: Name of the Provider Display Name\n\n Returns:\n dict: SAN Manager.\n " ]
Please provide a description of the function:def update_configuration(self, configuration): return self._client.update(configuration, uri=self.URI + "/configuration")
[ "\n Updates the metrics configuration with the new values. Overwrites the existing configuration.\n\n Args:\n configuration (dict):\n Dictionary with a list of objects which contain frequency, sample interval, and source type for each\n resource-type.\n\n Returns:\n dict: The current configuration for which metrics are being relayed.\n\n " ]
Please provide a description of the function:def delete_all(self, filter=None, timeout=-1): return self._client.delete_all(filter=filter, timeout=timeout)
[ "\n Delete an SNMPv3 User based on User name specified in filter. The user will be deleted only if it has no associated destinations.\n\n Args:\n username: ID or URI of SNMPv3 user.\n filter: A general filter/query string to narrow the list of items returned.\n The default is no filter - all resources are returned.\n\n Returns:\n bool: Indicates if the resource was successfully deleted.\n " ]
Please provide a description of the function:def update_ports(self, ports, id_or_uri): ports = merge_default_values(ports, {'type': 'port'}) uri = self._client.build_uri(id_or_uri) + "/update-ports" return self._client.update(uri=uri, resource=ports)
[ "\n Updates the switch ports. Only the ports under the management of OneView and those that are unlinked are\n supported for update.\n\n Note:\n This method is available for API version 300 or later.\n\n Args:\n ports: List of Switch Ports.\n id_or_uri: Can be either the switch id or the switch uri.\n\n Returns:\n dict: Switch\n " ]
Please provide a description of the function:def from_json_file(cls, file_name): with open(file_name) as json_data: config = json.load(json_data) return cls(config)
[ "\n Construct OneViewClient using a json file.\n\n Args:\n file_name: json full path.\n\n Returns:\n OneViewClient:\n " ]
Please provide a description of the function:def from_environment_variables(cls): ip = os.environ.get('ONEVIEWSDK_IP', '') image_streamer_ip = os.environ.get('ONEVIEWSDK_IMAGE_STREAMER_IP', '') api_version = int(os.environ.get('ONEVIEWSDK_API_VERSION', OneViewClient.DEFAULT_API_VERSION)) ssl_certificate = os.environ.get('ONEVIEWSDK_SSL_CERTIFICATE', '') username = os.environ.get('ONEVIEWSDK_USERNAME', '') auth_login_domain = os.environ.get('ONEVIEWSDK_AUTH_LOGIN_DOMAIN', '') password = os.environ.get('ONEVIEWSDK_PASSWORD', '') proxy = os.environ.get('ONEVIEWSDK_PROXY', '') sessionID = os.environ.get('ONEVIEWSDK_SESSIONID', '') timeout = os.environ.get('ONEVIEWSDK_CONNECTION_TIMEOUT') config = dict(ip=ip, image_streamer_ip=image_streamer_ip, api_version=api_version, ssl_certificate=ssl_certificate, credentials=dict(userName=username, authLoginDomain=auth_login_domain, password=password, sessionID=sessionID), proxy=proxy, timeout=timeout) return cls(config)
[ "\n Construct OneViewClient using environment variables.\n\n Allowed variables: ONEVIEWSDK_IP (required), ONEVIEWSDK_USERNAME (required), ONEVIEWSDK_PASSWORD (required),\n ONEVIEWSDK_AUTH_LOGIN_DOMAIN, ONEVIEWSDK_API_VERSION, ONEVIEWSDK_IMAGE_STREAMER_IP, ONEVIEWSDK_SESSIONID, ONEVIEWSDK_SSL_CERTIFICATE,\n ONEVIEWSDK_CONNECTION_TIMEOUT and ONEVIEWSDK_PROXY.\n\n Returns:\n OneViewClient:\n " ]
Please provide a description of the function:def __set_proxy(self, config): if "proxy" in config and config["proxy"]: proxy = config["proxy"] splitted = proxy.split(':') if len(splitted) != 2: raise ValueError(ONEVIEW_CLIENT_INVALID_PROXY) proxy_host = splitted[0] proxy_port = int(splitted[1]) self.__connection.set_proxy(proxy_host, proxy_port)
[ "\n Set proxy if needed\n Args:\n config: Config dict\n " ]
Please provide a description of the function:def create_image_streamer_client(self): image_streamer = ImageStreamerClient(self.__image_streamer_ip, self.__connection.get_session_id(), self.__connection._apiVersion, self.__connection._sslBundle) return image_streamer
[ "\n Create the Image Streamer API Client.\n\n Returns:\n ImageStreamerClient:\n " ]
Please provide a description of the function:def certificate_authority(self): if not self.__certificate_authority: self.__certificate_authority = CertificateAuthority(self.__connection) return self.__certificate_authority
[ "\n Gets the Certificate Authority API client.\n\n Returns:\n CertificateAuthority:\n " ]
Please provide a description of the function:def connections(self): if not self.__connections: self.__connections = Connections( self.__connection) return self.__connections
[ "\n Gets the Connections API client.\n\n Returns:\n Connections:\n " ]
Please provide a description of the function:def fcoe_networks(self): if not self.__fcoe_networks: self.__fcoe_networks = FcoeNetworks(self.__connection) return self.__fcoe_networks
[ "\n Gets the FcoeNetworks API client.\n\n Returns:\n FcoeNetworks:\n " ]
Please provide a description of the function:def fabrics(self): if not self.__fabrics: self.__fabrics = Fabrics(self.__connection) return self.__fabrics
[ "\n Gets the Fabrics API client.\n\n Returns:\n Fabrics:\n " ]
Please provide a description of the function:def restores(self): if not self.__restores: self.__restores = Restores(self.__connection) return self.__restores
[ "\n Gets the Restores API client.\n\n Returns:\n Restores:\n " ]
Please provide a description of the function:def scopes(self): if not self.__scopes: self.__scopes = Scopes(self.__connection) return self.__scopes
[ "\n Gets the Scopes API client.\n\n Returns:\n Scopes:\n " ]
Please provide a description of the function:def datacenters(self): if not self.__datacenters: self.__datacenters = Datacenters(self.__connection) return self.__datacenters
[ "\n Gets the Datacenters API client.\n\n Returns:\n Datacenters:\n " ]
Please provide a description of the function:def network_sets(self): if not self.__network_sets: self.__network_sets = NetworkSets(self.__connection) return self.__network_sets
[ "\n Gets the NetworkSets API client.\n\n Returns:\n NetworkSets:\n " ]
Please provide a description of the function:def server_hardware(self): if not self.__server_hardware: self.__server_hardware = ServerHardware(self.__connection) return self.__server_hardware
[ "\n Gets the ServerHardware API client.\n\n Returns:\n ServerHardware:\n " ]
Please provide a description of the function:def server_hardware_types(self): if not self.__server_hardware_types: self.__server_hardware_types = ServerHardwareTypes( self.__connection) return self.__server_hardware_types
[ "\n Gets the ServerHardwareTypes API client.\n\n Returns:\n ServerHardwareTypes:\n " ]
Please provide a description of the function:def id_pools_vsn_ranges(self): if not self.__id_pools_vsn_ranges: self.__id_pools_vsn_ranges = IdPoolsRanges('vsn', self.__connection) return self.__id_pools_vsn_ranges
[ "\n Gets the IdPoolsRanges API Client for VSN Ranges.\n\n Returns:\n IdPoolsRanges:\n " ]
Please provide a description of the function:def id_pools_vmac_ranges(self): if not self.__id_pools_vmac_ranges: self.__id_pools_vmac_ranges = IdPoolsRanges('vmac', self.__connection) return self.__id_pools_vmac_ranges
[ "\n Gets the IdPoolsRanges API Client for VMAC Ranges.\n\n Returns:\n IdPoolsRanges:\n " ]
Please provide a description of the function:def id_pools_vwwn_ranges(self): if not self.__id_pools_vwwn_ranges: self.__id_pools_vwwn_ranges = IdPoolsRanges('vwwn', self.__connection) return self.__id_pools_vwwn_ranges
[ "\n Gets the IdPoolsRanges API Client for VWWN Ranges.\n\n Returns:\n IdPoolsRanges:\n " ]
Please provide a description of the function:def id_pools_ipv4_ranges(self): if not self.__id_pools_ipv4_ranges: self.__id_pools_ipv4_ranges = IdPoolsIpv4Ranges(self.__connection) return self.__id_pools_ipv4_ranges
[ "\n Gets the IdPoolsIpv4Ranges API client.\n\n Returns:\n IdPoolsIpv4Ranges:\n " ]
Please provide a description of the function:def id_pools_ipv4_subnets(self): if not self.__id_pools_ipv4_subnets: self.__id_pools_ipv4_subnets = IdPoolsIpv4Subnets(self.__connection) return self.__id_pools_ipv4_subnets
[ "\n Gets the IdPoolsIpv4Subnets API client.\n\n Returns:\n IdPoolsIpv4Subnets:\n " ]
Please provide a description of the function:def id_pools(self): if not self.__id_pools: self.__id_pools = IdPools(self.__connection) return self.__id_pools
[ "\n Gets the IdPools API client.\n\n Returns:\n IdPools:\n " ]