]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #65224 from rhcs-dashboard/wip-72711-tentacle
authorafreen23 <afreen23.git@gmail.com>
Tue, 26 Aug 2025 15:18:59 +0000 (20:48 +0530)
committerGitHub <noreply@github.com>
Tue, 26 Aug 2025 15:18:59 +0000 (20:48 +0530)
tentacle: mgr/dashboard : Optimized /host API to minimum resp

Reviewed-by: Afreen Misbah <afreen@ibm.com>
1  2 
src/pybind/mgr/dashboard/controllers/host.py
src/pybind/mgr/dashboard/tests/test_host.py

index 10a6c9508f6c13376fd3f791a211df042168545c,aebfa0e31f643d9242c5feb64b631fc00ca86095..0048e89d097cb303480aaf7b30f19acaff5b74de
@@@ -105,33 -105,50 +105,51 @@@ class HostControllerTest(ControllerTest
                  'ceph': True,
                  'orchestrator': False
              },
+             'addr': '',
+             'cpu_cores': 0,
+             'model': '',
+             'nic_count': 0,
+             'hdd_count': 0,
+             'flash_count': 0,
+             'hdd_capacity_bytes': 0,
+             'flash_capacity_bytes': 0,
              'cpu_count': 1,
              'memory_total_kb': 1024,
 -            'services': [],
 -            'service_instances': [{'type': 'mon', 'count': 1}]
 +            'services': []
          }, {
              'hostname': 'host-1',
              'sources': {
                  'ceph': False,
                  'orchestrator': True
              },
+             'addr': '',
+             'cpu_cores': 0,
+             'model': '',
+             'nic_count': 0,
+             'hdd_count': 0,
+             'flash_count': 0,
+             'hdd_capacity_bytes': 0,
+             'flash_capacity_bytes': 0,
              'cpu_count': 2,
              'memory_total_kb': 1024,
 -            'services': [],
 -            'service_instances': [{'type': 'mon', 'count': 1}]
 +            'services': []
          }]
          # test with orchestrator available
          with patch_orch(True, hosts=hosts_without_facts) as fake_client:
              mock_get_hosts.return_value = hosts_without_facts
  
-             def get_facts_mock(hostname: str):
-                 if hostname == 'host-0':
-                     return [hosts_facts[0]]
-                 return [hosts_facts[1]]
+             def get_facts_mock(*args, **_kwargs):
+                 if args:
+                     hostname = args[0]
+                     return [hosts_facts[0]] if hostname == 'host-0' else [hosts_facts[1]]
+                 return hosts_facts
              fake_client.hosts.get_facts.side_effect = get_facts_mock
 -            # test with ?facts=true
 -            self._get('{}?facts=true'.format(self.URL_HOST), version=APIVersion(1, 3))
 +            # test with ?facts=true (explicitly disable service_instances)
 +            self._get(
 +                '{}?facts=true&include_service_instances=false'.format(self.URL_HOST),
 +                version=APIVersion(1, 3)
 +            )
              self.assertStatus(200)
              self.assertHeader('Content-Type',
                                APIVersion(1, 3).to_mime_type())