Feilong is a open source z/VM cloud connector project under the Open Mainframe Project umbrella that will accelerate the z/VM adoption, extending its ecosystem and its user experience. It provides a set of APIs to operate z/VM including guest, image, network, volume etc.
case3: reserve=True without passing pchid_info : raise Exception as expected
>>> pp(conn.send_request('get_volume_connector', 'JACKTEST', reserve=True, fcp_template_id=tid))
{'errmsg':
'Failed to get volume connector of JACKTEST because The PCHIDs '
"['021C', '0264', '02E4'] are missing in the pchid_info {}, though "
'are included in the FCP multipath template '
'(id=5129ba98-3b34-11ee-82df-0201012eebe3).',
'modID': 30,
'output': '',
'overallRC': 300,
'rc': 300,
'rs': 11}
log
[2023-09-03 09:50:14] [INFO] synchronized: acquiring lock volumeAttachOrDetach-JACKTEST, concurrent thread count 1, current thread: Thread-70
[2023-09-03 09:50:14] [INFO] synchronized: acquired lock volumeAttachOrDetach-JACKTEST, waited 0.00 seconds, current thread: Thread-70
[2023-09-03 09:50:14] [INFO] pchid_info: {}
[2023-09-03 09:50:14] [ERROR] The PCHIDs ['021C', '0264', '02E4'] are missing in the pchid_info {}, though are included in the FCP multipath template (id=5129ba98-3b34-11ee-82df-0201012eebe3).
[2023-09-03 09:50:14] [ERROR] Got SDK exception in FCP DB operation: Failed to get volume connector of JACKTEST because The PCHIDs ['021C', '0264', '02E4'] are missing in the pchid_info {}, though are included in the FCP multipath template (id=5129ba98-3b34-11ee-82df-0201012eebe3).
[2023-09-03 09:50:14] [INFO] synchronized: released lock volumeAttachOrDetach-JACKTEST, held 0.05 seconds, current thread: Thread-70
[2023-09-03 09:50:14] [INFO] synchronized: after releasing lock volumeAttachOrDetach-JACKTEST, concurrent thread count 0, current thread: Thread-70
[2023-09-03 09:50:14] [ERROR] [Thread-70] (127.0.0.1:43086) Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/zvmsdk/sdkserver.py", line 153, in serve_API
return_data = api_func(*api_args, **api_kwargs)
File "/usr/lib/python3.6/site-packages/zvmsdk/api.py", line 1670, in get_volume_connector
fcp_template_id=fcp_template_id, sp_name=sp_name, pchid_info=pchid_info)
File "/usr/lib/python3.6/site-packages/zvmsdk/volumeop.py", line 108, in get_volume_connector
sp_name=sp_name, pchid_info=pchid_info)
File "/usr/lib/python3.6/site-packages/zvmsdk/utils.py", line 431, in _wrapper
return func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/zvmsdk/volumeop.py", line 2593, in get_volume_connector
_precheck()
File "/usr/lib/python3.6/site-packages/zvmsdk/volumeop.py", line 2589, in _precheck
rs=11, userid=assigner_id, msg=errmsg)
zvmsdk.exception.SDKVolumeOperationError: Failed to get volume connector of JACKTEST because The PCHIDs ['021C', '0264', '02E4'] are missing in the pchid_info {}, though are included in the FCP multipath template (id=5129ba98-3b34-11ee-82df-0201012eebe3).
[2023-09-03 09:50:14] [INFO] The msg <{'overallRC': 300, 'modID': 30, 'rc': 300, 'rs': 11, 'errmsg': "Failed to get volume connector of JACKTEST because The PCHIDs ['021C', '0264', '02E4'] are missing in the pchid_info {}, though are included in the FCP multipath template (id=5129ba98-3b34-11ee-82df-0201012eebe3).", 'output': ''}> lead to return internal error
#### case4: reserve=True for a userid, when
- some path of the template does NOT have free FCP devices
```python
>>> pp(conn.send_request('get_volume_connector', 'JACKTEST', reserve=True, fcp_template_id=tid, pchid_info=pf))
{'errmsg': '',
'modID': None,
'output': {'cpc_name': 'M54',
'cpc_sn': '0000000000082F57',
'fcp_paths': 0,
'fcp_template_id': '5129ba98-3b34-11ee-82df-0201012eebe3',
'host': '',
'hypervisor_hostname': 'BOEM5401',
'is_reserved_changed': False, <-------
'lpar': 'ZVM4OCP1',
'pchid_fcp_map': {},
'phy_to_virt_initiators': {},
'wwpns': [],
'zvm_fcp': []},
'overallRC': 0,
'rc': 0,
'rs': 0}
[2023-08-31 00:38:15] [INFO] get_volume_connector: Enter allocate_fcp_devices.
[2023-08-31 00:38:15] [INFO] Previously allocated FCP devices [] for instance JACKTEST in FCP Multipath Template 5129ba98-3b34-11ee-82df-0201012eebe3.
[2023-08-31 00:38:15] [INFO] Enter: Sync FCP DB with FCP info queried from z/VM.
[2023-08-31 00:38:15] [INFO] Querying FCP status on z/VM.
[2023-08-31 00:38:18] [INFO] New FCP devices found on z/VM: set()
[2023-08-31 00:38:18] [INFO] FCP devices exist in FCP table but not in z/VM any more: set()
[2023-08-31 00:38:18] [INFO] FCP devices removed from FCP table: set()
[2023-08-31 00:38:18] [INFO] FCP devices exist in both FCP table and z/VM: {'1d1b', '1a0f', '1a09', '1b18', '1b02', '1d0d', '1a15', '1c15', '1b0b', '1a08', '1b0e', '1b01', '1c1a', '1a0a', '1d06', '1c0e', '1a0c', '1c0c', '1a19', '1b09', '1a10', '1c13', '1c0f', '1a1b', '1a04', '1a05', '1d14', '1b12', '1b17', '1a18', '1d00', '1c1d', '1d1c', '1c02', '1c18', '1d05', '1b16', '1c09', '1b13', '1c0d', '1c01', '1b19', '1a1a', '1a06', '1c05', '1d1e', '1c08', '1b11', '1c1b', '1b1c', '1b04', '1a14', '1c11', '1a17', '1d09', '1c14', '1c03', '1a16', '1d08', '1c06', '1d0a', '1b1e', '1a1f', '1b07', '1b0d', '1c19', '1a1d', '1c16', '1d16', '1a11', '1d11', '1d13', '1a0d', '1b1a', '1d1d', '1a0e', '1d17', '1d1a', '1c0b', '1d0e', '1b0c', '1d0b', '1b03', '1c07', '1c04', '1b1d', '1a0b', '1c10', '1b00', '1d12', '1d0c', '1a12', '1c0a', '1a00', '1b0f', '1d19', '1d18', '1a1c', '1b15', '1d03', '1b1f', '1c1e', '1c1c', '000e', '1a07', '1b10', '1b06', '1c1f', '1d02', '1d15', '1d10', '1b14', '1d07', '1d1f', '1b0a', '1c12', '1a13', '1b1b', '1a02', '1a1e', '1d0f', '1b08', '1c00', '1d04', '1a03', '1c17', '1d01', '1b05'}
[2023-08-31 00:38:18] [INFO] FCP devices need to update records in fcp table: []
[2023-08-31 00:38:18] [INFO] Exit: Sync FCP DB with FCP info queried from z/VM.
[2023-08-31 00:38:18] [INFO] There is no previously allocated FCP devices for the instance JACKTEST, allocating new ones.
[2023-08-31 00:38:18] [INFO] free_pchids_per_path:
{1: ['021C', '02E4']}
[2023-08-31 00:38:18] [INFO]
Not all paths of FCP Multipath Template (id=5129ba98-3b34-11ee-82df-0201012eebe3) have available FCP devices.
The count of minimum FCP device path is 2.
The count of total paths is 2.
The count of paths with available FCP devices is 1,
which is less than the total path count.
[2023-08-31 00:38:18] [ERROR]
The count of paths with available FCP devices must not be less than that of minimum FCP device path,
return empty list to abort the volume attachment.
API interface change:
When allocating new FCP devices to VM, take the PCHID free capacity into consideration
modification summary
zvmsdk/volumeop.py
zvmsdk/database.py
Tests: call ZCC API directly
Cases for reserve=True
case1: 1st time, reserve=True for a userid
log
[2023-08-30 04:18:38] [INFO] get_volume_connector: Enter allocate_fcp_devices. [2023-08-30 04:18:38] [INFO] Previously allocated FCP devices [] for instance JACKTEST in FCP Multipath Template 5129ba98-3b34-11ee-82df-0201012eebe3. [2023-08-30 04:18:38] [INFO] Enter: Sync FCP DB with FCP info queried from z/VM. [2023-08-30 04:18:38] [INFO] Querying FCP status on z/VM. [2023-08-30 04:18:41] [INFO] New FCP devices found on z/VM: set() [2023-08-30 04:18:41] [INFO] FCP devices exist in FCP table but not in z/VM any more: set() [2023-08-30 04:18:41] [INFO] FCP devices removed from FCP table: set() [2023-08-30 04:18:41] [INFO] FCP devices exist in both FCP table and z/VM: {'1b0a', '1d1c', '1c18', '1a1c', '1c07', '1c14', '1d01', '1d11', '1d19', '1d1b', '1a13', '1b05', '1b1c', '1c0e', '1d17', '1a10', '1a1a', '1d13', '1c03', '1d0b', '1d12', '1d06', '1d18', '1b1a', '1a16', '1a17', '1c02', '1b13', '1c05', '1b04', '1b06', '1b19', '1d04', '1b17', '1d15', '1d1a', '1a15', '1a0e', '1d08', '1d02', '1b1b', '1a18', '1c0d', '1d0d', '1c17', '1d10', '1c13', '1a00', '1d0e', '1b01', '1b15', '1b1e', '1a1f', '000e', '1b11', '1a03', '1a0a', '1b07', '1d05', '1a14', '1b0f', '1a19', '1c1d', '1b0e', '1b0d', '1c1c', '1c09', '1d1d', '1c00', '1a02', '1b0b', '1c04', '1b03', '1c1b', '1d03', '1a0c', '1c11', '1b02', '1c15', '1a04', '1c0f', '1a1d', '1d0f', '1b09', '1c1e', '1c1f', '1a09', '1b16', '1b1f', '1c0c', '1c01', '1b10', '1d14', '1a1e', '1d09', '1a0f', '1d16', '1c16', '1a12', '1c0a', '1d0a', '1b08', '1a0b', '1c12', '1c10', '1c0b', '1b18', '1c1a', '1c08', '1a08', '1d0c', '1a06', '1a1b', '1a0d', '1b12', '1a07', '1d1f', '1b00', '1c06', '1a11', '1c19', '1b0c', '1b1d', '1a05', '1b14', '1d00', '1d07', '1d1e'} [2023-08-30 04:18:41] [INFO] FCP devices need to update records in fcp table: [] [2023-08-30 04:18:41] [INFO] Exit: Sync FCP DB with FCP info queried from z/VM. [2023-08-30 04:18:41] [INFO] There is no previously allocated FCP devices for the instance JACKTEST, allocating new ones. [2023-08-30 04:18:41] [INFO] free_pchids_per_path:
[2023-08-30 04:18:41] [INFO] free_count_in_pchid_info:
[2023-08-30 04:18:41] [INFO] after _calculate_weight, pchids_per_path_combinations:
[2023-08-30 04:18:41] [INFO] after _remove_invalid_weight, pchids_per_path_combinations:
[2023-08-30 04:18:41] [INFO] after _select_max_weight, pchids_per_path_combinations:
[2023-08-30 04:18:41] [INFO] after _select_most_distributed_pchids, pchids_per_path_combinations:
[2023-08-30 04:18:41] [INFO] final_pchid_per_path:
[2023-08-30 04:18:41] [INFO] after _get_one_random_fcp_combinations, fcp_list:
[2023-08-30 04:18:41] [INFO] Newly allocated ['1C17', '1D17'] FCP devices for instance JACKTEST and FCP Multipath Template 5129ba98-3b34-11ee-82df-0201012eebe3 [2023-08-30 04:18:41] [INFO] get_volume_connector: Exit allocate_fcp_devices ['1C17', '1D17'] [2023-08-30 04:18:41] [INFO] get_volume_connector returns
[2023-08-30 04:18:41] [INFO] synchronized: released lock volumeAttachOrDetach-JACKTEST, held 2.32 seconds, current thread: Thread-57 [2023-08-30 04:18:41] [INFO] synchronized: after releasing lock volumeAttachOrDetach-JACKTEST, concurrent thread count 0, current thread: Thread-57
case2: 2nd time, reserve=True for a userid
case3: reserve=True without passing pchid_info : raise Exception as expected
[2023-09-03 09:50:14] [INFO] The msg <{'overallRC': 300, 'modID': 30, 'rc': 300, 'rs': 11, 'errmsg': "Failed to get volume connector of JACKTEST because The PCHIDs ['021C', '0264', '02E4'] are missing in the pchid_info {}, though are included in the FCP multipath template (id=5129ba98-3b34-11ee-82df-0201012eebe3).", 'output': ''}> lead to return internal error
log
[2023-08-31 00:38:15] [INFO] get_volume_connector: Enter allocate_fcp_devices. [2023-08-31 00:38:15] [INFO] Previously allocated FCP devices [] for instance JACKTEST in FCP Multipath Template 5129ba98-3b34-11ee-82df-0201012eebe3. [2023-08-31 00:38:15] [INFO] Enter: Sync FCP DB with FCP info queried from z/VM. [2023-08-31 00:38:15] [INFO] Querying FCP status on z/VM. [2023-08-31 00:38:18] [INFO] New FCP devices found on z/VM: set() [2023-08-31 00:38:18] [INFO] FCP devices exist in FCP table but not in z/VM any more: set() [2023-08-31 00:38:18] [INFO] FCP devices removed from FCP table: set() [2023-08-31 00:38:18] [INFO] FCP devices exist in both FCP table and z/VM: {'1d1b', '1a0f', '1a09', '1b18', '1b02', '1d0d', '1a15', '1c15', '1b0b', '1a08', '1b0e', '1b01', '1c1a', '1a0a', '1d06', '1c0e', '1a0c', '1c0c', '1a19', '1b09', '1a10', '1c13', '1c0f', '1a1b', '1a04', '1a05', '1d14', '1b12', '1b17', '1a18', '1d00', '1c1d', '1d1c', '1c02', '1c18', '1d05', '1b16', '1c09', '1b13', '1c0d', '1c01', '1b19', '1a1a', '1a06', '1c05', '1d1e', '1c08', '1b11', '1c1b', '1b1c', '1b04', '1a14', '1c11', '1a17', '1d09', '1c14', '1c03', '1a16', '1d08', '1c06', '1d0a', '1b1e', '1a1f', '1b07', '1b0d', '1c19', '1a1d', '1c16', '1d16', '1a11', '1d11', '1d13', '1a0d', '1b1a', '1d1d', '1a0e', '1d17', '1d1a', '1c0b', '1d0e', '1b0c', '1d0b', '1b03', '1c07', '1c04', '1b1d', '1a0b', '1c10', '1b00', '1d12', '1d0c', '1a12', '1c0a', '1a00', '1b0f', '1d19', '1d18', '1a1c', '1b15', '1d03', '1b1f', '1c1e', '1c1c', '000e', '1a07', '1b10', '1b06', '1c1f', '1d02', '1d15', '1d10', '1b14', '1d07', '1d1f', '1b0a', '1c12', '1a13', '1b1b', '1a02', '1a1e', '1d0f', '1b08', '1c00', '1d04', '1a03', '1c17', '1d01', '1b05'} [2023-08-31 00:38:18] [INFO] FCP devices need to update records in fcp table: [] [2023-08-31 00:38:18] [INFO] Exit: Sync FCP DB with FCP info queried from z/VM. [2023-08-31 00:38:18] [INFO] There is no previously allocated FCP devices for the instance JACKTEST, allocating new ones. [2023-08-31 00:38:18] [INFO] free_pchids_per_path:
[2023-08-31 00:38:18] [INFO]
[2023-08-31 00:38:18] [ERROR]
[2023-08-31 00:38:18] [INFO] get_volume_connector: Exit allocate_fcp_devices [] [2023-08-31 00:38:18] [ERROR]
[2023-08-31 00:38:18] [INFO] synchronized: released lock volumeAttachOrDetach-JACKTEST, held 2.64 seconds, current thread: Thread-1302 [2023-08-31 00:38:18] [INFO] synchronized: after releasing lock volumeAttachOrDetach-JACKTEST, concurrent thread count 0, current thread: Thread-1302
case2: reserve=False for a userid, when
case3: reserve=False for a userid, when
case4: reserve=False for a userid, when