From 40b771fffd3fde6c6017aedaed1728b3020a3fc9 Mon Sep 17 00:00:00 2001 From: tanjy Date: Fri, 17 Jun 2022 14:51:17 +0800 Subject: [PATCH] svc controller add cpu info --- .../drivers/ibm/storwize_svc/ssh_handler.py | 11 +++++- .../ibm/storwize_svc/test_ibm_storwize_svc.py | 39 ++++++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/delfin/drivers/ibm/storwize_svc/ssh_handler.py b/delfin/drivers/ibm/storwize_svc/ssh_handler.py index 51db58389..9b04d7bb1 100644 --- a/delfin/drivers/ibm/storwize_svc/ssh_handler.py +++ b/delfin/drivers/ibm/storwize_svc/ssh_handler.py @@ -500,6 +500,14 @@ def list_controllers(self, storage_id): deltail_info = self.exec_ssh_command(detail_command) control_map = {} self.handle_detail(deltail_info, control_map, split=' ') + cpu_map = {} + cpu_cmd = 'lsnodehw -delim , %s' % control_id + cpu_info = self.exec_ssh_command(cpu_cmd) + if 'command not found' in cpu_info: + cpu_cmd = 'lsnodecanisterhw -delim , %s' % control_id + cpu_info = self.exec_ssh_command(cpu_cmd) + self.handle_detail(cpu_info, cpu_map, split=',') + cpu_actual = cpu_map.get('cpu_actual') status = SSHHandler.CONTRL_STATUS_MAP.get( control_map.get('status'), constants.ControllerStatus.UNKNOWN) @@ -510,7 +518,8 @@ def list_controllers(self, storage_id): 'status': status, 'soft_version': control_map.get('code_level', '').split(' ')[0], - 'location': control_map.get('name') + 'location': control_map.get('name'), + 'cpu_info': cpu_actual } controller_list.append(controller_result) return controller_list diff --git a/delfin/tests/unit/drivers/ibm/storwize_svc/test_ibm_storwize_svc.py b/delfin/tests/unit/drivers/ibm/storwize_svc/test_ibm_storwize_svc.py index cd1151e21..0aecc2fb1 100644 --- a/delfin/tests/unit/drivers/ibm/storwize_svc/test_ibm_storwize_svc.py +++ b/delfin/tests/unit/drivers/ibm/storwize_svc/test_ibm_storwize_svc.py @@ -486,6 +486,39 @@ def __init__(self): serial_number 75PVZNA machine_signature 0214-784E-C029-0147 """ + +get_controller_cpu = """id,2 +name,node_165084 +status,online +IO_group_id,0 +IO_group_name,io_grp0 +hardware,CG8 +actual_different,no +actual_valid,yes +memory_configured,24 +memory_actual,24 +memory_valid,yes +cpu_count,1 +cpu_socket,1 +cpu_configured,6 core Intel(R) Xeon(R) CPU E5645 @ 2.40GHz +cpu_actual,6 core Intel(R) Xeon(R) CPU E5645 @ 2.40GHz +cpu_valid,yes +adapter_count,3 +adapter_location,1 +adapter_configured,Four port 8Gb/s FC adapter +adapter_actual,Four port 8Gb/s FC adapter +adapter_valid,yes +adapter_location,0 +adapter_configured,Two port 1Gb/s Ethernet adapter +adapter_actual,Two port 1Gb/s Ethernet adapter +adapter_valid,yes +adapter_location,2 +adapter_configured,none +adapter_actual,none +adapter_valid,yes +ports_different,no +""" + controller_result = [ { 'name': 'node_165084', @@ -493,7 +526,8 @@ def __init__(self): 'native_controller_id': '2', 'status': 'normal', 'soft_version': '7.8.1.11', - 'location': 'node_165084' + 'location': 'node_165084', + 'cpu_info': '6 core Intel(R) Xeon(R) CPU E5645 @ 2.40GHz' } ] @@ -1553,7 +1587,8 @@ def test_clear_alert(self): @mock.patch.object(SSHPool, 'get') def test_list_controllers(self, mock_ssh_get, mock_control): mock_ssh_get.return_value = {paramiko.SSHClient()} - mock_control.side_effect = [get_all_controllers, get_single_controller] + mock_control.side_effect = [get_all_controllers, get_single_controller, + get_controller_cpu] controller = self.driver.list_controllers(context) self.assertEqual(controller, controller_result)