Code
stringlengths 103
85.9k
| Summary
listlengths 0
94
|
---|---|
Please provide a description of the function:def remove(self, transport):
recipients = copy.copy(self.recipients)
for address, recManager in recipients.items():
recManager.remove(transport)
if not len(recManager.transports):
del self.recipients[address] | [
"\n removes a transport from all channels to which it belongs.\n "
]
|
Please provide a description of the function:def send(self, address, data_dict):
if type(address) == list:
recipients = [self.recipients.get(rec) for rec in address]
else:
recipients = [self.recipients.get(address)]
if recipients:
for recipient in recipients:
if recipient:
recipient.send(json.dumps(data_dict).encode()) | [
"\n address can either be a string or a list of strings\n\n data_dict gets sent along as is and could contain anything\n "
]
|
Please provide a description of the function:def subscribe(self, transport, data):
self.add(transport, address=data.get('hx_subscribe').encode())
self.send(
data['hx_subscribe'],
{'message': "%r is listening" % transport}
) | [
"\n adds a transport to a channel\n "
]
|
Please provide a description of the function:def cleanOptions(options):
_reload = options.pop('reload')
dev = options.pop('dev')
opts = []
store_true = [
'--nocache', '--global_cache', '--quiet', '--loud'
]
store_false = []
for key, value in options.items():
key = '--' + key
if (key in store_true and value) or (key in store_false and not value):
opts += [key, ]
elif value:
opts += [key, str(value)]
return _reload, opts | [
"\n Takes an options dict and returns a tuple containing the daemonize boolean,\n the reload boolean, and the parsed list of cleaned options as would be\n expected to be passed to hx\n "
]
|
Please provide a description of the function:def options(argv=[]):
parser = HendrixOptionParser
parsed_args = parser.parse_args(argv)
return vars(parsed_args[0]) | [
"\n A helper function that returns a dictionary of the default key-values pairs\n "
]
|
Please provide a description of the function:def remove(self, participant):
for topic, participants in list(self._participants_by_topic.items()):
self.unsubscribe(participant, topic)
# It's possible that we just nixe the last subscriber.
if not participants: # IE, nobody is still listening at this topic.
del self._participants_by_topic[topic] | [
"\n Unsubscribe this participant from all topic to which it is subscribed.\n "
]
|
Please provide a description of the function:def addSSLService(self):
"adds a SSLService to the instaitated HendrixService"
https_port = self.options['https_port']
self.tls_service = HendrixTCPServiceWithTLS(https_port, self.hendrix.site, self.key, self.cert,
self.context_factory, self.context_factory_kwargs)
self.tls_service.setServiceParent(self.hendrix) | []
|
Please provide a description of the function:def addResource(self, content, uri, headers):
self.cache[uri] = CachedResource(content, headers) | [
"\n Adds the a hendrix.contrib.cache.resource.CachedResource to the\n ReverseProxy cache connection\n "
]
|
Please provide a description of the function:def compressBuffer(buffer):
# http://jython.xhaus.com/http-compression-in-python-and-jython/
zbuf = cStringIO.StringIO()
zfile = gzip.GzipFile(mode='wb', fileobj=zbuf, compresslevel=9)
zfile.write(buffer)
zfile.close()
return zbuf.getvalue() | [
"\n Note that this code compresses into a buffer held in memory, rather\n than a disk file. This is done through the use of cStringIO.StringIO().\n "
]
|
Please provide a description of the function:def decompressBuffer(buffer):
"complements the compressBuffer function in CacheClient"
zbuf = cStringIO.StringIO(buffer)
zfile = gzip.GzipFile(fileobj=zbuf)
deflated = zfile.read()
zfile.close()
return deflated | []
|
Please provide a description of the function:def getMaxAge(self):
"get the max-age in seconds from the saved headers data"
max_age = 0
cache_control = self.headers.get('cache-control')
if cache_control:
params = dict(urlparse.parse_qsl(cache_control))
max_age = int(params.get('max-age', '0'))
return max_age | []
|
Please provide a description of the function:def getLastModified(self):
"returns the GMT last-modified datetime or None"
last_modified = self.headers.get('last-modified')
if last_modified:
last_modified = self.convertTimeString(last_modified)
return last_modified | []
|
Please provide a description of the function:def getDate(self):
"returns the GMT response datetime or None"
date = self.headers.get('date')
if date:
date = self.convertTimeString(date)
return date | []
|
Please provide a description of the function:def isFresh(self):
"returns True if cached object is still fresh"
max_age = self.getMaxAge()
date = self.getDate()
is_fresh = False
if max_age and date:
delta_time = datetime.now() - date
is_fresh = delta_time.total_seconds() < max_age
return is_fresh | []
|
Please provide a description of the function:def _parse_config_options(
config: Mapping[str, Union[ResourceOptions, Mapping[str, Any]]]=None):
if config is None:
return {}
if not isinstance(config, collections.abc.Mapping):
raise ValueError(
"Config must be mapping, got '{}'".format(config))
parsed = {}
options_keys = {
"allow_credentials", "expose_headers", "allow_headers", "max_age"
}
for origin, options in config.items():
# TODO: check that all origins are properly formatted.
# This is not a security issue, since origin is compared as strings.
if not isinstance(origin, str):
raise ValueError(
"Origin must be string, got '{}'".format(origin))
if isinstance(options, ResourceOptions):
resource_options = options
else:
if not isinstance(options, collections.abc.Mapping):
raise ValueError(
"Origin options must be either "
"aiohttp_cors.ResourceOptions instance or mapping, "
"got '{}'".format(options))
unexpected_args = frozenset(options.keys()) - options_keys
if unexpected_args:
raise ValueError(
"Unexpected keywords in resource options: {}".format(
# pylint: disable=bad-builtin
",".join(map(str, unexpected_args))))
resource_options = ResourceOptions(**options)
parsed[origin] = resource_options
return parsed | [
"Parse CORS configuration (default or per-route)\n\n :param config:\n Mapping from Origin to Resource configuration (allowed headers etc)\n defined either as mapping or `ResourceOptions` instance.\n\n Raises `ValueError` if configuration is not correct.\n "
]
|
Please provide a description of the function:def add(self,
routing_entity,
config: _ConfigType=None):
parsed_config = _parse_config_options(config)
self._router_adapter.add_preflight_handler(
routing_entity, self._preflight_handler)
self._router_adapter.set_config_for_routing_entity(
routing_entity, parsed_config)
return routing_entity | [
"Enable CORS for specific route or resource.\n\n If route is passed CORS is enabled for route's resource.\n\n :param routing_entity:\n Route or Resource for which CORS should be enabled.\n :param config:\n CORS options for the route.\n :return: `routing_entity`.\n "
]
|
Please provide a description of the function:async def _on_response_prepare(self,
request: web.Request,
response: web.StreamResponse):
if (not self._router_adapter.is_cors_enabled_on_request(request) or
self._router_adapter.is_preflight_request(request)):
# Either not CORS enabled route, or preflight request which is
# handled in its own handler.
return
# Processing response of non-preflight CORS-enabled request.
config = self._router_adapter.get_non_preflight_request_config(request)
# Handle according to part 6.1 of the CORS specification.
origin = request.headers.get(hdrs.ORIGIN)
if origin is None:
# Terminate CORS according to CORS 6.1.1.
return
options = config.get(origin, config.get("*"))
if options is None:
# Terminate CORS according to CORS 6.1.2.
return
assert hdrs.ACCESS_CONTROL_ALLOW_ORIGIN not in response.headers
assert hdrs.ACCESS_CONTROL_ALLOW_CREDENTIALS not in response.headers
assert hdrs.ACCESS_CONTROL_EXPOSE_HEADERS not in response.headers
# Process according to CORS 6.1.4.
# Set exposed headers (server headers exposed to client) before
# setting any other headers.
if options.expose_headers == "*":
# Expose all headers that are set in response.
exposed_headers = \
frozenset(response.headers.keys()) - _SIMPLE_RESPONSE_HEADERS
response.headers[hdrs.ACCESS_CONTROL_EXPOSE_HEADERS] = \
",".join(exposed_headers)
elif options.expose_headers:
# Expose predefined list of headers.
response.headers[hdrs.ACCESS_CONTROL_EXPOSE_HEADERS] = \
",".join(options.expose_headers)
# Process according to CORS 6.1.3.
# Set allowed origin.
response.headers[hdrs.ACCESS_CONTROL_ALLOW_ORIGIN] = origin
if options.allow_credentials:
# Set allowed credentials.
response.headers[hdrs.ACCESS_CONTROL_ALLOW_CREDENTIALS] = _TRUE | [
"Non-preflight CORS request response processor.\n\n If request is done on CORS-enabled route, process request parameters\n and set appropriate CORS response headers.\n "
]
|
Please provide a description of the function:def add(self,
routing_entity,
config: _ConfigType = None,
webview: bool=False):
if webview:
warnings.warn('webview argument is deprecated, '
'views are handled authomatically without '
'extra settings',
DeprecationWarning,
stacklevel=2)
return self._cors_impl.add(routing_entity, config) | [
"Enable CORS for specific route or resource.\n\n If route is passed CORS is enabled for route's resource.\n\n :param routing_entity:\n Route or Resource for which CORS should be enabled.\n :param config:\n CORS options for the route.\n :return: `routing_entity`.\n "
]
|
Please provide a description of the function:def _is_proper_sequence(seq):
return (isinstance(seq, collections.abc.Sequence) and
not isinstance(seq, str)) | [
"Returns is seq is sequence and not string."
]
|
Please provide a description of the function:def setup(app: web.Application, *,
defaults: Mapping[str, Union[ResourceOptions,
Mapping[str, Any]]]=None) -> CorsConfig:
cors = CorsConfig(app, defaults=defaults)
app[APP_CONFIG_KEY] = cors
return cors | [
"Setup CORS processing for the application.\n\n To enable CORS for a resource you need to explicitly add route for\n that resource using `CorsConfig.add()` method::\n\n app = aiohttp.web.Application()\n cors = aiohttp_cors.setup(app)\n cors.add(\n app.router.add_route(\"GET\", \"/resource\", handler),\n {\n \"*\": aiohttp_cors.ResourceOptions(\n allow_credentials=True,\n expose_headers=\"*\",\n allow_headers=\"*\"),\n })\n\n :param app:\n The application for which CORS will be configured.\n :param defaults:\n Default settings for origins.\n )\n "
]
|
Please provide a description of the function:def _parse_request_method(request: web.Request):
method = request.headers.get(hdrs.ACCESS_CONTROL_REQUEST_METHOD)
if method is None:
raise web.HTTPForbidden(
text="CORS preflight request failed: "
"'Access-Control-Request-Method' header is not specified")
# FIXME: validate method string (ABNF: method = token), if parsing
# fails, raise HTTPForbidden.
return method | [
"Parse Access-Control-Request-Method header of the preflight request\n "
]
|
Please provide a description of the function:def _parse_request_headers(request: web.Request):
headers = request.headers.get(hdrs.ACCESS_CONTROL_REQUEST_HEADERS)
if headers is None:
return frozenset()
# FIXME: validate each header string, if parsing fails, raise
# HTTPForbidden.
# FIXME: check, that headers split and stripped correctly (according
# to ABNF).
headers = (h.strip(" \t").upper() for h in headers.split(","))
# pylint: disable=bad-builtin
return frozenset(filter(None, headers)) | [
"Parse Access-Control-Request-Headers header or the preflight request\n\n Returns set of headers in upper case.\n "
]
|
Please provide a description of the function:async def _preflight_handler(self, request: web.Request):
# Handle according to part 6.2 of the CORS specification.
origin = request.headers.get(hdrs.ORIGIN)
if origin is None:
# Terminate CORS according to CORS 6.2.1.
raise web.HTTPForbidden(
text="CORS preflight request failed: "
"origin header is not specified in the request")
# CORS 6.2.3. Doing it out of order is not an error.
request_method = self._parse_request_method(request)
# CORS 6.2.5. Doing it out of order is not an error.
try:
config = \
await self._get_config(request, origin, request_method)
except KeyError:
raise web.HTTPForbidden(
text="CORS preflight request failed: "
"request method {!r} is not allowed "
"for {!r} origin".format(request_method, origin))
if not config:
# No allowed origins for the route.
# Terminate CORS according to CORS 6.2.1.
raise web.HTTPForbidden(
text="CORS preflight request failed: "
"no origins are allowed")
options = config.get(origin, config.get("*"))
if options is None:
# No configuration for the origin - deny.
# Terminate CORS according to CORS 6.2.2.
raise web.HTTPForbidden(
text="CORS preflight request failed: "
"origin '{}' is not allowed".format(origin))
# CORS 6.2.4
request_headers = self._parse_request_headers(request)
# CORS 6.2.6
if options.allow_headers == "*":
pass
else:
disallowed_headers = request_headers - options.allow_headers
if disallowed_headers:
raise web.HTTPForbidden(
text="CORS preflight request failed: "
"headers are not allowed: {}".format(
", ".join(disallowed_headers)))
# Ok, CORS actual request with specified in the preflight request
# parameters is allowed.
# Set appropriate headers and return 200 response.
response = web.Response()
# CORS 6.2.7
response.headers[hdrs.ACCESS_CONTROL_ALLOW_ORIGIN] = origin
if options.allow_credentials:
# Set allowed credentials.
response.headers[hdrs.ACCESS_CONTROL_ALLOW_CREDENTIALS] = _TRUE
# CORS 6.2.8
if options.max_age is not None:
response.headers[hdrs.ACCESS_CONTROL_MAX_AGE] = \
str(options.max_age)
# CORS 6.2.9
# TODO: more optimal for client preflight request cache would be to
# respond with ALL allowed methods.
response.headers[hdrs.ACCESS_CONTROL_ALLOW_METHODS] = request_method
# CORS 6.2.10
if request_headers:
# Note: case of the headers in the request is changed, but this
# shouldn't be a problem, since the headers should be compared in
# the case-insensitive way.
response.headers[hdrs.ACCESS_CONTROL_ALLOW_HEADERS] = \
",".join(request_headers)
return response | [
"CORS preflight request handler"
]
|
Please provide a description of the function:def add_preflight_handler(
self,
routing_entity: Union[web.Resource, web.StaticResource,
web.ResourceRoute],
handler):
if isinstance(routing_entity, web.Resource):
resource = routing_entity
# Add preflight handler for Resource, if not yet added.
if resource in self._resources_with_preflight_handlers:
# Preflight handler already added for this resource.
return
for route_obj in resource:
if route_obj.method == hdrs.METH_OPTIONS:
if route_obj.handler is handler:
return # already added
else:
raise ValueError(
"{!r} already has OPTIONS handler {!r}"
.format(resource, route_obj.handler))
elif route_obj.method == hdrs.METH_ANY:
if _is_web_view(route_obj):
self._preflight_routes.add(route_obj)
self._resources_with_preflight_handlers.add(resource)
return
else:
raise ValueError("{!r} already has a '*' handler "
"for all methods".format(resource))
preflight_route = resource.add_route(hdrs.METH_OPTIONS, handler)
self._preflight_routes.add(preflight_route)
self._resources_with_preflight_handlers.add(resource)
elif isinstance(routing_entity, web.StaticResource):
resource = routing_entity
# Add preflight handler for Resource, if not yet added.
if resource in self._resources_with_preflight_handlers:
# Preflight handler already added for this resource.
return
resource.set_options_route(handler)
preflight_route = resource._routes[hdrs.METH_OPTIONS]
self._preflight_routes.add(preflight_route)
self._resources_with_preflight_handlers.add(resource)
elif isinstance(routing_entity, web.ResourceRoute):
route = routing_entity
if not self.is_cors_for_resource(route.resource):
self.add_preflight_handler(route.resource, handler)
else:
raise ValueError(
"Resource or ResourceRoute expected, got {!r}".format(
routing_entity)) | [
"Add OPTIONS handler for all routes defined by `routing_entity`.\n\n Does nothing if CORS handler already handles routing entity.\n Should fail if there are conflicting user-defined OPTIONS handlers.\n "
]
|
Please provide a description of the function:def is_preflight_request(self, request: web.Request) -> bool:
route = self._request_route(request)
if _is_web_view(route, strict=False):
return request.method == 'OPTIONS'
return route in self._preflight_routes | [
"Is `request` is a CORS preflight request."
]
|
Please provide a description of the function:def is_cors_enabled_on_request(self, request: web.Request) -> bool:
return self._request_resource(request) in self._resource_config | [
"Is `request` is a request for CORS-enabled resource."
]
|
Please provide a description of the function:def set_config_for_routing_entity(
self,
routing_entity: Union[web.Resource, web.StaticResource,
web.ResourceRoute],
config):
if isinstance(routing_entity, (web.Resource, web.StaticResource)):
resource = routing_entity
# Add resource configuration or fail if it's already added.
if resource in self._resource_config:
raise ValueError(
"CORS is already configured for {!r} resource.".format(
resource))
self._resource_config[resource] = _ResourceConfig(
default_config=config)
elif isinstance(routing_entity, web.ResourceRoute):
route = routing_entity
# Add resource's route configuration or fail if it's already added.
if route.resource not in self._resource_config:
self.set_config_for_routing_entity(route.resource, config)
if route.resource not in self._resource_config:
raise ValueError(
"Can't setup CORS for {!r} request, "
"CORS must be enabled for route's resource first.".format(
route))
resource_config = self._resource_config[route.resource]
if route.method in resource_config.method_config:
raise ValueError(
"Can't setup CORS for {!r} route: CORS already "
"configured on resource {!r} for {} method".format(
route, route.resource, route.method))
resource_config.method_config[route.method] = config
else:
raise ValueError(
"Resource or ResourceRoute expected, got {!r}".format(
routing_entity)) | [
"Record configuration for resource or it's route."
]
|
Please provide a description of the function:def get_non_preflight_request_config(self, request: web.Request):
assert self.is_cors_enabled_on_request(request)
resource = self._request_resource(request)
resource_config = self._resource_config[resource]
# Take Route config (if any) with defaults from Resource CORS
# configuration and global defaults.
route = request.match_info.route
if _is_web_view(route, strict=False):
method_config = request.match_info.handler.get_request_config(
request, request.method)
else:
method_config = resource_config.method_config.get(request.method,
{})
defaulted_config = collections.ChainMap(
method_config,
resource_config.default_config,
self._default_config)
return defaulted_config | [
"Get stored CORS configuration for routing entity that handles\n specified request."
]
|
Please provide a description of the function:def get_visual_content(self, id_or_uri):
uri = self._client.build_uri(id_or_uri) + "/visualContent"
return self._client.get(uri) | [
"\n Gets a list of visual content objects describing each rack within the data center. The response aggregates data\n center and rack data with a specified metric (peak24HourTemp) to provide simplified access to display data for\n the data center.\n\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n\n Return:\n list: List of visual content objects.\n "
]
|
Please provide a description of the function:def add(self, information, timeout=-1):
return self._client.create(information, timeout=timeout) | [
"\n Adds a data center resource based upon the attributes specified.\n\n Args:\n information: Data center information\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: Added data center.\n "
]
|
Please provide a description of the function:def update(self, resource, timeout=-1):
return self._client.update(resource, timeout=timeout) | [
"\n Updates the specified data center resource.\n\n Args:\n resource (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: Updated data center.\n "
]
|
Please provide a description of the function:def remove_all(self, filter, force=False, timeout=-1):
return self._client.delete_all(filter=filter, force=force, timeout=timeout) | [
"\n Deletes the set of datacenters according to the specified parameters. A filter is required to identify the set\n of resources to be deleted.\n\n Args:\n filter:\n A general filter/query string to narrow the list of items that will be removed.\n force:\n If set to true, the operation completes despite any problems with\n network connectivity or errors 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: operation success\n "
]
|
Please provide a description of the function:def get_by(self, field, value):
return self._client.get_by(field=field, value=value) | [
"\n Gets all drive enclosures that match the filter.\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: A list of drive enclosures.\n "
]
|
Please provide a description of the function:def get_port_map(self, id_or_uri):
uri = self._client.build_uri(id_or_uri) + self.PORT_MAP_PATH
return self._client.get(id_or_uri=uri) | [
"\n Use to get the drive enclosure I/O adapter port to SAS interconnect port connectivity.\n\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n\n Returns:\n dict: Drive Enclosure Port Map\n "
]
|
Please provide a description of the function:def refresh_state(self, id_or_uri, configuration, timeout=-1):
uri = self._client.build_uri(id_or_uri) + self.REFRESH_STATE_PATH
return self._client.update(resource=configuration, uri=uri, timeout=timeout) | [
"\n Refreshes a drive enclosure.\n\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n configuration: Configuration\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: Drive Enclosure\n "
]
|
Please provide a description of the function:def get_all(self, start=0, count=-1, filter='', fields='', query='', sort='', view=''):
return self._client.get_all(start, count, filter=filter, sort=sort, query=query, fields=fields, view=view) | [
"\n Gets a list of Deployment Servers based on optional sorting and filtering, and constrained by start and count\n parameters.\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.\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 filter (list or str):\n A general filter/query string to narrow the list of items returned. The\n default is no filter; all resources are returned.\n fields:\n Specifies which fields should be returned in the result set.\n query:\n A general query string to narrow the list of resources returned. The default\n is no query - all resources are returned.\n sort:\n The sort order of the returned data set. By default, the sort order is based\n on create time with the oldest entry first.\n view:\n Return a specific subset of the attributes of the resource or collection, by\n specifying the name of a predefined view. The default view is expand - show all\n attributes of the resource and all elements of collections of resources.\n\n Returns:\n list: Os Deployment Servers\n "
]
|
Please provide a description of the function:def add(self, resource, timeout=-1):
return self._client.create(resource, timeout=timeout) | [
"\n Adds a Deployment Server using the information provided in the request body. Note: The type of the Deployment\n Server is always assigned as \"Image streamer\".\n\n Args:\n resource (dict):\n Deployment Manager resource.\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: The added resource.\n "
]
|
Please provide a description of the function:def update(self, resource, force=False, timeout=-1):
return self._client.update(resource, timeout=timeout, force=force) | [
"\n Updates the Deployment Server resource. The properties that are omitted (not included as part\n of the request body) are ignored.\n\n Args:\n resource (dict): Object to update.\n force:\n If set to true, the operation completes despite any problems with network connectivity or errors on\n 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, just stops waiting for its completion.\n\n Returns:\n Updated resource.\n "
]
|
Please provide a description of the function:def delete(self, resource, force=False, timeout=-1):
return self._client.delete(resource, force=force, timeout=timeout) | [
"\n Deletes a Deployment Server object based on its UUID or URI.\n\n Args:\n resource (dict):\n Object to delete.\n force:\n If set to true, the operation completes despite any problems with\n network connectivity or errors 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 volume was successfully deleted.\n "
]
|
Please provide a description of the function:def get_appliances(self, start=0, count=-1, filter='', fields='', query='', sort='', view=''):
uri = self.URI + '/image-streamer-appliances'
return self._client.get_all(start, count, filter=filter, sort=sort, query=query, fields=fields, view=view,
uri=uri) | [
"\n Gets a list of all the Image Streamer resources based on optional sorting and filtering, and constrained\n by start and count parameters.\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.\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 filter (list or str):\n A general filter/query string to narrow the list of items returned. The\n default is no filter; all resources are returned.\n fields:\n Specifies which fields should be returned in the result set.\n query:\n A general query string to narrow the list of resources returned. The default\n is no query - all resources are returned.\n sort:\n The sort order of the returned data set. By default, the sort order is based\n on create time with the oldest entry first.\n view:\n Return a specific subset of the attributes of the resource or collection, by\n specifying the name of a predefined view. The default view is expand - show all\n attributes of the resource and all elements of collections of resources.\n\n Returns:\n list: Image Streamer resources associated with the Deployment Servers.\n "
]
|
Please provide a description of the function:def get_appliance(self, id_or_uri, fields=''):
uri = self.URI + '/image-streamer-appliances/' + extract_id_from_uri(id_or_uri)
if fields:
uri += '?fields=' + fields
return self._client.get(uri) | [
"\n Gets the particular Image Streamer resource based on its ID or URI.\n\n Args:\n id_or_uri:\n Can be either the Os Deployment Server ID or the URI\n fields:\n Specifies which fields should be returned in the result.\n\n Returns:\n dict: Image Streamer resource.\n "
]
|
Please provide a description of the function:def get_appliance_by_name(self, appliance_name):
appliances = self.get_appliances()
if appliances:
for appliance in appliances:
if appliance['name'] == appliance_name:
return appliance
return None | [
"\n Gets the particular Image Streamer resource based on its name.\n\n Args:\n appliance_name:\n The Image Streamer resource name.\n\n Returns:\n dict: Image Streamer resource.\n "
]
|
Please provide a description of the function:def get_storage_pools(self, id_or_uri):
uri = self._client.build_uri(id_or_uri) + "/storage-pools"
return self._client.get(uri) | [
"\n Gets a list of Storage pools. Returns a list of storage pools belonging to the storage system referred by the\n Path property {ID} parameter or URI.\n\n Args:\n id_or_uri: Can be either the storage system ID (serial number) or the storage system URI.\n Returns:\n dict: Host types.\n "
]
|
Please provide a description of the function:def get_managed_ports(self, id_or_uri, port_id_or_uri=''):
if port_id_or_uri:
uri = self._client.build_uri(port_id_or_uri)
if "/managedPorts" not in uri:
uri = self._client.build_uri(id_or_uri) + "/managedPorts" + "/" + port_id_or_uri
else:
uri = self._client.build_uri(id_or_uri) + "/managedPorts"
return self._client.get_collection(uri) | [
"\n Gets all ports or a specific managed target port for the specified storage system.\n\n Args:\n id_or_uri: Can be either the storage system id or the storage system uri.\n port_id_or_uri: Can be either the port id or the port uri.\n\n Returns:\n dict: Managed ports.\n "
]
|
Please provide a description of the function:def get_by_ip_hostname(self, ip_hostname):
resources = self._client.get_all()
resources_filtered = [x for x in resources if x['credentials']['ip_hostname'] == ip_hostname]
if resources_filtered:
return resources_filtered[0]
else:
return None | [
"\n Retrieve a storage system by its IP.\n\n Works only with API version <= 300.\n\n Args:\n ip_hostname: Storage system IP or hostname.\n\n Returns:\n dict\n "
]
|
Please provide a description of the function:def get_by_hostname(self, hostname):
resources = self._client.get_all()
resources_filtered = [x for x in resources if x['hostname'] == hostname]
if resources_filtered:
return resources_filtered[0]
else:
return None | [
"\n Retrieve a storage system by its hostname.\n\n Works only in API500 onwards.\n\n Args:\n hostname: Storage system hostname.\n\n Returns:\n dict\n "
]
|
Please provide a description of the function:def get_reachable_ports(self, id_or_uri, start=0, count=-1, filter='', query='', sort='', networks=[]):
uri = self._client.build_uri(id_or_uri) + "/reachable-ports"
if networks:
elements = "\'"
for n in networks:
elements += n + ','
elements = elements[:-1] + "\'"
uri = uri + "?networks=" + elements
return self._client.get(self._client.build_query_uri(start=start, count=count, filter=filter, query=query,
sort=sort, uri=uri)) | [
"\n Gets the storage ports that are connected on the specified networks\n based on the storage system port's expected network connectivity.\n\n Returns:\n list: Reachable Storage Port List.\n "
]
|
Please provide a description of the function:def get_templates(self, id_or_uri, start=0, count=-1, filter='', query='', sort=''):
uri = self._client.build_uri(id_or_uri) + "/templates"
return self._client.get(self._client.build_query_uri(start=start, count=count, filter=filter,
query=query, sort=sort, uri=uri)) | [
"\n Gets a list of volume templates. Returns a list of storage templates belonging to the storage system.\n\n Returns:\n list: Storage Template List.\n "
]
|
Please provide a description of the function:def get_reserved_vlan_range(self, id_or_uri):
uri = self._client.build_uri(id_or_uri) + "/reserved-vlan-range"
return self._client.get(uri) | [
"\n Gets the reserved vlan ID range for the fabric.\n\n Note:\n This method is only available on HPE Synergy.\n\n Args:\n id_or_uri: ID or URI of fabric.\n\n Returns:\n dict: vlan-pool\n "
]
|
Please provide a description of the function:def update_reserved_vlan_range(self, id_or_uri, vlan_pool, force=False):
uri = self._client.build_uri(id_or_uri) + "/reserved-vlan-range"
return self._client.update(resource=vlan_pool, uri=uri, force=force, default_values=self.DEFAULT_VALUES) | [
"\n Updates the reserved vlan ID range for the fabric.\n\n Note:\n This method is only available on HPE Synergy.\n\n Args:\n id_or_uri: ID or URI of fabric.\n vlan_pool (dict): vlan-pool data to update.\n force: 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\n Returns:\n dict: The fabric\n "
]
|
Please provide a description of the function:def get(self, name_or_uri):
name_or_uri = quote(name_or_uri)
return self._client.get(name_or_uri) | [
"\n Get the role by its URI or Name.\n\n Args:\n name_or_uri:\n Can be either the Name or the URI.\n\n Returns:\n dict: Role\n "
]
|
Please provide a description of the function:def get_drives(self, id_or_uri):
uri = self._client.build_uri(id_or_uri=id_or_uri) + self.DRIVES_PATH
return self._client.get(id_or_uri=uri) | [
"\n Gets the list of drives allocated to this SAS logical JBOD.\n\n Args:\n id_or_uri: Can be either the SAS logical JBOD ID or the SAS logical JBOD URI.\n\n Returns:\n list: A list of Drives\n "
]
|
Please provide a description of the function:def enable(self, information, id_or_uri, timeout=-1):
uri = self._client.build_uri(id_or_uri)
return self._client.update(information, uri, timeout=timeout) | [
"\n Enables or disables a range.\n\n Args:\n information (dict): Information to update.\n id_or_uri: ID or URI of range.\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: Updated resource.\n "
]
|
Please provide a description of the function:def get_allocated_fragments(self, id_or_uri, count=-1, start=0):
uri = self._client.build_uri(id_or_uri) + "/allocated-fragments?start={0}&count={1}".format(start, count)
return self._client.get_collection(uri) | [
"\n Gets all fragments that have been allocated in range.\n\n Args:\n id_or_uri:\n ID or URI of range.\n count:\n The number of resources to return. A count of -1 requests all items. The actual number of items in\n the response may differ from the requested count if the sum of start and count exceed the total number\n of items.\n start:\n The first item to return, using 0-based indexing. If not specified, the default is 0 - start with the\n first available item.\n\n Returns:\n list: A list with the allocated fragements.\n "
]
|
Please provide a description of the function:def get_all(self, start=0, count=-1, sort=''):
return self._helper.get_all(start, count, sort=sort) | [
"\n Gets a list of logical interconnects based on optional sorting and filtering and is constrained by start\n and count parameters.\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.\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 sort:\n The sort order of the returned data set. By default, the sort order is based\n on create time with the oldest entry first.\n\n Returns:\n list: A list of logical interconnects.\n "
]
|
Please provide a description of the function:def update_compliance(self, timeout=-1):
uri = "{}/compliance".format(self.data["uri"])
return self._helper.update(None, uri, timeout=timeout) | [
"\n Returns logical interconnects to a consistent state. The current logical interconnect state is\n compared to the associated logical interconnect group.\n\n Any differences identified are corrected, bringing the logical interconnect back to a consistent\n state. Changes are asynchronously applied to all managed interconnects. Note that if the changes detected\n involve differences in the interconnect map between the logical interconnect group and the logical interconnect,\n the process of bringing the logical interconnect back to a consistent state might involve automatically removing\n existing interconnects from management and/or adding new interconnects for management.\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 Interconnect.\n "
]
|
Please provide a description of the function:def update_ethernet_settings(self, configuration, force=False, timeout=-1):
uri = "{}/ethernetSettings".format(self.data["uri"])
return self._helper.update(configuration, uri=uri, force=force, timeout=timeout) | [
"\n Updates the Ethernet interconnect settings for the logical interconnect.\n\n Args:\n configuration: Ethernet interconnect settings.\n force: 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: 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 Interconnect.\n "
]
|
Please provide a description of the function:def update_internal_networks(self, network_uri_list, force=False, timeout=-1):
uri = "{}/internalNetworks".format(self.data["uri"])
return self._helper.update(network_uri_list, uri=uri, force=force, timeout=timeout) | [
"\n Updates internal networks on the logical interconnect.\n\n Args:\n network_uri_list: List of Ethernet network uris.\n force: 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: 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 Interconnect.\n "
]
|
Please provide a description of the function:def update_settings(self, settings, force=False, timeout=-1):
data = settings.copy()
if 'ethernetSettings' in data:
ethernet_default_values = self._get_default_values(self.SETTINGS_ETHERNET_DEFAULT_VALUES)
data['ethernetSettings'] = merge_resources(data['ethernetSettings'],
ethernet_default_values)
uri = "{}/settings".format(self.data["uri"])
default_values = self._get_default_values(self.SETTINGS_DEFAULT_VALUES)
data = self._helper.update_resource_fields(data, default_values)
return self._helper.update(data, uri=uri, force=force, timeout=timeout) | [
"\n Updates interconnect settings on the logical interconnect. Changes to interconnect settings are asynchronously\n applied to all managed interconnects.\n (This method is not available from API version 600 onwards)\n Args:\n settings: Interconnect settings\n force: 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: 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 Interconnect\n "
]
|
Please provide a description of the function:def update_configuration(self, timeout=-1):
uri = "{}/configuration".format(self.data["uri"])
return self._helper.update(None, uri=uri, timeout=timeout) | [
"\n Asynchronously applies or re-applies the logical interconnect configuration to all managed interconnects.\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 Interconnect.\n "
]
|
Please provide a description of the function:def get_snmp_configuration(self):
uri = "{}{}".format(self.data["uri"], self.SNMP_CONFIGURATION_PATH)
return self._helper.do_get(uri) | [
"\n Gets the SNMP configuration for a logical interconnect.\n\n Returns:\n dict: SNMP configuration.\n "
]
|
Please provide a description of the function:def update_snmp_configuration(self, configuration, timeout=-1):
data = configuration.copy()
if 'type' not in data:
data['type'] = 'snmp-configuration'
uri = "{}{}".format(self.data["uri"], self.SNMP_CONFIGURATION_PATH)
return self._helper.update(data, uri=uri, timeout=timeout) | [
"\n Updates the SNMP configuration of a logical interconnect. Changes to the SNMP configuration are asynchronously\n applied to all managed interconnects.\n\n Args:\n configuration: snmp configuration.\n\n Returns:\n dict: The Logical Interconnect.\n "
]
|
Please provide a description of the function:def get_unassigned_ports(self):
uri = "{}/unassignedPortsForPortMonitor".format(self.data["uri"])
response = self._helper.do_get(uri)
return self._helper.get_members(response) | [
"\n Gets the collection ports from the member interconnects\n which are eligible for assignment to an anlyzer port\n\n Returns:\n dict: Collection of ports\n "
]
|
Please provide a description of the function:def get_port_monitor(self):
uri = "{}{}".format(self.data["uri"], self.PORT_MONITOR_PATH)
return self._helper.do_get(uri) | [
"\n Gets the port monitor configuration of a logical interconnect.\n\n Returns:\n dict: The Logical Interconnect.\n "
]
|
Please provide a description of the function:def update_port_monitor(self, resource, timeout=-1):
data = resource.copy()
if 'type' not in data:
data['type'] = 'port-monitor'
uri = "{}{}".format(self.data["uri"], self.PORT_MONITOR_PATH)
return self._helper.update(data, uri=uri, timeout=timeout) | [
"\n Updates the port monitor configuration of a logical interconnect.\n\n Args:\n resource: Port monitor configuration.\n\n Returns:\n dict: Port monitor configuration.\n "
]
|
Please provide a description of the function:def create_interconnect(self, location_entries, timeout=-1):
return self._helper.create(location_entries, uri=self.locations_uri, timeout=timeout) | [
"\n Creates an interconnect at the given location.\n\n Warning:\n It does not create the LOGICAL INTERCONNECT itself.\n It will fail if no interconnect is already present on the specified position.\n\n Args:\n location_entries (dict): Dictionary with location entries.\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: Created interconnect.\n "
]
|
Please provide a description of the function:def delete_interconnect(self, enclosure_uri, bay, timeout=-1):
uri = "{path}?location=Enclosure:{enclosure_uri},Bay:{bay}".format(path=self.LOCATIONS_PATH,
enclosure_uri=enclosure_uri,
bay=bay)
return self._helper.delete(uri, timeout=timeout) | [
"\n Deletes an interconnect from a location.\n\n Warning:\n This won't delete the LOGICAL INTERCONNECT itself and might cause inconsistency between the enclosure\n and Logical Interconnect Group.\n\n Args:\n enclosure_uri: URI of the Enclosure\n bay: Bay\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: Indicating if the interconnect was successfully deleted.\n "
]
|
Please provide a description of the function:def get_firmware(self):
firmware_uri = self._helper.build_subresource_uri(self.data["uri"], subresource_path=self.FIRMWARE_PATH)
return self._helper.do_get(firmware_uri) | [
"\n Gets the installed firmware for a logical interconnect.\n\n Returns:\n dict: LIFirmware.\n "
]
|
Please provide a description of the function:def install_firmware(self, firmware_information):
firmware_uri = self._helper.build_subresource_uri(self.data["uri"], subresource_path=self.FIRMWARE_PATH)
return self._helper.update(firmware_information, firmware_uri) | [
"\n Installs firmware to a logical interconnect. The three operations that are supported for the firmware\n update are Stage (uploads firmware to the interconnect), Activate (installs firmware on the interconnect),\n and Update (which does a Stage and Activate in a sequential manner).\n\n Args:\n firmware_information: Options to install firmware to a logical interconnect.\n\n Returns:\n dict\n "
]
|
Please provide a description of the function:def get_forwarding_information_base(self, filter=''):
uri = "{}{}".format(self.data["uri"], self.FORWARDING_INFORMATION_PATH)
return self._helper.get_collection(uri, filter=filter) | [
"\n Gets the forwarding information base data for a logical interconnect. A maximum of 100 entries is returned.\n Optional filtering criteria might be specified.\n\n Args:\n filter (list or str):\n Filtering criteria may be specified using supported attributes: interconnectUri, macAddress,\n internalVlan, externalVlan, and supported relation = (Equals). macAddress is 12 hexadecimal digits with\n a colon between each pair of digits (upper case or lower case).\n The default is no filter; all resources are returned.\n\n Returns:\n list: A set of interconnect MAC address entries.\n "
]
|
Please provide a description of the function:def create_forwarding_information_base(self, timeout=-1):
uri = "{}{}".format(self.data["uri"], self.FORWARDING_INFORMATION_PATH)
return self._helper.do_post(uri, None, timeout, None) | [
"\n Generates the forwarding information base dump file for a logical interconnect.\n\n Args:\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in\n OneView, just stops waiting for its completion.\n\n Returns: Interconnect Forwarding Information Base DataInfo.\n "
]
|
Please provide a description of the function:def get_qos_aggregated_configuration(self):
uri = "{}{}".format(self.data["uri"], self.QOS_AGGREGATED_CONFIGURATION)
return self._helper.do_get(uri) | [
"\n Gets the QoS aggregated configuration for the logical interconnect.\n\n Returns:\n dict: QoS Configuration.\n "
]
|
Please provide a description of the function:def update_qos_aggregated_configuration(self, qos_configuration, timeout=-1):
uri = "{}{}".format(self.data["uri"], self.QOS_AGGREGATED_CONFIGURATION)
return self._helper.update(qos_configuration, uri=uri, timeout=timeout) | [
"\n Updates the QoS aggregated configuration for the logical interconnect.\n\n Args:\n qos_configuration:\n QOS configuration.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in\n OneView, just stops waiting for its completion.\n\n Returns:\n dict: Logical Interconnect.\n "
]
|
Please provide a description of the function:def update_telemetry_configurations(self, configuration, timeout=-1):
telemetry_conf_uri = self._get_telemetry_configuration_uri()
default_values = self._get_default_values(self.SETTINGS_TELEMETRY_CONFIG_DEFAULT_VALUES)
configuration = self._helper.update_resource_fields(configuration, default_values)
return self._helper.update(configuration, uri=telemetry_conf_uri, timeout=timeout) | [
"\n Updates the telemetry configuration of a logical interconnect. Changes to the telemetry configuration are\n asynchronously applied to all managed interconnects.\n\n Args:\n configuration:\n The telemetry configuration for the logical interconnect.\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in\n OneView, just stops waiting for its completion.\n\n Returns:\n dict: The Logical Interconnect.\n "
]
|
Please provide a description of the function:def get_ethernet_settings(self):
uri = "{}/ethernetSettings".format(self.data["uri"])
return self._helper.do_get(uri) | [
"\n Gets the Ethernet interconnect settings for the Logical Interconnect.\n\n Returns:\n dict: Ethernet Interconnect Settings\n "
]
|
Please provide a description of the function:def download_archive(self, name, file_path):
uri = self.URI + "/archive/" + name
return self._client.download(uri, file_path) | [
"\n Download archived logs of the OS Volume.\n\n Args:\n name: Name of the OS Volume.\n file_path (str): Destination file path.\n\n Returns:\n bool: Indicates if the resource was successfully downloaded.\n "
]
|
Please provide a description of the function:def get_storage(self, id_or_uri):
uri = self.URI + "/{}/storage".format(extract_id_from_uri(id_or_uri))
return self._client.get(uri) | [
"\n Get storage details of an OS Volume.\n\n Args:\n id_or_uri: ID or URI of the OS Volume.\n\n Returns:\n dict: Storage details\n "
]
|
Please provide a description of the function:def get_device_topology(self, id_or_uri):
uri = self._client.build_uri(id_or_uri) + "/deviceTopology"
return self._client.get(uri) | [
"\n Retrieves the topology information for the rack resource specified by ID or URI.\n\n Args:\n id_or_uri: Can be either the resource ID or the resource URI.\n\n Return:\n dict: Device topology.\n "
]
|
Please provide a description of the function:def get_by_name(self, name):
managed_sans = self.get_all()
result = [x for x in managed_sans if x['name'] == name]
resource = result[0] if result else None
if resource:
resource = self.new(self._connection, resource)
return resource | [
"\n Gets a Managed SAN by name.\n\n Args:\n name: Name of the Managed SAN\n\n Returns:\n dict: Managed SAN.\n "
]
|
Please provide a description of the function:def get_endpoints(self, start=0, count=-1, filter='', sort=''):
uri = "{}/endpoints/".format(self.data["uri"])
return self._helper.get_all(start, count, filter=filter, sort=sort, uri=uri) | [
"\n Gets a list of endpoints in a SAN.\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.\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 filter (list or str):\n A general filter/query string to narrow the list of items returned. The\n default is no filter; all resources are returned.\n sort:\n The sort order of the returned data set. By default, the sort order is based\n on create time with the oldest entry first.\n\n Returns:\n list: A list of endpoints.\n "
]
|
Please provide a description of the function:def create_endpoints_csv_file(self, timeout=-1):
uri = "{}/endpoints/".format(self.data["uri"])
return self._helper.do_post(uri, {}, timeout, None) | [
"\n Creates an endpoints CSV file for a SAN.\n\n Args:\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in\n OneView, just stops waiting for its completion.\n\n Returns:\n dict: Endpoint CSV File Response.\n "
]
|
Please provide a description of the function:def create_issues_report(self, timeout=-1):
uri = "{}/issues/".format(self.data["uri"])
return self._helper.create_report(uri, timeout) | [
"\n Creates an unexpected zoning report for a SAN.\n\n Args:\n timeout:\n Timeout in seconds. Wait for task completion by default. The timeout does not abort the operation in\n OneView, just stops waiting for its completion.\n\n Returns:\n list: A list of FCIssueResponse dict.\n "
]
|
Please provide a description of the function:def create(self, resource, id=None, timeout=-1):
if not id:
available_id = self.__get_first_available_id()
uri = '%s/%s' % (self.URI, str(available_id))
else:
uri = '%s/%s' % (self.URI, str(id))
return self._client.create(resource, uri=uri, timeout=timeout) | [
"\n Adds the specified trap forwarding destination.\n The trap destination associated with the specified id will be created if trap destination with that id does not exists.\n The id can only be an integer greater than 0.\n\n Args:\n resource (dict): Object to create.\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: Created resource.\n\n "
]
|
Please provide a description of the function:def __findFirstMissing(self, array, start, end):
if (start > end):
return end + 1
if (start != array[start]):
return start
mid = int((start + end) / 2)
if (array[mid] == mid):
return self.__findFirstMissing(array, mid + 1, end)
return self.__findFirstMissing(array, start, mid) | [
"\n Find the smallest elements missing in a sorted array.\n\n Returns:\n int: The smallest element missing.\n "
]
|
Please provide a description of the function:def __get_first_available_id(self):
traps = self.get_all()
if traps:
used_ids = [0]
for trap in traps:
used_uris = trap.get('uri')
used_ids.append(int(used_uris.split('/')[-1]))
used_ids.sort()
return self.__findFirstMissing(used_ids, 0, len(used_ids) - 1)
else:
return 1 | [
"\n Private method to get the first available id.\n The id can only be an integer greater than 0.\n\n Returns:\n int: The first available id\n "
]
|
Please provide a description of the function:def delete(self, id_or_uri, timeout=-1):
return self._client.delete(id_or_uri, timeout=timeout) | [
"\n Deletes SNMPv1 trap forwarding destination based on {Id}.\n\n Args:\n id_or_uri: dict object to delete\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 bool: Indicates if the resource was successfully deleted.\n\n "
]
|
Please provide a description of the function:def update(self, information, timeout=-1):
return self._client.update(information, timeout=timeout) | [
"\n Edit an IPv4 Range.\n\n Args:\n information (dict): Information 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: Updated IPv4 range.\n "
]
|
Please provide a description of the function:def wait_for_task(self, task, timeout=-1):
self.__wait_task_completion(task, timeout)
task = self.get(task)
logger.debug("Waiting for task. Percentage complete: " + str(task.get('computedPercentComplete')))
logger.debug("Waiting for task. Task state: " + str(task.get('taskState')))
task_response = self.__get_task_response(task)
logger.debug('Task completed')
return task_response | [
"\n Wait for task execution and return associated resource.\n\n Args:\n task: task dict\n timeout: timeout in seconds\n\n Returns:\n Associated resource when creating or updating; True when deleting.\n "
]
|
Please provide a description of the function:def get_completed_task(self, task, timeout=-1):
self.__wait_task_completion(task, timeout)
return self.get(task) | [
"\n Waits until the task is completed and returns the task resource.\n\n Args:\n task: TaskResource\n timeout: Timeout in seconds\n\n Returns:\n dict: TaskResource\n "
]
|
Please provide a description of the function:def is_task_running(self, task, connection_failure_control=None):
if 'uri' in task:
try:
task = self.get(task)
if connection_failure_control:
# Updates last success
connection_failure_control['last_success'] = self.get_current_seconds()
if 'taskState' in task and task['taskState'] in TASK_PENDING_STATES:
return True
except Exception as error:
logger.error('; '.join(str(e) for e in error.args) + ' when waiting for the task: ' + str(task))
if not connection_failure_control:
raise error
if hasattr(error, 'errno') and error.errno in self.CONNECTION_FAILURE_ERROR_NUMBERS:
last_success = connection_failure_control['last_success']
if last_success + self.CONNECTION_FAILURE_TIMEOUT < self.get_current_seconds():
# Timeout reached
raise error
else:
# Return task is running when network instability occurs
return True
else:
raise error
return False | [
"\n Check if a task is running according to: TASK_PENDING_STATES ['New', 'Starting',\n 'Pending', 'Running', 'Suspended', 'Stopping']\n\n Args:\n task (dict): OneView Task resource.\n connection_failure_control (dict):\n A dictionary instance that contains last_success for error tolerance control.\n\n Examples:\n\n >>> connection_failure_control = dict(last_success=int(time.time()))\n >>> while self.is_task_running(task, connection_failure_control):\n >>> pass\n\n Returns:\n True when in TASK_PENDING_STATES; False when not.\n "
]
|
Please provide a description of the function:def get_associated_resource(self, task):
if not task:
raise HPOneViewUnknownType(MSG_INVALID_TASK)
if task['category'] != 'tasks' and task['category'] != 'backups':
# it is an error if type is not in obj, so let the except flow
raise HPOneViewUnknownType(MSG_UNKNOWN_OBJECT_TYPE)
if task['type'] == 'TaskResourceV2':
resource_uri = task['associatedResource']['resourceUri']
if resource_uri and resource_uri.startswith("/rest/appliance/support-dumps/"):
# Specific for support dumps
return task, resource_uri
elif task['type'] == 'BACKUP':
task = self._connection.get(task['taskUri'])
resource_uri = task['uri']
else:
raise HPOneViewInvalidResource(MSG_TASK_TYPE_UNRECONIZED % task['type'])
entity = {}
if resource_uri:
entity = self._connection.get(resource_uri)
return task, entity | [
"\n Retrieve a resource associated with a task.\n\n Args:\n task: task dict\n\n Returns:\n tuple: task (updated), the entity found (dict)\n "
]
|
Please provide a description of the function:def update_config(self, config, timeout=-1):
return self._client.update(config, uri=self.URI + "/config", timeout=timeout) | [
"\n Updates the remote server configuration and the automatic backup schedule for backup.\n\n Args:\n config (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, just stop waiting for its completion.\n\n Returns:\n dict: Backup details.\n\n "
]
|
Please provide a description of the function:def update_remote_archive(self, save_uri, timeout=-1):
return self._client.update_with_zero_body(uri=save_uri, timeout=timeout) | [
"\n Saves a backup of the appliance to a previously-configured remote location.\n\n Args:\n save_uri (dict): The URI for saving the backup to a previously configured location.\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: Backup details.\n\n "
]
|
Please provide a description of the function:def get_ethernet_networks(self):
network_uris = self.data.get('networkUris')
networks = []
if network_uris:
for uri in network_uris:
networks.append(self._ethernet_networks.get_by_uri(uri))
return networks | [
"\n Gets a list of associated ethernet networks of an uplink set.\n\n Args:\n id_or_uri: Can be either the uplink set id or the uplink set uri.\n\n Returns:\n list: Associated ethernet networks.\n "
]
|
Please provide a description of the function:def __set_ethernet_uris(self, ethernet_names, operation="add"):
if not isinstance(ethernet_names, list):
ethernet_names = [ethernet_names]
associated_enets = self.data.get('networkUris', [])
ethernet_uris = []
for i, enet in enumerate(ethernet_names):
enet_exists = self._ethernet_networks.get_by_name(enet)
if enet_exists:
ethernet_uris.append(enet_exists.data['uri'])
else:
raise HPOneViewResourceNotFound("Ethernet: {} does not exist".foramt(enet))
if operation == "remove":
enets_to_update = sorted(list(set(associated_enets) - set(ethernet_uris)))
elif operation == "add":
enets_to_update = sorted(list(set(associated_enets).union(set(ethernet_uris))))
else:
raise ValueError("Value {} is not supported as operation. The supported values are: ['add', 'remove']")
if set(enets_to_update) != set(associated_enets):
updated_network = {'networkUris': enets_to_update}
self.update(updated_network) | [
"Updates network uris."
]
|
Please provide a description of the function:def get_settings(self):
uri = "{}/settings".format(self.data["uri"])
return self._helper.do_get(uri) | [
"\n Gets the interconnect settings for a logical interconnect group.\n\n Returns:\n dict: Interconnect Settings.\n "
]
|
Please provide a description of the function:def upload(self, file_path, timeout=-1):
return self._client.upload(file_path, timeout=timeout) | [
"\n Upload an SPP ISO image file or a hotfix file to the appliance.\n The API supports upload of one hotfix at a time into the system.\n For the successful upload of a hotfix, ensure its original name and extension are not altered.\n\n Args:\n file_path: Full path to firmware.\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: Information about the updated firmware bundle.\n "
]
|
Please provide a description of the function:def get_all(self, category='', count=-1, fields='', filter='', padding=0, query='', reference_uri='',
sort='', start=0, user_query='', view=''):
uri = self.URI + '?'
uri += self.__list_or_str_to_query(category, 'category')
uri += self.__list_or_str_to_query(fields, 'fields')
uri += self.__list_or_str_to_query(filter, 'filter')
uri += self.__list_or_str_to_query(padding, 'padding')
uri += self.__list_or_str_to_query(query, 'query')
uri += self.__list_or_str_to_query(reference_uri, 'referenceUri')
uri += self.__list_or_str_to_query(sort, 'sort')
uri += self.__list_or_str_to_query(user_query, 'userQuery')
uri += self.__list_or_str_to_query(view, 'view')
uri = uri.replace('?&', '?')
return self._client.get_all(start=start, count=count, uri=uri) | [
"\n Gets a list of index resources based on optional sorting and filtering and is constrained by start\n and count parameters.\n\n Args:\n category (str or list):\n Category of resources. Multiple Category parameters are applied with OR condition.\n count (int):\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 fields (str):\n Specifies which fields should be returned in the result set.\n filter (list or str):\n A general filter/query string to narrow the list of items returned. The\n default is no filter; all resources are returned.\n padding (int):\n Number of resources to be returned before the reference URI resource.\n query (str):\n A general query string to narrow the list of resources returned.\n The default is no query - all resources are returned.\n reference_uri (str):\n Load one page of resources, pagination is applied with reference to referenceUri provided.\n sort (str):\n The sort order of the returned data set. By default, the sort order is based\n on create time with the oldest entry first.\n start (int):\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 user_query (str):\n Free text Query string to search the resources. This will match the string in any field that is indexed.\n view (str):\n Return a specific subset of the attributes of the resource or collection, by specifying the name of a predefined view.\n\n Returns:\n list: A list of index resources.\n "
]
|
Please provide a description of the function:def get(self, uri):
uri = self.URI + uri
return self._client.get(uri) | [
"\n Gets an index resource by URI.\n\n Args:\n uri: The resource URI.\n\n Returns:\n dict: The index resource.\n "
]
|
Please provide a description of the function:def get_aggregated(self, attribute, category, child_limit=6, filter='', query='', user_query=''):
uri = self.URI + '/aggregated?'
# Add attribute to query
uri += self.__list_or_str_to_query(attribute, 'attribute')
uri += self.__list_or_str_to_query(category, 'category')
uri += self.__list_or_str_to_query(child_limit, 'childLimit')
uri += self.__list_or_str_to_query(filter, 'filter')
uri += self.__list_or_str_to_query(query, 'query')
uri += self.__list_or_str_to_query(user_query, 'userQuery')
uri = uri.replace('?&', '?')
return self._client.get(uri) | [
"\n Gets a list of index resources based on optional sorting and filtering and is constrained by start\n and count parameters.\n\n Args:\n attribute (list or str):\n Attribute to pass in as query filter.\n category (str):\n Category of resources. Multiple Category parameters are applied with an OR condition.\n child_limit (int):\n Number of resources to be retrieved. Default=6.\n filter (list or str):\n A general filter/query string to narrow the list of items returned. The\n default is no filter; all resources are returned.\n query (str):\n A general query string to narrow the list of resources returned.\n The default is no query - all resources are returned.\n user_query (str):\n Free text Query string to search the resources.\n This will match the string in any field that is indexed.\n\n Returns:\n list: An aggregated list of index resources.\n "
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.