Exemplo n.º 1
0
def highest_online_cpu_nr() -> int:
    """
    Return The highest online CPU number

    Returns:
        :obj:`int`: The highest online CPU number
    """
    if not TypesCPUClass.cpus_online:
        raise DelayedAttributeError('cpus_online')
    return TypesCPUClass.cpus_online[-1]
Exemplo n.º 2
0
    def for_each_online_nid(self) -> Iterable[int]:
        """
        Iterate over each online NUMA Node ID

        Yields:
            :obj:`int`: The next NUMA Node ID
        """
        if not self.nids_online:
            raise DelayedAttributeError('node_states')

        for nid in self.nids_online:
            yield nid
Exemplo n.º 3
0
    def get(self, name: str) -> CollectedValue:
        """
        Obtain the object associated with name

        Args:
            name: The attribute name associated with the :obj:`.DelayedValue`

        Returns:
            :obj:`object`: The underlying object associated with this name.

        Raises:
            :obj:`NameError`: The name does not exist.
            :obj:`.DelayedAttributeError`: The name exists but the value
                has not been resolved yet.
        """
        if name not in self.attrs:
            raise NameError(f"'{self.__class__}' object has no '{name}'")

        if self.attrs[name].value is not None:
            setattr(self, name, self.attrs[name].value)
            return self.attrs[name].value

        raise DelayedAttributeError(name)
Exemplo n.º 4
0
 def _utsname_field(self, name: str) -> str:
     try:
         return self._utsname_cache[name]
     except KeyError:
         raise DelayedAttributeError(name) from None
Exemplo n.º 5
0
 def get(self, owner):
     if self.value is None:
         raise DelayedAttributeError(owner, self.name)
     return self.value
Exemplo n.º 6
0
 def get(self) -> Any:
     if self.value is None:
         raise DelayedAttributeError(self.name)
     return self.value