7. Mock support
The zhmcclient PyPI package provides unit testing support for its users via its
zhmcclient_mock
Python package. That package allows users of zhmcclient to
easily define a faked HMC that is populated with resources as needed by the
test case.
The faked HMC environment is set up by creating an instance of the
zhmcclient_mock.FakedSession
class instead of the
zhmcclient.Session
class:
import zhmcclient
import zhmcclient_mock
session = zhmcclient_mock.FakedSession('fake-host', 'fake-hmc', '2.13.1',
'1.8')
client = zhmcclient.Client(session)
cpcs = client.cpcs.list()
. . .
Other than using a different session class, the code operates against the same
zhmcclient API as before. For example, you can see in the example above that
the client object is set up from the same zhmcclient.Client
class as
before, and that the CPCs can be listed through the API of the client object as
before.
The difference is that the faked session object contains a faked HMC and does not communicate at all with an actual HMC.
The faked HMC of the faked session object can be accessed via the
hmc
attribute of the faked session object
in order to populate it with resources, for example to build up an initial
resource environment for a test case.
The following example of a unit test case shows how an initial set of resources
that is defined as a dictionary and loaded into the faked HMC using the
add_resources()
method:
import unittest
import zhmcclient
import zhmcclient_mock
class MyTests(unittest.TestCase):
def setUp(self):
self.session = zhmcclient_mock.FakedSession(
'fake-host', 'fake-hmc', '2.13.1', '1.8')
self.session.hmc.add_resources({
'cpcs': [
{
'properties': {
'name': 'cpc_1',
'description': 'CPC #1',
},
'adapters': [
{
'properties': {
'name': 'osa_1',
'description': 'OSA #1',
'adapter-family': 'osa',
},
'ports': [
{
'properties': {
'name': 'osa_1_1',
'description': 'OSA #1 Port #1',
},
},
]
},
]
},
]
})
self.client = zhmcclient.Client(self.session)
def test_list(self):
cpcs = self.client.cpcs.list()
self.assertEqual(len(cpcs), 1)
self.assertEqual(cpcs[0].name, 'cpc_1')
In this example, the test_list()
method tests the CPC list method of the
zhmcclient package, but the same approach is used for testing code that
uses the zhmcclient package.
As an alternative to bulk-loading resources via the input dictionary, it is
also possible to add resources one by one using the add()
methods of the
faked resource manager classes, as shown in the following example:
class MyTests(unittest.TestCase):
def setUp(self):
self.session = zhmcclient_mock.FakedSession(
'fake-host', 'fake-hmc', '2.13.1', '1.8')
cpc1 = self.session.hmc.cpcs.add({
'name': 'cpc_1',
'description': 'CPC #1',
})
adapter1 = cpc1.adapters.add({
'name': 'osa_1',
'description': 'OSA #1',
'adapter-family': 'osa',
})
port1 = adapter1.ports.add({
'name': 'osa_1_1',
'description': 'OSA #1 Port #1',
})
self.client = zhmcclient.Client(self.session)
As you can see, the resources need to be added from top to bottom in the
resource tree, starting at the hmc
attribute of the faked session object.
Section Faked HMC describes all faked resource and manager classes that you can use to add resources that way.
Section Faked session describes the faked session class.
7.1. Faked session
A faked Session class for the zhmcclient package.
- class zhmcclient_mock.FakedSession(host, hmc_name, hmc_version, api_version, userid=None, password=None)[source]
A faked Session class for the zhmcclient package, that can be used as a replacement for the
zhmcclient.Session
class.This class is derived from
zhmcclient.Session
.This class can be used by projects using the zhmcclient package for their unit testing. It can also be used by unit tests of the zhmcclient package itself.
This class provides a faked HMC with all of its resources that are relevant for the zhmcclient.
The faked HMC provided by this class maintains its resource state in memory as Python objects, and no communication happens to any real HMC. The faked HMC implements all HMC operations that are relevant for the zhmcclient package in a successful manner.
It is possible to populate the faked HMC with an initial resource state (see
add_resources()
).- Parameters:
host (string) – HMC host the mocked HMC will be set up with.
hmc_name (string) – HMC name. Used for result of Query Version Info operation.
hmc_version (string) – HMC version string (e.g. ‘2.13.1’). Used for result of Query Version Info operation.
api_version (string) – HMC API version string (e.g. ‘1.8’). Used for result of Query Version Info operation.
userid (string) – HMC userid for logging in to the mocked HMC.
password (string) – HMC password for logging in to the mocked HMC.
- property hmc
The faked HMC provided by this faked session.
The faked HMC supports being populated with initial resource state, for example using its
zhmcclient_mock.FakedHmc.add_resources()
method.As an alternative to providing an entire resource tree, the resources can also be added one by one, from top to bottom, using the
zhmcclient_mock.FakedBaseManager.add()
methods of the respective managers (the top-level manager for CPCs can be accessed viahmc.cpcs
).- Type:
- static from_hmc_yaml_file(filepath, userid=None, password=None)[source]
Return a new FakedSession object from an HMC definition in a YAML file.
The data format of the YAML file is validated using a schema.
- Parameters:
- Returns:
New faked session with faked HMC set up from HMC definition.
- Return type:
- Raises:
IOError – Error opening the YAML file for reading.
YamlFormatError – Invalid YAML syntax in HMC definition.
HmcDefinitionSchemaError – Invalid data format in HMC definition.
- static from_hmc_yaml(hmc_yaml, filepath=None, userid=None, password=None)[source]
Return a new FakedSession object from an HMC definition YAML string or stream.
An HMC definition YAML string can be created using
zhmcclient.Client.to_hmc_yaml()
.The timestamp in metric values can have any valid ISO8601 format. Timezone-naive values are amended with the local timezone.
The data format of the YAML string is validated using a schema.
- Parameters:
hmc_yaml (string or stream) – HMC definition YAML string or stream.
filepath (string) – Path name of the YAML file that contains the HMC definition; used only in exception messages. If None, no filename is used in exception messages.
userid (string) – Userid of the HMC user to be used for logging in, or None.
password (string) – Password of the HMC user if userid was specified, or None.
- Returns:
New faked session with faked HMC set up from HMC definition.
- Return type:
- Raises:
YamlFormatError – Invalid YAML syntax in HMC definition YAML string or stream.
HmcDefinitionSchemaError – Invalid data format in HMC definition.
- static from_hmc_dict(hmc_dict, filepath=None, userid=None, password=None)[source]
Return a new FakedSession object from an HMC definition dictionary.
An HMC definition dictionary can be created using
zhmcclient.Client.to_hmc_dict()
.The timestamp in metric values can have any valid ISO8601 format. Timezone-naive values are amended with the local timezone.
The data format of the YAML string is validated using a schema.
- Parameters:
hmc_dict (dict) – HMC definition dictionary.
filepath (string) – Path name of the YAML file that contains the HMC definition; used only in exception messages. If None, no filename is used in exception messages.
userid (string) – Userid of the HMC user to be used for logging in, or None.
password (string) – Password of the HMC user if userid was specified, or None.
- Returns:
New faked session with faked HMC set up from the HMC definition.
- Return type:
- Raises:
HmcDefinitionSchemaError – Invalid data format in HMC definition.
- get(uri, logon_required=True)[source]
Perform the HTTP GET method against the resource identified by a URI, on the faked HMC.
- Parameters:
uri (string) – Relative URI path of the resource, e.g. “/api/session”. This URI is relative to the base URL of the session (see the
base_url
property). Must not be None.logon_required (bool) –
Boolean indicating whether the operation requires that the session is logged on to the HMC.
Because this is a faked HMC, this does not perform a real logon, but it is still used to update the state in the faked HMC.
- Returns:
json object with the operation result.
- Raises:
- post(uri, body=None, logon_required=True, wait_for_completion=True, operation_timeout=None)[source]
Perform the HTTP POST method against the resource identified by a URI, using a provided request body, on the faked HMC.
HMC operations using HTTP POST are either synchronous or asynchronous. Asynchronous operations return the URI of an asynchronously executing job that can be queried for status and result.
Examples for synchronous operations:
With no response body: “Logon”, “Update CPC Properties”
With a response body: “Create Partition”
Examples for asynchronous operations:
With no
job-results
field in the completed job status response: “Start Partition”With a
job-results
field in the completed job status response (under certain conditions): “Activate a Blade”, or “Set CPC Power Save”
The wait_for_completion parameter of this method can be used to deal with asynchronous HMC operations in a synchronous way.
- Parameters:
uri (string) – Relative URI path of the resource, e.g. “/api/session”. This URI is relative to the base URL of the session (see the
base_url
property). Must not be None.body (json object) – JSON object to be used as the HTTP request body (payload). None means the same as an empty dictionary, namely that no HTTP body is included in the request.
logon_required (bool) –
Boolean indicating whether the operation requires that the session is logged on to the HMC. For example, the “Logon” operation does not require that.
Because this is a faked HMC, this does not perform a real logon, but it is still used to update the state in the faked HMC.
wait_for_completion (bool) –
Boolean controlling whether this method should wait for completion of the requested HMC operation, as follows:
If True, this method will wait for completion of the requested operation, regardless of whether the operation is synchronous or asynchronous.
This will cause an additional entry in the time statistics to be created for the asynchronous operation and waiting for its completion. This entry will have a URI that is the targeted URI, appended with “+completion”.
If False, this method will immediately return the result of the HTTP POST method, regardless of whether the operation is synchronous or asynchronous.
operation_timeout (number) –
Timeout in seconds, when waiting for completion of an asynchronous operation. The special value 0 means that no timeout is set. None means that the default async operation timeout of the session is used.
For wait_for_completion=True, a
OperationTimeout
is raised when the timeout expires.For wait_for_completion=False, this parameter has no effect.
- Returns:
If wait_for_completion is True, returns a JSON object representing the response body of the synchronous operation, or the response body of the completed job that performed the asynchronous operation. If a synchronous operation has no response body, None is returned.
If wait_for_completion is False, returns a JSON object representing the response body of the synchronous or asynchronous operation. In case of an asynchronous operation, the JSON object will have a member named
job-uri
, whose value can be used with thequery_job_status()
method to determine the status of the job and the result of the original operation, once the job has completed.See the section in the HMC API book about the specific HMC operation and about the ‘Query Job Status’ operation, for a description of the members of the returned JSON objects.
- Return type:
- Raises:
- delete(uri, logon_required=True)[source]
Perform the HTTP DELETE method against the resource identified by a URI, on the faked HMC.
- Parameters:
uri (string) – Relative URI path of the resource, e.g. “/api/session/{session-id}”. This URI is relative to the base URL of the session (see the
base_url
property). Must not be None.logon_required (bool) –
Boolean indicating whether the operation requires that the session is logged on to the HMC. For example, for the logoff operation, it does not make sense to first log on.
Because this is a faked HMC, this does not perform a real logon, but it is still used to update the state in the faked HMC.
- Raises:
7.2. Faked HMC
The zhmcclient_mock package provides a faked HMC with all resources that are relevant for the zhmcclient package. The faked HMC is implemented as a local Python object and maintains its resource state across operations.
- class zhmcclient_mock.InputError(message)[source]
An error that is raised by the faked resource classes and indicates that the input is invalid in some way.
args[0]
will be set to a message detailing the issue.
- class zhmcclient_mock.FakedHmc(hmc_name, hmc_version, api_version)[source]
A faked HMC.
Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.An object of this class represents a faked HMC that can have all faked resources that are relevant for the zhmcclient package.
The Python API to this class and its child resource classes is not compatible with the zhmcclient API. Instead, these classes serve as an in-memory backend for a faked session class (see
zhmcclient_mock.FakedSession
) that replaces the normalzhmcclient.Session
class.Objects of this class should not be created by the user. Instead, access the
zhmcclient_mock.FakedSession.hmc
attribute.- property metric_values
The metric values in this HMC that have been prepared for later retrieval, with:
key(string): Metric group name, e.g. ‘partition-usage’.
value(list of
FakedMetricObjectValues
): The metric values of this metric group.
- Type:
- property metric_groups
The metric groups supported by this HMC, with:
key(string): Metric group name, e.g. ‘partition-usage’.
value(list of
FakedMetricGroupDefinition
): The metric groups including their metric values and their types.
- Type:
- property enabled
Return whether the faked HMC is enabled.
- disable()[source]
Disable the faked HMC. This will cause an error to be raised when a faked session attempts to communicate with the disabled HMC.
- lookup_by_uri(uri)[source]
Look up a faked resource by its object URI, within this faked HMC.
- Parameters:
uri (string) – The object URI of the faked resource (e.g. value of the ‘object-uri’ property).
- Returns:
The faked resource.
- Return type:
- Raises:
KeyError – No resource found for this object ID.
- add_metric_values(values)[source]
Add one set of faked metric values for a particular resource to the metrics response for a particular metric group, for later retrieval.
For defined metric groups, see chapter “Metric groups” in the HMC API book.
- Parameters:
values (
FakedMetricObjectValues
) – The set of metric values to be added. It specifies the resource URI and the targeted metric group name.
- class zhmcclient_mock.FakedActivationProfileManager(hmc, cpc, profile_type)[source]
A manager for faked Activation Profile resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked Activation Profile resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’name’ (the OID property for this resource type!) will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the OID (‘name’) property, if not specified.
’class’ will be auto-generated to ‘{profile_type}’-activation-profile’, if not specified.
- Returns:
- The faked
Activation Profile resource.
- Return type:
- property profile_type
Type of the activation profile (‘reset’, ‘image’, ‘load’).
- class zhmcclient_mock.FakedActivationProfile(manager, properties)[source]
A faked Activation Profile resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedAdapterManager(hmc, cpc)[source]
A manager for faked Adapter resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked Adapter resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’object-uri’ will be auto-generated based upon the object ID, if not specified.
’class’ will be auto-generated to ‘adapter’, if not specified.
’status’ is auto-set to ‘active’, if not specified.
’adapter-family’ or ‘type’ is required to be specified, in order to determine whether the adapter is a network or storage adapter.
’adapter-family’ is auto-set based upon ‘type’, if not specified.
For network adapters, ‘network-port-uris’ is auto-set to an empty list, if not specified.
For storage adapters, ‘storage-port-uris’ is auto-set to an empty list, if not specified.
- Returns:
The faked Adapter resource.
- Return type:
- Raises:
zhmcclient_mock.InputError – Some issue with the input properties.
- class zhmcclient_mock.FakedAdapter(manager, properties)[source]
A faked Adapter resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.- __repr__()[source]
Return a string with the state of this faked Adapter resource, for debug purposes.
- property ports
The Port resources of this Adapter.
If the kind of adapter does not have ports, this is None.
- Type:
- property adapter_kind
The kind of adapter, determined from the ‘adapter-family’ or ‘type’ properties. This is currently used to distinguish storage and network adapters.
Possible values are: * ‘network’ - A network adapter (OSA, ROCE, Hipersockets) * ‘storage’ - A storage adapter (FICON, FCP) * ‘other’ - Another adapter (zEDC, Crypto)
- Type:
string
- class zhmcclient_mock.FakedCapacityGroupManager(hmc, cpc)[source]
A manager for faked CapacityGroup resources within a faked Cpc (see
zhmcclient_mock.FakedCpc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked CapacityGroup resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the object ID, if not specified.
’class’ will be auto-generated to ‘capacity-group’, if not specified.
’capping-enabled’ will be auto-generated to True, if not specified.
- Returns:
- The faked CapacityGroup
resource.
- Return type:
- class zhmcclient_mock.FakedCapacityGroup(manager, properties)[source]
A faked CapacityGroup resource within a faked Cpc (see
zhmcclient_mock.FakedCpc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedConsoleManager(hmc, client)[source]
A manager for faked Console resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- property console
The faked Console representing the faked HMC (an object of
FakedConsole
). The object is cached.
- add(properties)[source]
Add a faked Console resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-uri’ will be auto-generated to ‘/api/console’, if not specified.
’class’ will be auto-generated to ‘console’, if not specified.
- Returns:
The faked Console resource.
- Return type:
- class zhmcclient_mock.FakedConsole(manager, properties)[source]
A faked Console resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.- __repr__()[source]
Return a string with the state of this faked Console resource, for debug purposes.
- property storage_groups
Access to the faked Storage Group resources of this Console.
- Type:
FakedStorageGroupManager
- property users
Access to the faked User resources of this Console.
- Type:
- property user_roles
Access to the faked User Role resources of this Console.
- Type:
- property user_patterns
Access to the faked User Pattern resources of this Console.
- Type:
- property password_rules
Access to the faked Password Rule resources of this Console.
- Type:
FakedPasswordRulesManager
- property tasks
Access to the faked Task resources of this Console.
- Type:
- property ldap_server_definitions
Access to the faked LDAP Server Definition resources of this Console.
- property unmanaged_cpcs
Access to the faked unmanaged CPC resources of this Console.
- Type:
- class zhmcclient_mock.FakedCpcManager(hmc, client)[source]
A manager for faked managed CPC resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked CPC resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’object-uri’ will be auto-generated based upon the object ID, if not specified.
’class’ will be auto-generated to ‘cpc’, if not specified.
’dpm-enabled’ is auto-set to False, if not specified.
’is-ensemble-member’ is auto-set to False, if not specified.
’status’ is auto-set, if not specified, as follows: If the ‘dpm-enabled’ property is True, it is set to ‘active’; otherwise it is set to ‘operating’.
- Returns:
The faked CPC resource.
- Return type:
- class zhmcclient_mock.FakedCpc(manager, properties)[source]
A faked managed CPC resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.- property dpm_enabled
Indicates whether this CPC is in DPM mode.
This returns the value of the ‘dpm-enabled’ property.
- Type:
- property lpars
Access to the faked LPAR resources of this CPC.
- Type:
- property partitions
Access to the faked Partition resources of this CPC.
- Type:
- property adapters
Access to the faked Adapter resources of this CPC.
- Type:
- property virtual_switches
Access to the faked Virtual Switch resources of this CPC.
- property capacity_groups
Access to the faked Capacity Group resources of this CPC.
- property reset_activation_profiles
Access to the faked Reset Activation Profile resources of this CPC.
- property image_activation_profiles
Access to the faked Image Activation Profile resources of this CPC.
- property load_activation_profiles
Access to the faked Load Activation Profile resources of this CPC.
- class zhmcclient_mock.FakedHbaManager(hmc, partition)[source]
A manager for faked HBA resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked HBA resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the element ID, if not specified.
’class’ will be auto-generated to ‘hba’, if not specified.
’adapter-port-uri’ identifies the backing FCP port for this HBA and is required to be specified.
’device-number’ will be auto-generated with a unique value within the partition in the range 0x8000 to 0xFFFF, if not specified.
This method also updates the ‘hba-uris’ property in the parent faked Partition resource, by adding the URI for the faked HBA resource.
- Returns:
The faked HBA resource.
- Return type:
- Raises:
zhmcclient_mock.InputError – Some issue with the input properties.
- class zhmcclient_mock.FakedHba(manager, properties)[source]
A faked HBA resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedLdapServerDefinitionManager(hmc, console)[source]
A manager for faked LDAP Server Definition resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked LDAP Server Definition resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the element ID, if not specified.
’class’ will be auto-generated to ‘ldap-server-definition’, if not specified.
’connection-port’ will be auto-generated to None, if not specified.
’use-ssl’ will be auto-generated to False, if not specified.
- Returns:
The faked LdapServerDefinition resource.
- Return type:
- class zhmcclient_mock.FakedLdapServerDefinition(manager, properties)[source]
A faked LDAP Server Definition resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedLparManager(hmc, cpc)[source]
A manager for faked LPAR resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked LPAR resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’object-uri’ will be auto-generated based upon the object ID, if not specified.
’class’ will be auto-generated to ‘logical-partition’, if not specified.
’status’ is auto-set to ‘not-activated’, if not specified.
- Returns:
The faked LPAR resource.
- Return type:
- class zhmcclient_mock.FakedLpar(manager, properties)[source]
A faked LPAR resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedNicManager(hmc, partition)[source]
A manager for faked NIC resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked NIC resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the element ID, if not specified.
’class’ will be auto-generated to ‘nic’, if not specified.
Either ‘network-adapter-port-uri’ (for backing ROCE adapters) or ‘virtual-switch-uri’(for backing OSA or Hipersockets adapters) is required to be specified.
’device-number’ will be auto-generated with a unique value within the partition in the range 0x8000 to 0xFFFF, if not specified.
’type’ will be auto-generated to ‘iqd’, if not specified.
’ssc-management-nic’ will be auto-generated to False, if not specified.
This method also updates the ‘nic-uris’ property in the parent faked Partition resource, by adding the URI for the faked NIC resource.
This method also updates the ‘connected-vnic-uris’ property in the virtual switch referenced by ‘virtual-switch-uri’ property, and sets it to the URI of the faked NIC resource.
- Returns:
The faked NIC resource.
- Return type:
- Raises:
zhmcclient_mock.InputError – Some issue with the input properties.
- class zhmcclient_mock.FakedNic(manager, properties)[source]
A faked NIC resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedPartitionManager(hmc, cpc)[source]
A manager for faked Partition resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked Partition resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’object-uri’ will be auto-generated based upon the object ID, if not specified.
’class’ will be auto-generated to ‘partition’, if not specified.
’hba-uris’ will be auto-generated as an empty array, if not specified.
’nic-uris’ will be auto-generated as an empty array, if not specified.
’virtual-function-uris’ will be auto-generated as an empty array, if not specified.
’storage-group-uris’ will be auto-generated as an empty array, if not specified.
’tape-link-uris’ will be auto-generated as an empty array, if not specified.
’partition-link-uris’ will be auto-generated as an empty array, if not specified.
’status’ is auto-set to ‘stopped’, if not specified.
- Returns:
- The faked Partition
resource.
- Return type:
- class zhmcclient_mock.FakedPartition(manager, properties)[source]
A faked Partition resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.Each partition uses the device number range of 0x8000 to 0xFFFF for automatically assigned device numbers of HBAs, NICs and virtual functions. Users of the mock support should not use device numbers in that range (unless all of them are user-assigned for a particular partition).
- __repr__()[source]
Return a string with the state of this faked Partition resource, for debug purposes.
- property nics
Access to the faked NIC resources of this Partition.
- Type:
- property hbas
Access to the faked HBA resources of this Partition.
- Type:
- property virtual_functions
Access to the faked Virtual Function resources of this Partition.
- devno_alloc()[source]
Allocates a device number unique to this partition, in the range of 0x8000 to 0xFFFF.
- Returns:
The device number as four hexadecimal digits in upper case.
- Return type:
string
- Raises:
ValueError – No more device numbers available in that range.
- devno_free(devno)[source]
Free a device number allocated with
devno_alloc()
.The device number must be allocated.
- Parameters:
devno (string) – The device number as four hexadecimal digits.
- Raises:
ValueError – Device number not in pool range or not currently allocated.
- devno_free_if_allocated(devno)[source]
Free a device number allocated with
devno_alloc()
.If the device number is not currently allocated or not in the pool range, nothing happens.
- Parameters:
devno (string) – The device number as four hexadecimal digits.
- wwpn_alloc()[source]
Allocates a WWPN unique to this partition, in the range of 0xAFFEAFFE00008000 to 0xAFFEAFFE0000FFFF.
- Returns:
The WWPN as 16 hexadecimal digits in upper case.
- Return type:
string
- Raises:
ValueError – No more WWPNs available in that range.
- wwpn_free(wwpn)[source]
Free a WWPN allocated with
wwpn_alloc()
.The WWPN must be allocated.
- Parameters:
WWPN (string) – The WWPN as 16 hexadecimal digits.
- Raises:
ValueError – WWPN not in pool range or not currently allocated.
- wwpn_free_if_allocated(wwpn)[source]
Free a WWPN allocated with
wwpn_alloc()
.If the WWPN is not currently allocated or not in the pool range, nothing happens.
- Parameters:
WWPN (string) – The WWPN as 16 hexadecimal digits.
- class zhmcclient_mock.FakedPasswordRuleManager(hmc, console)[source]
A manager for faked Password Rule resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked Password Rule resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the element ID, if not specified.
’class’ will be auto-generated to ‘password-rule’, if not specified.
’min-length’ will be auto-generated to 8, if not specified.
’max-length’ will be auto-generated to 256, if not specified.
- Returns:
The faked Password Rule resource.
- Return type:
- class zhmcclient_mock.FakedPasswordRule(manager, properties)[source]
A faked Password Rule resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedPortManager(hmc, adapter)[source]
A manager for faked Adapter Port resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked Port resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the element ID, if not specified.
’class’ will be auto-generated to ‘network-port’ or ‘storage-port’, if not specified.
This method also updates the ‘network-port-uris’ or ‘storage-port-uris’ property in the parent Adapter resource, by adding the URI for the faked Port resource.
- Returns:
The faked Port resource.
- Return type:
- class zhmcclient_mock.FakedPort(manager, properties)[source]
A faked Adapter Port resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedTaskManager(hmc, console)[source]
A manager for faked Task resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked Task resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the element ID, if not specified.
’class’ will be auto-generated to ‘task’, if not specified.
- Returns:
The faked Task resource.
- Return type:
- class zhmcclient_mock.FakedTask(manager, properties)[source]
A faked Task resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedUnmanagedCpcManager(hmc, console)[source]
A manager for faked unmanaged CPC resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked unmanaged CPC resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’object-uri’ will be auto-generated based upon the object ID, if not specified.
- Returns:
The faked unmanaged CPC resource.
- Return type:
- class zhmcclient_mock.FakedUnmanagedCpc(manager, properties)[source]
A faked unmanaged CPC resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedUserManager(hmc, console)[source]
A manager for faked User resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked User resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’object-uri’ will be auto-generated based upon the object ID, if not specified.
’class’ will be auto-generated to ‘user’, if not specified.
’disabled’ will be auto-generated to False, if not specified.
- Returns:
The faked User resource.
- Return type:
- class zhmcclient_mock.FakedUser(manager, properties)[source]
A faked User resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedUserPatternManager(hmc, console)[source]
A manager for faked User Pattern resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked User Pattern resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the element ID, if not specified.
’class’ will be auto-generated to ‘user-pattern’, if not specified.
- Returns:
The faked User Pattern resource.
- Return type:
- class zhmcclient_mock.FakedUserPattern(manager, properties)[source]
A faked User Pattern resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedUserRoleManager(hmc, console)[source]
A manager for faked User Role resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked User Role resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’object-uri’ will be auto-generated based upon the object ID, if not specified.
’class’ will be auto-generated to ‘user-role’, if not specified.
’type’ will be auto-generated to ‘user-defined’, if not specified.
’is-inheritance-enabled’ will be auto-generated to False, if not specified.
- Returns:
The faked User Role resource.
- Return type:
- class zhmcclient_mock.FakedUserRole(manager, properties)[source]
A faked User Role resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedVirtualFunctionManager(hmc, partition)[source]
A manager for faked Virtual Function resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked Virtual Function resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’element-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’element-uri’ will be auto-generated based upon the element ID, if not specified.
’class’ will be auto-generated to ‘virtual-function’, if not specified.
’device-number’ will be auto-generated with a unique value within the partition in the range 0x8000 to 0xFFFF, if not specified.
This method also updates the ‘virtual-function-uris’ property in the parent Partition resource, by adding the URI for the faked Virtual Function resource.
- Returns:
- The faked Virtual
Function resource.
- Return type:
- remove(oid)[source]
Remove a faked Virtual Function resource.
This method also updates the ‘virtual-function-uris’ property in the parent Partition resource, by removing the URI for the faked Virtual Function resource.
- Parameters:
oid (string) – The object ID of the faked Virtual Function resource.
- class zhmcclient_mock.FakedVirtualFunction(manager, properties)[source]
A faked Virtual Function resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedVirtualSwitchManager(hmc, cpc)[source]
A manager for faked Virtual Switch resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.- add(properties)[source]
Add a faked Virtual Switch resource.
- Parameters:
properties (dict) –
Resource properties.
Special handling and requirements for certain properties:
’object-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’object-uri’ will be auto-generated based upon the object ID, if not specified.
’class’ will be auto-generated to ‘virtual-switch’, if not specified.
’connected-vnic-uris’ will be auto-generated as an empty array, if not specified.
- Returns:
- The faked Virtual
Switch resource.
- Return type:
- class zhmcclient_mock.FakedVirtualSwitch(manager, properties)[source]
A faked Virtual Switch resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.
- class zhmcclient_mock.FakedMetricsContextManager(hmc, client)[source]
A manager for faked Metrics Context resources within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseManager
, see there for common methods and attributes.Example:
The following code sets up the faked data for metrics retrieval for partition usage metrics, and then retrieves the metrics:
session = FakedSession('fake-host', 'fake-hmc', '2.13.1', '1.8') client = Client(session) # URIs of (faked or real) Partitions the metric apply to: part1_uri = ... part2_uri = ... # Prepare the faked metric response for that metric group, with # data for two partitions: session.hmc.add_metric_values( FakedMetricObjectValues( group_name='partition-usage', resource_uri=part1_uri, timestamp=datetime.now(), values=[ ('processor-usage', 15), ('network-usage', 0), ('storage-usage', 1), ('accelerator-usage', 0), ('crypto-usage', 0), ])) session.hmc.add_metric_values( FakedMetricObjectValues( group_name='partition-usage', resource_uri=part2_uri, timestamp=datetime.now(), values=[ ('processor-usage', 17), ('network-usage', 5), ('storage-usage', 2), ('accelerator-usage', 0), ('crypto-usage', 0), ])) # Create a Metrics Context resource for one metric group: mc = client.metrics_contexts.create({ 'anticipated-frequency-seconds': 15, 'metric-groups' ['partition-usage'], }) # Retrieve the metrics for that metric context: metrics_response = mc.get_metrics()
- add(properties)[source]
Add a faked Metrics Context resource.
- Parameters:
properties (dict) –
Resource properties, as defined in the description of the
FakedMetricsContext
class.Special handling and requirements for certain properties:
’fake-id’ will be auto-generated with a unique value across all instances of this resource type, if not specified.
’fake-uri’ will be auto-generated based upon the ‘fake-id’ property, if not specified.
- Returns:
The faked Metrics Context resource.
- Return type:
- class zhmcclient_mock.FakedMetricsContext(manager, properties)[source]
A faked Metrics Context resource within a faked HMC (see
zhmcclient_mock.FakedHmc
).Derived from
zhmcclient_mock.FakedBaseResource
, see there for common methods and attributes.The Metrics Context “resource” is really a service and therefore does not have a data model defined in the HMC API book. In order to fit into the zhmcclient mock framework, the faked Metrics Context in the zhmcclient mock framework is treated like all other faked resources and does have a data model.
Data Model:
‘fake-id’ (string): Object ID of the resource.
Initialization: Optional. If omitted, it will be auto-generated.
- ‘fake-uri’ (string): Resource URI of the resource (used for Get
Metrics operation).
Initialization: Optional. If omitted, it will be auto-generated from the Object ID.
- ‘anticipated-frequency-seconds’ (integer):
The number of seconds the client anticipates will elapse between metrics retrievals using this context. The minimum accepted value is 15.
Initialization: Required.
- ‘metric-groups’ (list of string):
The metric group names to be returned by a metric retrieval using this context.
Initialization: Optional. If omitted or the empty list, all metric groups that are valid for the operational mode of each CPC will be returned.
- get_metric_group_definitions()[source]
Get the faked metric group definitions for this context object that are to be returned from its create operation.
If a ‘metric-groups’ property had been specified for this context, only those faked metric group definitions of its manager object that are in that list, are included in the result. Otherwise, all metric group definitions of its manager are included in the result.
- Returns:
The faked metric group definitions, in the order they had been added.
- Return type:
iterable of
FakedMetricGroupDefinition
- get_metric_group_infos()[source]
Get the faked metric group definitions for this context object that are to be returned from its create operation, in the format needed for the “Create Metrics Context” operation response.
- Returns:
- “metric-group-infos” JSON object as described for the “Create Metrics
Context “operation response.
- get_metric_values()[source]
Get the faked metrics, for all metric groups and all resources that have been prepared on the manager object of this context object.
- Returns:
- The faked
metrics, in the order they had been added, where:
group_name (string): Metric group name.
- values (
FakedMetricObjectValues
): The metric values for one resource at one point in time.
- values (
- Return type:
iterable of tuple (group_name, iterable of values)
- get_metric_values_response()[source]
Get the faked metrics, for all metric groups and all resources that have been prepared on the manager object of this context object, as a string in the format needed for the “Get Metrics” operation response.
- Returns:
- “MetricsResponse” string as described for the “Get Metrics”
operation response.
- class zhmcclient_mock.FakedMetricGroupDefinition(name, types)[source]
A faked metric group definition (of one metric group).
An object of this class contains the information (in a differently structured way) of a “metric-group-info” object described for the “Create Metrics Context” operation in the HMC API book.
The following table lists for each type mentioned in the metric group descriptions in chapter “Metric groups” in the HMC API book, the Python types that are used for representing metric values of that type, and the metric type strings used in the metric group definitions for that type:
Metric group description type
Python type
Metric type string
Boolean
boolean-metric
Byte
byte-metric
Short
short-metric
Integer
integer-metric
Long
long-metric
Double
double-metric
String, String Enum
string-metric
- Parameters:
- class zhmcclient_mock.FakedMetricObjectValues(group_name, resource_uri, timestamp, values)[source]
Faked metric values for one resource and one metric group.
An object of this class contains the information (in a structured way) of an “ObjectValues” item described for the data format of the response body of the “Get Metrics” operation in the HMC API book.
- Parameters:
group_name (string) – Name of the metric group to which these metric values apply.
resource_uri (string) – URI of the resource to which these metric values apply.
timestamp (datetime) – Point in time to which these metric values apply. Timezone-naive values are converted to timezone-aware values using the local timezone as determined by
dateutil.tz.tzlocal
.values (list of tuple(name, value)) –
The metric values, as follows:
name (string): The metric name.
value: The metric value as an object of the Python type listed in the table in the description of
FakedMetricGroupDefinition
).
- class zhmcclient_mock.FakedBaseManager(hmc, parent, resource_class, base_uri, oid_prop, uri_prop, class_value, name_prop, case_insensitive_names=False)[source]
A base class for manager classes for faked resources in the faked HMC.
- property parent
The parent (scoping resource) for this manager (an object of a derived class of
FakedBaseResource
).
- property resource_class
The resource class managed by this manager (a derived class of
FakedBaseResource
).
- property base_uri
The base URI for URIs of resources managed by this manager.
- property oid_prop
The name of the resource property for the object ID (‘object-id’ or ‘element-id’ or ‘name’).
- property uri_prop
The name of the resource property for the object URI (‘object-uri’ or ‘element-uri’).
- property class_value
The value for the “class” property of resources managed by this manager, as defined in the data model for the resource. For example, for LPAR resources this is set to ‘logical-partition’.
- add(properties)[source]
Add a faked resource to this manager.
For URI-based lookup, the resource is also added to the faked HMC.
- Parameters:
properties (dict) – Resource properties. If the URI property (e.g. ‘object-uri’) or the object ID property (e.g. ‘object-id’) are not specified, they will be auto-generated.
- Returns:
The faked resource object.
- Return type:
- remove(oid)[source]
Remove a faked resource from this manager.
- Parameters:
oid (string) – The object ID of the resource (e.g. value of the ‘object-uri’ property).
- list(filter_args=None)[source]
List the faked resources of this manager.
- lookup_by_oid(oid)[source]
Look up a faked resource by its object ID, in the scope of this manager.
- Parameters:
oid (string) – The object ID of the faked resource (e.g. value of the ‘object-id’ property).
- Returns:
The faked resource object.
- Return type:
- Raises:
KeyError – No resource found for this object ID.
- class zhmcclient_mock.FakedBaseResource(manager, properties)[source]
A base class for faked resource classes in the faked HMC.
- __repr__()[source]
Return a string with the state of this faked resource, for debug purposes.
Note that the derived faked resource classes that have child resources have their own __repr__() methods, because only they know which child resources they have.
- property manager
The manager for this resource (a derived class of
FakedBaseManager
).
- property properties
The properties of this resource (a dictionary).
- property oid
The object ID (property ‘object-id’ or ‘element-id’) of this resource.
- property uri
The object URI (property ‘object-uri’ or ‘element-uri’) of this resource.
- property name
The name (property ‘name’) of this resource.
- Raises:
KeyError – Resource does not have a ‘name’ property.
- update(properties)[source]
update the properties of this resource.
- Parameters:
properties (dict) – Resource properties to be updated. Any other properties remain unchanged.
- add_resources(resource_dict)[source]
Add faked child resources to this resource, from the provided resource definition.
Duplicate resource names in the same scope are not permitted.
Although this method is typically used to initially load the faked HMC with resource state just once, it can be invoked multiple times and can also be invoked on faked resources (e.g. on a faked CPC).
- Parameters:
resource_dict (dict) –
Resource definition of faked child resources to be added.
For an explanation of how the resource dictionary is set up, see the examples below.
For requirements on and auto-generation of certain resource properties, see the
add()
methods of the various faked resource managers (e.g.zhmcclient_mock.FakedCpcManager.add()
). For example, the object-id or element-id properties and the corresponding uri properties are always auto-generated.The resource dictionary specifies a tree of resource managers and resources, in an alternating manner. It starts with the resource managers of child resources of the target resource, which contains a list of those child resources. For an HMC, the CPCs managed by the HMC would be its child resources.
Each resource specifies its own properties (
properties
key) and the resource managers for its child resources. For example, the CPC resource specifies its adapter child resources using theadapters
key. The keys for the child resource managers are the attribute names of these resource managers in the parent resource. For example, theadapters
key is named after thezhmcclient.Cpc.adapters
attribute (which has the same name as in its corresponding faked CPC resource:zhmcclient_mock.FakedCpc.adapters
).- Raises:
zhmcclient_mock.InputError – Some issue with the input resources.
Examples
Example for targeting a faked HMC for adding a CPC with one adapter:
resource_dict = { 'cpcs': [ # name of manager attribute for this resource { 'properties': { 'name': 'cpc_1', }, 'adapters': [ # name of manager attribute for this # resource { 'properties': { 'object-id': '12', 'name': 'ad_1', }, 'ports': [ { 'properties': { 'name': 'port_1', } }, ], }, ], }, ], }
Example for targeting a faked CPC for adding an LPAR and a load activation profile:
resource_dict = { 'lpars': [ # name of manager attribute for this resource { 'properties': { # object-id is not provided -> auto-generated # object-uri is not provided -> auto-generated 'name': 'lpar_1', }, }, ], 'load_activation_profiles': [ # name of manager attribute { 'properties': { # object-id is not provided -> auto-generated # object-uri is not provided -> auto-generated 'name': 'lpar_1', }, }, ], }
7.3. URI handler
A module with various handler classes for the HTTP methods against HMC URIs, based on the faked HMC.
Most handler classes do not need to be documented, but some of them have methods that can be mocked in order to provoke non-standard behavior in the handling of the HTTP methods.
- class zhmcclient_mock.LparActivateHandler[source]
A handler class for the “Activate Logical Partition” operation.
- static get_status()[source]
Status retrieval method that returns the status the faked Lpar will have after completion of the “Activate Logical Partition” operation.
This method returns the successful status ‘not-operating’ for LPARs that do not auto-load their OSs, and can be mocked by testcases to return a different status (e.g. ‘operating’ for LPARs that do auto-load, or ‘acceptable’ or ‘exceptions’).
- class zhmcclient_mock.LparDeactivateHandler[source]
A handler class for the “Deactivate Logical Partition” operation.
- static get_status()[source]
Status retrieval method that returns the status the faked Lpar will have after completion of the “Deactivate Logical Partition” operation.
This method returns the successful status ‘not-activated’, and can be mocked by testcases to return a different status (e.g. ‘exceptions’).
- class zhmcclient_mock.LparLoadHandler[source]
A handler class for the “Load Logical Partition” operation.
- static get_status()[source]
Status retrieval method that returns the status the faked Lpar will have after completion of the “Load Logical Partition” operation.
This method returns the successful status ‘operating’, and can be mocked by testcases to return a different status (e.g. ‘acceptable’ or ‘exceptions’).