From 54ce126e20d941c162c5462c90909cee970a7efa Mon Sep 17 00:00:00 2001 From: Xavier Rodriguez Date: Mon, 9 Mar 2026 15:26:51 +0100 Subject: [PATCH] Refactor Cisco MAC Monitor: Implement HTTPS service and restructure code - Removed old requirements.txt and test_new_format.py files. - Added new src/cisco_mac_http_service.py to implement an HTTPS service for MAC monitoring. - Introduced src/cisco_mac_monitor.py for the main MAC monitoring functionality. - Created new requirements.txt for dependencies. - Added example usage documentation in Docs/example. - Updated test_new_format.py to validate new JSON output format. --- CHANGELOG.md | 11 +++++++++++ Dockerfile | 6 +++--- example => Docs/example | 0 build.sh | 2 +- .../cisco_mac_http_service.py | 0 cisco_mac_monitor.py => src/cisco_mac_monitor.py | 0 requirements.txt => src/requirements.txt | 0 test_new_format.py => src/test_new_format.py | 0 8 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 CHANGELOG.md rename example => Docs/example (100%) rename cisco_mac_http_service.py => src/cisco_mac_http_service.py (100%) rename cisco_mac_monitor.py => src/cisco_mac_monitor.py (100%) rename requirements.txt => src/requirements.txt (100%) rename test_new_format.py => src/test_new_format.py (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6f2a98b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +CHANGELOG.md + +2026/02/09 +Refactor Cisco MAC Monitor: Implement HTTPS service and restructure code + +- Removed old requirements.txt and test_new_format.py files. +- Added new src/cisco_mac_http_service.py to implement an HTTPS service for MAC monitoring. +- Introduced src/cisco_mac_monitor.py for the main MAC monitoring functionality. +- Created new requirements.txt for dependencies. +- Added example usage documentation in Docs/example. +- Updated test_new_format.py to validate new JSON output format. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ca72a54..81e3071 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ RUN dnf update -y && \ RUN useradd -m -u 1000 -s /bin/bash monitor # Copiar requirements.txt primero para cache de Docker -COPY requirements.txt /tmp/requirements.txt +COPY src/requirements.txt /tmp/requirements.txt # Instalar dependencias Python desde requirements.txt RUN pip3 install --no-cache-dir --upgrade pip && \ @@ -48,8 +48,8 @@ USER monitor WORKDIR /app # Copiar scripts principales -COPY --chmod=755 --chown=monitor:monitor cisco_mac_monitor.py /app/ -COPY --chmod=755 --chown=monitor:monitor cisco_mac_http_service.py /app/ +COPY --chmod=755 --chown=monitor:monitor src/cisco_mac_monitor.py /app/ +COPY --chmod=755 --chown=monitor:monitor src/cisco_mac_http_service.py /app/ # Exponer puerto HTTPS EXPOSE 8443 diff --git a/example b/Docs/example similarity index 100% rename from example rename to Docs/example diff --git a/build.sh b/build.sh index 69f4443..3d72164 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker build --platform linux/amd64 -t localhost/cisco-friends:$(date +%Y%m%d%H) . \ No newline at end of file +docker build --platform linux/amd64 --no-cache -t localhost/cisco-friends:$(date +%Y%m%d%H) . \ No newline at end of file diff --git a/cisco_mac_http_service.py b/src/cisco_mac_http_service.py similarity index 100% rename from cisco_mac_http_service.py rename to src/cisco_mac_http_service.py diff --git a/cisco_mac_monitor.py b/src/cisco_mac_monitor.py similarity index 100% rename from cisco_mac_monitor.py rename to src/cisco_mac_monitor.py diff --git a/requirements.txt b/src/requirements.txt similarity index 100% rename from requirements.txt rename to src/requirements.txt diff --git a/test_new_format.py b/src/test_new_format.py similarity index 100% rename from test_new_format.py rename to src/test_new_format.py