Exemplo n.º 1
0
    def test_netinfo_interface_module_lookup_success(self, mock_readlink):
        mock_readlink.return_value = '../../../../module/dummy_net_module'

        module = netinfo.get_interface_kernel_module('dummy_iface')
        mock_readlink.assert_called_once_with(
            '/sys/class/net/dummy_iface/device/driver/module')

        self.assertEqual(module, 'dummy_net_module')
Exemplo n.º 2
0
    def test_netinfo_interface_module_lookup_success(self, mock_readlink):
        mock_readlink.return_value = '../../../../module/dummy_net_module'

        module = netinfo.get_interface_kernel_module('dummy_iface')
        mock_readlink.assert_called_once_with(
            '/sys/class/net/dummy_iface/device/driver/module')

        self.assertEqual(module, 'dummy_net_module')
Exemplo n.º 3
0
    def enable_sriov(self, name, args):
        kernel_mod = netinfo.get_interface_kernel_module(name)
        if kernel_mod not in ['mlx5_core', 'mlx5-core']:
            raise InvalidOperation("GINNET0076E", {
                'name': name,
                'module': kernel_mod
            })

        num_vfs = self._mlx5_SRIOV_precheck(name, args)

        params = {'name': name, 'num_vfs': num_vfs}

        task_id = AsyncTask('/plugins/ginger/network/%s/enable_sriov' % name,
                            self._mlx5_SRIOV_enable_task, params).id
        return self.task.lookup(task_id)
Exemplo n.º 4
0
    def enable_sriov(self, name, args):
        kernel_mod = netinfo.get_interface_kernel_module(name)
        if kernel_mod not in ['mlx5_core', 'mlx5-core']:
            raise InvalidOperation("GINNET0076E",
                                   {'name': name, 'module': kernel_mod})

        num_vfs = self._mlx5_SRIOV_precheck(name, args)

        params = {'name': name, 'num_vfs': num_vfs}

        task_id = AsyncTask(
            '/plugins/ginger/network/%s/enable_sriov' % name,
            self._mlx5_SRIOV_enable_task, params
        ).id
        return self.task.lookup(task_id)
Exemplo n.º 5
0
    def lookup(self, name):
        """
        Populate info using runtime information from /sys/class/net files for
        active interfaces and for inactive bond and vlan interfaces from cfg
        files
        :param name:
        :return:
        """
        try:
            # encode name to ensure comparison are in same type.
            if encode_value(name) in ethtool.get_devices():
                info = netinfo.get_interface_info(name)
            elif cfgInterfacesHelper.is_cfgfileexist(name):
                type = cfgInterfacesHelper.get_type(name).lower()
                if type not in IFACE_BOND + [IFACE_VLAN]:
                    raise ValueError
                device = cfgInterfacesHelper.get_device(name)
                info = {
                    'device': device,
                    'type': cfgInterfacesHelper.get_type(name),
                    'status': "down",
                    'ipaddr': "",
                    'netmask': "",
                    'macaddr': "",
                    'module': netinfo.get_interface_kernel_module(name)
                }

                if info.get('type') is not 'nic':
                    info['nic_type'] = 'N/A'
                else:
                    info['nic_type'] = netinfo.get_nic_type(device)

            else:
                raise ValueError('unknown interface: %s' % name)

            info['rdma_enabled'] = netinfo.is_rdma_enabled(name)

            return info

        except ValueError:
            raise NotFoundError("GINNET0014E", {'name': name})
Exemplo n.º 6
0
    def lookup(self, name):
        """
        Populate info using runtime information from /sys/class/net files for
        active interfaces and for inactive bond and vlan interfaces from cfg
        files
        :param name:
        :return:
        """
        try:
            # encode name to ensure comparison are in same type.
            if encode_value(name) in ethtool.get_devices():
                info = netinfo.get_interface_info(name)
            elif cfgInterfacesHelper.is_cfgfileexist(name):
                type = cfgInterfacesHelper.get_type(name).lower()
                if type not in IFACE_BOND + [IFACE_VLAN]:
                    raise ValueError
                device = cfgInterfacesHelper.get_device(name)
                info = {'device': device,
                        'type': cfgInterfacesHelper.get_type(name),
                        'status': "down",
                        'ipaddr': "",
                        'netmask': "",
                        'macaddr': "",
                        'module': netinfo.get_interface_kernel_module(name)}

                if info.get('type') is not 'nic':
                    info['nic_type'] = 'N/A'
                else:
                    info['nic_type'] = netinfo.get_nic_type(device)

            else:
                raise ValueError('unknown interface: %s' % name)

            info['rdma_enabled'] = netinfo.is_rdma_enabled(name)

            return info

        except ValueError:
            raise NotFoundError("GINNET0014E", {'name': name})