code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
# We do here some lazy loading.
if not self._reset_activation_profiles:
self._reset_activation_profiles = \
ActivationProfileManager(self, profile_type='reset')
return self._reset_activation_profiles | def reset_activation_profiles(self) | :class:`~zhmcclient.ActivationProfileManager`: Access to the
:term:`Reset Activation Profiles <Reset Activation Profile>` in this
CPC. | 6.21995 | 4.12922 | 1.506325 |
# We do here some lazy loading.
if not self._image_activation_profiles:
self._image_activation_profiles = \
ActivationProfileManager(self, profile_type='image')
return self._image_activation_profiles | def image_activation_profiles(self) | :class:`~zhmcclient.ActivationProfileManager`: Access to the
:term:`Image Activation Profiles <Image Activation Profile>` in this
CPC. | 4.683078 | 3.716303 | 1.260144 |
# We do here some lazy loading.
if not self._load_activation_profiles:
self._load_activation_profiles = \
ActivationProfileManager(self, profile_type='load')
return self._load_activation_profiles | def load_activation_profiles(self) | :class:`~zhmcclient.ActivationProfileManager`: Access to the
:term:`Load Activation Profiles <load Activation Profile>` in this
CPC. | 6.212577 | 4.051997 | 1.533214 |
machine_type = self.get_property('machine-type')
try:
max_parts = self._MAX_PARTITIONS_BY_MACHINE_TYPE[machine_type]
except KeyError:
raise ValueError("Unknown machine type: {!r}".format(machine_type))
return max_parts | def maximum_active_partitions(self) | Integer: The maximum number of active logical partitions or partitions
of this CPC.
The following table shows the maximum number of active logical
partitions or partitions by machine generations supported at the HMC
API:
========================= ==================
Machine generation Maximum partitions
========================= ==================
z196 60
z114 30
zEC12 60
zBC12 30
z13 / Emperor 85
z13s / Rockhopper 40
z14 / Emperor II 85
z14-ZR1 / Rockhopper II 40
========================= ==================
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`ValueError`: Unknown machine type | 3.477294 | 3.51551 | 0.989129 |
feature_list = self.prop('available-features-list', None)
if feature_list is None:
raise ValueError("Firmware features are not supported on CPC %s" %
self.name)
return feature_list | def feature_info(self) | Returns information about the features available for this CPC.
Authorization requirements:
* Object-access permission to this CPC.
Returns:
:term:`iterable`:
An iterable where each item represents one feature that is
available for this CPC.
Each item is a dictionary with the following items:
* `name` (:term:`unicode string`): Name of the feature.
* `description` (:term:`unicode string`): Short description of
the feature.
* `state` (bool): Enablement state of the feature (`True` if the
enabled, `False` if disabled).
Raises:
:exc:`ValueError`: Features are not supported on the HMC.
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 9.43512 | 6.904111 | 1.366594 |
result = self.manager.session.post(
self.uri + '/operations/start',
wait_for_completion=wait_for_completion,
operation_timeout=operation_timeout)
return result | def start(self, wait_for_completion=True, operation_timeout=None) | Start this CPC, using the HMC operation "Start CPC".
Authorization requirements:
* Object-access permission to this CPC.
* Task permission for the "Start (start a single DPM system)" task.
Parameters:
wait_for_completion (bool):
Boolean controlling whether this method should wait for completion
of the requested asynchronous HMC operation, as follows:
* If `True`, this method will wait for completion of the
asynchronous job performing the operation.
* If `False`, this method will return immediately once the HMC has
accepted the request to perform the operation.
operation_timeout (:term:`number`):
Timeout in seconds, for waiting for completion of the asynchronous
job performing the operation. The special value 0 means that no
timeout is set. `None` means that the default async operation
timeout of the session is used. If the timeout expires when
`wait_for_completion=True`, a
:exc:`~zhmcclient.OperationTimeout` is raised.
Returns:
`None` or :class:`~zhmcclient.Job`:
If `wait_for_completion` is `True`, returns `None`.
If `wait_for_completion` is `False`, returns a
:class:`~zhmcclient.Job` object representing the asynchronously
executing job on the HMC.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`~zhmcclient.OperationTimeout`: The timeout expired while
waiting for completion of the operation. | 3.520299 | 3.401698 | 1.034865 |
body = {'profile-area': profile_area}
result = self.manager.session.post(
self.uri + '/operations/import-profiles',
body,
wait_for_completion=wait_for_completion,
operation_timeout=operation_timeout)
return result | def import_profiles(self, profile_area, wait_for_completion=True,
operation_timeout=None) | Import activation profiles and/or system activity profiles for this CPC
from the SE hard drive into the CPC using the HMC operation
"Import Profiles".
This operation is not permitted when the CPC is in DPM mode.
Authorization requirements:
* Object-access permission to this CPC.
* Task permission for the "CIM Actions ExportSettingsData" task.
Parameters:
profile_area (int):
The numbered hard drive area (1-4) from which the profiles are
imported.
wait_for_completion (bool):
Boolean controlling whether this method should wait for completion
of the requested asynchronous HMC operation, as follows:
* If `True`, this method will wait for completion of the
asynchronous job performing the operation.
* If `False`, this method will return immediately once the HMC has
accepted the request to perform the operation.
operation_timeout (:term:`number`):
Timeout in seconds, for waiting for completion of the asynchronous
job performing the operation. The special value 0 means that no
timeout is set. `None` means that the default async operation
timeout of the session is used. If the timeout expires when
`wait_for_completion=True`, a
:exc:`~zhmcclient.OperationTimeout` is raised.
Returns:
`None` or :class:`~zhmcclient.Job`:
If `wait_for_completion` is `True`, returns `None`.
If `wait_for_completion` is `False`, returns a
:class:`~zhmcclient.Job` object representing the asynchronously
executing job on the HMC.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`~zhmcclient.OperationTimeout`: The timeout expired while
waiting for completion of the operation. | 2.846494 | 3.484528 | 0.816895 |
body = {'partitions': [p.uri for p in partitions]}
result = self.manager.session.post(self._uri + '/operations/'
'export-port-names-list', body=body)
# Parse the returned comma-separated string for each WWPN into a dict:
wwpn_list = []
dict_keys = ('partition-name', 'adapter-id', 'device-number', 'wwpn')
for wwpn_item in result['wwpn-list']:
dict_values = wwpn_item.split(',')
wwpn_list.append(dict(zip(dict_keys, dict_values)))
return wwpn_list | def get_wwpns(self, partitions) | Return the WWPNs of the host ports (of the :term:`HBAs <HBA>`) of the
specified :term:`Partitions <Partition>` of this CPC.
This method performs the HMC operation "Export WWPN List".
Authorization requirements:
* Object-access permission to this CPC.
* Object-access permission to the Partitions designated by the
"partitions" parameter.
* Task permission for the "Export WWPNs" task.
Parameters:
partitions (:term:`iterable` of :class:`~zhmcclient.Partition`):
:term:`Partitions <Partition>` to be used.
Returns:
A list of items for each WWPN, where each item is a dict with the
following keys:
* 'partition-name' (string): Name of the :term:`Partition`.
* 'adapter-id' (string): ID of the :term:`FCP Adapter`.
* 'device-number' (string): Virtual device number of the :term:`HBA`.
* 'wwpn' (string): WWPN of the HBA.
Raises:
:exc:`~zhmcclient.HTTPError`: See the HTTP status and reason codes of
operation "Export WWPN List" in the :term:`HMC API` book.
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 4.543259 | 3.586165 | 1.266885 |
body = {'power-saving': power_saving}
result = self.manager.session.post(
self.uri + '/operations/set-cpc-power-save',
body,
wait_for_completion=wait_for_completion,
operation_timeout=operation_timeout)
if wait_for_completion:
# The HMC API book does not document what the result data of the
# completed job is. It turns out that the completed job has this
# dictionary as its result data:
# {'message': 'Operation executed successfully'}
# We transform that to None.
return None
return result | def set_power_save(self, power_saving, wait_for_completion=True,
operation_timeout=None) | Set the power save setting of this CPC.
The current power save setting in effect for a CPC is described in the
"cpc-power-saving" property of the CPC.
This method performs the HMC operation "Set CPC Power Save". It
requires that the feature "Automate/advanced management suite"
(FC 0020) is installed and enabled, and fails otherwise.
This method will also fail if the CPC is under group control.
Whether a CPC currently allows this method is described in the
"cpc-power-save-allowed" property of the CPC.
Authorization requirements:
* Object-access permission to this CPC.
* Task permission for the "Power Save" task.
Parameters:
power_saving (:term:`string`):
The new power save setting, with the possible values:
* "high-performance" - The power consumption and performance of
the CPC are not reduced. This is the default setting.
* "low-power" - Low power consumption for all components of the
CPC enabled for power saving.
* "custom" - Components may have their own settings changed
individually. No component settings are actually changed when
this mode is entered.
wait_for_completion (bool):
Boolean controlling whether this method should wait for completion
of the requested asynchronous HMC operation, as follows:
* If `True`, this method will wait for completion of the
asynchronous job performing the operation.
* If `False`, this method will return immediately once the HMC has
accepted the request to perform the operation.
operation_timeout (:term:`number`):
Timeout in seconds, for waiting for completion of the asynchronous
job performing the operation. The special value 0 means that no
timeout is set. `None` means that the default async operation
timeout of the session is used. If the timeout expires when
`wait_for_completion=True`, a
:exc:`~zhmcclient.OperationTimeout` is raised.
Returns:
`None` or :class:`~zhmcclient.Job`:
If `wait_for_completion` is `True`, returns `None`.
If `wait_for_completion` is `False`, returns a
:class:`~zhmcclient.Job` object representing the asynchronously
executing job on the HMC.
Raises:
:exc:`~zhmcclient.HTTPError`: See the HTTP status and reason codes of
operation "Set CPC Power Save" in the :term:`HMC API` book.
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`~zhmcclient.OperationTimeout`: The timeout expired while
waiting for completion of the operation. | 6.114517 | 5.040025 | 1.213192 |
body = {'power-capping-state': power_capping_state}
if power_cap is not None:
body['power-cap-current'] = power_cap
result = self.manager.session.post(
self.uri + '/operations/set-cpc-power-capping',
body,
wait_for_completion=wait_for_completion,
operation_timeout=operation_timeout)
if wait_for_completion:
# The HMC API book does not document what the result data of the
# completed job is. Just in case there is similar behavior to the
# "Set CPC Power Save" operation, we transform that to None.
# TODO: Verify job result of a completed "Set CPC Power Capping".
return None
return result | def set_power_capping(self, power_capping_state, power_cap=None,
wait_for_completion=True, operation_timeout=None) | Set the power capping settings of this CPC. The power capping settings
of a CPC define whether or not the power consumption of the CPC is
limited and if so, what the limit is. Use this method to limit the
peak power consumption of a CPC, or to remove a power consumption
limit for a CPC.
The current power capping settings in effect for a CPC are described in
the "cpc-power-capping-state" and "cpc-power-cap-current" properties of
the CPC.
This method performs the HMC operation "Set CPC Power Capping". It
requires that the feature "Automate/advanced management suite"
(FC 0020) is installed and enabled, and fails otherwise.
This method will also fail if the CPC is under group control.
Whether a CPC currently allows this method is described in the
"cpc-power-cap-allowed" property of the CPC.
Authorization requirements:
* Object-access permission to this CPC.
* Task permission for the "Power Capping" task.
Parameters:
power_capping_state (:term:`string`):
The power capping state to be set, with the possible values:
* "disabled" - The power cap of the CPC is not set and the peak
power consumption is not limited. This is the default setting.
* "enabled" - The peak power consumption of the CPC is limited to
the specified power cap value.
* "custom" - Individually configure the components for power
capping. No component settings are actually changed when this
mode is entered.
power_cap (:term:`integer`):
The power cap value to be set, as a power consumption in Watt. This
parameter is required not to be `None` if
`power_capping_state="enabled"`.
The specified value must be between the values of the CPC
properties "cpc-power-cap-minimum" and "cpc-power-cap-maximum".
wait_for_completion (bool):
Boolean controlling whether this method should wait for completion
of the requested asynchronous HMC operation, as follows:
* If `True`, this method will wait for completion of the
asynchronous job performing the operation.
* If `False`, this method will return immediately once the HMC has
accepted the request to perform the operation.
operation_timeout (:term:`number`):
Timeout in seconds, for waiting for completion of the asynchronous
job performing the operation. The special value 0 means that no
timeout is set. `None` means that the default async operation
timeout of the session is used. If the timeout expires when
`wait_for_completion=True`, a
:exc:`~zhmcclient.OperationTimeout` is raised.
Returns:
`None` or :class:`~zhmcclient.Job`:
If `wait_for_completion` is `True`, returns `None`.
If `wait_for_completion` is `False`, returns a
:class:`~zhmcclient.Job` object representing the asynchronously
executing job on the HMC.
Raises:
:exc:`~zhmcclient.HTTPError`: See the HTTP status and reason codes of
operation "Set CPC Power Save" in the :term:`HMC API` book.
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`~zhmcclient.OperationTimeout`: The timeout expired while
waiting for completion of the operation. | 5.002289 | 4.073784 | 1.227922 |
result = self.manager.session.get(self.uri + '/energy-management-data')
em_list = result['objects']
if len(em_list) != 1:
uris = [em_obj['object-uri'] for em_obj in em_list]
raise ParseError("Energy management data returned for no resource "
"or for more than one resource: %r" % uris)
em_cpc_obj = em_list[0]
if em_cpc_obj['object-uri'] != self.uri:
raise ParseError("Energy management data returned for an "
"unexpected resource: %r" %
em_cpc_obj['object-uri'])
if em_cpc_obj['error-occurred']:
raise ParseError("Errors occurred when retrieving energy "
"management data for CPC. Operation result: %r" %
result)
cpc_props = em_cpc_obj['properties']
return cpc_props | def get_energy_management_properties(self) | Return the energy management properties of the CPC.
The returned energy management properties are a subset of the
properties of the CPC resource, and are also available as normal
properties of the CPC resource. In so far, there is no new data
provided by this method. However, because only a subset of the
properties is returned, this method is faster than retrieving the
complete set of CPC properties (e.g. via
:meth:`~zhmcclient.BaseResource.pull_full_properties`).
This method performs the HMC operation "Get CPC Energy Management
Data", and returns only the energy management properties for this CPC
from the operation result. Note that in non-ensemble mode of a CPC, the
HMC operation result will only contain data for the CPC alone.
It requires that the feature "Automate/advanced management suite"
(FC 0020) is installed and enabled, and returns empty values for most
properties, otherwise.
Authorization requirements:
* Object-access permission to this CPC.
Returns:
dict: A dictionary of properties of the CPC that are related to
energy management. For details, see section "Energy management
related additional properties" in the data model for the CPC
resource in the :term:`HMC API` book.
Raises:
:exc:`~zhmcclient.HTTPError`: See the HTTP status and reason codes of
operation "Get CPC Energy Management Data" in the :term:`HMC API`
book.
:exc:`~zhmcclient.ParseError`: Also raised by this method when the
JSON response could be parsed but contains inconsistent data.
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 3.486044 | 3.026837 | 1.151712 |
if filter_args is None:
filter_args = {}
else:
filter_args = filter_args.copy()
if 'cpc-uri' in filter_args:
raise ValueError(
"The filter_args parameter specifies the 'cpc-uri' property "
"with value: %s" % filter_args['cpc-uri'])
filter_args['cpc-uri'] = self.uri
sg_list = self.manager.console.storage_groups.list(
full_properties, filter_args)
return sg_list | def list_associated_storage_groups(
self, full_properties=False, filter_args=None) | Return the :term:`storage groups <storage group>` that are associated
to this CPC.
If the CPC does not support the "dpm-storage-management" feature, or
does not have it enabled, an empty list is returned.
Storage groups for which the authenticated user does not have
object-access permission are not included.
Authorization requirements:
* Object-access permission to any storage groups to be included in the
result.
Parameters:
full_properties (bool):
Controls that the full set of resource properties for each returned
storage group is being retrieved, vs. only the following short set:
"object-uri", "cpc-uri", "name", "fulfillment-state", and
"type".
filter_args (dict):
Filter arguments that narrow the list of returned resources to
those that match the specified filter arguments. For details, see
:ref:`Filtering`.
`None` causes no filtering to happen.
The 'cpc-uri' property is automatically added to the filter
arguments and must not be specified in this parameter.
Returns:
: A list of :class:`~zhmcclient.StorageGroup` objects.
Raises:
ValueError: The filter_args parameter specifies the 'cpc-uri'
property
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 2.732161 | 2.544122 | 1.073911 |
# The operation requires exactly 16 characters in lower case
host_wwpn_16 = format(int(host_wwpn, 16), '016x')
wwpn_16 = format(int(wwpn, 16), '016x')
lun_16 = format(int(lun, 16), '016x')
body = {
'host-world-wide-port-name': host_wwpn_16,
'adapter-port-uri': host_port.uri,
'target-world-wide-port-name': wwpn_16,
'logical-unit-number': lun_16,
}
self.manager.session.post(
self.uri + '/operations/validate-lun-path',
body=body) | def validate_lun_path(self, host_wwpn, host_port, wwpn, lun) | Validate if an FCP storage volume on an actual storage subsystem is
reachable from this CPC, through a specified host port and using
a specified host WWPN.
This method performs the "Validate LUN Path" HMC operation.
If the volume is reachable, the method returns. If the volume is not
reachable (and no other errors occur), an :exc:`~zhmcclient.HTTPError`
is raised, and its :attr:`~zhmcclient.HTTPError.reason` property
indicates the reason as follows:
* 484: Target WWPN cannot be reached.
* 485: Target WWPN can be reached, but LUN cannot be reached.
The CPC must have the "dpm-storage-management" feature enabled.
Parameters:
host_wwpn (:term:`string`):
World wide port name (WWPN) of the host (CPC),
as a hexadecimal number of up to 16 characters in any lexical case.
This may be the WWPN of the physical storage port, or a WWPN of a
virtual HBA. In any case, it must be the kind of WWPN that is used
for zoning and LUN masking in the SAN.
host_port (:class:`~zhmcclient.Port`):
Storage port on the CPC that will be used for validating
reachability.
wwpn (:term:`string`):
World wide port name (WWPN) of the FCP storage subsystem containing
the storage volume,
as a hexadecimal number of up to 16 characters in any lexical case.
lun (:term:`string`):
Logical Unit Number (LUN) of the storage volume within its FCP
storage subsystem,
as a hexadecimal number of up to 16 characters in any lexical case.
Authorization requirements:
* Object-access permission to the storage group owning this storage
volume.
* Task permission to the "Configure Storage - Storage Administrator"
task.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 2.696632 | 2.500937 | 1.078248 |
# noqa: E501
body = {
'user-pattern-uris': [up.uri for up in user_patterns]
}
self.manager.session.post(
'/api/console/operations/reorder-user-patterns',
body=body) | def reorder(self, user_patterns) | Reorder the User Patterns of the HMC as specified.
The order of User Patterns determines the search order during logon
processing.
Authorization requirements:
* Task permission to the "Manage User Patterns" task.
Parameters:
user_patterns (list of :class:`~zhmcclient.UserPattern`):
The User Patterns in the desired order.
Must not be `None`.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 6.255577 | 6.502201 | 0.962071 |
self._count = 0
self._sum = float(0)
self._min = float('inf')
self._max = float(0) | def reset(self) | Reset the time statistics data for the operation. | 4.217685 | 3.251037 | 1.297335 |
if self.keeper.enabled:
if self._begin_time is None:
raise RuntimeError("end() called without preceding begin()")
dt = time.time() - self._begin_time
self._begin_time = None
self._count += 1
self._sum += dt
if dt > self._max:
self._max = dt
if dt < self._min:
self._min = dt | def end(self) | This method must be called after the operation returns.
Note that this method is not to be invoked by the user; it is invoked
by the implementation of the :class:`~zhmcclient.Session` class.
If the statistics keeper holding this time statistics is enabled, this
method takes the current time, calculates the duration of the operation
since the last call to :meth:`~zhmcclient.TimeStats.begin`, and updates
the time statistics to reflect the new operation.
If the statistics keeper holding this time statistics is disabled,
this method does nothing, in order to save resources.
If this method is called without a preceding call to
:meth:`~zhmcclient.TimeStats.begin`, a :exc:`py:RuntimeError` is
raised.
Raises:
RuntimeError | 3.21316 | 2.833191 | 1.134113 |
if not self.enabled:
return self._disabled_stats
if name not in self._time_stats:
self._time_stats[name] = TimeStats(self, name)
return self._time_stats[name] | def get_stats(self, name) | Get the time statistics for a name.
If a time statistics for that name does not exist yet, create one.
Parameters:
name (string):
Name of the time statistics.
Returns:
TimeStats: The time statistics for the specified name. If the
statistics keeper is disabled, a dummy time statistics object is
returned, in order to save resources. | 3.221316 | 2.780584 | 1.158503 |
resource_obj_list = []
resource_obj = self._try_optimized_lookup(filter_args)
if resource_obj:
resource_obj_list.append(resource_obj)
else:
query_parms, client_filters = self._divide_filter_args(filter_args)
uri = self.parent.uri + '/operations/list-unmanaged-cpcs' + \
query_parms
result = self.session.get(uri)
if result:
props_list = result['cpcs']
for props in props_list:
resource_obj = self.resource_class(
manager=self,
uri=props[self._uri_prop],
name=props.get(self._name_prop, None),
properties=props)
if self._matches_filters(resource_obj, client_filters):
resource_obj_list.append(resource_obj)
self._name_uri_cache.update_from(resource_obj_list)
return resource_obj_list | def list(self, full_properties=False, filter_args=None) | List the unmanaged CPCs exposed by the HMC this client is connected to.
Because the CPCs are unmanaged, the returned
:class:`~zhmcclient.UnmanagedCpc` objects cannot perform any operations
and will have only the following properties:
* ``object-uri``
* ``name``
Authorization requirements:
* None
Parameters:
full_properties (bool):
Ignored (exists for consistency with other list() methods).
filter_args (dict):
Filter arguments that narrow the list of returned resources to
those that match the specified filter arguments. For details, see
:ref:`Filtering`.
`None` causes no filtering to happen, i.e. all resources are
returned.
Returns:
: A list of :class:`~zhmcclient.UnmanagedCpc` objects.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 3.620236 | 3.252457 | 1.113077 |
if not query_str:
return None
query_parms = {}
for query_item in query_str.split('&'):
# Example for these items: 'name=a%20b'
if query_item == '':
continue
items = query_item.split('=')
if len(items) != 2:
raise BadRequestError(
method, uri, reason=1,
message="Invalid format for URI query parameter: {!r} "
"(valid format is: 'name=value').".
format(query_item))
name = unquote(items[0])
value = unquote(items[1])
if name in query_parms:
existing_value = query_parms[name]
if not isinstance(existing_value, list):
query_parms[name] = list()
query_parms[name].append(existing_value)
query_parms[name].append(value)
else:
query_parms[name] = value
return query_parms | def parse_query_parms(method, uri, query_str) | Parse the specified query parms string and return a dictionary of query
parameters. The key of each dict item is the query parameter name, and the
value of each dict item is the query parameter value. If a query parameter
shows up more than once, the resulting dict item value is a list of all
those values.
query_str is the query string from the URL, everything after the '?'. If
it is empty or None, None is returned.
If a query parameter is not of the format "name=value", an HTTPError 400,1
is raised. | 2.575058 | 2.571912 | 1.001223 |
# Check presence of request body
if body is None:
raise BadRequestError(method, uri, reason=3,
message="Missing request body")
# Check required input fields
for field_name in field_names:
if field_name not in body:
raise BadRequestError(method, uri, reason=5,
message="Missing required field in request "
"body: {}".format(field_name)) | def check_required_fields(method, uri, body, field_names) | Check required fields in the request body.
Raises:
BadRequestError with reason 3: Missing request body
BadRequestError with reason 5: Missing required field in request body | 3.35851 | 2.487639 | 1.35008 |
status = cpc.properties.get('status', None)
if status is None:
# Do nothing if no status is set on the faked CPC
return
valid_statuses = ['active', 'service-required', 'degraded', 'exceptions']
if status not in valid_statuses:
if uri.startswith(cpc.uri):
# The uri targets the CPC (either is the CPC uri or some
# multiplicity under the CPC uri)
raise ConflictError(method, uri, reason=1,
message="The operation cannot be performed "
"because the targeted CPC {} has a status "
"that is not valid for the operation: {}".
format(cpc.name, status))
else:
# The uri targets a resource hosted by the CPC
raise ConflictError(method, uri, reason=6,
message="The operation cannot be performed "
"because CPC {} hosting the targeted resource "
"has a status that is not valid for the "
"operation: {}".
format(cpc.name, status)) | def check_valid_cpc_status(method, uri, cpc) | Check that the CPC is in a valid status, as indicated by its 'status'
property.
If the Cpc object does not have a 'status' property set, this function does
nothing (in order to make the mock support easy to use).
Raises:
ConflictError with reason 1: The CPC itself has been targeted by the
operation.
ConflictError with reason 6: The CPC is hosting the resource targeted by
the operation. | 4.382372 | 3.643717 | 1.20272 |
status = partition.properties.get('status', None)
if status is None:
# Do nothing if no status is set on the faked partition
return
if valid_statuses and status not in valid_statuses or \
invalid_statuses and status in invalid_statuses:
if uri.startswith(partition.uri):
# The uri targets the partition (either is the partition uri or
# some multiplicity under the partition uri)
raise ConflictError(method, uri, reason=1,
message="The operation cannot be performed "
"because the targeted partition {} has a "
"status that is not valid for the operation: "
"{}".
format(partition.name, status))
else:
# The uri targets a resource hosted by the partition
raise ConflictError(method, uri,
reason=1, # Note: 6 not used for partitions
message="The operation cannot be performed "
"because partition {} hosting the targeted "
"resource has a status that is not valid for "
"the operation: {}".
format(partition.name, status)) | def check_partition_status(method, uri, partition, valid_statuses=None,
invalid_statuses=None) | Check that the partition is in one of the valid statuses (if specified)
and not in one of the invalid statuses (if specified), as indicated by its
'status' property.
If the Partition object does not have a 'status' property set, this
function does nothing (in order to make the mock support easy to use).
Raises:
ConflictError with reason 1 (reason 6 is not used for partitions). | 4.636734 | 4.203621 | 1.103033 |
if 'crypto-configuration' not in partition.properties or \
partition.properties['crypto-configuration'] is None:
partition.properties['crypto-configuration'] = {}
crypto_config = partition.properties['crypto-configuration']
if 'crypto-adapter-uris' not in crypto_config or \
crypto_config['crypto-adapter-uris'] is None:
crypto_config['crypto-adapter-uris'] = []
adapter_uris = crypto_config['crypto-adapter-uris']
if 'crypto-domain-configurations' not in crypto_config or \
crypto_config['crypto-domain-configurations'] is None:
crypto_config['crypto-domain-configurations'] = []
domain_configs = crypto_config['crypto-domain-configurations']
return adapter_uris, domain_configs | def ensure_crypto_config(partition) | Ensure that the 'crypto-configuration' property on the faked partition
is initialized. | 1.781679 | 1.617778 | 1.101312 |
try:
resource = hmc.lookup_by_uri(uri)
except KeyError:
raise InvalidResourceError(method, uri)
return resource.properties | def get(method, hmc, uri, uri_parms, logon_required) | Operation: Get <resource> Properties. | 5.643846 | 4.437002 | 1.271995 |
assert wait_for_completion is True # async not supported yet
try:
resource = hmc.lookup_by_uri(uri)
except KeyError:
raise InvalidResourceError(method, uri)
resource.update(body) | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Update <resource> Properties. | 6.059366 | 5.515124 | 1.098682 |
try:
resource = hmc.lookup_by_uri(uri)
except KeyError:
raise InvalidResourceError(method, uri)
resource.manager.remove(resource.oid) | def delete(method, hmc, uri, uri_parms, logon_required) | Operation: Delete <resource>. | 6.267822 | 5.654634 | 1.10844 |
assert wait_for_completion is True # synchronous operation
console_uri = '/api/console'
try:
console = hmc.lookup_by_uri(console_uri)
except KeyError:
raise InvalidResourceError(method, uri)
check_required_fields(method, uri, body, ['user-pattern-uris'])
new_order_uris = body['user-pattern-uris']
objs = console.user_patterns.list()
obj_by_uri = {}
for obj in objs:
obj_by_uri[obj.uri] = obj
# Perform the reordering in the faked HMC:
for uri in new_order_uris:
obj = obj_by_uri[uri]
console.user_patterns.remove(obj.oid) # remove from old position
console.user_patterns.add(obj.properties) | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Reorder User Patterns. | 4.568647 | 3.763137 | 1.214053 |
assert wait_for_completion is True # synchronous operation
console_uri = '/api/console'
try:
hmc.lookup_by_uri(console_uri)
except KeyError:
raise InvalidResourceError(method, uri)
resp = []
# TODO: Add the ability to return audit log entries in mock support.
return resp | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Get Console Audit Log. | 12.481513 | 9.701969 | 1.286493 |
query_str = uri_parms[0]
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
result_ucpcs = []
filter_args = parse_query_parms(method, uri, query_str)
for ucpc in console.unmanaged_cpcs.list(filter_args):
result_ucpc = {}
for prop in ucpc.properties:
if prop in ('object-uri', 'name'):
result_ucpc[prop] = ucpc.properties[prop]
result_ucpcs.append(result_ucpc)
return {'cpcs': result_ucpcs} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Unmanaged CPCs. | 3.781003 | 3.229715 | 1.170692 |
query_str = uri_parms[0]
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
result_users = []
filter_args = parse_query_parms(method, uri, query_str)
for user in console.users.list(filter_args):
result_user = {}
for prop in user.properties:
if prop in ('object-uri', 'name', 'type'):
result_user[prop] = user.properties[prop]
result_users.append(result_user)
return {'users': result_users} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Users. | 3.339178 | 3.056753 | 1.092394 |
try:
user = hmc.lookup_by_uri(uri)
except KeyError:
raise InvalidResourceError(method, uri)
# Check user type
type_ = user.properties['type']
if type_ == 'pattern-based':
raise BadRequestError(
method, uri, reason=312,
message="Cannot delete pattern-based user {!r}".
format(user.name))
# Delete the mocked resource
user.manager.remove(user.oid) | def delete(method, hmc, uri, uri_parms, logon_required) | Operation: Delete User. | 6.298251 | 5.835387 | 1.07932 |
assert wait_for_completion is True # synchronous operation
user_oid = uri_parms[0]
user_uri = '/api/users/' + user_oid
try:
user = hmc.lookup_by_uri(user_uri)
except KeyError:
raise InvalidResourceError(method, uri)
check_required_fields(method, uri, body, ['user-role-uri'])
user_type = user.properties['type']
if user_type in ('pattern-based', 'system-defined'):
raise BadRequestError(
method, uri, reason=314,
message="Cannot add user role to user of type {}: {}".
format(user_type, user_uri))
user_role_uri = body['user-role-uri']
try:
hmc.lookup_by_uri(user_role_uri)
except KeyError:
raise InvalidResourceError(method, user_role_uri, reason=2)
if user.properties.get('user-roles', None) is None:
user.properties['user-roles'] = []
user.properties['user-roles'].append(user_role_uri) | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Add User Role to User. | 3.092007 | 2.860936 | 1.080768 |
query_str = uri_parms[0]
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
result_user_roles = []
filter_args = parse_query_parms(method, uri, query_str)
for user_role in console.user_roles.list(filter_args):
result_user_role = {}
for prop in user_role.properties:
if prop in ('object-uri', 'name', 'type'):
result_user_role[prop] = user_role.properties[prop]
result_user_roles.append(result_user_role)
return {'user-roles': result_user_roles} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List User Roles. | 3.036598 | 2.735388 | 1.110116 |
assert wait_for_completion is True # synchronous operation
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
check_required_fields(method, uri, body, ['name'])
properties = copy.deepcopy(body)
if 'type' in properties:
raise BadRequestError(
method, uri, reason=6,
message="Type specified when creating a user role: {!r}".
format(properties['type']))
properties['type'] = 'user-defined'
new_user_role = console.user_roles.add(properties)
return {'object-uri': new_user_role.uri} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create User Role. | 5.17044 | 4.60523 | 1.122732 |
assert wait_for_completion is True # synchronous operation
user_role_oid = uri_parms[0]
user_role_uri = '/api/user-roles/' + user_role_oid
try:
user_role = hmc.lookup_by_uri(user_role_uri)
except KeyError:
raise InvalidResourceError(method, uri)
check_required_fields(method, uri, body,
['permitted-object', 'permitted-object-type'])
# Reject if User Role is system-defined:
if user_role.properties['type'] == 'system-defined':
raise BadRequestError(
method, uri, reason=314, message="Cannot add permission to "
"system-defined user role: {}".format(user_role_uri))
# Apply defaults, so our internally stored copy has all fields:
permission = copy.deepcopy(body)
if 'include-members' not in permission:
permission['include-members'] = False
if 'view-only-mode' not in permission:
permission['view-only-mode'] = True
# Add the permission to its store (the faked User Role object):
if user_role.properties.get('permissions', None) is None:
user_role.properties['permissions'] = []
user_role.properties['permissions'].append(permission) | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Add Permission to User Role. | 4.330637 | 3.8897 | 1.11336 |
query_str = uri_parms[0]
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
result_tasks = []
filter_args = parse_query_parms(method, uri, query_str)
for task in console.tasks.list(filter_args):
result_task = {}
for prop in task.properties:
if prop in ('element-uri', 'name'):
result_task[prop] = task.properties[prop]
result_tasks.append(result_task)
return {'tasks': result_tasks} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Tasks. | 3.468234 | 3.161071 | 1.097171 |
query_str = uri_parms[0]
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
result_user_patterns = []
filter_args = parse_query_parms(method, uri, query_str)
for user_pattern in console.user_patterns.list(filter_args):
result_user_pattern = {}
for prop in user_pattern.properties:
if prop in ('element-uri', 'name', 'type'):
result_user_pattern[prop] = user_pattern.properties[prop]
result_user_patterns.append(result_user_pattern)
return {'user-patterns': result_user_patterns} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List User Patterns. | 3.167668 | 2.785578 | 1.137168 |
query_str = uri_parms[0]
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
result_password_rules = []
filter_args = parse_query_parms(method, uri, query_str)
for password_rule in console.password_rules.list(filter_args):
result_password_rule = {}
for prop in password_rule.properties:
if prop in ('element-uri', 'name', 'type'):
result_password_rule[prop] = password_rule.properties[prop]
result_password_rules.append(result_password_rule)
return {'password-rules': result_password_rules} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Password Rules. | 3.107596 | 2.810591 | 1.105673 |
assert wait_for_completion is True # synchronous operation
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
check_required_fields(method, uri, body, ['name'])
new_password_rule = console.password_rules.add(body)
return {'element-uri': new_password_rule.uri} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create Password Rule. | 6.540294 | 5.287412 | 1.236956 |
query_str = uri_parms[0]
try:
console = hmc.consoles.lookup_by_oid(None)
except KeyError:
raise InvalidResourceError(method, uri)
result_ldap_srv_defs = []
filter_args = parse_query_parms(method, uri, query_str)
for ldap_srv_def in console.ldap_server_definitions.list(filter_args):
result_ldap_srv_def = {}
for prop in ldap_srv_def.properties:
if prop in ('element-uri', 'name', 'type'):
result_ldap_srv_def[prop] = ldap_srv_def.properties[prop]
result_ldap_srv_defs.append(result_ldap_srv_def)
return {'ldap-server-definitions': result_ldap_srv_defs} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List LDAP Server Definitions. | 2.952477 | 2.621012 | 1.126464 |
query_str = uri_parms[0]
result_cpcs = []
filter_args = parse_query_parms(method, uri, query_str)
for cpc in hmc.cpcs.list(filter_args):
result_cpc = {}
for prop in cpc.properties:
if prop in ('object-uri', 'name', 'status'):
result_cpc[prop] = cpc.properties[prop]
result_cpcs.append(result_cpc)
return {'cpcs': result_cpcs} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List CPCs. | 2.876127 | 2.5446 | 1.130287 |
assert wait_for_completion is True # async not supported yet
cpc_oid = uri_parms[0]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
check_required_fields(method, uri, body, ['power-saving'])
power_saving = body['power-saving']
if power_saving not in ['high-performance', 'low-power', 'custom']:
raise BadRequestError(method, uri, reason=7,
message="Invalid power-saving value: %r" %
power_saving)
cpc.properties['cpc-power-saving'] = power_saving
cpc.properties['cpc-power-saving-state'] = power_saving
cpc.properties['zcpc-power-saving'] = power_saving
cpc.properties['zcpc-power-saving-state'] = power_saving | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Set CPC Power Save (any CPC mode). | 3.24313 | 3.049943 | 1.063341 |
assert wait_for_completion is True # async not supported yet
cpc_oid = uri_parms[0]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
check_required_fields(method, uri, body, ['power-capping-state'])
power_capping_state = body['power-capping-state']
power_cap_current = body.get('power-cap-current', None)
if power_capping_state not in ['disabled', 'enabled', 'custom']:
raise BadRequestError(method, uri, reason=7,
message="Invalid power-capping-state value: "
"%r" % power_capping_state)
if power_capping_state == 'enabled' and power_cap_current is None:
raise BadRequestError(method, uri, reason=7,
message="Power-cap-current must be provided "
"when enabling power capping")
cpc.properties['cpc-power-capping-state'] = power_capping_state
cpc.properties['cpc-power-cap-current'] = power_cap_current
cpc.properties['zcpc-power-capping-state'] = power_capping_state
cpc.properties['zcpc-power-cap-current'] = power_cap_current | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Set CPC Power Capping (any CPC mode). | 2.555902 | 2.415056 | 1.05832 |
cpc_oid = uri_parms[0]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
energy_props = {
'cpc-power-cap-allowed':
cpc.properties.get('cpc-power-cap-allowed'),
'cpc-power-cap-current':
cpc.properties.get('cpc-power-cap-current'),
'cpc-power-cap-maximum':
cpc.properties.get('cpc-power-cap-maximum'),
'cpc-power-cap-minimum':
cpc.properties.get('cpc-power-cap-minimum'),
'cpc-power-capping-state':
cpc.properties.get('cpc-power-capping-state'),
'cpc-power-consumption':
cpc.properties.get('cpc-power-consumption'),
'cpc-power-rating':
cpc.properties.get('cpc-power-rating'),
'cpc-power-save-allowed':
cpc.properties.get('cpc-power-save-allowed'),
'cpc-power-saving':
cpc.properties.get('cpc-power-saving'),
'cpc-power-saving-state':
cpc.properties.get('cpc-power-saving-state'),
'zcpc-ambient-temperature':
cpc.properties.get('zcpc-ambient-temperature'),
'zcpc-dew-point':
cpc.properties.get('zcpc-dew-point'),
'zcpc-exhaust-temperature':
cpc.properties.get('zcpc-exhaust-temperature'),
'zcpc-heat-load':
cpc.properties.get('zcpc-heat-load'),
'zcpc-heat-load-forced-air':
cpc.properties.get('zcpc-heat-load-forced-air'),
'zcpc-heat-load-water':
cpc.properties.get('zcpc-heat-load-water'),
'zcpc-humidity':
cpc.properties.get('zcpc-humidity'),
'zcpc-maximum-potential-heat-load':
cpc.properties.get('zcpc-maximum-potential-heat-load'),
'zcpc-maximum-potential-power':
cpc.properties.get('zcpc-maximum-potential-power'),
'zcpc-power-cap-allowed':
cpc.properties.get('zcpc-power-cap-allowed'),
'zcpc-power-cap-current':
cpc.properties.get('zcpc-power-cap-current'),
'zcpc-power-cap-maximum':
cpc.properties.get('zcpc-power-cap-maximum'),
'zcpc-power-cap-minimum':
cpc.properties.get('zcpc-power-cap-minimum'),
'zcpc-power-capping-state':
cpc.properties.get('zcpc-power-capping-state'),
'zcpc-power-consumption':
cpc.properties.get('zcpc-power-consumption'),
'zcpc-power-rating':
cpc.properties.get('zcpc-power-rating'),
'zcpc-power-save-allowed':
cpc.properties.get('zcpc-power-save-allowed'),
'zcpc-power-saving':
cpc.properties.get('zcpc-power-saving'),
'zcpc-power-saving-state':
cpc.properties.get('zcpc-power-saving-state'),
}
cpc_data = {
'error-occurred': False,
'object-uri': cpc.uri,
'object-id': cpc.oid,
'class': 'cpcs',
'properties': energy_props,
}
result = {'objects': [cpc_data]}
return result | def get(method, hmc, uri, uri_parms, logon_required) | Operation: Get CPC Energy Management Data (any CPC mode). | 1.498244 | 1.459964 | 1.02622 |
assert wait_for_completion is True # async not supported yet
cpc_oid = uri_parms[0]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
if not cpc.dpm_enabled:
raise CpcNotInDpmError(method, uri, cpc)
cpc.properties['status'] = 'not-operating' | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Stop CPC (requires DPM mode). | 4.607003 | 4.107832 | 1.121517 |
assert wait_for_completion is True # this operation is always synchr.
cpc_oid = uri_parms[0]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
if not cpc.dpm_enabled:
raise CpcNotInDpmError(method, uri, cpc)
check_required_fields(method, uri, body, ['partitions'])
partition_uris = body['partitions']
if len(partition_uris) == 0:
raise BadRequestError(
method, uri, reason=149,
message="'partitions' field in request body is empty.")
wwpn_list = []
for partition_uri in partition_uris:
partition = hmc.lookup_by_uri(partition_uri)
partition_cpc = partition.manager.parent
if partition_cpc.oid != cpc_oid:
raise BadRequestError(
method, uri, reason=149,
message="Partition %r specified in 'partitions' field "
"is not in the targeted CPC with ID %r (but in the CPC "
"with ID %r)." %
(partition.uri, cpc_oid, partition_cpc.oid))
partition_name = partition.properties.get('name', '')
for hba in partition.hbas.list():
port_uri = hba.properties['adapter-port-uri']
port = hmc.lookup_by_uri(port_uri)
adapter = port.manager.parent
adapter_id = adapter.properties.get('adapter-id', '')
devno = hba.properties.get('device-number', '')
wwpn = hba.properties.get('wwpn', '')
wwpn_str = '%s,%s,%s,%s' % (partition_name, adapter_id,
devno, wwpn)
wwpn_list.append(wwpn_str)
return {
'wwpn-list': wwpn_list
} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Export WWPN List (requires DPM mode). | 2.896516 | 2.720198 | 1.064818 |
assert wait_for_completion is True # always synchronous
check_required_fields(method, uri, body,
['anticipated-frequency-seconds'])
new_metrics_context = hmc.metrics_contexts.add(body)
result = {
'metrics-context-uri': new_metrics_context.uri,
'metric-group-infos': new_metrics_context.get_metric_group_infos()
}
return result | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create Metrics Context. | 5.795965 | 4.991899 | 1.161074 |
try:
metrics_context = hmc.lookup_by_uri(uri)
except KeyError:
raise InvalidResourceError(method, uri)
hmc.metrics_contexts.remove(metrics_context.oid) | def delete(method, hmc, uri, uri_parms, logon_required) | Operation: Delete Metrics Context. | 8.038406 | 4.632932 | 1.735058 |
try:
metrics_context = hmc.lookup_by_uri(uri)
except KeyError:
raise InvalidResourceError(method, uri)
result = metrics_context.get_metric_values_response()
return result | def get(method, hmc, uri, uri_parms, logon_required) | Operation: Get Metrics. | 6.378214 | 5.186401 | 1.229796 |
cpc_oid = uri_parms[0]
query_str = uri_parms[1]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
result_adapters = []
if cpc.dpm_enabled:
filter_args = parse_query_parms(method, uri, query_str)
for adapter in cpc.adapters.list(filter_args):
result_adapter = {}
for prop in adapter.properties:
if prop in ('object-uri', 'name', 'status'):
result_adapter[prop] = adapter.properties[prop]
result_adapters.append(result_adapter)
return {'adapters': result_adapters} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Adapters of a CPC (empty result if not in DPM
mode). | 3.064855 | 2.669867 | 1.147943 |
assert wait_for_completion is True
cpc_oid = uri_parms[0]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
if not cpc.dpm_enabled:
raise CpcNotInDpmError(method, uri, cpc)
check_required_fields(method, uri, body, ['name'])
# We need to emulate the behavior of this POST to always create a
# hipersocket, but the add() method is used for adding all kinds of
# faked adapters to the faked HMC. So we need to specify the adapter
# type, but because the behavior of the Adapter resource object is
# that it only has its input properties set, we add the 'type'
# property on a copy of the input properties.
body2 = body.copy()
body2['type'] = 'hipersockets'
try:
new_adapter = cpc.adapters.add(body2)
except InputError as exc:
raise BadRequestError(method, uri, reason=5, message=str(exc))
return {'object-uri': new_adapter.uri} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create Hipersocket (requires DPM mode). | 5.686607 | 5.345662 | 1.06378 |
try:
adapter = hmc.lookup_by_uri(uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = adapter.manager.parent
assert cpc.dpm_enabled
adapter.manager.remove(adapter.oid) | def delete(method, hmc, uri, uri_parms, logon_required) | Operation: Delete Hipersocket (requires DPM mode). | 7.927327 | 6.590697 | 1.202806 |
assert wait_for_completion is True # HMC operation is synchronous
adapter_uri = uri.split('/operations/')[0]
try:
adapter = hmc.lookup_by_uri(adapter_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = adapter.manager.parent
assert cpc.dpm_enabled
check_required_fields(method, uri, body, ['crypto-type'])
# Check the validity of the new crypto_type
crypto_type = body['crypto-type']
if crypto_type not in ['accelerator', 'cca-coprocessor',
'ep11-coprocessor']:
raise BadRequestError(
method, uri, reason=8,
message="Invalid value for 'crypto-type' field: %s" %
crypto_type)
# Reflect the result of changing the crypto type
adapter.properties['crypto-type'] = crypto_type | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Change Crypto Type (requires DPM mode). | 5.68122 | 4.904455 | 1.15838 |
assert wait_for_completion is True # HMC operation is synchronous
adapter_uri = uri.split('/operations/')[0]
try:
adapter = hmc.lookup_by_uri(adapter_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = adapter.manager.parent
assert cpc.dpm_enabled
check_required_fields(method, uri, body, ['type'])
new_adapter_type = body['type']
# Check the validity of the adapter family
adapter_family = adapter.properties.get('adapter-family', None)
if adapter_family != 'ficon':
raise BadRequestError(
method, uri, reason=18,
message="The adapter type cannot be changed for adapter "
"family: %s" % adapter_family)
# Check the adapter status
adapter_status = adapter.properties.get('status', None)
if adapter_status == 'exceptions':
raise BadRequestError(
method, uri, reason=18,
message="The adapter type cannot be changed for adapter "
"status: %s" % adapter_status)
# Check the validity of the new adapter type
if new_adapter_type not in ['fc', 'fcp', 'not-configured']:
raise BadRequestError(
method, uri, reason=8,
message="Invalid new value for 'type' field: %s" %
new_adapter_type)
# Check that the new adapter type is not already set
adapter_type = adapter.properties.get('type', None)
if new_adapter_type == adapter_type:
raise BadRequestError(
method, uri, reason=8,
message="New value for 'type' field is already set: %s" %
new_adapter_type)
# TODO: Reject if adapter is attached to a partition.
# Reflect the result of changing the adapter type
adapter.properties['type'] = new_adapter_type | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Change Adapter Type (requires DPM mode). | 3.224643 | 2.972914 | 1.084674 |
cpc_oid = uri_parms[0]
query_str = uri_parms[1]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
# Reflect the result of listing the partition
result_partitions = []
if cpc.dpm_enabled:
filter_args = parse_query_parms(method, uri, query_str)
for partition in cpc.partitions.list(filter_args):
result_partition = {}
for prop in partition.properties:
if prop in ('object-uri', 'name', 'status'):
result_partition[prop] = partition.properties[prop]
result_partitions.append(result_partition)
return {'partitions': result_partitions} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Partitions of a CPC (empty result if not in DPM
mode). | 3.419844 | 3.140445 | 1.088968 |
assert wait_for_completion is True # async not supported yet
cpc_oid = uri_parms[0]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
if not cpc.dpm_enabled:
raise CpcNotInDpmError(method, uri, cpc)
check_valid_cpc_status(method, uri, cpc)
check_required_fields(method, uri, body,
['name', 'initial-memory', 'maximum-memory'])
# TODO: There are some more input properties that are required under
# certain conditions.
# Reflect the result of creating the partition
new_partition = cpc.partitions.add(body)
return {'object-uri': new_partition.uri} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create Partition (requires DPM mode). | 5.23255 | 4.866884 | 1.075133 |
assert wait_for_completion is True # async not supported yet
partition_oid = uri_parms[0]
partition_uri = '/api/partitions/' + partition_oid
try:
partition = hmc.lookup_by_uri(partition_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
valid_statuses=['stopped'])
# Reflect the result of starting the partition
partition.properties['status'] = 'active'
return {} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Start Partition (requires DPM mode). | 5.68258 | 5.121253 | 1.109607 |
assert wait_for_completion is True # synchronous operation
partition_oid = uri_parms[0]
partition_uri = '/api/partitions/' + partition_oid
try:
partition = hmc.lookup_by_uri(partition_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
invalid_statuses=['starting', 'stopping'])
# Parse and check required query parameters
query_parms = parse_query_parms(method, uri, uri_parms[1])
try:
image_name = query_parms['image-name']
except KeyError:
raise BadRequestError(
method, uri, reason=1,
message="Missing required URI query parameter 'image-name'")
try:
ins_file_name = query_parms['ins-file-name']
except KeyError:
raise BadRequestError(
method, uri, reason=1,
message="Missing required URI query parameter 'ins-file-name'")
# Reflect the effect of mounting in the partition properties
partition.properties['boot-iso-image-name'] = image_name
partition.properties['boot-iso-ins-file'] = ins_file_name
return {} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Mount ISO Image (requires DPM mode). | 3.838317 | 3.521105 | 1.090089 |
assert wait_for_completion is True # async not supported yet
partition_oid = uri_parms[0]
partition_uri = '/api/partitions/' + partition_oid
try:
partition = hmc.lookup_by_uri(partition_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
invalid_statuses=['starting', 'stopping'])
check_required_fields(method, uri, body, []) # check just body
adapter_uris, domain_configs = ensure_crypto_config(partition)
add_adapter_uris = body.get('crypto-adapter-uris', [])
add_domain_configs = body.get('crypto-domain-configurations', [])
# We don't support finding errors in this simple-minded mock support,
# so we assume that the input is fine (e.g. no invalid adapters) and
# we just add it.
for uri in add_adapter_uris:
if uri not in adapter_uris:
adapter_uris.append(uri)
for dc in add_domain_configs:
if dc not in domain_configs:
domain_configs.append(dc) | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Increase Crypto Configuration (requires DPM mode). | 5.113085 | 4.836558 | 1.057174 |
assert wait_for_completion is True # async not supported yet
partition_oid = uri_parms[0]
partition_uri = '/api/partitions/' + partition_oid
try:
partition = hmc.lookup_by_uri(partition_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
invalid_statuses=['starting', 'stopping'])
check_required_fields(method, uri, body, []) # check just body
adapter_uris, domain_configs = ensure_crypto_config(partition)
remove_adapter_uris = body.get('crypto-adapter-uris', [])
remove_domain_indexes = body.get('crypto-domain-indexes', [])
# We don't support finding errors in this simple-minded mock support,
# so we assume that the input is fine (e.g. no invalid adapters) and
# we just remove it.
for uri in remove_adapter_uris:
if uri in adapter_uris:
adapter_uris.remove(uri)
for remove_di in remove_domain_indexes:
for i, dc in enumerate(domain_configs):
if dc['domain-index'] == remove_di:
del domain_configs[i] | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Decrease Crypto Configuration (requires DPM mode). | 5.234822 | 4.907786 | 1.066636 |
assert wait_for_completion is True # async not supported yet
partition_uri = re.sub('/hbas$', '', uri)
try:
partition = hmc.lookup_by_uri(partition_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
invalid_statuses=['starting', 'stopping'])
check_required_fields(method, uri, body, ['name', 'adapter-port-uri'])
# Check the port-related input property
port_uri = body['adapter-port-uri']
m = re.match(r'(^/api/adapters/[^/]+)/storage-ports/[^/]+$', port_uri)
if not m:
# We treat an invalid port URI like "port not found".
raise InvalidResourceError(method, uri, reason=6,
resource_uri=port_uri)
adapter_uri = m.group(1)
try:
hmc.lookup_by_uri(adapter_uri)
except KeyError:
raise InvalidResourceError(method, uri, reason=2,
resource_uri=adapter_uri)
try:
hmc.lookup_by_uri(port_uri)
except KeyError:
raise InvalidResourceError(method, uri, reason=6,
resource_uri=port_uri)
new_hba = partition.hbas.add(body)
return {'element-uri': new_hba.uri} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create HBA (requires DPM mode). | 3.640463 | 3.39062 | 1.073686 |
try:
hba = hmc.lookup_by_uri(uri)
except KeyError:
raise InvalidResourceError(method, uri)
partition = hba.manager.parent
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
invalid_statuses=['starting', 'stopping'])
partition.hbas.remove(hba.oid) | def delete(method, hmc, uri, uri_parms, logon_required) | Operation: Delete HBA (requires DPM mode). | 6.078058 | 5.341413 | 1.137912 |
assert wait_for_completion is True # async not supported yet
partition_oid = uri_parms[0]
partition_uri = '/api/partitions/' + partition_oid
hba_oid = uri_parms[1]
hba_uri = '/api/partitions/' + partition_oid + '/hbas/' + hba_oid
try:
hba = hmc.lookup_by_uri(hba_uri)
except KeyError:
raise InvalidResourceError(method, uri)
partition = hmc.lookup_by_uri(partition_uri) # assert it exists
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
invalid_statuses=['starting', 'stopping'])
check_required_fields(method, uri, body, ['adapter-port-uri'])
# Reflect the effect of the operation on the HBA
new_port_uri = body['adapter-port-uri']
hba.properties['adapter-port-uri'] = new_port_uri | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Reassign Storage Adapter Port (requires DPM mode). | 3.695719 | 3.482351 | 1.061271 |
assert wait_for_completion is True # async not supported yet
partition_uri = re.sub('/nics$', '', uri)
try:
partition = hmc.lookup_by_uri(partition_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
invalid_statuses=['starting', 'stopping'])
check_required_fields(method, uri, body, ['name'])
# Check the port-related input properties
if 'network-adapter-port-uri' in body:
port_uri = body['network-adapter-port-uri']
m = re.match(r'(^/api/adapters/[^/]+)/network-ports/[^/]+$',
port_uri)
if not m:
# We treat an invalid port URI like "port not found".
raise InvalidResourceError(method, uri, reason=6,
resource_uri=port_uri)
adapter_uri = m.group(1)
try:
hmc.lookup_by_uri(adapter_uri)
except KeyError:
raise InvalidResourceError(method, uri, reason=2,
resource_uri=adapter_uri)
try:
hmc.lookup_by_uri(port_uri)
except KeyError:
raise InvalidResourceError(method, uri, reason=6,
resource_uri=port_uri)
elif 'virtual-switch-uri' in body:
vswitch_uri = body['virtual-switch-uri']
try:
hmc.lookup_by_uri(vswitch_uri)
except KeyError:
raise InvalidResourceError(method, uri, reason=2,
resource_uri=vswitch_uri)
else:
nic_name = body.get('name', None)
raise BadRequestError(
method, uri, reason=5,
message="The input properties for creating a NIC {!r} in "
"partition {!r} must specify either the "
"'network-adapter-port-uri' or the "
"'virtual-switch-uri' property.".
format(nic_name, partition.name))
# We have ensured that the vswitch exists, so no InputError handling
new_nic = partition.nics.add(body)
return {'element-uri': new_nic.uri} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create NIC (requires DPM mode). | 3.101945 | 3.005107 | 1.032224 |
assert wait_for_completion is True # async not supported yet
partition_uri = re.sub('/virtual-functions$', '', uri)
try:
partition = hmc.lookup_by_uri(partition_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = partition.manager.parent
assert cpc.dpm_enabled
check_valid_cpc_status(method, uri, cpc)
check_partition_status(method, uri, partition,
invalid_statuses=['starting', 'stopping'])
check_required_fields(method, uri, body, ['name'])
new_vf = partition.virtual_functions.add(body)
return {'element-uri': new_vf.uri} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create Virtual Function (requires DPM mode). | 5.376182 | 4.673022 | 1.150472 |
cpc_oid = uri_parms[0]
query_str = uri_parms[1]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
result_vswitches = []
if cpc.dpm_enabled:
filter_args = parse_query_parms(method, uri, query_str)
for vswitch in cpc.virtual_switches.list(filter_args):
result_vswitch = {}
for prop in vswitch.properties:
if prop in ('object-uri', 'name', 'type'):
result_vswitch[prop] = vswitch.properties[prop]
result_vswitches.append(result_vswitch)
return {'virtual-switches': result_vswitches} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Virtual Switches of a CPC (empty result if not in
DPM mode). | 2.971719 | 2.535159 | 1.172202 |
assert wait_for_completion is True # async not supported yet
vswitch_oid = uri_parms[0]
vswitch_uri = '/api/virtual-switches/' + vswitch_oid
try:
vswitch = hmc.lookup_by_uri(vswitch_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = vswitch.manager.parent
assert cpc.dpm_enabled
connected_vnic_uris = vswitch.properties['connected-vnic-uris']
return {'connected-vnic-uris': connected_vnic_uris} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Get Connected VNICs of a Virtual Switch
(requires DPM mode). | 4.61675 | 3.918442 | 1.178211 |
query_str = uri_parms[0]
filter_args = parse_query_parms(method, uri, query_str)
result_storage_groups = []
for sg in hmc.consoles.console.storage_groups.list(filter_args):
result_sg = {}
for prop in sg.properties:
if prop in ('object-uri', 'cpc-uri', 'name', 'status',
'fulfillment-state', 'type'):
result_sg[prop] = sg.properties[prop]
result_storage_groups.append(result_sg)
return {'storage-groups': result_storage_groups} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Storage Groups (always global but with filters). | 3.426477 | 3.084526 | 1.11086 |
assert wait_for_completion is True # async not supported yet
check_required_fields(method, uri, body, ['name', 'cpc-uri', 'type'])
cpc_uri = body['cpc-uri']
try:
cpc = hmc.lookup_by_uri(cpc_uri)
except KeyError:
raise InvalidResourceError(method, uri)
if not cpc.dpm_enabled:
raise CpcNotInDpmError(method, uri, cpc)
check_valid_cpc_status(method, uri, cpc)
# Reflect the result of creating the storage group
body2 = body.copy()
sv_requests = body2.pop('storage-volumes', None)
new_storage_group = hmc.consoles.console.storage_groups.add(body2)
sv_uris = []
if sv_requests:
for sv_req in sv_requests:
check_required_fields(method, uri, sv_req, ['operation'])
operation = sv_req['operation']
if operation == 'create':
sv_props = sv_req.copy()
del sv_props['operation']
if 'element-uri' in sv_props:
raise BadRequestError(
method, uri, 7,
"The 'element-uri' field in storage-volumes is "
"invalid for the create operation")
sv_uri = new_storage_group.storage_volumes.add(sv_props)
sv_uris.append(sv_uri)
else:
raise BadRequestError(
method, uri, 5,
"Invalid value for storage-volumes 'operation' "
"field: %s" % operation)
return {
'object-uri': new_storage_group.uri,
'element-uris': sv_uris,
} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Create Storage Group. | 2.990556 | 2.926668 | 1.021829 |
assert wait_for_completion is True # async not supported yet
# The URI is a POST operation, so we need to construct the SG URI
storage_group_oid = uri_parms[0]
storage_group_uri = '/api/storage-groups/' + storage_group_oid
try:
storage_group = hmc.lookup_by_uri(storage_group_uri)
except KeyError:
raise InvalidResourceError(method, uri)
# Reflect the result of modifying the storage group
body2 = body.copy()
sv_requests = body2.pop('storage-volumes', None)
storage_group.update(body2)
sv_uris = []
if sv_requests:
for sv_req in sv_requests:
check_required_fields(method, uri, sv_req, ['operation'])
operation = sv_req['operation']
if operation == 'create':
sv_props = sv_req.copy()
del sv_props['operation']
if 'element-uri' in sv_props:
raise BadRequestError(
method, uri, 7,
"The 'element-uri' field in storage-volumes is "
"invalid for the create operation")
sv_uri = storage_group.storage_volumes.add(sv_props)
sv_uris.append(sv_uri)
elif operation == 'modify':
check_required_fields(method, uri, sv_req, ['element-uri'])
sv_uri = sv_req['element-uri']
storage_volume = hmc.lookup_by_uri(sv_uri)
storage_volume.update_properties(sv_props)
elif operation == 'delete':
check_required_fields(method, uri, sv_req, ['element-uri'])
sv_uri = sv_req['element-uri']
storage_volume = hmc.lookup_by_uri(sv_uri)
storage_volume.delete()
else:
raise BadRequestError(
method, uri, 5,
"Invalid value for storage-volumes 'operation' "
"field: %s" % operation)
return {
'element-uris': sv_uris, # SVs created, maintaining the order
} | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Modify Storage Group Properties. | 2.713298 | 2.681162 | 1.011986 |
assert wait_for_completion is True # async not supported yet
# The URI is a POST operation, so we need to construct the SG URI
storage_group_oid = uri_parms[0]
storage_group_uri = '/api/storage-groups/' + storage_group_oid
try:
storage_group = hmc.lookup_by_uri(storage_group_uri)
except KeyError:
raise InvalidResourceError(method, uri)
# TODO: Check that the SG is detached from any partitions
# Reflect the result of deleting the storage_group
storage_group.manager.remove(storage_group.oid) | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Delete Storage Group. | 6.562687 | 5.965765 | 1.100058 |
assert wait_for_completion is True # async not supported yet
# The URI is a POST operation, so we need to construct the SG URI
storage_group_oid = uri_parms[0]
storage_group_uri = '/api/storage-groups/' + storage_group_oid
try:
hmc.lookup_by_uri(storage_group_uri)
except KeyError:
raise InvalidResourceError(method, uri)
# Reflect the result of requesting fulfilment for the storage group
pass | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Request Storage Group Fulfillment. | 7.833829 | 6.811338 | 1.150116 |
assert wait_for_completion is True # async not supported yet
# The URI is a POST operation, so we need to construct the SG URI
storage_group_oid = uri_parms[0]
storage_group_uri = '/api/storage-groups/' + storage_group_oid
try:
storage_group = hmc.lookup_by_uri(storage_group_uri)
except KeyError:
raise InvalidResourceError(method, uri)
check_required_fields(method, uri, body, ['adapter-port-uris'])
# TODO: Check that storage group has type FCP
# Reflect the result of adding the candidate ports
candidate_adapter_port_uris = \
storage_group.properties['candidate-adapter-port-uris']
for ap_uri in body['adapter-port-uris']:
if ap_uri in candidate_adapter_port_uris:
raise ConflictError(method, uri, 483,
"Adapter port is already in candidate "
"list of storage group %s: %s" %
(storage_group.name, ap_uri))
else:
candidate_adapter_port_uris.append(ap_uri) | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Add Candidate Adapter Ports to an FCP Storage Group. | 4.075235 | 3.607637 | 1.129613 |
cpc_oid = uri_parms[0]
query_str = uri_parms[1]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
result_lpars = []
if not cpc.dpm_enabled:
filter_args = parse_query_parms(method, uri, query_str)
for lpar in cpc.lpars.list(filter_args):
result_lpar = {}
for prop in lpar.properties:
if prop in ('object-uri', 'name', 'status'):
result_lpar[prop] = lpar.properties[prop]
result_lpars.append(result_lpar)
return {'logical-partitions': result_lpars} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Logical Partitions of CPC (empty result in DPM
mode. | 3.054776 | 2.791634 | 1.094261 |
assert wait_for_completion is True # async not supported yet
lpar_oid = uri_parms[0]
lpar_uri = '/api/logical-partitions/' + lpar_oid
try:
lpar = hmc.lookup_by_uri(lpar_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = lpar.manager.parent
assert not cpc.dpm_enabled
status = lpar.properties.get('status', None)
force = body.get('force', False) if body else False
if status == 'operating' and not force:
raise ServerError(method, uri, reason=263,
message="LPAR {!r} could not be activated "
"because the LPAR is in status {} "
"(and force was not specified).".
format(lpar.name, status))
act_profile_name = body.get('activation-profile-name', None)
if not act_profile_name:
act_profile_name = lpar.properties.get(
'next-activation-profile-name', None)
if act_profile_name is None:
act_profile_name = ''
# Perform the check between LPAR name and profile name
if act_profile_name != lpar.name:
raise ServerError(method, uri, reason=263,
message="LPAR {!r} could not be activated "
"because the name of the image activation "
"profile {!r} is different from the LPAR name.".
format(lpar.name, act_profile_name))
# Reflect the activation in the resource
lpar.properties['status'] = LparActivateHandler.get_status()
lpar.properties['last-used-activation-profile'] = act_profile_name | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Activate Logical Partition (requires classic mode). | 3.614968 | 3.484643 | 1.0374 |
assert wait_for_completion is True # async not supported yet
lpar_oid = uri_parms[0]
lpar_uri = '/api/logical-partitions/' + lpar_oid
try:
lpar = hmc.lookup_by_uri(lpar_uri)
except KeyError:
raise InvalidResourceError(method, uri)
cpc = lpar.manager.parent
assert not cpc.dpm_enabled
status = lpar.properties.get('status', None)
force = body.get('force', False) if body else False
clear_indicator = body.get('clear-indicator', True) if body else True
store_status_indicator = body.get('store-status-indicator',
False) if body else False
if status == 'not-activated':
raise ConflictError(method, uri, reason=0,
message="LPAR {!r} could not be loaded "
"because the LPAR is in status {}.".
format(lpar.name, status))
elif status == 'operating' and not force:
raise ServerError(method, uri, reason=263,
message="LPAR {!r} could not be loaded "
"because the LPAR is already loaded "
"(and force was not specified).".
format(lpar.name))
load_address = body.get('load-address', None) if body else None
if not load_address:
# Starting with z14, this parameter is optional and a last-used
# property is available.
load_address = lpar.properties.get('last-used-load-address', None)
if load_address is None:
# TODO: Verify actual error for this case on a z14.
raise BadRequestError(method, uri, reason=5,
message="LPAR {!r} could not be loaded "
"because a load address is not specified "
"in the request or in the Lpar last-used "
"property".
format(lpar.name))
load_parameter = body.get('load-parameter', None) if body else None
if not load_parameter:
# Starting with z14, a last-used property is available.
load_parameter = lpar.properties.get(
'last-used-load-parameter', None)
if load_parameter is None:
load_parameter = ''
# Reflect the load in the resource
if clear_indicator:
lpar.properties['memory'] = ''
if store_status_indicator:
lpar.properties['stored-status'] = status
else:
lpar.properties['stored-status'] = None
lpar.properties['status'] = LparLoadHandler.get_status()
lpar.properties['last-used-load-address'] = load_address
lpar.properties['last-used-load-parameter'] = load_parameter | def post(method, hmc, uri, uri_parms, body, logon_required,
wait_for_completion) | Operation: Load Logical Partition (requires classic mode). | 3.207016 | 3.108717 | 1.03162 |
cpc_oid = uri_parms[0]
query_str = uri_parms[1]
try:
cpc = hmc.cpcs.lookup_by_oid(cpc_oid)
except KeyError:
raise InvalidResourceError(method, uri)
assert not cpc.dpm_enabled # TODO: Verify error or empty result?
result_profiles = []
filter_args = parse_query_parms(method, uri, query_str)
for profile in cpc.load_activation_profiles.list(filter_args):
result_profile = {}
for prop in profile.properties:
if prop in ('element-uri', 'name'):
result_profile[prop] = profile.properties[prop]
result_profiles.append(result_profile)
return {'load-activation-profiles': result_profiles} | def get(method, hmc, uri, uri_parms, logon_required) | Operation: List Load Activation Profiles (requires classic mode). | 3.972533 | 3.421015 | 1.161215 |
result = self.session.post(self.cpc.uri + '/partitions',
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(result)
name = props.get(self._name_prop, None)
uri = props[self._uri_prop]
part = Partition(self, uri, name, props)
self._name_uri_cache.update(name, uri)
return part | def create(self, properties) | Create and configure a Partition in this CPC.
Authorization requirements:
* Object-access permission to this CPC.
* Task permission to the "New Partition" task.
Parameters:
properties (dict): Initial property values.
Allowable properties are defined in section 'Request body contents'
in section 'Create Partition' in the :term:`HMC API` book.
Returns:
Partition:
The resource object for the new Partition.
The object will have its 'object-uri' property set as returned by
the HMC, and will also have the input properties set.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 5.318057 | 4.616697 | 1.151918 |
# We do here some lazy loading.
if not self._nics:
self._nics = NicManager(self)
return self._nics | def nics(self) | :class:`~zhmcclient.NicManager`: Access to the :term:`NICs <NIC>` in
this Partition. | 7.067183 | 5.533133 | 1.277248 |
# We do here some lazy loading.
if not self._hbas:
try:
dpm_sm = self.feature_enabled('dpm-storage-management')
except ValueError:
dpm_sm = False
if not dpm_sm:
self._hbas = HbaManager(self)
return self._hbas | def hbas(self) | :class:`~zhmcclient.HbaManager`: Access to the :term:`HBAs <HBA>` in
this Partition.
If the "dpm-storage-management" feature is enabled, this property is
`None`. | 6.413161 | 3.954511 | 1.621733 |
# We do here some lazy loading.
if not self._virtual_functions:
self._virtual_functions = VirtualFunctionManager(self)
return self._virtual_functions | def virtual_functions(self) | :class:`~zhmcclient.VirtualFunctionManager`: Access to the
:term:`Virtual Functions <Virtual Function>` in this Partition. | 6.132973 | 4.78088 | 1.282813 |
feature_list = self.prop('available-features-list', None)
if feature_list is None:
raise ValueError("Firmware features are not supported on CPC %s" %
self.manager.cpc.name)
for feature in feature_list:
if feature['name'] == feature_name:
break
else:
raise ValueError("Firmware feature %s is not available on CPC %s" %
(feature_name, self.manager.cpc.name))
return feature['state'] | def feature_enabled(self, feature_name) | Indicates whether the specified feature is enabled for the CPC of this
partition.
The HMC must generally support features, and the specified feature must
be available for the CPC.
For a list of available features, see section "Features" in the
:term:`HMC API`, or use the :meth:`feature_info` method.
Authorization requirements:
* Object-access permission to this partition.
Parameters:
feature_name (:term:`string`): The name of the feature.
Returns:
bool: `True` if the feature is enabled, or `False` if the feature is
disabled (but available).
Raises:
:exc:`ValueError`: Features are not supported on the HMC.
:exc:`ValueError`: The specified feature is not available for the
CPC.
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 3.382086 | 3.084493 | 1.09648 |
feature_list = self.prop('available-features-list', None)
if feature_list is None:
raise ValueError("Firmware features are not supported on CPC %s" %
self.manager.cpc.name)
return feature_list | def feature_info(self) | Returns information about the features available for the CPC of this
partition.
Authorization requirements:
* Object-access permission to this partition.
Returns:
:term:`iterable`:
An iterable where each item represents one feature that is
available for the CPC of this partition.
Each item is a dictionary with the following items:
* `name` (:term:`unicode string`): Name of the feature.
* `description` (:term:`unicode string`): Short description of
the feature.
* `state` (bool): Enablement state of the feature (`True` if the
enabled, `False` if disabled).
Raises:
:exc:`ValueError`: Features are not supported on the HMC.
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 9.216369 | 6.80482 | 1.354388 |
result = self.manager.session.post(
self.uri + '/operations/start',
wait_for_completion=wait_for_completion,
operation_timeout=operation_timeout)
if wait_for_completion:
statuses = ["active", "degraded"]
self.wait_for_status(statuses, status_timeout)
return result | def start(self, wait_for_completion=True, operation_timeout=None,
status_timeout=None) | Start (activate) this Partition, using the HMC operation "Start
Partition".
This HMC operation has deferred status behavior: If the asynchronous
job on the HMC is complete, it takes a few seconds until the partition
status has reached the desired value (it still may show status
"paused"). If `wait_for_completion=True`, this method repeatedly checks
the status of the partition after the HMC operation has completed, and
waits until the status is in one of the desired states "active" or
"degraded".
TODO: Describe what happens if the maximum number of active partitions
is exceeded.
Authorization requirements:
* Object-access permission to this Partition.
* Object-access permission to the CPC containing this Partition.
* Task permission to the "Start Partition" task.
Parameters:
wait_for_completion (bool):
Boolean controlling whether this method should wait for completion
of the requested asynchronous HMC operation, as follows:
* If `True`, this method will wait for completion of the
asynchronous job performing the operation.
* If `False`, this method will return immediately once the HMC has
accepted the request to perform the operation.
operation_timeout (:term:`number`):
Timeout in seconds, for waiting for completion of the asynchronous
job performing the operation. The special value 0 means that no
timeout is set. `None` means that the default async operation
timeout of the session is used. If the timeout expires when
`wait_for_completion=True`, a
:exc:`~zhmcclient.OperationTimeout` is raised.
status_timeout (:term:`number`):
Timeout in seconds, for waiting that the status of the partition
has reached the desired status, after the HMC operation has
completed.
The special value 0 means that no timeout is set. `None` means that
the default async operation timeout of the session is used.
If the timeout expires when `wait_for_completion=True`, a
:exc:`~zhmcclient.StatusTimeout` is raised.
Returns:
:class:`py:dict` or :class:`~zhmcclient.Job`:
If `wait_for_completion` is `True`, returns an empty
:class:`py:dict` object.
If `wait_for_completion` is `False`, returns a
:class:`~zhmcclient.Job` object representing the asynchronously
executing job on the HMC.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`~zhmcclient.OperationTimeout`: The timeout expired while
waiting for completion of the operation.
:exc:`~zhmcclient.StatusTimeout`: The timeout expired while
waiting for the desired partition status. | 3.48729 | 3.410285 | 1.02258 |
result = self.manager.session.post(
self.uri + '/operations/scsi-dump',
wait_for_completion=wait_for_completion,
operation_timeout=operation_timeout,
body=parameters)
return result | def dump_partition(self, parameters, wait_for_completion=True,
operation_timeout=None) | Dump this Partition, by loading a standalone dump program from a SCSI
device and starting its execution, using the HMC operation
'Dump Partition'.
Authorization requirements:
* Object-access permission to this Partition.
* Task permission to the "Dump Partition" task.
Parameters:
parameters (dict): Input parameters for the operation.
Allowable input parameters are defined in section
'Request body contents' in section 'Dump Partition' in the
:term:`HMC API` book.
wait_for_completion (bool):
Boolean controlling whether this method should wait for completion
of the requested asynchronous HMC operation, as follows:
* If `True`, this method will wait for completion of the
asynchronous job performing the operation.
* If `False`, this method will return immediately once the HMC has
accepted the request to perform the operation.
operation_timeout (:term:`number`):
Timeout in seconds, for waiting for completion of the asynchronous
job performing the operation. The special value 0 means that no
timeout is set. `None` means that the default async operation
timeout of the session is used. If the timeout expires when
`wait_for_completion=True`, a
:exc:`~zhmcclient.OperationTimeout` is raised.
Returns:
:class:`py:dict` or :class:`~zhmcclient.Job`:
If `wait_for_completion` is `True`, returns an empty
:class:`py:dict` object.
If `wait_for_completion` is `False`, returns a
:class:`~zhmcclient.Job` object representing the asynchronously
executing job on the HMC.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`~zhmcclient.OperationTimeout`: The timeout expired while
waiting for completion of the operation. | 4.476641 | 3.989433 | 1.122125 |
query_parms_str = '?image-name={}&ins-file-name={}'. \
format(quote(image_name, safe=''), quote(ins_file_name, safe=''))
self.manager.session.post(
self.uri + '/operations/mount-iso-image' + query_parms_str,
body=image) | def mount_iso_image(self, image, image_name, ins_file_name) | Upload an ISO image and associate it to this Partition
using the HMC operation 'Mount ISO Image'.
When the partition already has an ISO image associated,
the newly uploaded image replaces the current one.
Authorization requirements:
* Object-access permission to this Partition.
* Task permission to the "Partition Details" task.
Parameters:
image (:term:`byte string` or file-like object):
The content of the ISO image.
Images larger than 2GB cannot be specified as a Byte string; they
must be specified as a file-like object.
File-like objects must have opened the file in binary mode.
image_name (:term:`string`): The displayable name of the image.
This value must be a valid Linux file name without directories,
must not contain blanks, and must end with '.iso' in lower case.
This value will be shown in the 'boot-iso-image-name' property of
this partition.
ins_file_name (:term:`string`): The path name of the INS file within
the file system of the ISO image.
This value will be shown in the 'boot-iso-ins-file' property of
this partition.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 3.6964 | 3.238927 | 1.141242 |
body = {'include-refresh-messages': include_refresh_messages}
result = self.manager.session.post(
self.uri + '/operations/open-os-message-channel', body)
return result['topic-name'] | def open_os_message_channel(self, include_refresh_messages=True) | Open a JMS message channel to this partition's operating system,
returning the string "topic" representing the message channel.
Parameters:
include_refresh_messages (bool):
Boolean controlling whether refresh operating systems messages
should be sent, as follows:
* If `True`, refresh messages will be recieved when the user
connects to the topic. The default.
* If `False`, refresh messages will not be recieved when the user
connects to the topic.
Returns:
:term:`string`:
Returns a string representing the os-message-notification JMS
topic. The user can connect to this topic to start the flow of
operating system messages.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 5.05241 | 4.44259 | 1.137267 |
body = {'is-priority': is_priority,
'operating-system-command-text': os_command_text}
self.manager.session.post(
self.uri + '/operations/send-os-cmd', body) | def send_os_command(self, os_command_text, is_priority=False) | Send a command to the operating system running in this partition.
Parameters:
os_command_text (string): The text of the operating system command.
is_priority (bool):
Boolean controlling whether this is a priority operating system
command, as follows:
* If `True`, this message is treated as a priority operating
system command.
* If `False`, this message is not treated as a priority
operating system command. The default.
Returns:
None
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 5.198136 | 4.786803 | 1.085931 |
if status_timeout is None:
status_timeout = \
self.manager.session.retry_timeout_config.status_timeout
if status_timeout > 0:
end_time = time.time() + status_timeout
if isinstance(status, (list, tuple)):
statuses = status
else:
statuses = [status]
while True:
# Fastest way to get actual status value:
parts = self.manager.cpc.partitions.list(
filter_args={'name': self.name})
assert len(parts) == 1
this_part = parts[0]
actual_status = this_part.get_property('status')
if actual_status in statuses:
return
if status_timeout > 0 and time.time() > end_time:
raise StatusTimeout(
"Waiting for partition {} to reach status(es) '{}' timed "
"out after {} s - current status is '{}'".
format(self.name, statuses, status_timeout, actual_status),
actual_status, statuses, status_timeout)
time.sleep(1) | def wait_for_status(self, status, status_timeout=None) | Wait until the status of this partition has a desired value.
Parameters:
status (:term:`string` or iterable of :term:`string`):
Desired partition status or set of status values to reach; one or
more of the values defined for the 'status' property in the
data model for partitions in the :term:`HMC API` book.
status_timeout (:term:`number`):
Timeout in seconds, for waiting that the status of the partition
has reached one of the desired status values. The special value 0
means that no timeout is set.
`None` means that the default status timeout will be used.
If the timeout expires, a :exc:`~zhmcclient.StatusTimeout` is
raised.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`~zhmcclient.StatusTimeout`: The status timeout expired while
waiting for the desired partition status. | 3.148535 | 2.939804 | 1.071002 |
crypto_adapter_uris = [a.uri for a in crypto_adapters]
body = {'crypto-adapter-uris': crypto_adapter_uris,
'crypto-domain-configurations': crypto_domain_configurations}
self.manager.session.post(
self.uri + '/operations/increase-crypto-configuration', body) | def increase_crypto_config(self, crypto_adapters,
crypto_domain_configurations) | Add crypto adapters and/or crypto domains to the crypto configuration
of this partition.
The general principle for maintaining crypto configurations of
partitions is as follows: Each adapter included in the crypto
configuration of a partition has all crypto domains included in the
crypto configuration. Each crypto domain included in the crypto
configuration has the same access mode on all adapters included in the
crypto configuration.
Example: Assume that the current crypto configuration of a partition
includes crypto adapter A and crypto domains 0 and 1. When this method
is called to add adapter B and domain configurations for domains 1 and
2, the resulting crypto configuration of the partition will include
domains 0, 1, and 2 on each of the adapters A and B.
Authorization requirements:
* Object-access permission to this Partition.
* Task permission to the "Partition Details" task.
Parameters:
crypto_adapters (:term:`iterable` of :class:`~zhmcclient.Adapter`):
Crypto adapters that should be added to the crypto configuration of
this partition.
crypto_domain_configurations (:term:`iterable` of `domain_config`):
Crypto domain configurations that should be added to the crypto
configuration of this partition.
A crypto domain configuration (`domain_config`) is a dictionary
with the following keys:
* ``"domain-index"`` (:term:`integer`): Domain index of the crypto
domain.
The domain index is a number in the range of 0 to a maximum that
depends on the model of the crypto adapter and the CPC model. For
the Crypto Express 5S adapter in a z13, the maximum domain index
is 84.
* ``"access-mode"`` (:term:`string`): Access mode for the crypto
domain.
The access mode specifies the way the partition can use the
crypto domain on the crypto adapter(s), using one of the
following string values:
* ``"control"`` - The partition can load cryptographic keys into
the domain, but it may not use the domain to perform
cryptographic operations.
* ``"control-usage"`` - The partition can load cryptographic keys
into the domain, and it can use the domain to perform
cryptographic operations.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 3.394663 | 4.153505 | 0.817301 |
crypto_adapter_uris = [a.uri for a in crypto_adapters]
body = {'crypto-adapter-uris': crypto_adapter_uris,
'crypto-domain-indexes': crypto_domain_indexes}
self.manager.session.post(
self.uri + '/operations/decrease-crypto-configuration', body) | def decrease_crypto_config(self, crypto_adapters,
crypto_domain_indexes) | Remove crypto adapters and/or crypto domains from the crypto
configuration of this partition.
For the general principle for maintaining crypto configurations of
partitions, see :meth:`~zhmcclient.Partition.increase_crypto_config`.
Example: Assume that the current crypto configuration of a partition
includes crypto adapters A, B and C and crypto domains 0, 1, and 2 (on
each of the adapters). When this method is called to remove adapter C
and domain 2, the resulting crypto configuration of the partition will
include domains 0 and 1 on each of the adapters A and B.
Authorization requirements:
* Object-access permission to this Partition.
* Task permission to the "Partition Details" task.
Parameters:
crypto_adapters (:term:`iterable` of :class:`~zhmcclient.Adapter`):
Crypto adapters that should be removed from the crypto
configuration of this partition.
crypto_domain_indexes (:term:`iterable` of :term:`integer`):
Domain indexes of the crypto domains that should be removed from
the crypto configuration of this partition. For values, see
:meth:`~zhmcclient.Partition.increase_crypto_config`.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 3.410797 | 3.894028 | 0.875905 |
body = {'domain-index': crypto_domain_index,
'access-mode': access_mode}
self.manager.session.post(
self.uri + '/operations/change-crypto-domain-configuration', body) | def change_crypto_domain_config(self, crypto_domain_index, access_mode) | Change the access mode for a crypto domain that is currently included
in the crypto configuration of this partition.
The access mode will be changed for the specified crypto domain on all
crypto adapters currently included in the crypto configuration of this
partition.
For the general principle for maintaining crypto configurations of
partitions, see :meth:`~zhmcclient.Partition.increase_crypto_config`.
Authorization requirements:
* Object-access permission to this Partition.
* Task permission to the "Partition Details" task.
Parameters:
crypto_domain_index (:term:`integer`):
Domain index of the crypto domain to be changed. For values, see
:meth:`~zhmcclient.Partition.increase_crypto_config`.
access_mode (:term:`string`):
The new access mode for the crypto domain. For values, see
:meth:`~zhmcclient.Partition.increase_crypto_config`.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 4.412808 | 5.126781 | 0.860737 |
body = {
'crypto-adapter-uri': crypto_adapter.uri,
'domain-index': crypto_domain_index
}
self.manager.session.post(
self.uri + '/operations/zeroize-crypto-domain', body) | def zeroize_crypto_domain(self, crypto_adapter, crypto_domain_index) | Zeroize a single crypto domain on a crypto adapter.
Zeroizing a crypto domain clears the cryptographic keys and
non-compliance mode settings in the crypto domain.
The crypto domain must be attached to this partition in "control-usage"
access mode.
Supported CPC versions: z14 GA2 and above, and the corresponding
LinuxOne systems.
Authorization requirements:
* Object-access permission to this Partition and to the Crypto Adapter.
* Task permission to the "Zeroize Crypto Domain" task.
Parameters:
crypto_adapter (:class:`~zhmcclient.Adapter`):
Crypto adapter with the crypto domain to be zeroized.
crypto_domain_index (:term:`integer`):
Domain index of the crypto domain to be zeroized.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 4.718666 | 4.57184 | 1.032115 |
body = {'storage-group-uri': storage_group.uri}
self.manager.session.post(
self.uri + '/operations/attach-storage-group', body) | def attach_storage_group(self, storage_group) | Attach a :term:`storage group` to this partition.
This will cause the :term:`storage volumes <storage volume>` of the
storage group to be attached to the partition, instantiating any
necessary :term:`virtual storage resource` objects.
A storage group can be attached to a partition regardless of its
fulfillment state. The fulfillment state of its storage volumes
and thus of the entire storage group changes as volumes are discovered
by DPM, and will eventually reach "complete".
The CPC must have the "dpm-storage-management" feature enabled.
Authorization requirements:
* Object-access permission to this partition.
* Object-access permission to the specified storage group.
* Task permission to the "Partition Details" task.
Parameters:
storage_group (:class:`~zhmcclient.StorageGroup`):
Storage group to be attached. The storage group must not currently
be attached to this partition.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 4.928187 | 5.122694 | 0.96203 |
body = {'storage-group-uri': storage_group.uri}
self.manager.session.post(
self.uri + '/operations/detach-storage-group', body) | def detach_storage_group(self, storage_group) | Detach a :term:`storage group` from this partition.
This will cause the :term:`storage volumes <storage volume>` of the
storage group to be detached from the partition, removing any
:term:`virtual storage resource` objects that had been created upon
attachment.
A storage group can be detached from a partition regardless of its
fulfillment state. The fulfillment state of its storage volumes
changes as volumes are discovered by DPM.
The CPC must have the "dpm-storage-management" feature enabled.
Authorization requirements:
* Object-access permission to this partition.
* Task permission to the "Partition Details" task.
Parameters:
storage_group (:class:`~zhmcclient.StorageGroup`):
Storage group to be detached. The storage group must currently
be attached to this partition.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 4.694835 | 5.000581 | 0.938858 |
sg_list = []
sg_uris = self.get_property('storage-group-uris')
if sg_uris:
cpc = self.manager.cpc
for sg_uri in sg_uris:
sg = cpc.storage_groups.resource_object(sg_uri)
sg_list.append(sg)
if full_properties:
sg.pull_full_properties()
return sg_list | def list_attached_storage_groups(self, full_properties=False) | Return the storage groups that are attached to this partition.
The CPC must have the "dpm-storage-management" feature enabled.
Authorization requirements:
* Object-access permission to this partition.
* Task permission to the "Partition Details" task.
Parameters:
full_properties (bool):
Controls that the full set of resource properties for each returned
storage group is being retrieved, vs. only the following short set:
"object-uri", "object-id", "class", "parent".
TODO: Verify short list of properties.
Returns:
List of :class:`~zhmcclient.StorageGroup` objects representing the
storage groups that are attached to this partition.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 2.844207 | 2.712246 | 1.048654 |
self.manager.session.post(self.uri, body=properties)
# The name of Password Rules cannot be updated. An attempt to do so
# should cause HTTPError to be raised in the POST above, so we assert
# that here, because we omit the extra code for handling name updates:
assert self.manager._name_prop not in properties
self.properties.update(copy.deepcopy(properties)) | def update_properties(self, properties) | Update writeable properties of this PasswordRule.
The Password Rule must be user-defined. System-defined Password Rules
cannot be updated.
Authorization requirements:
* Task permission to the "Manage Password Rules" task.
Parameters:
properties (dict): New values for the properties to be updated.
Properties not to be updated are omitted.
Allowable properties are the properties with qualifier (w) in
section 'Data model' in section 'Password Rule object' in the
:term:`HMC API` book.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.AuthError`
:exc:`~zhmcclient.ConnectionError` | 16.568779 | 12.617125 | 1.313198 |
if self._api_version is None:
self.query_api_version()
return self._api_version['api-major-version'],\
self._api_version['api-minor-version'] | def version_info(self) | Returns API version information for the HMC.
This operation does not require authentication.
Returns:
:term:`HMC API version`: The HMC API version supported by the HMC.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.ConnectionError` | 4.004511 | 6.433034 | 0.622492 |
version_resp = self._session.get('/api/version',
logon_required=False)
self._api_version = version_resp
return self._api_version | def query_api_version(self) | The Query API Version operation returns information about
the level of Web Services API supported by the HMC.
This operation does not require authentication.
Returns:
:term:`json object`:
A JSON object with members ``api-major-version``,
``api-minor-version``, ``hmc-version`` and ``hmc-name``.
For details about these properties, see section
'Response body contents' in section 'Query API Version' in the
:term:`HMC API` book.
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.ConnectionError` | 6.824972 | 8.822394 | 0.773596 |
uri = '/api/services/inventory'
body = {'resources': resources}
result = self.session.post(uri, body=body)
return result | def get_inventory(self, resources) | Returns a JSON object with the requested resources and their
properties, that are managed by the HMC.
This method performs the 'Get Inventory' HMC operation.
Parameters:
resources (:term:`iterable` of :term:`string`):
Resource classes and/or resource classifiers specifying the types
of resources that should be included in the result. For valid
values, see the 'Get Inventory' operation in the :term:`HMC API`
book.
Element resources of the specified resource types are automatically
included as children (for example, requesting 'partition' includes
all of its 'hba', 'nic' and 'virtual-function' element resources).
Must not be `None`.
Returns:
:term:`JSON object`:
The resources with their properties, for the requested resource
classes and resource classifiers.
Example:
resource_classes = ['partition', 'adapter']
result_dict = client.get_inventory(resource_classes)
Raises:
:exc:`~zhmcclient.HTTPError`
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.ConnectionError` | 5.358238 | 6.932107 | 0.772959 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.