Skip to content

Documentation for Addonmanager Module

AddondManager

Responsible for initializing and managing system add-ons.

This class handles the lifecycle of optional services (add-ons) such as mobility simulation, GPS module, and network simulation. Add-ons are conditionally deployed based on the provided configuration.

Source code in nebula/core/addonmanager.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
class AddondManager:
    """
    Responsible for initializing and managing system add-ons.

    This class handles the lifecycle of optional services (add-ons) such as mobility simulation,
    GPS module, and network simulation. Add-ons are conditionally deployed based on the provided configuration.
    """

    def __init__(self, engine: "Engine", config: Config):
        """
        Initializes the AddondManager instance.

        Args:
            engine (Engine): Reference to the main engine instance of the system.
            config (dict): Configuration object containing participant settings for enabling add-ons.

        This constructor sets up the internal references to the engine and configuration, and
        initializes the list of add-ons to be managed.
        """
        self._engine = engine
        self._config = config
        self._addons = []

    async def deploy_additional_services(self):
        """
        Deploys and starts additional services based on the participant's configuration.

        This method checks the configuration to determine which optional components should be
        activated. It supports:
            - Mobility simulation (e.g., moving node behavior).
            - GPS module (e.g., geolocation updates).
            - Network simulation (e.g., changing connectivity conditions).

        All enabled add-ons are instantiated and started asynchronously.

        Notes:
            - Add-ons are stored in the internal list `_addons` for lifecycle management.
            - Services are only launched if the corresponding configuration flags are set.
        """
        print_msg_box(msg="Deploying Additional Services", indent=2, title="Addons Manager")
        if self._config.participant["trustworthiness"]:
            from nebula.addons.trustworthiness.trustworthiness import Trustworthiness

            trustworthiness = Trustworthiness(self._engine, self._config)
            self._addons.append(trustworthiness)

        if self._config.participant["mobility_args"]["mobility"]:
            mobility = Mobility(self._config, verbose=False)
            self._addons.append(mobility)

            update_interval = 5
            gps = factory_gpsmodule("nebula", self._config, self._engine.addr, update_interval, verbose=False)
            self._addons.append(gps)

        if self._config.participant["network_args"]["simulation"]:
            refresh_conditions_interval = 5
            network_simulation = factory_network_simulator("nebula", refresh_conditions_interval, "eth0", verbose=False)
            self._addons.append(network_simulation)

        for add in self._addons:
            await add.start()

    async def stop_additional_services(self):
        """
        Stops all additional services.
        """
        logging.info("🛑  Stopping additional services...")
        for add in self._addons:
            try:
                logging.info(f"🛑  Stopping addon: {add.__class__.__name__}")
                await add.stop()
                logging.info(f"✅  Successfully stopped addon: {add.__class__.__name__}")
            except Exception as e:
                logging.exception(f"❌  Error stopping addon {add.__class__.__name__}: {e}")
        logging.info("🛑  Finished stopping additional services")

__init__(engine, config)

Initializes the AddondManager instance.

Parameters:

Name Type Description Default
engine Engine

Reference to the main engine instance of the system.

required
config dict

Configuration object containing participant settings for enabling add-ons.

required

This constructor sets up the internal references to the engine and configuration, and initializes the list of add-ons to be managed.

Source code in nebula/core/addonmanager.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def __init__(self, engine: "Engine", config: Config):
    """
    Initializes the AddondManager instance.

    Args:
        engine (Engine): Reference to the main engine instance of the system.
        config (dict): Configuration object containing participant settings for enabling add-ons.

    This constructor sets up the internal references to the engine and configuration, and
    initializes the list of add-ons to be managed.
    """
    self._engine = engine
    self._config = config
    self._addons = []

deploy_additional_services() async

Deploys and starts additional services based on the participant's configuration.

This method checks the configuration to determine which optional components should be activated. It supports: - Mobility simulation (e.g., moving node behavior). - GPS module (e.g., geolocation updates). - Network simulation (e.g., changing connectivity conditions).

All enabled add-ons are instantiated and started asynchronously.

Notes
  • Add-ons are stored in the internal list _addons for lifecycle management.
  • Services are only launched if the corresponding configuration flags are set.
Source code in nebula/core/addonmanager.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
async def deploy_additional_services(self):
    """
    Deploys and starts additional services based on the participant's configuration.

    This method checks the configuration to determine which optional components should be
    activated. It supports:
        - Mobility simulation (e.g., moving node behavior).
        - GPS module (e.g., geolocation updates).
        - Network simulation (e.g., changing connectivity conditions).

    All enabled add-ons are instantiated and started asynchronously.

    Notes:
        - Add-ons are stored in the internal list `_addons` for lifecycle management.
        - Services are only launched if the corresponding configuration flags are set.
    """
    print_msg_box(msg="Deploying Additional Services", indent=2, title="Addons Manager")
    if self._config.participant["trustworthiness"]:
        from nebula.addons.trustworthiness.trustworthiness import Trustworthiness

        trustworthiness = Trustworthiness(self._engine, self._config)
        self._addons.append(trustworthiness)

    if self._config.participant["mobility_args"]["mobility"]:
        mobility = Mobility(self._config, verbose=False)
        self._addons.append(mobility)

        update_interval = 5
        gps = factory_gpsmodule("nebula", self._config, self._engine.addr, update_interval, verbose=False)
        self._addons.append(gps)

    if self._config.participant["network_args"]["simulation"]:
        refresh_conditions_interval = 5
        network_simulation = factory_network_simulator("nebula", refresh_conditions_interval, "eth0", verbose=False)
        self._addons.append(network_simulation)

    for add in self._addons:
        await add.start()

stop_additional_services() async

Stops all additional services.

Source code in nebula/core/addonmanager.py
76
77
78
79
80
81
82
83
84
85
86
87
88
async def stop_additional_services(self):
    """
    Stops all additional services.
    """
    logging.info("🛑  Stopping additional services...")
    for add in self._addons:
        try:
            logging.info(f"🛑  Stopping addon: {add.__class__.__name__}")
            await add.stop()
            logging.info(f"✅  Successfully stopped addon: {add.__class__.__name__}")
        except Exception as e:
            logging.exception(f"❌  Error stopping addon {add.__class__.__name__}: {e}")
    logging.info("🛑  Finished stopping additional services")