Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature/simultaneous_queues] Improved version for scenario management #29

Merged
merged 39 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8410553
feature: multiple queues working with different users using the defau…
FerTV Nov 21, 2024
e2fb2b1
fix network prefix 192.168.1 changed to 192.168.2
FerTV Nov 25, 2024
7a7091e
Fix different queue for each user
FerTV Nov 26, 2024
c7901a9
feature: show scenarios in the dashboard depending on the role of the…
FerTV Nov 26, 2024
278faf8
refactor: changed location of utils.py
FerTV Nov 26, 2024
6108dce
fix: nebula-frontend port
FerTV Nov 26, 2024
8885d48
fix: launching scenarios with same user in different frontend instance
FerTV Nov 26, 2024
cf9166a
fix: launching scenarios with same user in different frontend instance
FerTV Nov 26, 2024
2a3d285
fix: stopping only instance
FerTV Nov 26, 2024
47158ba
fix: stopping only instance
FerTV Nov 26, 2024
2212ae1
fix: remove instance network
FerTV Nov 26, 2024
2316b07
fix: killing other instance docker when starting new scenario
FerTV Nov 26, 2024
e98b985
Merge remote-tracking branch 'origin/main' into feature/simultaneous_…
FerTV Nov 26, 2024
7b123a3
Merge remote-tracking branch 'origin/main' into feature/simultaneous_…
FerTV Nov 27, 2024
d2a64e3
fix: stop bugs
FerTV Nov 27, 2024
2db5626
feature: display queues for each user
FerTV Nov 27, 2024
791a661
Fix persistence on session and dbs
enriquetomasmb Nov 27, 2024
1f81b12
Fix persistence on session
FerTV Nov 27, 2024
ea2862a
fix: scenario database, database dashboard
FerTV Nov 27, 2024
62233a7
Minor changes in user management
enriquetomasmb Nov 27, 2024
a2095b7
Improve update docker images
enriquetomasmb Nov 27, 2024
d84e8c3
remove reconnections (more debug needed)
enriquetomasmb Nov 28, 2024
cd9f978
fix: scenario title setted to empty when theres no scenario title
FerTV Nov 28, 2024
99d2b8e
fix: redirect to dashboard.py
FerTV Nov 28, 2024
6b5d818
fix: waf containers on production mode working
FerTV Nov 28, 2024
f2fc1f9
fix: change user in config files automatically
FerTV Nov 28, 2024
528e011
fix: remove unnecesary variable user
FerTV Nov 28, 2024
f50cc69
remove unused functions
enriquetomasmb Nov 28, 2024
468f769
fix: blockchain network endpoint
FerTV Nov 29, 2024
80a5796
fix: deploying different scenarios with process
FerTV Dec 3, 2024
672b22b
define NEBULA Controller API, update makefile
enriquetomasmb Dec 3, 2024
bf39d18
enable controller endpoint from the frontend
enriquetomasmb Dec 4, 2024
4d40773
fix: connection between nodes in process deployment
FerTV Dec 4, 2024
b32bcca
refactor: fronted.log in run_frontend for frontend.log
FerTV Dec 4, 2024
526a8cf
feature: halt scenarios when RAM or GPU usage is maxed out
FerTV Dec 13, 2024
0f9dff2
fix: obtain list of gpus available based in user
FerTV Dec 13, 2024
773f56f
fix: gpus list
FerTV Dec 13, 2024
6c4ec13
fix: docker ips and gpus lists
FerTV Dec 13, 2024
539465c
Fix generate statistics
enriquetomasmb Dec 16, 2024
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
79 changes: 38 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ PYTHON_VERSION := 3.11
UV_INSTALL_SCRIPT := https://astral.sh/uv/install.sh
PATH := $(HOME)/.local/bin:$(PATH)

command_exists = $(shell command -v $(1) >/dev/null 2>&1 && echo true || echo false)

define install_uv
@echo "📦 uv is not installed. Installing uv..."
@curl -LsSf $(UV_INSTALL_SCRIPT) | sh
endef

.PHONY: check-uv
check-uv: ## Check and install uv if necessary
@if command -v $(UV) >/dev/null 2>&1; then \
Expand All @@ -33,33 +26,26 @@ install-python: check-uv ## Install Python with uv
.PHONY: install
install: install-python ## Install core dependencies
@echo "📦 Installing core dependencies with uv"
@$(UV) sync --group core
@$(UV) sync --group controller --group core
@echo "🔧 Installing pre-commit hooks"
@$(UV) run pre-commit install
@echo ""
@echo "🐳 Building nebula-frontend docker image. Do you want to continue (overrides existing image)? (y/n)"
@read ans; if [ "$${ans:-N}" = y ]; then \
docker build -t nebula-frontend -f nebula/frontend/Dockerfile .; \
else \
echo "Skipping nebula-frontend docker build."; \
fi
@echo ""
@echo "🐳 Building nebula-core docker image. Do you want to continue? (overrides existing image)? (y/n)"
@read ans; if [ "$${ans:-N}" = y ]; then \
docker build -t nebula-core .; \
else \
echo "Skipping nebula-core docker build."; \
fi
@$(MAKE) update
@echo ""
@$(MAKE) shell

.PHONY: full-install
full-install: install-python ## Install all dependencies (core, docs)
@echo "📦 Installing all dependencies with uv"
@$(UV) sync --group core --group docs
@echo "🔧 Installing pre-commit hooks"
@$(UV) run pre-commit install
@$(MAKE) shell
.PHONY: install-production
install-production: install ## Install production dependencies
@echo "🐳 Updating production docker images..."
@echo "🐳 Building nebula-waf"
@docker build -t nebula-waf -f nebula/addons/waf/Dockerfile-waf --build-arg USER=$(USER) nebula/addons/waf
@echo "🐳 Building nebula-loki"
@docker build -t nebula-waf-loki -f nebula/addons/waf/Dockerfile-loki nebula/addons/waf
@echo "🐳 Building nebula-promtail"
@docker build -t nebula-waf-promtail -f nebula/addons/waf/Dockerfile-promtail --build-arg USER=$(USER) nebula/addons/waf
@echo "🐳 Building nebula-grafana"
@docker build -t nebula-waf-grafana -f nebula/addons/waf/Dockerfile-grafana --build-arg USER=$(USER) nebula/addons/waf
echo "🐳 Docker images updated."

.PHONY: shell
shell: ## Start a shell in the uv environment
Expand All @@ -79,20 +65,31 @@ shell: ## Start a shell in the uv environment
echo "🚀 Created by \033[1;34mEnrique Tomás Martínez Beltrán\033[0m <\033[1;[email protected]\033[0m>"; \
fi

.PHONY: update
update: ## Update docker images
@echo "🐳 Updating docker images..."
@echo "🐳 Building nebula-frontend docker image. Do you want to continue (overrides existing image)? (y/n)"
@read ans; if [ "$${ans:-N}" = y ]; then \
docker build -t nebula-frontend -f nebula/frontend/Dockerfile .; \
else \
echo "Skipping nebula-frontend docker build."; \
fi
@echo ""
@echo "🐳 Building nebula-core docker image. Do you want to continue? (overrides existing image)? (y/n)"
@read ans; if [ "$${ans:-N}" = y ]; then \
docker build -t nebula-core .; \
else \
echo "Skipping nebula-core docker build."; \
fi
echo "🐳 Docker images updated."

.PHONY: lock
lock: ## Update the lock file
@echo "🔒 This will update the lock file. Do you want to continue? (y/n)"
@read ans && [ $${ans:-N} = y ] || { echo "Lock cancelled."; exit 1; }
@echo "🔒 Locking dependencies..."
@$(UV) lock

.PHONY: update-libs
update-libs: ## Update libraries to the latest version
@echo "🔧 This will override the versions of current libraries. Do you want to continue? (y/n)"
@read ans && [ $${ans:-N} = y ] || { echo "Update cancelled."; exit 1; }
@echo "📦 Updating libraries..."
@$(UV) update

.PHONY: check
check: ## Run code quality tools
@echo "🛠️ Running code quality checks"
Expand Down Expand Up @@ -127,6 +124,12 @@ publish: ## Publish a release to PyPI
.PHONY: build-and-publish
build-and-publish: build publish ## Build and publish the package

.PHONY: doc-install
full-install: install-python ## Install dependencies for documentation
@echo "📦 Installing doc dependencies with uv"
@$(UV) sync --group core --group docs
@$(MAKE) shell

.PHONY: doc-test
doc-test: ## Test if documentation can be built without errors
@$(UV) run mkdocs build -f docs/mkdocs.yml -d _build -s
Expand All @@ -139,12 +142,6 @@ doc-build: ## Build the documentation
doc-serve: ## Serve the documentation locally
@$(UV) run mkdocs serve -f docs/mkdocs.yml

.PHONY: format
format: ## Format code with black and isort
@echo "🎨 Formatting code"
@$(UV) run black .
@$(UV) run isort .

.PHONY: clean
clean: clean-build ## Clean up build artifacts and caches
@echo "🧹 Cleaning up build artifacts and caches"
Expand Down
33 changes: 26 additions & 7 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

argparser = argparse.ArgumentParser(description="Controller of NEBULA platform", add_help=False)

argparser.add_argument(
"-cp",
"--controllerport",
dest="controllerport",
default=5000,
help="Controller port (default: 5000)",
)

argparser.add_argument(
"--grafanaport",
dest="grafanaport",
Expand Down Expand Up @@ -38,6 +46,14 @@
help="Frontend port (default: 6060)",
)

argparser.add_argument(
"-sp",
"--statsport",
dest="statsport",
default=8080,
help="Statistics port (default: 8080)",
)

argparser.add_argument("-t", "--test", dest="test", action="store_true", default=False, help="Run tests")

argparser.add_argument(
Expand All @@ -49,42 +65,41 @@
default=None,
help="Stop NEBULA platform or nodes only (use '--stop nodes' to stop only the nodes)",
)
argparser.add_argument(
"-sp",
"--statsport",
dest="statsport",
default=8080,
help="Statistics port (default: 8080)",
)

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",
)

argparser.add_argument(
"-l",
"--logs",
dest="logs",
default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "logs"),
help="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",
)

argparser.add_argument(
"-e",
"--env",
dest="env",
default=os.path.join(os.path.dirname(os.path.abspath(__file__)), ".env"),
help=".env file path",
)

argparser.add_argument(
"-p",
"--production",
Expand All @@ -93,6 +108,7 @@
default=False,
help="Production mode",
)

argparser.add_argument(
"-ad",
"--advanced",
Expand All @@ -101,20 +117,23 @@
default=False,
help="Advanced analytics",
)

argparser.add_argument(
"-v",
"--version",
action="version",
version="%(prog)s " + nebula.__version__,
help="Show version",
)

argparser.add_argument(
"-a",
"--about",
action="version",
version="Created by Enrique Tomás Martínez Beltrán",
help="Show author",
)

argparser.add_argument("-h", "--help", action="help", default=argparse.SUPPRESS, help="Show help")

args = argparser.parse_args()
Expand Down
2 changes: 1 addition & 1 deletion docs/_prebuilt/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ frontend, controller, and nodes.

## Possible issues during the installation or execution

If frontend is not working, check the logs in app/logs/server.log
If frontend is not working, check the logs in app/logs/frontend.log

If any of the following errors appear, take a look at the docker logs of
the nebula-frontend container:
Expand Down
5 changes: 5 additions & 0 deletions nebula/addons/waf/Dockerfile-grafana
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM grafana/grafana:latest

ARG USER
ENV USER=${USER}

COPY ./grafana/dashboard_config.yml /etc/grafana/provisioning/dashboards/local.yml
COPY ./grafana/automatic.yml /etc/grafana/provisioning/datasources/automatic.yml
COPY ./grafana/dashboard.json /var/lib/grafana/dashboards/dashboard.json

RUN sed -i "s|http://nebula|http://$USER|g" /etc/grafana/provisioning/datasources/automatic.yml
2 changes: 2 additions & 0 deletions nebula/addons/waf/Dockerfile-loki
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
FROM grafana/loki:latest

COPY loki-config.yml /mnt/config/loki-config.yml
7 changes: 7 additions & 0 deletions nebula/addons/waf/Dockerfile-promtail
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
FROM grafana/promtail:latest

ARG USER
ENV USER=${USER}

COPY promtail-config.yml /etc/promtail/config.yml

RUN sed -i "s|http://nebula|http://$USER|g" /etc/promtail/config.yml
6 changes: 6 additions & 0 deletions nebula/addons/waf/Dockerfile-waf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM owasp/modsecurity-crs:3.3.5-nginx-202310170110

ARG NGINX_VERSION=1.24.0

ARG USER
ENV USER=${USER}

# Installed necessary packages
RUN apt-get update && apt-get install -y libmaxminddb0 libmaxminddb-dev mmdb-bin git wget
RUN apt install -y build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev
Expand Down Expand Up @@ -37,6 +40,9 @@ RUN wget https://git.io/GeoLite2-Country.mmdb -P /usr/share/GeoIP/

# nginx configuration files
COPY default.conf /etc/nginx/templates/conf.d/default.conf.template

RUN sed -i "s|http://nebula|http://${USER}|g" /etc/nginx/templates/conf.d/default.conf.template

COPY nginx.conf /etc/nginx/templates/nginx.conf.template

# owasp crs
Expand Down
2 changes: 1 addition & 1 deletion nebula/addons/waf/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ server {
listen 80 default_server;

server_name localhost;
set $upstream http://nebula-frontend; # Change this
set $upstream http://nebula-nebula-frontend; # Change this
set $always_redirect off;
modsecurity on;
location /nebula {
Expand Down
2 changes: 1 addition & 1 deletion nebula/addons/waf/grafana/automatic.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
datasources:
- name: Loki
type: loki
url: http://loki:3100
url: http://nebula-nebula-waf-loki:3100
isDefault: true
editable: true
2 changes: 1 addition & 1 deletion nebula/addons/waf/promtail-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ positions:
filename: /tmp/positions.yaml

clients:
- url: http://loki:3100/loki/api/v1/push
- url: http://nebula-nebula-waf-loki:3100/loki/api/v1/push

scrape_configs:
- job_name: nginx
Expand Down
Loading
Loading