Exemple #1
0
def test_knownledge_base():
    """Test loading a e3.platform_db extension."""
    # Create a new entry point referencing AmberCPUSupport and load it.
    mydb_ep = pkg_resources.EntryPoint.parse_group(
        "e3.platform_db",
        ["mydb = e3.platform_db:AmberCPUSupport"],
        dist=pkg_resources.get_distribution("e3-core"),
    )["mydb"]
    mydb_ep.load()

    # Inject it in the ExtensionManager entry point cache

    old_cache = stevedore.ExtensionManager.ENTRY_POINT_CACHE
    try:
        stevedore.ExtensionManager.ENTRY_POINT_CACHE["e3.platform_db"].append(mydb_ep)

        db = get_knowledge_base()
        # Check that the new amber CPU has been inserted
        for cpu_name in ("amber23", "amber25"):
            assert cpu_name not in db.cpu_info

        # Force a reload of the platform_db knowledge base
        get_knowledge_base.cache_clear()
        db = get_knowledge_base()

        # Check that the new amber CPU has been inserted
        for cpu_name in ("amber23", "amber25"):
            assert db.cpu_info[cpu_name] == {"endian": "little", "bits": 32}
    finally:
        # restore entry point cache
        stevedore.ExtensionManager.ENTRY_POINT_CACHE = old_cache
Exemple #2
0
def test_knownledge_base():
    """Test loading a e3.platform_db extension."""
    # Create a new entry point referencing AmberCPUSupport and load it.
    mydb_ep = pkg_resources.EntryPoint.parse_group(
        'e3.platform_db', ['mydb = e3.platform_db:AmberCPUSupport'],
        dist=pkg_resources.get_distribution('e3-core'))['mydb']
    mydb_ep.load()

    # Inject it in the ExtensionManager entry point cache

    old_cache = stevedore.ExtensionManager.ENTRY_POINT_CACHE
    try:
        stevedore.ExtensionManager.ENTRY_POINT_CACHE['e3.platform_db'].append(
            mydb_ep)

        # Force a reload of the platform_db knowledge base
        db = get_knowledge_base(reset_cache=True)

        # Check that the new amber CPU has been inserted
        for cpu_name in ('amber23', 'amber25'):
            assert db.cpu_info[cpu_name] == {'endian': 'little', 'bits': 32}
    finally:
        # restore entry point cache
        stevedore.ExtensionManager.ENTRY_POINT_CACHE = old_cache
Exemple #3
0
"""Provides function to detect platform specific information."""
from __future__ import absolute_import, division, print_function

import os
import re
import sys
from collections import namedtuple
from platform import uname as platform_uname

import e3.log
from e3.platform_db import get_knowledge_base

KNOWLEDGE_BASE = get_knowledge_base()

UNKNOWN = 'unknown'

Uname = namedtuple(
    "Uname", ["system", "node", "release", "version", "machine", "processor"])


class SystemInfo(object):
    """Gather info about the system.

    :cvar network_ifs: dictionary addressed by network interface name for which
        each value is the result of netifaces.ifaddresses function on the given
        interface
    :cvar uname: instance of Uname namedtuple containing the result of
        ``uname`` system call.
    :cvar core_number: integer containing the number of processor cores on the
        machine
    :cvar nis_domain: host nis domain
Exemple #4
0
from __future__ import absolute_import
from __future__ import print_function

import collections

import e3.os
import e3.os.platform
from e3.platform_db import get_knowledge_base


KNOWLEDGE_BASE = get_knowledge_base()


# noinspection PyUnresolvedReferences
class Platform(
    collections.namedtuple(
        'Platform',
        ['cpu', 'os', 'is_hie', 'platform', 'triplet',
         'machine', 'domain', 'is_host', 'is_default'])):
    """Class that allow user to retrieve os/cpu specific information.

    Attributes are:

    - cpu: CPU information
    - os: Operating System information
    - is_hie: whether the system is a high integrity system
    - platform: the platform name, e.g. arm-elf-linux
    - triplet: the GCC target
    - machine: machine name
    - domain: domain name
    - is_host: True if the instance represent information for the current