Ejemplo n.º 1
0
 def test_get_cpu_numa_info_without_online(self, mock_output):
     mock_output.side_effect = [
         processutils.ProcessExecutionError(), LSCPU_NO_ONLINE
     ]
     expected_output = {'0': [0, 1], '1': [2, 3]}
     output = os_capability_linux.LinuxHost().get_cpu_numa_info()
     self.assertEqual(expected_output, output)
Ejemplo n.º 2
0
 def test_get_host_mem(self):
     data = ('MemTotal:        3882464 kB\nMemFree:         3514608 kB\n'
             'MemAvailable:    3556372 kB\n')
     m_open = mock_open(read_data=data)
     with mock.patch.object(six.moves.builtins, "open", m_open,
                            create=True):
         output = os_capability_linux.LinuxHost().get_host_mem()
         used = (3882464 - 3556372)
         self.assertEqual((3882464, 3514608, 3556372, used), output)
Ejemplo n.º 3
0
 def get_host_mem(self):
     return os_capability_linux.LinuxHost().get_host_mem()
Ejemplo n.º 4
0
 def get_pci_resources(self):
     return os_capability_linux.LinuxHost().get_pci_resources()
Ejemplo n.º 5
0
 def get_host_numa_topology(self):
     numa_topo_obj = objects.NUMATopology()
     os_capability_linux.LinuxHost().get_host_numa_topology(numa_topo_obj)
     return numa_topo_obj
Ejemplo n.º 6
0
    def test_get_pci_resource(self, mock_output, mock_netname, mock_ifname):
        mock_netname.return_value = 'net_enp2s0f3_ec_38_8f_79_11_2b'
        mock_ifname.return_value = 'enp2s0f3'
        value1 = '''0000:02:10.7 "Ethernet controller...." ""'''
        value2 = '02:10.7 0200: 8086:1520 (rev 01)'
        value3 = '''Slot:   02:10.7
        Class:  Ethernet controller
        Vendor: Intel Corporation
        Device: I350 Ethernet Controller Virtual Function
        Rev:    01
        NUMANode:   0'''
        value4 = 'class physfn'
        value5 = '''DRIVER=igbvf
        PCI_CLASS=20000
        PCI_ID=8086:1520
        PCI_SUBSYS_ID=FFFF:0000
        PCI_SLOT_NAME=0000:02:10.7
        MODALIAS=pci:v00008086d00001520sv0000FFFFsd00000000bc02sc00i00'''
        value6 = '''Features for enp2s0f3:
rx-checksumming: on
tx-checksumming: on
scatter-gather: on
tcp-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: on
tx-vlan-offload: on
ntuple-filters: off [fixed]
receive-hashing: on
highdma: on [fixed]
rx-vlan-filter: on [fixed]
vlan-challenged: off [fixed]
tx-lockless: off [fixed]
netns-local: off [fixed]
tx-gso-robust: off [fixed]
tx-fcoe-segmentation: off [fixed]
tx-gre-segmentation: off [fixed]
tx-ipip-segmentation: off [fixed]
tx-sit-segmentation: off [fixed]
tx-udp_tnl-segmentation: off [fixed]
tx-mpls-segmentation: off [fixed]
rx-fcs: off [fixed]
tx-vlan-stag-hw-insert: off [fixed]
rx-vlan-stag-hw-parse: off [fixed]
rx-vlan-stag-filter: off [fixed]'''
        values = [(value1, 0), (value2, 0), (value3, 0), (value4, 0),
                  (value5, 0), (value6, 0)]
        mock_output.side_effect = values
        expected = {
            "dev_id": "pci_0000_02_10_7",
            "address": "0000:02:10.7",
            "vendor_id": "8086",
            "product_id": "1520",
            "numa_node": 0,
            "label": "label_8086_1520",
            "dev_type": "VF",
            "parent_addr": "0000:02:10.7"
        }
        output = os_capability_linux.LinuxHost().get_pci_resources()

        pci_infos = jsonutils.loads(output)
        for pci_info in pci_infos:
            self.assertEqual(expected['dev_id'], str(pci_info['dev_id']))
            self.assertEqual(expected['address'], str(pci_info['address']))
            self.assertEqual(expected['product_id'],
                             str(pci_info['product_id']))
            self.assertEqual(expected['vendor_id'], str(pci_info['vendor_id']))
            self.assertEqual(expected['numa_node'], pci_info['numa_node'])
            self.assertEqual(expected['label'], str(pci_info['label']))
            self.assertEqual(expected['dev_type'], str(pci_info['dev_type']))
            self.assertEqual(expected['parent_addr'],
                             str(pci_info['parent_addr']))
Ejemplo n.º 7
0
 def test_get_cpu_numa_info_exception(self, mock_output):
     mock_output.side_effect = exception.CommandError()
     self.assertRaises(exception.CommandError,
                       os_capability_linux.LinuxHost().get_cpu_numa_info)
Ejemplo n.º 8
0
 def test_get_cpu_numa_info_with_online(self, mock_output):
     mock_output.return_value = LSCPU_ON
     output = os_capability_linux.LinuxHost().get_cpu_numa_info()
     expected_output = {'0': [0, 8], '1': [16, 24], '2': [32]}
     self.assertEqual(expected_output, output)