code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
if self.humidity is None: return None humidity = round(float(self.humidity) / 100, 1) return humidity
def state(self)
Main state of sensor.
4.672678
3.875396
1.205729
if self.lightlevel is None: return None lux = round(10 ** (float(self.lightlevel - 1) / 10000), 1) return lux
def state(self)
Main state of sensor.
5.907415
4.898623
1.205934
field = self.deconz_id + '/config' await self._async_set_state_callback(field, data)
async def async_set_config(self, data)
Set config of thermostat. { "mode": "auto", "heatsetpoint": 180, }
10.610222
9.382129
1.130897
if metric_type in (int, float): try: return metric_type(value_str) except ValueError: raise ValueError("Invalid {} metric value: {!r}". format(metric_type.__class__.__name__, value_str)) elif metric_type is six.text_type: # In Pyt...
def _metric_value(value_str, metric_type)
Return a Python-typed metric value from a metric value string.
2.557867
2.497179
1.024303
for item in _PATTERN_UNIT_LIST: pattern, unit = item if pattern.match(metric_name): return unit return None
def _metric_unit_from_name(metric_name)
Return a metric unit string for human consumption, that is inferred from the metric name. If a unit cannot be inferred, `None` is returned.
5.058171
5.839599
0.866185
result = self.session.post('/api/services/metrics/context', body=properties) mc_properties = properties.copy() mc_properties.update(result) new_metrics_context = MetricsContext(self, result['metrics-...
def create(self, properties)
Create a :term:`Metrics Context` resource in the HMC this client is connected to. Parameters: properties (dict): Initial property values. Allowable properties are defined in section 'Request body contents' in section 'Create Metrics Context' in the :term:`HMC API` boo...
4.823184
3.741044
1.289261
# Dictionary of MetricGroupDefinition objects, by metric group name metric_group_definitions = dict() for mg_info in self.properties['metric-group-infos']: mg_name = mg_info['group-name'] mg_def = MetricGroupDefinition( name=mg_name, ...
def _setup_metric_group_definitions(self)
Return the dict of MetricGroupDefinition objects for this metrics context, by processing its 'metric-group-infos' property.
2.473366
2.118781
1.167353
metrics_response = self.manager.session.get(self.uri) return metrics_response
def get_metrics(self)
Retrieve the current metric values for this :term:`Metrics Context` resource from the HMC. The metric values are returned by this method as a string in the `MetricsResponse` format described with the 'Get Metrics' operation in the :term:`HMC API` book. The :class:`~zhmcclient.M...
11.272791
10.472924
1.076375
self.manager.session.delete(self.uri) self.manager._metrics_contexts.remove(self)
def delete(self)
Delete this :term:`Metrics Context` resource. Raises: :exc:`~zhmcclient.HTTPError` :exc:`~zhmcclient.ParseError` :exc:`~zhmcclient.AuthError` :exc:`~zhmcclient.ConnectionError`
12.099667
7.879065
1.535673
mg_defs = self._metrics_context.metric_group_definitions metric_group_name = None resource_uri = None dt_timestamp = None object_values = None metric_group_values = list() state = 0 for mr_line in self._metrics_response_str.splitlines(): ...
def _setup_metric_group_values(self)
Return the list of MetricGroupValues objects for this metrics response, by processing its metrics response string. The lines in the metrics response string are:: MetricsResponse: MetricsGroup{0,*} <emptyline> a third empty line at the end Metr...
4.208942
3.756891
1.120326
if self._resource is not None: return self._resource resource_class = self.metric_group_definition.resource_class resource_uri = self.resource_uri if resource_class == 'cpc': filter_args = {'object-uri': resource_uri} resource = self.client....
def resource(self)
:class:`~zhmcclient.BaseResource`: The Python resource object of the resource these metric values apply to. Raises: :exc:`~zhmcclient.NotFound`: No resource found for this URI in the management scope of the HMC.
1.909284
1.764249
1.082208
assert not self._free # free pool is empty expand_end = self._expand_start + self._expand_len if expand_end > self._range_end: # This happens if the size of the value range is not a multiple # of the expansion chunk size. expand_end = self._range_end...
def _expand(self)
Expand the free pool, if possible. If out of capacity w.r.t. the defined ID value range, ValueError is raised.
4.805634
3.670351
1.309312
if not self._free: self._expand() id = self._free.pop() self._used.add(id) return id
def alloc(self)
Allocate an ID value and return it. Raises: ValueError: Out of capacity in ID pool.
4.866313
4.637119
1.049426
result = self.session.post(self.partition.uri + '/nics', body=properties) # There should not be overlaps, but just in case there are, the # returned props should overwrite the input props: props = copy.deepcopy(properties) props.update(...
def create(self, properties)
Create and configure a NIC in this Partition. The NIC must be backed by an adapter port (on an OSA, ROCE, or Hipersockets adapter). The way the backing adapter port is specified in the "properties" parameter of this method depends on the adapter type, as follows: * For OSA and...
5.236603
4.91001
1.066516
self.manager.session.delete(self._uri) self.manager._name_uri_cache.delete( self.properties.get(self.manager._name_prop, None))
def delete(self)
Delete this NIC. Authorization requirements: * Object-access permission to the Partition containing this HBA. * Task permission to the "Partition Details" task. Raises: :exc:`~zhmcclient.HTTPError` :exc:`~zhmcclient.ParseError` :exc:`~zhmcclient.AuthErro...
7.726585
7.401349
1.043943
self.manager.session.post(self.uri, body=properties) is_rename = self.manager._name_prop in properties if is_rename: # Delete the old name from the cache self.manager._name_uri_cache.delete(self.name) self.properties.update(copy.deepcopy(properties)) ...
def update_properties(self, properties)
Update writeable properties of this NIC. Authorization requirements: * Object-access permission to the Partition containing this NIC. * Object-access permission to the backing Adapter for this NIC. * Task permission to the "Partition Details" task. Parameters: prope...
3.772585
3.971371
0.949945
if self._attached_partition is None: part_mgr = self.manager.storage_group.manager.cpc.partitions part = part_mgr.resource_object(self.get_property('partition-uri')) self._attached_partition = part return self._attached_partition
def attached_partition(self)
:class:`~zhmcclient.Partition`: The partition to which this virtual storage resource is attached. The returned partition object has only a minimal set of properties set ('object-id', 'object-uri', 'class', 'parent'). Note that a virtual storage resource is always attached to a partitio...
5.476174
8.311606
0.658859
if self._adapter_port is None: port_uri = self.get_property('adapter-port-uri') assert port_uri is not None m = re.match(r'^(/api/adapters/[^/]+)/.*', port_uri) adapter_uri = m.group(1) adapter_mgr = self.manager.storage_group.manager.cpc.adap...
def adapter_port(self)
:class:`~zhmcclient.Port`: The storage adapter port associated with this virtual storage resource, once discovery has determined which port to use for this virtual storage resource. This applies to both, FCP and FICON/ECKD typed storage groups. The returned adapter port object has only...
3.518645
3.677686
0.956755
self.auto_invalidate() try: return self._uris[name] except KeyError: self.refresh() try: return self._uris[name] except KeyError: raise NotFound({self._manager._name_prop: name}, self._manager)
def get(self, name)
Get the resource URI for a specified resource name. If an entry for the specified resource name does not exist in the Name-URI cache, the cache is refreshed from the HMC with all resources of the manager holding this cache. If an entry for the specified resource name still does not exi...
5.501408
4.98178
1.104306
current = datetime.now() if current > self._invalidated + timedelta(seconds=self._timetolive): self.invalidate()
def auto_invalidate(self)
Invalidate the cache if the current time is past the time to live.
6.850448
4.46748
1.533403
self.invalidate() full = not self._manager._list_has_name res_list = self._manager.list(full_properties=full) self.update_from(res_list)
def refresh(self)
Refresh the Name-URI cache from the HMC. This is done by invalidating the cache, listing the resources of this manager from the HMC, and populating the cache with that information.
12.6457
9.531483
1.32673
for res in res_list: # We access the properties dictionary, in order to make sure # we don't drive additional HMC interactions. name = res.properties.get(self._manager._name_prop, None) uri = res.properties.get(self._manager._uri_prop, None) s...
def update_from(self, res_list)
Update the Name-URI cache from the provided resource list. This is done by going through the resource list and updating any cache entries for non-empty resource names in that list. Other cache entries remain unchanged.
6.767976
6.241582
1.084337
if filter_args is None or len(filter_args) != 1 or \ self._oid_prop not in filter_args: return None oid_match = filter_args[self._oid_prop] if not isinstance(oid_match, six.string_types) or \ not re.match(r'^[a-zA-Z0-9_\-]+$', oid_match): ...
def _try_optimized_lookup(self, filter_args)
Try to optimize the lookup by checking whether the filter arguments specify the property that is used as the last segment in the resource URI, with a plain string as match value (i.e. not using regular expression matching). If so, the lookup is performed by constructing the resource URI...
3.929511
3.254112
1.207552
query_parms = [] # query parameter strings client_filter_args = {} if filter_args is not None: for prop_name in filter_args: prop_match = filter_args[prop_name] if prop_name in self._query_props: self._append_query_parms(...
def _divide_filter_args(self, filter_args)
Divide the filter arguments into filter query parameters for filtering on the server side, and the remaining client-side filters. Parameters: filter_args (dict): Filter arguments that narrow the list of returned resources to those that match the specified filter argum...
2.673592
2.428281
1.101022
if filter_args is not None: for prop_name in filter_args: prop_match = filter_args[prop_name] if not self._matches_prop(obj, prop_name, prop_match): return False return True
def _matches_filters(self, obj, filter_args)
Return a boolean indicating whether a resource object matches a set of filter arguments. This is used for client-side filtering. Depending on the properties specified in the filter arguments, this method retrieves the resource properties from the HMC. Parameters: obj...
2.554624
2.929257
0.872106
if isinstance(prop_match, (list, tuple)): # List items are logically ORed, so one matching item suffices. for pm in prop_match: if self._matches_prop(obj, prop_name, pm): return True else: # Some lists of resources do not h...
def _matches_prop(self, obj, prop_name, prop_match)
Return a boolean indicating whether a resource object matches with a single property against a property match value. This is used for client-side filtering. Depending on the specified property, this method retrieves the resource properties from the HMC. Parameters: o...
6.283506
5.895142
1.065879
if uri_or_oid.startswith('/api/'): assert uri_or_oid[-1] != '/' uri = uri_or_oid oid = uri.split('/')[-1] else: assert '/' not in uri_or_oid oid = uri_or_oid uri = '{}/{}'.format(self._base_uri, oid) res_props = { ...
def resource_object(self, uri_or_oid, props=None)
Return a minimalistic Python resource object for this resource class, that is scoped to this manager. This method is an internal helper function and is not normally called by users. The returned resource object will have the following minimal set of properties set automatically...
2.527852
2.479708
1.019415
if len(filter_args) == 1 and self._name_prop in filter_args: try: obj = self.find_by_name(filter_args[self._name_prop]) except NotFound: return [] return [obj] else: obj_list = self.list(filter_args=filter_args) ...
def findall(self, **filter_args)
Find zero or more resources in scope of this manager, by matching resource properties against the specified filter arguments, and return a list of their Python resource objects (e.g. for CPCs, a list of :class:`~zhmcclient.Cpc` objects is returned). Any resource property may be specifie...
2.930368
3.858131
0.759531
obj_list = self.findall(**filter_args) num_objs = len(obj_list) if num_objs == 0: raise NotFound(filter_args, self) elif num_objs > 1: raise NoUniqueMatch(filter_args, self, obj_list) else: return obj_list[0]
def find(self, **filter_args)
Find exactly one resource in scope of this manager, by matching resource properties against the specified filter arguments, and return its Python resource object (e.g. for a CPC, a :class:`~zhmcclient.Cpc` object is returned). Any resource property may be specified in a filter argument....
2.605178
3.35549
0.776393
uri = self._name_uri_cache.get(name) obj = self.resource_class( manager=self, uri=uri, name=name, properties=None) return obj
def find_by_name(self, name)
Find a resource by name (i.e. value of its 'name' resource property) and return its Python resource object (e.g. for a CPC, a :class:`~zhmcclient.Cpc` object is returned). This method performs an optimized lookup that uses a name-to-URI mapping cached in this manager object. Th...
5.478735
7.350366
0.745369
od_saved = OrderedDict.__repr__ try: OrderedDict.__repr__ = dict.__repr__ yield finally: OrderedDict.__repr__ = od_saved
def pprint_for_ordereddict()
Context manager that causes pprint() to print OrderedDict objects as nicely as standard Python dictionary objects.
5.395082
4.571994
1.180028
for child_attr in resources: child_list = resources[child_attr] self._process_child_list(self, child_attr, child_list)
def add_resources(self, resources)
Add faked child resources to this resource, from the provided resource definitions. Duplicate resource names in the same scope are not permitted. Although this method is typically used to initially load the faked HMC with resource state just once, it can be invoked multiple times ...
5.444254
8.692438
0.626321
resource = self.resource_class(self, properties) self._resources[resource.oid] = resource self._hmc.all_resources[resource.uri] = resource return resource
def add(self, properties)
Add a faked resource to this manager. For URI-based lookup, the resource is also added to the faked HMC. Parameters: properties (dict): Resource properties. If the URI property (e.g. 'object-uri') or the object ID property (e.g. 'object-id') are not specified, they ...
5.800816
5.836091
0.993956
uri = self._resources[oid].uri del self._resources[oid] del self._hmc.all_resources[uri]
def remove(self, oid)
Remove a faked resource from this manager. Parameters: oid (string): The object ID of the resource (e.g. value of the 'object-uri' property).
9.887001
10.787163
0.916553
res = list() for oid in self._resources: resource = self._resources[oid] if self._matches_filters(resource, filter_args): res.append(resource) return res
def list(self, filter_args=None)
List the faked resources of this manager. Parameters: filter_args (dict): Filter arguments. `None` causes no filtering to happen. See :meth:`~zhmcclient.BaseManager.list()` for details. Returns: list of FakedBaseResource: The faked resource objects of this ...
3.860736
5.662395
0.68182
if self._console is None: self._console = self.list()[0] return self._console
def console(self)
The faked Console representing the faked HMC (an object of :class:`~zhmcclient_mock.FakedConsole`). The object is cached.
5.609549
5.953728
0.942191
new_hba = super(FakedHbaManager, self).add(properties) partition = self.parent # Reflect the new NIC in the partition assert 'hba-uris' in partition.properties partition.properties['hba-uris'].append(new_hba.uri) # Create a default device-number if not specifi...
def add(self, properties)
Add a faked HBA resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across all instances of this resource type, if not spe...
3.297988
2.884375
1.143398
hba = self.lookup_by_oid(oid) partition = self.parent devno = hba.properties.get('device-number', None) if devno: partition.devno_free_if_allocated(devno) wwpn = hba.properties.get('wwpn', None) if wwpn: partition.wwpn_free_if_allocated(ww...
def remove(self, oid)
Remove a faked HBA resource. This method also updates the 'hba-uris' property in the parent Partition resource, by removing the URI for the faked HBA resource. Parameters: oid (string): The object ID of the faked HBA resource.
3.50115
3.121192
1.121735
new_nic = super(FakedNicManager, self).add(properties) partition = self.parent # For OSA-backed NICs, reflect the new NIC in the virtual switch if 'virtual-switch-uri' in new_nic.properties: vswitch_uri = new_nic.properties['virtual-switch-uri'] # Even ...
def add(self, properties)
Add a faked NIC resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across all instances of this resource type, if not spe...
4.139891
3.258517
1.270483
nic = self.lookup_by_oid(oid) partition = self.parent devno = nic.properties.get('device-number', None) if devno: partition.devno_free_if_allocated(devno) assert 'nic-uris' in partition.properties nic_uris = partition.properties['nic-uris'] ni...
def remove(self, oid)
Remove a faked NIC resource. This method also updates the 'nic-uris' property in the parent Partition resource, by removing the URI for the faked NIC resource. Parameters: oid (string): The object ID of the faked NIC resource.
5.669331
4.541828
1.248249
devno_int = self._devno_pool.alloc() devno = "{:04X}".format(devno_int) return devno
def devno_alloc(self)
Allocates a device number unique to this partition, in the range of 0x8000 to 0xFFFF. Returns: string: The device number as four hexadecimal digits in upper case. Raises: ValueError: No more device numbers available in that range.
5.099126
5.182414
0.983929
devno_int = int(devno, 16) self._devno_pool.free(devno_int)
def devno_free(self, devno)
Free a device number allocated with :meth:`devno_alloc`. The device number must be allocated. Parameters: devno (string): The device number as four hexadecimal digits. Raises: ValueError: Device number not in pool range or not currently allocated.
4.295485
5.250628
0.81809
devno_int = int(devno, 16) self._devno_pool.free_if_allocated(devno_int)
def devno_free_if_allocated(self, devno)
Free a device number allocated with :meth:`devno_alloc`. If the device number is not currently allocated or not in the pool range, nothing happens. Parameters: devno (string): The device number as four hexadecimal digits.
3.793463
4.86913
0.779084
wwpn_int = self._wwpn_pool.alloc() wwpn = "AFFEAFFE0000" + "{:04X}".format(wwpn_int) return wwpn
def wwpn_alloc(self)
Allocates a WWPN unique to this partition, in the range of 0xAFFEAFFE00008000 to 0xAFFEAFFE0000FFFF. Returns: string: The WWPN as 16 hexadecimal digits in upper case. Raises: ValueError: No more WWPNs available in that range.
7.806667
5.652688
1.381054
wwpn_int = int(wwpn[-4:], 16) self._wwpn_pool.free(wwpn_int)
def wwpn_free(self, wwpn)
Free a WWPN allocated with :meth:`wwpn_alloc`. The WWPN must be allocated. Parameters: WWPN (string): The WWPN as 16 hexadecimal digits. Raises: ValueError: WWPN not in pool range or not currently allocated.
4.790776
6.382482
0.750613
wwpn_int = int(wwpn[-4:], 16) self._wwpn_pool.free_if_allocated(wwpn_int)
def wwpn_free_if_allocated(self, wwpn)
Free a WWPN allocated with :meth:`wwpn_alloc`. If the WWPN is not currently allocated or not in the pool range, nothing happens. Parameters: WWPN (string): The WWPN as 16 hexadecimal digits.
4.51527
5.989615
0.75385
new_port = super(FakedPortManager, self).add(properties) adapter = self.parent if 'network-port-uris' in adapter.properties: adapter.properties['network-port-uris'].append(new_port.uri) if 'storage-port-uris' in adapter.properties: adapter.properties['sto...
def add(self, properties)
Add a faked Port resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across all instances of this resource type, if not sp...
3.448973
2.12442
1.623489
port = self.lookup_by_oid(oid) adapter = self.parent if 'network-port-uris' in adapter.properties: port_uris = adapter.properties['network-port-uris'] port_uris.remove(port.uri) if 'storage-port-uris' in adapter.properties: port_uris = adapter...
def remove(self, oid)
Remove a faked Port resource. This method also updates the 'network-port-uris' or 'storage-port-uris' property in the parent Adapter resource, by removing the URI for the faked Port resource. Parameters: oid (string): The object ID of the faked Port resource.
3.297883
2.107973
1.564481
new_vf = super(FakedVirtualFunctionManager, self).add(properties) partition = self.parent assert 'virtual-function-uris' in partition.properties partition.properties['virtual-function-uris'].append(new_vf.uri) if 'device-number' not in new_vf.properties: devn...
def add(self, properties)
Add a faked Virtual Function resource. Parameters: properties (dict): Resource properties. Special handling and requirements for certain properties: * 'element-id' will be auto-generated with a unique value across all instances of this resource typ...
4.89607
3.37172
1.452098
virtual_function = self.lookup_by_oid(oid) partition = self.parent devno = virtual_function.properties.get('device-number', None) if devno: partition.devno_free_if_allocated(devno) assert 'virtual-function-uris' in partition.properties vf_uris = parti...
def remove(self, oid)
Remove a faked Virtual Function resource. This method also updates the 'virtual-function-uris' property in the parent Partition resource, by removing the URI for the faked Virtual Function resource. Parameters: oid (string): The object ID of the faked Virtual Fun...
5.674128
4.24587
1.336388
assert isinstance(definition, FakedMetricGroupDefinition) group_name = definition.name if group_name in self._metric_group_defs: raise ValueError("A metric group definition with this name " "already exists: {}".format(group_name)) self._m...
def add_metric_group_definition(self, definition)
Add a faked metric group definition. The definition will be used: * For later addition of faked metrics responses. * For returning the metric-group-info objects in the response of the Create Metrics Context operations. For defined metric groups, see chapter "Metric groups" i...
2.368765
2.294889
1.032191
if group_name not in self._metric_group_defs: raise ValueError("A metric group definition with this name does " "not exist: {}".format(group_name)) return self._metric_group_defs[group_name]
def get_metric_group_definition(self, group_name)
Get a faked metric group definition by its group name. Parameters: group_name (:term:`string`): Name of the metric group. Returns: :class:~zhmcclient.FakedMetricGroupDefinition`: Definition of the metric group. Raises: ValueError: A metric group de...
2.566793
2.604506
0.98552
assert isinstance(values, FakedMetricObjectValues) group_name = values.group_name if group_name not in self._metric_values: self._metric_values[group_name] = [] self._metric_values[group_name].append(values) if group_name not in self._metric_value_names: ...
def add_metric_values(self, values)
Add one set of faked metric values for a particular resource to the metrics response for a particular metric group, for later retrieval. For defined metric groups, see chapter "Metric groups" in the :term:`HMC API` book. Parameters: values (:class:`~zhmclient.FakedMetricObje...
2.53389
2.349321
1.078563
if group_name not in self._metric_values: raise ValueError("Metric values for this group name do not " "exist: {}".format(group_name)) return self._metric_values[group_name]
def get_metric_values(self, group_name)
Get the faked metric values for a metric group, by its metric group name. The result includes all metric object values added earlier for that metric group name, using :meth:`~zhmcclient.FakedMetricsContextManager.add_metric_object_values` i.e. the metric values for all resources...
2.943019
3.248399
0.905991
group_names = self.properties.get('metric-groups', None) if not group_names: group_names = self.manager.get_metric_group_definition_names() mg_defs = [] for group_name in group_names: try: mg_def = self.manager.get_metric_group_definition(...
def get_metric_group_definitions(self)
Get the faked metric group definitions for this context object that are to be returned from its create operation. If a 'metric-groups' property had been specified for this context, only those faked metric group definitions of its manager object that are in that list, are included in the...
2.651186
2.623598
1.010515
mg_defs = self.get_metric_group_definitions() mg_infos = [] for mg_def in mg_defs: metric_infos = [] for metric_name, metric_type in mg_def.types: metric_infos.append({ 'metric-name': metric_name, 'metric-ty...
def get_metric_group_infos(self)
Get the faked metric group definitions for this context object that are to be returned from its create operation, in the format needed for the "Create Metrics Context" operation response. Returns: "metric-group-infos" JSON object as described for the "Create Metrics Conte...
2.027251
2.024095
1.001559
group_names = self.properties.get('metric-groups', None) if not group_names: group_names = self.manager.get_metric_values_group_names() ret = [] for group_name in group_names: try: mo_val = self.manager.get_metric_values(group_name) ...
def get_metric_values(self)
Get the faked metrics, for all metric groups and all resources that have been prepared on the manager object of this context object. Returns: iterable of tuple (group_name, iterable of values): The faked metrics, in the order they had been added, where: group_name (s...
3.328517
3.191854
1.042816
mv_list = self.get_metric_values() resp_lines = [] for mv in mv_list: group_name = mv[0] resp_lines.append('"{}"'.format(group_name)) mo_vals = mv[1] for mo_val in mo_vals: resp_lines.append('"{}"'.format(mo_val.resource_ur...
def get_metric_values_response(self)
Get the faked metrics, for all metric groups and all resources that have been prepared on the manager object of this context object, as a string in the format needed for the "Get Metrics" operation response. Returns: "MetricsResponse" string as described for the "Get Metrics" ...
2.400593
2.412192
0.995191
result = self.session.post(self.console.uri + '/user-roles', body=properties) # There should not be overlaps, but just in case there are, the # returned props should overwrite the input props: props = copy.deepcopy(properties) props.upd...
def create(self, properties)
Create a new (user-defined) User Role in this HMC. Authorization requirements: * Task permission to the "Manage User Roles" task. Parameters: properties (dict): Initial property values. Allowable properties are defined in section 'Request body contents' in s...
5.116864
4.176909
1.225036
# noqa: E501 if isinstance(permitted_object, BaseResource): perm_obj = permitted_object.uri perm_type = 'object' elif isinstance(permitted_object, six.string_types): perm_obj = permitted_object perm_type = 'object-class' else: ...
def add_permission(self, permitted_object, include_members=False, view_only=True)
Add permission for the specified permitted object(s) to this User Role, thereby granting that permission to all users that have this User Role. The granted permission depends on the resource class of the permitted object(s): * For Task resources, the granted permission is task permissi...
2.34645
2.360478
0.994057
volreq_obj = copy.deepcopy(properties) volreq_obj['operation'] = 'create' body = { 'storage-volumes': [volreq_obj], } if email_to_addresses: body['email-to-addresses'] = email_to_addresses if email_cc_addresses: body['...
def create(self, properties, email_to_addresses=None, email_cc_addresses=None, email_insert=None)
Create a :term:`storage volume` in this storage group on the HMC, and optionally send emails to storage administrators requesting creation of the storage volume on the storage subsystem and setup of any resources related to the storage volume (e.g. LUN mask definition on the storage subs...
2.91155
2.55497
1.139563
m = re.match(r'^/api/storage-groups/[^/]*/storage-volumes/([^/]*)$', self.uri) oid = m.group(1) return oid
def oid(self)
:term `unicode string`: The object ID of this storage volume. The object ID is unique within the parent storage group. Note that for storage volumes, the 'name' property is not unique and therefore cannot be used to identify a storage volume. Therefore, storage volumes provide easy acce...
7.14037
3.825582
1.866479
volreq_obj = { 'operation': 'delete', 'element-uri': self.uri, } body = { 'storage-volumes': [ volreq_obj ], } if email_to_addresses: body['email-to-addresses'] = email_to_addresses ...
def delete(self, email_to_addresses=None, email_cc_addresses=None, email_insert=None)
Delete this storage volume on the HMC, and optionally send emails to storage administrators requesting deletion of the storage volume on the storage subsystem and cleanup of any resources related to the storage volume (e.g. LUN mask definitions on a storage subsystem). This method perfo...
2.671577
2.311996
1.155528
volreq_obj = copy.deepcopy(properties) volreq_obj['operation'] = 'modify' volreq_obj['element-uri'] = self.uri body = { 'storage-volumes': [volreq_obj], } if email_to_addresses: body['email-to-addresses'] = email_to_addresses ...
def update_properties(self, properties, email_to_addresses=None, email_cc_addresses=None, email_insert=None)
Update writeable properties of this storage volume on the HMC, and optionally send emails to storage administrators requesting modification of the storage volume on the storage subsystem and of any resources related to the storage volume. This method performs the "Modify Storage Group P...
2.374793
2.007332
1.18306
# The operation requires exactly 2 characters in lower case unit_address_2 = format(int(unit_address, 16), '02x') body = { 'control-unit-uri': control_unit.uri, 'unit-address': unit_address_2, } self.manager.session.post( self.uri + ...
def indicate_fulfillment_ficon(self, control_unit, unit_address)
TODO: Add ControlUnit objects etc for FICON support. Indicate completion of :term:`fulfillment` for this ECKD (=FICON) storage volume and provide identifying information (control unit and unit address) about the actual storage volume on the storage subsystem. Manually indicatin...
6.003973
3.843163
1.562248
# The operation requires exactly 16 characters in lower case wwpn_16 = format(int(wwpn, 16), '016x') lun_16 = format(int(lun, 16), '016x') body = { 'world-wide-port-name': wwpn_16, 'logical-unit-number': lun_16, 'adapter-port-uri': host_port...
def indicate_fulfillment_fcp(self, wwpn, lun, host_port)
Indicate completion of :term:`fulfillment` for this FCP storage volume and provide identifying information (WWPN and LUN) about the actual storage volume on the storage subsystem. Manually indicating fulfillment is required for storage volumes that will be used as boot devices for a par...
3.696711
2.932872
1.260441
return "classname={!r}; read_timeout={!r}; read_retries={!r}; " \ "message={!r};". \ format(self.__class__.__name__, self.read_timeout, self.read_retries, self.args[0])
def str_def(self)
:term:`string`: The exception as a string in a Python definition-style format, e.g. for parsing by scripts: .. code-block:: text classname={}; read_timeout={}; read_retries={}; message={};
5.690309
2.745052
2.072933
return "classname={!r}; connect_retries={!r}; message={!r};". \ format(self.__class__.__name__, self.connect_retries, self.args[0])
def str_def(self)
:term:`string`: The exception as a string in a Python definition-style format, e.g. for parsing by scripts: .. code-block:: text classname={}; connect_retries={}; message={};
9.528188
3.336901
2.8554
return "classname={!r}; line={!r}; column={!r}; message={!r};". \ format(self.__class__.__name__, self.line, self.column, self.args[0])
def str_def(self)
:term:`string`: The exception as a string in a Python definition-style format, e.g. for parsing by scripts: .. code-block:: text classname={}; line={}; column={}; message={};
5.256377
2.901951
1.811325
return "classname={!r}; min_api_version={!r}; api_version={!r}; " \ "message={!r};". \ format(self.__class__.__name__, self.min_api_version, self.api_version, self.args[0])
def str_def(self)
:term:`string`: The exception as a string in a Python definition-style format, e.g. for parsing by scripts: .. code-block:: text classname={}; min_api_version={}; api_version={}; message={};
4.868738
2.498488
1.948673
return "classname={!r}; operation_timeout={!r}; message={!r};". \ format(self.__class__.__name__, self.operation_timeout, self.args[0])
def str_def(self)
:term:`string`: The exception as a string in a Python definition-style format, e.g. for parsing by scripts: .. code-block:: text classname={}; operation_timeout={}; message={};
8.940027
3.448732
2.592265
body = {'adapter-port-uri': port.uri} self.manager.session.post( self._uri + '/operations/reassign-storage-adapter-port', body=body) self.properties.update(body)
def reassign_port(self, port)
Reassign this HBA to a new underlying :term:`FCP port`. This method performs the HMC operation "Reassign Storage Adapter Port". Authorization requirements: * Object-access permission to the Partition containing this HBA. * Object-access permission to the Adapter with the new Port. ...
8.00409
5.395326
1.483523
resource_obj_list = [] uris = self.partition.get_property('virtual-function-uris') if uris: for uri in uris: resource_obj = self.resource_class( manager=self, uri=uri, name=None, ...
def list(self, full_properties=False, filter_args=None)
List the Virtual Functions of this Partition. Authorization requirements: * Object-access permission to this Partition. Parameters: full_properties (bool): Controls whether the full set of resource properties should be retrieved, vs. only the short set as re...
3.309702
2.963085
1.116978
result = self.manager.session.get( self.uri + '/operations/get-connected-vnics') nic_uris = result['connected-vnic-uris'] nic_list = [] parts = {} # Key: Partition ID; Value: Partition object for nic_uri in nic_uris: m = re.match(r"^/api/partitio...
def get_connected_nics(self)
List the :term:`NICs <NIC>` connected to this Virtual Switch. This method performs the "Get Connected VNICs of a Virtual Switch" HMC operation. Authorization requirements: * Object-access permission to this CPC. * Object-access permission to the backing Adapter of this Virtual...
3.262568
2.604918
1.252465
uris_prop = self.adapter.port_uris_prop if not uris_prop: # Adapter does not have any ports return [] uris = self.adapter.get_property(uris_prop) assert uris is not None # TODO: Remove the following circumvention once fixed. # The follow...
def list(self, full_properties=False, filter_args=None)
List the Ports of this Adapter. If the adapter does not have any ports, an empty list is returned. Authorization requirements: * Object-access permission to this Adapter. Parameters: full_properties (bool): Controls whether the full set of resource properties s...
4.575094
3.936551
1.162209
body = { 'user-role-uri': user_role.uri } self.manager.session.post( self.uri + '/operations/add-user-role', body=body)
def add_user_role(self, user_role)
Add the specified User Role to this User. This User must not be a system-defined or pattern-based user. Authorization requirements: * Task permission to the "Manage Users" task to modify a standard user or the "Manage User Templates" task to modify a template user. Paramete...
5.173254
4.393709
1.177423
body = { 'user-role-uri': user_role.uri } self.manager.session.post( self.uri + '/operations/remove-user-role', body=body)
def remove_user_role(self, user_role)
Remove the specified User Role from this User. This User must not be a system-defined or pattern-based user. Authorization requirements: * Task permission to the "Manage Users" task to modify a standard user or the "Manage User Templates" task to modify a template user. Par...
4.736624
4.153422
1.140415
try: return self._urihandler.get(self._hmc, uri, logon_required) except HTTPError as exc: raise zhmcclient.HTTPError(exc.response()) except ConnectionError as exc: raise zhmcclient.ConnectionError(exc.message, None)
def get(self, uri, logon_required=True)
Perform the HTTP GET method against the resource identified by a URI, on the faked HMC. Parameters: uri (:term:`string`): Relative URI path of the resource, e.g. "/api/session". This URI is relative to the base URL of the session (see the :attr:`~zhmcclien...
4.611453
4.690133
0.983224
try: return self._urihandler.post(self._hmc, uri, body, logon_required, wait_for_completion) except HTTPError as exc: raise zhmcclient.HTTPError(exc.response()) except ConnectionError as exc: raise zhmcclient.C...
def post(self, uri, body=None, logon_required=True, wait_for_completion=True, operation_timeout=None)
Perform the HTTP POST method against the resource identified by a URI, using a provided request body, on the faked HMC. HMC operations using HTTP POST are either synchronous or asynchronous. Asynchronous operations return the URI of an asynchronously executing job that can be queried fo...
4.077782
4.367527
0.933659
while True: with self._handover_cond: # Wait until MessageListener has a new notification while len(self._handover_dict) == 0: self._handover_cond.wait(self._wait_timeout) if self._handover_dict['headers'] is None: ...
def notifications(self)
Generator method that yields all HMC notifications (= JMS messages) received by this notification receiver. Example:: receiver = zhmcclient.NotificationReceiver(topic, hmc, userid, password) for headers, message in receiver...
3.634767
3.343061
1.087257
with self._handover_cond: # Wait until receiver has processed the previous notification while len(self._handover_dict) > 0: self._handover_cond.wait(self._wait_timeout) # Indicate to receiver that there is a termination notification sel...
def on_disconnected(self)
Event method that gets called when the JMS session has been disconnected. It hands over a termination notification (headers and message are None).
5.95108
4.274231
1.392316
with self._handover_cond: # Wait until receiver has processed the previous notification while len(self._handover_dict) > 0: self._handover_cond.wait(self._wait_timeout) # Indicate to receiver that there is a new notification self._hando...
def on_message(self, headers, message)
Event method that gets called when this listener has received a JMS message (representing an HMC notification). Parameters: headers (dict): JMS message headers, as described for `headers` tuple item returned by the :meth:`~zhmcclient.NotificationReceiver.notifications...
4.161813
4.035295
1.031353
uri = self._base_uri # There is only one console object. if full_properties: props = self.session.get(uri) else: # Note: The Console resource's Object ID is not part of its URI. props = { self._uri_prop: uri, } res...
def list(self, full_properties=True, filter_args=None)
List the (one) :term:`Console` representing the HMC this client is connected to. Authorization requirements: * None Parameters: full_properties (bool): Controls whether the full set of resource properties should be retrieved, vs. only a short set con...
5.104106
4.512986
1.130982
# We do here some lazy loading. if not self._storage_groups: self._storage_groups = StorageGroupManager(self) return self._storage_groups
def storage_groups(self)
:class:`~zhmcclient.StorageGroupManager`: Manager object for the Storage Groups in scope of this Console.
5.786421
4.849194
1.193275
# We do here some lazy loading. if not self._users: self._users = UserManager(self) return self._users
def users(self)
:class:`~zhmcclient.UserManager`: Access to the :term:`Users <User>` in this Console.
8.514685
6.570387
1.295918
# We do here some lazy loading. if not self._user_roles: self._user_roles = UserRoleManager(self) return self._user_roles
def user_roles(self)
:class:`~zhmcclient.UserRoleManager`: Access to the :term:`User Roles <User Role>` in this Console.
5.937143
4.778646
1.242432
# We do here some lazy loading. if not self._user_patterns: self._user_patterns = UserPatternManager(self) return self._user_patterns
def user_patterns(self)
:class:`~zhmcclient.UserPatternManager`: Access to the :term:`User Patterns <User Pattern>` in this Console.
6.087473
4.848991
1.25541
# We do here some lazy loading. if not self._password_rules: self._password_rules = PasswordRuleManager(self) return self._password_rules
def password_rules(self)
:class:`~zhmcclient.PasswordRuleManager`: Access to the :term:`Password Rules <Password Rule>` in this Console.
6.44249
4.930369
1.306695
# We do here some lazy loading. if not self._tasks: self._tasks = TaskManager(self) return self._tasks
def tasks(self)
:class:`~zhmcclient.TaskManager`: Access to the :term:`Tasks <Task>` in this Console.
8.397778
6.763185
1.24169
# We do here some lazy loading. if not self._ldap_server_definitions: self._ldap_server_definitions = LdapServerDefinitionManager(self) return self._ldap_server_definitions
def ldap_server_definitions(self)
:class:`~zhmcclient.LdapServerDefinitionManager`: Access to the :term:`LDAP Server Definitions <LDAP Server Definition>` in this Console.
4.458018
3.688098
1.208758
# We do here some lazy loading. if not self._unmanaged_cpcs: self._unmanaged_cpcs = UnmanagedCpcManager(self) return self._unmanaged_cpcs
def unmanaged_cpcs(self)
:class:`~zhmcclient.UnmanagedCpcManager`: Access to the unmanaged :term:`CPCs <CPC>` in this Console.
5.557804
4.03863
1.376161
body = {'force': force} self.manager.session.post(self.uri + '/operations/restart', body=body) if wait_for_available: time.sleep(10) self.manager.client.wait_for_available( operation_timeout=operation_timeout)
def restart(self, force=False, wait_for_available=True, operation_timeout=None)
Restart the HMC represented by this Console object. Once the HMC is online again, this Console object, as well as any other resource objects accessed through this HMC, can continue to be used. An automatic re-logon will be performed under the covers, because the HMC restart invalidates ...
3.48174
4.811282
0.723662
body = {'force': force} self.manager.session.post(self.uri + '/operations/shutdown', body=body)
def shutdown(self, force=False)
Shut down and power off the HMC represented by this Console object. While the HMC is powered off, any Python resource objects retrieved from this HMC may raise exceptions upon further use. In order to continue using Python resource objects retrieved from this HMC, the HMC needs to be s...
6.928641
7.750426
0.893969
query_parms = [] if begin_time is not None: begin_ts = timestamp_from_datetime(begin_time) qp = 'begin-time={}'.format(begin_ts) query_parms.append(qp) if end_time is not None: end_ts = timestamp_from_datetime(end_time) qp = 'e...
def _time_query_parms(begin_time, end_time)
Return the URI query paramterer string for the specified begin time and end time.
1.643176
1.573171
1.044499
query_parms = self._time_query_parms(begin_time, end_time) uri = self.uri + '/operations/get-audit-log' + query_parms result = self.manager.session.post(uri) return result
def get_audit_log(self, begin_time=None, end_time=None)
Return the console audit log entries, optionally filtered by their creation time. Authorization requirements: * Task permission to the "Audit and Log Management" task. Parameters: begin_time (:class:`~py:datetime.datetime`): Begin time for filtering. Log entries...
4.835946
4.617509
1.047306
filter_args = dict() if name is not None: filter_args['name'] = name cpcs = self.unmanaged_cpcs.list(filter_args=filter_args) return cpcs
def list_unmanaged_cpcs(self, name=None)
List the unmanaged CPCs of this HMC. For details, see :meth:`~zhmcclient.UnmanagedCpc.list`. Authorization requirements: * None Parameters: name (:term:`string`): Regular expression pattern for the CPC name, as a filter that narrows the list of retu...
2.628294
3.765915
0.697916
# We do here some lazy loading. if not self._lpars: self._lpars = LparManager(self) return self._lpars
def lpars(self)
:class:`~zhmcclient.LparManager`: Access to the :term:`LPARs <LPAR>` in this CPC.
7.943796
5.295362
1.500142
# We do here some lazy loading. if not self._partitions: self._partitions = PartitionManager(self) return self._partitions
def partitions(self)
:class:`~zhmcclient.PartitionManager`: Access to the :term:`Partitions <Partition>` in this CPC.
8.726624
6.743738
1.294034
# We do here some lazy loading. if not self._adapters: self._adapters = AdapterManager(self) return self._adapters
def adapters(self)
:class:`~zhmcclient.AdapterManager`: Access to the :term:`Adapters <Adapter>` in this CPC.
8.242954
6.811649
1.210126
# We do here some lazy loading. if not self._virtual_switches: self._virtual_switches = VirtualSwitchManager(self) return self._virtual_switches
def virtual_switches(self)
:class:`~zhmcclient.VirtualSwitchManager`: Access to the :term:`Virtual Switches <Virtual Switch>` in this CPC.
5.126836
4.188794
1.223941