Skip to content

Commit 0102cf0

Browse files
vontedduchaithraVonteddu Chaithra
andauthored
Added support for tape library (#2092)
Signed-off-by: Vonteddu Chaithra <Vonteddu.Chaithra1@ibm.com> Co-authored-by: Vonteddu Chaithra <Vonteddu.Chaithra1@ibm.com>
1 parent 40cc690 commit 0102cf0

13 files changed

Lines changed: 1183 additions & 2 deletions

File tree

docs/appendix.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,13 @@ Resources scoped to CPCs in DPM mode
539539

540540
Storage Volume Template
541541
A template for :term:`Storage Volumes <Storage Volume>`.
542+
543+
Tape library
544+
A Tape Library represents one physical tape storage unit connected to
545+
a CPC.Tape libraries are automatically discovered,but discovery requires
546+
preprocessing,A single Worldwide Port Name (WWPN) must be zoned so the CPC
547+
can see the tape library.
548+
For details, see section :ref:`Tape Library`.
542549

543550
vHBA
544551
Synonym for :term:`HBA`. In this resource model, HBAs are always

docs/resources.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,26 @@ Storage Volumes
338338
:special-members: __str__
339339

340340

341+
.. _`Tape Libraries`:
342+
343+
Tape Libraries
344+
-----------------
345+
346+
.. automodule:: zhmcclient._tape_library
347+
348+
.. autoclass:: zhmcclient.TapeLibraryManager
349+
:members:
350+
:autosummary:
351+
:autosummary-inherited-members:
352+
:special-members: __str__
353+
354+
.. autoclass:: zhmcclient.TapeLibrary
355+
:members:
356+
:autosummary:
357+
:autosummary-inherited-members:
358+
:special-members: __str__
359+
360+
341361
.. _`Virtual Storage Resources`:
342362

343363
Virtual Storage Resources

tests/end2end/mocked_hmc_z14.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ hmc_definition:
319319
primary-hostname-ipaddr: 10.11.12.13
320320
search-distinguished-name: "test{0}"
321321
replication-overwrite-possible: false
322-
description: "LSD 1"
323322
connection-port: null
324323
backup-hostname-ipaddr: null
325324
use-ssl: false

tests/end2end/mocked_hmc_z16.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ hmc_definition:
319319
primary-hostname-ipaddr: 10.11.12.13
320320
search-distinguished-name: "test{0}"
321321
replication-overwrite-possible: false
322-
description: "LSD 1"
323322
connection-port: null
324323
backup-hostname-ipaddr: null
325324
use-ssl: false
@@ -356,6 +355,16 @@ hmc_definition:
356355
adapter-port-uri: /api/adapters/fcp1
357356
partition-uri: /api/partitions/part1
358357

358+
tape_library:
359+
- properties:
360+
# class : created automatically
361+
# parent : created automatically
362+
# object-uri: created automatically
363+
object-id : tl1
364+
name : Tape Library
365+
description : Tape Library resource 1
366+
cpc-uri : /api/cpcs/cpc_dpm
367+
359368
hw_messages:
360369
- properties:
361370
# class: created automatically

tests/end2end/test_tape_library.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Copyright 2026 IBM Corp. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
End2end tests for Tape Library (on CPCs in DPM mode).
17+
18+
These tests do not change any existing Tape Library, but discover,
19+
modify and undefine test Tape Libraries.
20+
"""
21+
22+
import pytest
23+
from requests.packages import urllib3
24+
25+
import zhmcclient
26+
27+
from .utils import skip_warn, pick_test_resources, \
28+
runtest_find_list, runtest_get_properties
29+
30+
urllib3.disable_warnings()
31+
32+
# Properties in minimalistic Tape Library objects (e.g. find_by_name())
33+
TL_MINIMAL_PROPS = ['object-uri', 'name']
34+
35+
# Properties in Tape Library objects returned by list() without full props
36+
TL_LIST_PROPS = ['object-uri', 'cpc-uri', 'name', 'state']
37+
38+
# Properties whose values can change between retrievals of StorageGroup objs
39+
TL_VOLATILE_PROPS = []
40+
41+
42+
def test_tl_find_list(hmc_session):
43+
"""
44+
Test list(), find(), findall().
45+
"""
46+
client = zhmcclient.Client(hmc_session)
47+
console = client.consoles.console
48+
hd = hmc_session.hmc_definition
49+
50+
# Pick the Tape Library to test with
51+
tl_list = console.tape_library.list()
52+
if not tl_list:
53+
skip_warn(f"No Tape Library defined on HMC {hd.host}")
54+
tl_list = pick_test_resources(tl_list)
55+
56+
for tl in tl_list:
57+
print(f"Testing with Tape Library {tl.name!r}")
58+
runtest_find_list(
59+
hmc_session, console.tape_library, tl.name,
60+
'name', 'object-uri', TL_VOLATILE_PROPS,
61+
TL_MINIMAL_PROPS, TL_LIST_PROPS)
62+
63+
64+
def test_tl_property(hmc_session):
65+
"""
66+
Test property related methods
67+
"""
68+
client = zhmcclient.Client(hmc_session)
69+
console = client.consoles.console
70+
hd = hmc_session.hmc_definition
71+
72+
# Pick the Tape Library to test with
73+
tl_list = console.tape_library.list()
74+
if not tl_list:
75+
skip_warn(f"No Tape Library defined on HMC {hd.host}")
76+
tl_list = pick_test_resources(tl_list)
77+
78+
for tl in tl_list:
79+
print(f"Testing with Tape Library {tl.name!r}")
80+
81+
# Select a property that is not returned by list()
82+
non_list_prop = 'description'
83+
84+
runtest_get_properties(tl.manager, non_list_prop)
85+
86+
87+
def test_tl_crud(hmc_session):
88+
"""
89+
Test update Tape Library
90+
"""
91+
client = zhmcclient.Client(hmc_session)
92+
console = client.consoles.console
93+
hd = hmc_session.hmc_definition
94+
tl_name_new = 'newtl1'
95+
96+
# Pick the Tape Library to test with
97+
tl_list = console.tape_library.list()
98+
if not tl_list:
99+
skip_warn(f"No Tape Library defined on HMC {hd.host}")
100+
tl = tl_list[0]
101+
102+
# Test updating a property of the Tape Library
103+
104+
new_desc = "Updated Tape Library description."
105+
106+
# The code to be tested
107+
tl.update_properties(dict(description=new_desc))
108+
109+
assert tl.properties['description'] == new_desc
110+
tl.pull_full_properties()
111+
assert tl.properties['description'] == new_desc
112+
113+
# Test that Tape Library can be renamed
114+
115+
# The code to be tested
116+
tl.update_properties(dict(name=tl_name_new))
117+
tl.pull_full_properties()
118+
with pytest.raises(zhmcclient.NotFound):
119+
console.tape_library.find(name='Tape Library')

tests/unit/zhmcclient/mock/test_session.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@
128128
],
129129
},
130130
],
131+
'tape_library': [
132+
{
133+
'properties': {
134+
'object-id': 'tl1',
135+
'name': 'Tape Library 1',
136+
'cpc-uri': '/api/cpcs/cpc1',
137+
'state': 'complete',
138+
},
139+
},
140+
],
131141
},
132142
],
133143
'cpcs': [

0 commit comments

Comments
 (0)