示例#1
0
 def get_list(self):
     """
     Return the active interfaces returned by ethtool.getdevices
     and interfaces that are inactive and are of type of bond and vlan.
     :return:
     """
     return cfgInterfacesHelper.get_interface_list()
示例#2
0
 def get_list(self):
     """
     Return the active interfaces returned by ethtool.getdevices
     and interfaces that are inactive and are of type of bond and vlan.
     :return:
     """
     return cfgInterfacesHelper.get_interface_list()
示例#3
0
    def _mlx5_SRIOV_enable_task(self, cb, params):
        iface = params.get('name')
        num_vfs = params.get('num_vfs')

        sriov_file = self._mlx5_SRIOV_get_numvf_config_file(iface)

        cb('Setting SR-IOV for %s' % iface)

        try:
            with open(sriov_file, 'w') as f:
                f.write('0\n')

            if num_vfs == 0:
                add_config_to_mlx5_SRIOV_boot_script(iface, num_vfs)
            else:
                ifaces_without_sriov = \
                    cfgInterfacesHelper.get_interface_list()

                with open(sriov_file, 'w') as f:
                    f.write(str(num_vfs) + '\n')

                add_config_to_mlx5_SRIOV_boot_script(iface, num_vfs)

                new_ifaces = self._wait_VFs_setup(ifaces_without_sriov)

                for new_iface in new_ifaces:
                    cfgInterfacesHelper.create_interface_cfg_file(new_iface)

        except Exception as e:
            raise OperationFailed("GINNET0085E", {'err': e.message})

        cb('SR-IOV setup for %s completed' % iface, True)
示例#4
0
    def _mlx5_SRIOV_enable_task(self, cb, params):
        iface = params.get('name')
        num_vfs = params.get('num_vfs')

        sriov_file = self._mlx5_SRIOV_get_numvf_config_file(iface)

        cb('Setting SR-IOV for %s' % iface)

        try:
            with open(sriov_file, 'w') as f:
                f.write('0\n')

            if num_vfs == 0:
                add_config_to_mlx5_SRIOV_boot_script(iface, num_vfs)
            else:
                ifaces_without_sriov = \
                    cfgInterfacesHelper.get_interface_list()

                with open(sriov_file, 'w') as f:
                    f.write(str(num_vfs) + '\n')

                add_config_to_mlx5_SRIOV_boot_script(iface, num_vfs)

                new_ifaces = self._wait_VFs_setup(ifaces_without_sriov)

                for new_iface in new_ifaces:
                    cfgInterfacesHelper.create_interface_cfg_file(new_iface)

        except Exception as e:
            raise OperationFailed("GINNET0085E", {'err': e.message})

        cb('SR-IOV setup for %s completed' % iface, True)
示例#5
0
 def get_list(self):
     nics = cfgInterfacesHelper.get_interface_list()
     nics_with_ifcfgfile = []
     for iface in nics:
         filename = ifcfg_filename_format % iface
         fileexist = os.path.isfile(os.sep + network_configpath + filename)
         if not fileexist:
             wok_log.warn('ifcfg file not exist for' ' interface :' + iface)
         else:
             nics_with_ifcfgfile.append(iface)
     return sorted(map(decode_value, nics_with_ifcfgfile))
示例#6
0
 def get_list(self):
     nics = cfgInterfacesHelper.get_interface_list()
     nics_with_ifcfgfile = []
     for iface in nics:
         filename = ifcfg_filename_format % iface
         fileexist = os.path.isfile(os.sep + network_configpath + filename)
         if not fileexist:
             wok_log.warn('ifcfg file not exist for'
                          ' interface :' + iface)
         else:
             nics_with_ifcfgfile.append(iface)
     return sorted(map(decode_value, nics_with_ifcfgfile))
示例#7
0
 def get_list(self):
     nics = cfgInterfacesHelper.get_interface_list()
     # To handle issue https://github.com/kimchi-project/ginger/issues/99
     # cfginterface resource model deals with interface which has config
     # files.remove interface from interface list if ifcfg file not exist.
     nics_with_ifcfgfile = []
     for iface in nics:
         filename = ifcfg_filename_format % iface
         fileexist = os.path.isfile(os.sep + network_configpath + filename)
         if not fileexist:
             wok_log.warn('ifcfg file not exist for'
                          ' interface :' + iface)
         else:
             nics_with_ifcfgfile.append(iface)
     return sorted(nics_with_ifcfgfile)
示例#8
0
 def get_list(self):
     nics = cfgInterfacesHelper.get_interface_list()
     # To handle issue https://github.com/kimchi-project/ginger/issues/99
     # cfginterface resource model deals with interface which has config
     # files.remove interface from interface list if ifcfg file not exist.
     nics_with_ifcfgfile = []
     for iface in nics:
         filename = ifcfg_filename_format % iface
         fileexist = os.path.isfile(os.sep + network_configpath + filename)
         if not fileexist:
             wok_log.warn('ifcfg file not exist for' ' interface :' + iface)
         else:
             nics_with_ifcfgfile.append(iface)
     # Ensure comparison are done in same type.
     return sorted(map(decode_value, nics_with_ifcfgfile))
示例#9
0
    def _wait_VFs_setup(self, ifaces_without_sriov):
        timeout = 0
        new_ifaces = None
        while timeout < 5:
            current_ifaces = cfgInterfacesHelper.get_interface_list()
            new_ifaces = ifaces_without_sriov ^ current_ifaces

            if 'eth0' in new_ifaces:
                timeout += 0.5
                time.sleep(0.5)
            else:
                break
        if 0 < timeout < 5:
            wok_log.info('Ginger backend waited ' + str(timeout) +
                         ' seconds for the mlx5_core driver to '
                         'complete the SR-IOV setup.')
        elif timeout == 5:
            wok_log.error('Ginger backend waited 5 seconds but the '
                          'mlx5_core driver did not complete the SR-IOV '
                          'setup. Is the mlx5_core driver working '
                          'properly?')
        return new_ifaces
示例#10
0
    def _wait_VFs_setup(self, ifaces_without_sriov):
        timeout = 0
        new_ifaces = None
        while timeout < 5:
            current_ifaces = cfgInterfacesHelper.get_interface_list()
            new_ifaces = ifaces_without_sriov ^ current_ifaces

            if 'eth0' in new_ifaces:
                timeout += 0.5
                time.sleep(0.5)
            else:
                break
        if 0 < timeout < 5:
            wok_log.info('Ginger backend waited ' + str(timeout) +
                         ' seconds for the mlx5_core driver to '
                         'complete the SR-IOV setup.')
        elif timeout == 5:
            wok_log.error('Ginger backend waited 5 seconds but the '
                          'mlx5_core driver did not complete the SR-IOV '
                          'setup. Is the mlx5_core driver working '
                          'properly?')
        return new_ifaces