Return the kernel boot parameters
486550
def kernelparams():
    '''
    
    '''
    if salt.utils.platform.is_windows():
        # TODO: add grains using `bcdedit /enum {current}`
        return {}
    else:
        try:
            with salt.utils.files.fopen('/proc/cmdline', 'r') as fhr:
                cmdline = fhr.read()
                grains = {'kernelparams': []}
                for data in [item.split('=') for item in salt.utils.args.shlex_split(cmdline)]:
                    value = None
                    if len(data) == 2:
                        value = data[1].strip('"')

                    grains['kernelparams'] += [(data[0], value)]
        except IOError as exc:
            grains = {}
            log.debug('Failed to read /proc/cmdline: %s', exc)

        return grains
1212714
def get_kernel_data(self):
        """"""
        return {
            'subplex_scratch_float': LocalMemory(
                'mot_float_type', 4 + self._var_replace_dict['NMR_PARAMS'] * 2
                                    + self._var_replace_dict['MAX_SUBSPACE_LENGTH'] * 2
                                    + (self._var_replace_dict['MAX_SUBSPACE_LENGTH'] * 2
                                       + self._var_replace_dict['MAX_SUBSPACE_LENGTH']+1)**2 + 1),
            'subplex_scratch_int': LocalMemory(
                'int', 2 + self._var_replace_dict['NMR_PARAMS']
                         + (self._var_replace_dict['NMR_PARAMS'] // self._var_replace_dict['MIN_SUBSPACE_LENGTH'])),
            'initial_simplex_scale': LocalMemory('mot_float_type', self._var_replace_dict['NMR_PARAMS'])
        }
1338076
def _get_os_properties():
    
    if IS_DISTRO_INSTALLED:
        return distro.linux_distribution(full_distribution_name=False)
    return platform.linux_distribution(full_distribution_name=False)
979076
def init_kernel(self):
        '''
        

        '''

        if self.kernel_params is None:
            X = self.apply_mask(self.fpix / self.flux.reshape(-1, 1))
            y = self.apply_mask(self.flux) - np.dot(X, np.linalg.solve(
                np.dot(X.T, X), np.dot(X.T, self.apply_mask(self.flux))))
            white = np.nanmedian([np.nanstd(c) for c in Chunks(y, 13)])
            amp = self.gp_factor * np.nanstd(y)
            tau = 30.0
            if self.kernel == 'Basic':
                self.kernel_params = [white, amp, tau]
            elif self.kernel == 'QuasiPeriodic':
                self.kernel_params = [white, amp, 1., 20.]
1088803
def get_secure_boot_mode(self):
        
        system = self._get_host_details()

        if ('links' not in system['Oem']['Hp'] or
           'SecureBoot' not in system['Oem']['Hp']['links']):
            msg = ('"SecureBoot" resource or feature is not supported'
                   ' on this system')
            raise exception.IloCommandNotSupportedError(msg)

        secure_boot_uri = system['Oem']['Hp']['links']['SecureBoot']['href']

        # get the Secure Boot object
        status, headers, secure_boot_settings = self._rest_get(secure_boot_uri)

        if status >= 300:
            msg = self._get_extended_error(secure_boot_settings)
            raise exception.IloError(msg)

        return secure_boot_settings['SecureBootCurrentState']
863687
def get_supported_boot_mode(supported_boot_mode):
        
        boot_mode_bios = 'false'
        boot_mode_uefi = 'false'
        if (supported_boot_mode ==
                sys_cons.SUPPORTED_LEGACY_BIOS_ONLY):
            boot_mode_bios = 'true'
        elif (supported_boot_mode ==
                sys_cons.SUPPORTED_UEFI_ONLY):
            boot_mode_uefi = 'true'
        elif (supported_boot_mode ==
                sys_cons.SUPPORTED_LEGACY_BIOS_AND_UEFI):
            boot_mode_bios = 'true'
            boot_mode_uefi = 'true'

        return SupportedBootModes(boot_mode_bios=boot_mode_bios,
                                  boot_mode_uefi=boot_mode_uefi)
128083
def _bsd_cpudata(osdata):
    '''
    
    '''
    # Provides:
    #   cpuarch
    #   num_cpus
    #   cpu_model
    #   cpu_flags
    sysctl = salt.utils.path.which('sysctl')
    arch = salt.utils.path.which('arch')
    cmds = {}

    if sysctl:
        cmds.update({
            'num_cpus': '{0} -n hw.ncpu'.format(sysctl),
            'cpuarch': '{0} -n hw.machine'.format(sysctl),
            'cpu_model': '{0} -n hw.model'.format(sysctl),
        })

    if arch and osdata['kernel'] == 'OpenBSD':
        cmds['cpuarch'] = '{0} -s'.format(arch)

    if osdata['kernel'] == 'Darwin':
        cmds['cpu_model'] = '{0} -n machdep.cpu.brand_string'.format(sysctl)
        cmds['cpu_flags'] = '{0} -n machdep.cpu.features'.format(sysctl)

    grains = dict([(k, __salt__['cmd.run'](v)) for k, v in six.iteritems(cmds)])

    if 'cpu_flags' in grains and isinstance(grains['cpu_flags'], six.string_types):
        grains['cpu_flags'] = grains['cpu_flags'].split(' ')

    if osdata['kernel'] == 'NetBSD':
        grains['cpu_flags'] = []
        for line in __salt__['cmd.run']('cpuctl identify 0').splitlines():
            cpu_match = re.match(r'cpu[0-9]:\ features[0-9]?\ .+<(.+)>', line)
            if cpu_match:
                flag = cpu_match.group(1).split(',')
                grains['cpu_flags'].extend(flag)

    if osdata['kernel'] == 'FreeBSD' and os.path.isfile('/var/run/dmesg.boot'):
        grains['cpu_flags'] = []
        # TODO: at least it needs to be tested for BSD other then FreeBSD
        with salt.utils.files.fopen('/var/run/dmesg.boot', 'r') as _fp:
            cpu_here = False
            for line in _fp:
                if line.startswith('CPU: '):
                    cpu_here = True  # starts CPU descr
                    continue
                if cpu_here:
                    if not line.startswith(' '):
                        break  # game over
                    if 'Features' in line:
                        start = line.find('<')
                        end = line.find('>')
                        if start > 0 and end > 0:
                            flag = line[start + 1:end].split(',')
                            grains['cpu_flags'].extend(flag)
    try:
        grains['num_cpus'] = int(grains['num_cpus'])
    except ValueError:
        grains['num_cpus'] = 1

    return grains
233979
protected function getKernelParameters()
    {
        return array_merge(
            array(
                'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
                'kernel.environment' => $this->environment,
                'kernel.debug' => $this->debug,
                'kernel.name' => $this->name,
                'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
                'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
                'kernel.charset' => $this->getCharset(),
                'kernel.container_class' => $this->getContainerClass(),
            ),
            $this->getEnvParameters()
        );
    }
737585
def c_getprocs(self):
        """"""
        getprocs = []
        for name, dummy_args in self.funcs:
            if name == 'GetProcAddress':
                if callable(self.opts.hash_func):
                    continue
                getter = 'get_proc_by_string'
            elif self.opts.no_structs:
                getter = 'GetProcAddress'
            else:
                getter = 'windll->kernel32.GetProcAddress'
            if callable(self.opts.hash_func):
                getter = 'get_proc_by_hash'
            if self.opts.no_structs:
                var = name
            else:
                var = 'windll->{}.{}'.format(self.name, name)
            getproc = '{} = ({} *){}({}, {}{});\n'.format(
                var,
                self._c_type_name(name),
                getter,
                self._c_base_var(),
                self.opts.prefix, name
            )
            getprocs.append(getproc + self._c_null_check(var))
        return getprocs
235167
private function getPossibleKernelClasses()
    {
        if (empty($this->config['kernel_class'])) {
            return self::$possibleKernelClasses;
        }

        if (!is_string($this->config['kernel_class'])) {
            throw new ModuleException(
                __CLASS__,
                "Parameter 'kernel_class' must have 'string' type.\n"
            );
        }

        return [$this->config['kernel_class']];
    }
1212625
def kernel_modules(attrs=None, where=None):
    '''
    
    '''
    if __grains__['os_family'] in ['RedHat', 'Debian']:
        return _osquery_cmd(table='kernel_modules', attrs=attrs, where=where)
    return {'result': False, 'comment': 'Only available on Red Hat or Debian based systems.'}
348348
def get_uefi_boot_string(self, mac):
        
        boot_sources = self.boot_sources
        if not boot_sources:
            msg = ('Boot sources are not found')
            LOG.debug(msg)
            raise exception.IloError(msg)

        for boot_source in boot_sources:
            if (mac.upper() in boot_source['UEFIDevicePath'] and
                    'iSCSI' in boot_source['UEFIDevicePath']):
                return boot_source['StructuredBootString']
        else:
            msg = ('MAC provided "%s" is Invalid' % mac)
            raise exception.IloInvalidInputError(msg)
915962
def get_kernel_id(self):
        
        sessions_url = self.get_session_url()
        sessions_req = requests.get(sessions_url).content.decode()
        sessions = json.loads(sessions_req)

        if os.name == 'nt':
            path = self.path.replace('\\', '/')
        else:
            path = self.path

        for session in sessions:
            notebook_path = session.get('notebook', {}).get('path')
            if notebook_path is not None and notebook_path == path:
                kernel_id = session['kernel']['id']
                return kernel_id
1059160
public function boot(): KernelInterface
    {
        if (! $this->isBooted) {
            foreach ($this->serviceProviders as $provider) {
                $this->bootProvider($provider);
            }
            $this->isBooted = true;
        }

        return $this;
    }
787562
async def get_default_min_hwe_kernel(cls) -> typing.Optional[str]:
        
        data = await cls.get_config("default_min_hwe_kernel")
        return None if data is None or data == "" else data
844534
def slurm_params(self):
        """"""
        # Main loop #
        result = OrderedDict()
        for param, info in self.slurm_headers.items():
            if not info['needed'] and not param in self.kwargs: continue
            if param in self.kwargs: result[param] = self.kwargs.get(param)
            else:                    result[param] = info['default']
        # Special cases #
        if result.get('cluster') == 'halvan': result['partition'] = 'halvan'
        # Return #
        return result
859044
async def get_kernel_options(cls) -> typing.Optional[str]:
        
        data = await cls.get_config("kernel_opts")
        return None if data is None or data == "" else data