Skip to content

Commit

Permalink
Merge 9032ea0 into 2d07358
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-maier committed May 5, 2023
2 parents 2d07358 + 9032ea0 commit 94b6ede
Show file tree
Hide file tree
Showing 31 changed files with 1,040 additions and 45 deletions.
7 changes: 7 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ Released: not yet
is used with filters that can be handled by the HMC, because in such cases
the resource properties do not need to be retrieved.

* Added a 'pull_properties()' method to zhmcclient resource classes, that
performs a "Get Properties" HMC operation with the 'properties' query
parameter defined. This can be used to speed up certain property retrieval
operations, for example on the Console or on CPCs. (issue #862)

* Test: Added end2end testcases for property retrieval.

**Cleanup:**

**Known issues:**
Expand Down
41 changes: 40 additions & 1 deletion tests/end2end/test_activation_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
from zhmcclient.testutils import classic_mode_cpcs # noqa: F401, E501
# pylint: enable=line-too-long,unused-import

from .utils import pick_test_resources, runtest_find_list, skip_warn
from .utils import skip_warn, pick_test_resources, runtest_find_list, \
runtest_get_properties

urllib3.disable_warnings()

Expand Down Expand Up @@ -75,3 +76,41 @@ def test_actprof_find_list(classic_mode_cpcs, profile_type): # noqa: F811
session, actprof_mgr, actprof.name, 'name', 'element-uri',
ACTPROF_VOLATILE_PROPS, ACTPROF_MINIMAL_PROPS,
ACTPROF_LIST_PROPS)


@pytest.mark.parametrize(
"profile_type", ['reset', 'image', 'load']
)
def test_actprof_property(classic_mode_cpcs, profile_type): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Test property related methods
"""
if not classic_mode_cpcs:
pytest.skip("HMC definition does not include any CPCs in classic mode")

for cpc in classic_mode_cpcs:
assert not cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition
actprof_mgr = getattr(cpc, profile_type + '_activation_profiles')

# Pick the activation profiles to test with
actprof_list = actprof_mgr.list()
if not actprof_list:
skip_warn("No {t} activation profiles on CPC {c} managed by "
"HMC {h}".
format(t=profile_type, c=cpc.name, h=hd.host))
actprof_list = pick_test_resources(actprof_list)

for actprof in actprof_list:
print("Testing on CPC {c} with {t} activation profile {p!r}".
format(c=cpc.name, t=profile_type, p=actprof.name))

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, actprof.manager, non_list_prop, (2, 15))
37 changes: 35 additions & 2 deletions tests/end2end/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
from zhmcclient.testutils import dpm_mode_cpcs # noqa: F401, E501
# pylint: enable=line-too-long,unused-import

from .utils import pick_test_resources, runtest_find_list, TEST_PREFIX, \
skip_warn, standard_partition_props
from .utils import skip_warn, pick_test_resources, TEST_PREFIX, \
standard_partition_props, runtest_find_list, runtest_get_properties

urllib3.disable_warnings()

Expand Down Expand Up @@ -78,6 +78,39 @@ def test_adapter_find_list(dpm_mode_cpcs): # noqa: F811
ADAPTER_LIST_PROPS)


def test_adapter_property(dpm_mode_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Test property related methods
"""
if not dpm_mode_cpcs:
pytest.skip("HMC definition does not include any CPCs in DPM mode")

for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

# Pick the adapters to test with
adapter_list = cpc.adapters.list()
if not adapter_list:
skip_warn("No adapters on CPC {c} managed by HMC {h}".
format(c=cpc.name, h=hd.host))
adapter_list = pick_test_resources(adapter_list)

for adapter in adapter_list:
print("Testing on CPC {c} with adapter {a!r}".
format(c=cpc.name, a=adapter.name))

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, adapter.manager, non_list_prop, None)


def test_adapter_hs_crud(dpm_mode_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Expand Down
37 changes: 35 additions & 2 deletions tests/end2end/test_capacity_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from zhmcclient.testutils import dpm_mode_cpcs # noqa: F401, E501
# pylint: enable=line-too-long,unused-import

from .utils import pick_test_resources, runtest_find_list, TEST_PREFIX, \
skip_warn
from .utils import skip_warn, pick_test_resources, TEST_PREFIX, \
runtest_find_list, runtest_get_properties

urllib3.disable_warnings()

Expand Down Expand Up @@ -76,6 +76,39 @@ def test_capgrp_find_list(dpm_mode_cpcs): # noqa: F811
CAPGRP_LIST_PROPS)


def test_capgrp_property(dpm_mode_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Test property related methods
"""
if not dpm_mode_cpcs:
pytest.skip("HMC definition does not include any CPCs in DPM mode")

for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

# Pick the capacity groups to test with
capgrp_list = cpc.capacity_groups.list()
if not capgrp_list:
skip_warn("No capacity groups defined on CPC {c} managed by "
"HMC {h}".format(c=cpc.name, h=hd.host))
capgrp_list = pick_test_resources(capgrp_list)

for capgrp in capgrp_list:
print("Testing on CPC {c} with capacity group {g!r}".
format(c=cpc.name, g=capgrp.name))

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(
client, capgrp.manager, non_list_prop, None)


def test_capgrp_crud(dpm_mode_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Expand Down
15 changes: 14 additions & 1 deletion tests/end2end/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from zhmcclient.testutils import hmc_definition, hmc_session # noqa: F401, E501
# pylint: enable=line-too-long,unused-import

from .utils import runtest_find_list
from .utils import runtest_find_list, runtest_get_properties

urllib3.disable_warnings()

Expand Down Expand Up @@ -55,3 +55,16 @@ def test_console_find_list(hmc_session): # noqa: F811
hmc_session, client.consoles, console.name, 'name',
'object-uri', CONSOLE_VOLATILE_PROPS, CONSOLE_MINIMAL_PROPS,
CONSOLE_LIST_PROPS)


def test_console_property(hmc_session): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Test property related methods
"""
client = zhmcclient.Client(hmc_session)

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, client.consoles, non_list_prop, (2, 15))
22 changes: 21 additions & 1 deletion tests/end2end/test_cpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
from zhmcclient.testutils import all_cpcs, classic_mode_cpcs # noqa: F401, E501
# pylint: enable=line-too-long,unused-import

from .utils import runtest_find_list, assert_res_prop, skip_warn
from .utils import skip_warn, assert_res_prop, runtest_find_list, \
runtest_get_properties

urllib3.disable_warnings()

Expand Down Expand Up @@ -107,6 +108,25 @@ def test_cpc_find_list(hmc_session): # noqa: F811
CPC_VOLATILE_PROPS, CPC_MINIMAL_PROPS, cpc_list_props)


def test_cpc_property(all_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Test property related methods
"""
if not all_cpcs:
pytest.skip("HMC definition does not include any CPCs")

for cpc in all_cpcs:
print("Testing with CPC {c}".format(c=cpc.name))

client = cpc.manager.client

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, cpc.manager, non_list_prop, (2, 14))


def test_cpc_features(all_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Expand Down
42 changes: 40 additions & 2 deletions tests/end2end/test_hba.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
from zhmcclient.testutils import dpm_mode_cpcs # noqa: F401, E501
# pylint: enable=line-too-long,unused-import

from .utils import pick_test_resources, runtest_find_list, TEST_PREFIX, \
standard_partition_props, skipif_storage_mgmt_feature, skip_warn
from .utils import skip_warn, pick_test_resources, TEST_PREFIX, \
standard_partition_props, skipif_storage_mgmt_feature, \
runtest_find_list, runtest_get_properties

urllib3.disable_warnings()

Expand Down Expand Up @@ -81,6 +82,43 @@ def test_hba_find_list(dpm_mode_cpcs): # noqa: F811
HBA_VOLATILE_PROPS, HBA_MINIMAL_PROPS, HBA_LIST_PROPS)


def test_hba_property(dpm_mode_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Test property related methods
"""
if not dpm_mode_cpcs:
pytest.skip("HMC definition does not include any CPCs in DPM mode")

for cpc in dpm_mode_cpcs:
assert cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

# Pick the HBAs to test with
part_hba_tuples = []
part_list = cpc.partitions.list()
for part in part_list:
hba_list = part.hbas.list()
for hba in hba_list:
part_hba_tuples.append((part, hba))
if not part_hba_tuples:
skip_warn("No partitions with HBAs on CPC {c} managed by HMC {h}".
format(c=cpc.name, h=hd.host))
part_hba_tuples = pick_test_resources(part_hba_tuples)

for part, hba in part_hba_tuples:
print("Testing on CPC {c} with HBA {h!r} of partition {p!r}".
format(c=cpc.name, h=hba.name, p=part.name))

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, hba.manager, non_list_prop, None)


def test_hba_crud(dpm_mode_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Expand Down
37 changes: 35 additions & 2 deletions tests/end2end/test_ldap_server_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
from zhmcclient.testutils import hmc_definition, hmc_session # noqa: F401, E501
# pylint: enable=line-too-long,unused-import

from .utils import pick_test_resources, runtest_find_list, TEST_PREFIX, \
skip_warn
from .utils import skip_warn, pick_test_resources, TEST_PREFIX, \
runtest_find_list, runtest_get_properties

urllib3.disable_warnings()

Expand Down Expand Up @@ -79,6 +79,39 @@ def test_ldapsrvdef_find_list(hmc_session): # noqa: F811
LDAPSRVDEF_MINIMAL_PROPS, LDAPSRVDEF_LIST_PROPS)


def test_ldapsrvdef_property(hmc_session): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Test property related methods
"""
client = zhmcclient.Client(hmc_session)
console = client.consoles.console
hd = hmc_session.hmc_definition

api_version = client.query_api_version()
hmc_version = api_version['hmc-version']
hmc_version_info = tuple(map(int, hmc_version.split('.')))
if hmc_version_info < (2, 13, 0):
skip_warn("HMC {h} of version {v} does not yet support LDAP server "
"definitions".format(h=hd.host, v=hmc_version))

# Pick the LDAP server definitions to test with
ldapsrvdef_list = console.ldap_server_definitions.list()
if not ldapsrvdef_list:
skip_warn("No LDAP server definitions defined on HMC {h}".
format(h=hd.host))
ldapsrvdef_list = pick_test_resources(ldapsrvdef_list)

for ldapsrvdef in ldapsrvdef_list:
print("Testing with LDAP server definition {d!r}".
format(d=ldapsrvdef.name))

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, ldapsrvdef.manager, non_list_prop, None)


def test_ldapsrvdef_crud(hmc_session): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Expand Down
35 changes: 34 additions & 1 deletion tests/end2end/test_lpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
from zhmcclient.testutils import classic_mode_cpcs # noqa: F401, E501
# pylint: enable=line-too-long,unused-import

from .utils import pick_test_resources, runtest_find_list, skip_warn
from .utils import skip_warn, pick_test_resources, runtest_find_list, \
runtest_get_properties

urllib3.disable_warnings()

Expand Down Expand Up @@ -70,3 +71,35 @@ def test_lpar_find_list(classic_mode_cpcs): # noqa: F811
runtest_find_list(
session, cpc.lpars, lpar.name, 'name', 'status',
LPAR_VOLATILE_PROPS, LPAR_MINIMAL_PROPS, LPAR_LIST_PROPS)


def test_lpar_property(classic_mode_cpcs): # noqa: F811
# pylint: disable=redefined-outer-name
"""
Test property related methods
"""
if not classic_mode_cpcs:
pytest.skip("HMC definition does not include any CPCs in classic mode")

for cpc in classic_mode_cpcs:
assert not cpc.dpm_enabled

client = cpc.manager.client
session = cpc.manager.session
hd = session.hmc_definition

# Pick the LPARs to test with
lpar_list = cpc.lpars.list()
if not lpar_list:
skip_warn("No LPARs on CPC {c} managed by HMC {h}".
format(c=cpc.name, h=hd.host))
lpar_list = pick_test_resources(lpar_list)

for lpar in lpar_list:
print("Testing on CPC {c} with LPAR {p!r}".
format(c=cpc.name, p=lpar.name))

# Select a property that is not returned by list()
non_list_prop = 'description'

runtest_get_properties(client, lpar.manager, non_list_prop, (2, 14))

0 comments on commit 94b6ede

Please sign in to comment.