Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ update-dockers: ## Update docker images
else \
echo "Skipping nebula-controller docker build."; \
fi
@echo "🐳 Building nebula-database docker image. Do you want to continue (overrides existing image)? (y/n)"
@read ans; if [ "$${ans:-N}" = y ]; then \
docker build -t nebula-database -f nebula/database/adapters/postgress/docker/Dockerfile .; \
docker build -t nebula-pgweb -f nebula/database/pgweb/Dockerfile .; \
else \
echo "Skipping nebula-database docker build."; \
fi
@echo ""
@echo "🐳 Building nebula-frontend docker image. Do you want to continue (overrides existing image)? (y/n)"
@read ans; if [ "$${ans:-N}" = y ]; then \
Expand Down
647 changes: 543 additions & 104 deletions app/deployer.py

Large diffs are not rendered by default.

33 changes: 18 additions & 15 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
help="Controller port (default: 5050)",
)

argparser.add_argument(
"-fcp",
"--federationcontrollerport",
dest="federationcontrollerport",
default=5052,
help="federation controller port port (default: 5052)",
)

argparser.add_argument(
"--grafanaport",
dest="grafanaport",
Expand Down Expand Up @@ -64,38 +72,36 @@
help="Stop NEBULA platform or nodes only (use '--stop nodes' to stop only the nodes)",
)

argparser.add_argument("-s", "--simulation", action="store_false", dest="simulation", help="Run simulation")

argparser.add_argument(
"-c",
"--config",
dest="config",
default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "config"),
help="Config directory path",
help="NEBULA config directory path",
)

argparser.add_argument(
"-d",
"--database",
dest="databases",
default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "databases"),
help="Nebula databases path",
help="NEBULA databases directory path",
)

argparser.add_argument(
"-l",
"--logs",
dest="logs",
default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "logs"),
help="Logs directory path",
help="NEBULA logs directory path",
)

argparser.add_argument(
"-ce",
"--certs",
dest="certs",
default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "certs"),
help="Certs directory path",
help="NEBULA certs directory path",
)

argparser.add_argument(
Expand All @@ -106,24 +112,21 @@
help=".env file path",
)

argparser.add_argument("-dev", "--developement", dest="developement", default=True, help="Nebula for devs")

argparser.add_argument(
"-p",
"--production",
dest="production",
action="store_true",
default=False,
help="Production mode",
help="Deploy NEBULA in production mode",
)

argparser.add_argument(
"-ad",
"--advanced",
dest="advanced_analytics",
action="store_true",
default=False,
help="Advanced analytics",
"-pr",
"--prefix",
dest="prefix",
default="dev",
help="Deploy NEBULA components with a prefix",
)

argparser.add_argument(
Expand Down
2 changes: 1 addition & 1 deletion nebula/addons/attacks/attacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def create_attack(engine) -> Attack:
}

# Get attack name and parameters from the engine configuration
attack_params = engine.config.participant["adversarial_args"].get("attack_params", {})
attack_params = engine.config.participant["addons"]["adversarial_args"].get("attack_params", {})
attack_name = attack_params.get("attacks", None)
if attack_name is None:
raise AttackException("No attack specified")
Expand Down
4 changes: 2 additions & 2 deletions nebula/addons/gps/nebulagps.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ async def is_running(self):
return self._running.is_set()

async def get_geoloc(self):
latitude = self._config.participant["mobility_args"]["latitude"]
longitude = self._config.participant["mobility_args"]["longitude"]
latitude = self._config.participant["addons"]["mobility"]["latitude"]
longitude = self._config.participant["addons"]["mobility"]["longitude"]
return (latitude, longitude)

async def calculate_distance(self, self_lat, self_long, other_lat, other_long):
Expand Down
26 changes: 13 additions & 13 deletions nebula/addons/mobility.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ def __init__(self, config, verbose=False):
self._mobility_task = None # Track the background task

# Mobility configuration
self.mobility = self.config.participant["mobility_args"]["mobility"]
self.mobility_type = self.config.participant["mobility_args"]["mobility_type"]
self.grace_time = self.config.participant["mobility_args"]["grace_time_mobility"]
self.period = self.config.participant["mobility_args"]["change_geo_interval"]
self.mobility = self.config.participant["addons"]["mobility"]["enabled"]
self.mobility_type = self.config.participant["addons"]["mobility"]["mobility_type"]
self.grace_time = self.config.participant["addons"]["mobility"]["grace_time_mobility"]
self.period = self.config.participant["addons"]["mobility"]["change_geo_interval"]
# INFO: These values may change according to the needs of the federation
self.max_distance_with_direct_connections = 150 # meters
self.max_movement_random_strategy = 50 # meters
self.max_movement_nearest_strategy = 50 # meters
self.max_initiate_approximation = self.max_distance_with_direct_connections * 1.2
self.radius_federation = float(config.participant["mobility_args"]["radius_federation"])
self.scheme_mobility = config.participant["mobility_args"]["scheme_mobility"]
self.round_frequency = int(config.participant["mobility_args"]["round_frequency"])
self.radius_federation = float(config.participant["addons"]["mobility"]["radius_federation"])
self.scheme_mobility = config.participant["addons"]["mobility"]["scheme_mobility"]
self.round_frequency = int(config.participant["addons"]["mobility"]["round_frequency"])
# Logging box with mobility information
mobility_msg = f"Mobility: {self.mobility}\nMobility type: {self.mobility_type}\nRadius federation: {self.radius_federation}\nScheme mobility: {self.scheme_mobility}\nEach {self.round_frequency} rounds"
print_msg_box(msg=mobility_msg, indent=2, title="Mobility information")
Expand Down Expand Up @@ -267,11 +267,11 @@ async def set_geo_location(self, latitude, longitude):

if latitude < -90 or latitude > 90 or longitude < -180 or longitude > 180:
# If the new location is out of bounds, we keep the old location
latitude = self.config.participant["mobility_args"]["latitude"]
longitude = self.config.participant["mobility_args"]["longitude"]
latitude = self.config.participant["addons"]["mobility"]["latitude"]
longitude = self.config.participant["addons"]["mobility"]["longitude"]

self.config.participant["mobility_args"]["latitude"] = latitude
self.config.participant["mobility_args"]["longitude"] = longitude
self.config.participant["addons"]["mobility"]["latitude"] = latitude
self.config.participant["addons"]["mobility"]["longitude"] = longitude
if self._verbose:
logging.info(f"📍 New geo location: {latitude}, {longitude}")
cle = ChangeLocationEvent(latitude, longitude)
Expand Down Expand Up @@ -301,8 +301,8 @@ async def change_geo_location(self):
"""
if self.mobility and (self.mobility_type == "topology" or self.mobility_type == "both"):
random.seed(time.time() + self.config.participant["device_args"]["idx"])
latitude = float(self.config.participant["mobility_args"]["latitude"])
longitude = float(self.config.participant["mobility_args"]["longitude"])
latitude = float(self.config.participant["addons"]["mobility"]["latitude"])
longitude = float(self.config.participant["addons"]["mobility"]["longitude"])
if True:
# Get neighbor closer to me
async with self._nodes_distances_lock:
Expand Down
2 changes: 1 addition & 1 deletion nebula/addons/networksimulation/nebulanetworksimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def cm(self):
async def start(self):
logging.info("🌐 Nebula Network Simulator starting...")
self._running.set()
grace_time = self.cm.config.participant["mobility_args"]["grace_time_mobility"]
grace_time = self.cm.config.participant["addons"]["mobility"]["grace_time_mobility"]
# if self._verbose: logging.info(f"Waiting {grace_time}s to start applying network conditions based on distances between devices")
# await asyncio.sleep(grace_time)
await EventManager.get_instance().subscribe_addonevent(
Expand Down
21 changes: 17 additions & 4 deletions nebula/addons/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import sys
from nebula.controller.federation.utils_requests import NodeUpdateRequest, NodeDoneRequest
from typing import TYPE_CHECKING

import aiohttp
Expand Down Expand Up @@ -54,7 +55,7 @@ def __init__(self, config, trainer):
self.frequency = self.config.participant["reporter_args"]["report_frequency"]
self.grace_time = self.config.participant["reporter_args"]["grace_time_reporter"]
self.data_queue = asyncio.Queue()
self.url = f"http://{self.config.participant['scenario_args']['controller']}/nodes/{self.config.participant['scenario_args']['name']}/update"
self.url = f"http://{self.config.participant['scenario_args']['controller']}/nodes/{self.config.participant['scenario_args']['federation_id']}/update"
self.counter = 0

self.first_net_metrics = True
Expand Down Expand Up @@ -170,8 +171,18 @@ async def report_scenario_finished(self):
might be temporarily overloaded.
- Logs exceptions if the connection attempt to the controller fails.
"""
url = f"http://{self.config.participant['scenario_args']['controller']}/nodes/{self.config.participant['scenario_args']['name']}/done"
data = json.dumps({"idx": self.config.participant["device_args"]["idx"]})
url = f"http://{self.config.participant['scenario_args']['controller']}/nodes/{self.config.participant['scenario_args']['federation_id']}/done"
node_done_req = NodeDoneRequest(idx=self.config.participant["device_args"]["idx"],
deployment=self.config.participant["scenario_args"]["deployment"],
name=self.config.participant["scenario_args"]["name"],
federation_id=self.config.participant["scenario_args"]["federation_id"]
)
payload = node_done_req.model_dump()
data = json.dumps(payload)
# data = json.dumps({"idx": self.config.participant["device_args"]["idx"],
# "deployment": self.config.participant["scenario_args"]["deployment"],
# "name": self.config.participant["scenario_args"]["name"],
# "federation_id": self.config.participant["scenario_args"]["federation_id"]})
headers = {
"Content-Type": "application/json",
"User-Agent": f"NEBULA Participant {self.config.participant['device_args']['idx']}",
Expand Down Expand Up @@ -263,11 +274,13 @@ async def __report_status_to_controller(self):
- Delays for 5 seconds upon general exceptions to avoid rapid retry loops.
"""
try:
node_updt_req = NodeUpdateRequest(config=self.config.participant)
payload = node_updt_req.model_dump()
async with (
aiohttp.ClientSession() as session,
session.post(
self.url,
data=json.dumps(self.config.participant),
data=json.dumps(payload),
headers={
"Content-Type": "application/json",
"User-Agent": f"NEBULA Participant {self.config.participant['device_args']['idx']}",
Expand Down
Loading