From 1dfa1127cec4f4b3afe343008b25164960539665 Mon Sep 17 00:00:00 2001 From: Patrik Majer Date: Sun, 22 Jun 2025 22:21:10 +0200 Subject: [PATCH 1/3] adminator3: add work-handlers for node-update --- .../app/Core/Topology/nodeAction.class.php | 4 +- adminator3/app/Core/work.php | 116 +++++++++++------- 2 files changed, 73 insertions(+), 47 deletions(-) diff --git a/adminator3/app/Core/Topology/nodeAction.class.php b/adminator3/app/Core/Topology/nodeAction.class.php index 452d6d70..4c565f7d 100644 --- a/adminator3/app/Core/Topology/nodeAction.class.php +++ b/adminator3/app/Core/Topology/nodeAction.class.php @@ -687,7 +687,7 @@ public function update(ServerRequestInterface $request): string } // konec foreach - $pole .= "".$pole3; + $pole .= $pole3; if ($uprava) { $vysledek_write = 1; @@ -702,7 +702,7 @@ public function update(ServerRequestInterface $request): string ); //automaticke restarty - $this->work->workActionTopologyNodeDiff(); + $this->work->workActionTopologyNodeDiff($pole, $id_new, $pole_puvodni_data, ); } else { //zobrazime formular diff --git a/adminator3/app/Core/work.php b/adminator3/app/Core/work.php index 7ceb652c..feed8cd4 100644 --- a/adminator3/app/Core/work.php +++ b/adminator3/app/Core/work.php @@ -306,34 +306,34 @@ public function workActionObjektyFiberDiff(string $changes, array $origData, $it ) ) ) { - $work_output[] = $this->work_handler("1"); //reinhard-3 (ros) - restrictions (net-n/sikana) - $work_output[] = $this->work_handler("2"); //reinhard-wifi (ros) - restrictions (net-n/sikana) + $work_output[] = $this->work_handler("1"); + $work_output[] = $this->work_handler("2"); - $work_output[] = $this->work_handler("3"); //reinhard-fiber - sikana/net-n + $work_output[] = $this->work_handler("3"); - $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius - $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) + $work_output[] = $this->work_handler("4"); + $work_output[] = $this->work_handler("21"); - $work_output[] = $this->work_handler("6"); //(reinhard-fiber) - mikrotik.dhcp.leases.erase + $work_output[] = $this->work_handler("6"); - $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update + $work_output[] = $this->work_handler("7"); } elseif (preg_match("/.*změna.*IP.*adresy.*z.*/", $changes)) { - $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius + $work_output[] = $this->work_handler("4"); - $work_output[] = $this->work_handler("6"); //(reinhard-fiber) - mikrotik.dhcp.leases.erase + $work_output[] = $this->work_handler("6"); - $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update + $work_output[] = $this->work_handler("7"); } if (preg_match("/.*změna.*MAC.*adresy.*/", $changes)) { - $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius - $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) + $work_output[] = $this->work_handler("4"); + $work_output[] = $this->work_handler("21"); - $work_output[] = $this->work_handler("6"); //(reinhard-fiber) - mikrotik.dhcp.leases.erase - $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update + $work_output[] = $this->work_handler("6"); + $work_output[] = $this->work_handler("7"); } @@ -343,10 +343,10 @@ public function workActionObjektyFiberDiff(string $changes, array $origData, $it //zmena cisla portu if (preg_match("/.*Číslo sw. portu.*/", $changes)) { - $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius - $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) + $work_output[] = $this->work_handler("4"); + $work_output[] = $this->work_handler("21"); - $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update + $work_output[] = $this->work_handler("7"); } // $output .= var_export($work_output, true); @@ -365,13 +365,13 @@ public function workActionObjektyFiber(string $changes, int $itemId): array $output = ""; $work_output = []; - $work_output[] = $this->work_handler("3"); //rh-fiber - iptables - $work_output[] = $this->work_handler("4"); //rh-fiber - radius - $work_output[] = $this->work_handler("5"); //rh-fiber - shaper - $work_output[] = $this->work_handler("6"); //reinhard-fiber - mikrotik.dhcp.leases.erase - $work_output[] = $this->work_handler("7"); //trinity - sw.h3c.vlan.set.pl update + $work_output[] = $this->work_handler("3"); + $work_output[] = $this->work_handler("4"); + $work_output[] = $this->work_handler("5"); + $work_output[] = $this->work_handler("6"); + $work_output[] = $this->work_handler("7"); - $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) + $work_output[] = $this->work_handler("21"); // $output .= var_export($work_output, true); @@ -553,6 +553,11 @@ public function workActionObjektyWifi(string $changes, int $itemId, array $args) public function workActionTopologyRouterAdd(): void { + $this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called"); + + $output = ""; + $work_output = []; + // TODO: enable actions for topology/router-add // Aglobal::work_handler("13"); //reinhard-wifi (ros) - shaper (client's tariffs) @@ -576,6 +581,11 @@ public function workActionTopologyRouterAdd(): void public function workActionTopologyRouterDiff(): void { + $this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called"); + + $output = ""; + $work_output = []; + // TODO: enable actions for topology/router-update // if( ereg(".*změna.*Alarmu.*z.*", $pole3) ) // { @@ -616,44 +626,60 @@ public function workActionTopologyRouterDiff(): void // } } - public function workActionTopologyNodeDiff(): void + public function workActionTopologyNodeDiff(string $changes, array $origData, $itemId): array { - // TODO: fix automatic restarts - // if(ereg(".*Routeru, kde se provádí filtrace.*", $pole3)) { - // Aglobal::work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart - // } + $this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called"); - // if(ereg(".*Routeru.*", $pole3)) { - // Aglobal::work_handler("1"); //reinhard-3 (ros) - restrictions (net-n/sikana) - // Aglobal::work_handler("20"); //reinhard-3 (ros) - shaper (client's tariffs) + $output = ""; + $work_output = []; - // Aglobal::work_handler("24"); //reinhard-5 (ros) - restrictions (net-n/sikana) - // Aglobal::work_handler("23"); //reinhard-5 (ros) - shaper (client's tariffs) + if(preg_match("/.*Routeru, kde se provádí filtrace.*/", $changes)) { + $work_output[] = $this->work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart + } - // Aglobal::work_handler("13"); //reinhard-wifi (ros) - shaper (client's tariffs) - // Aglobal::work_handler("2"); //reinhard-wifi (ros) - restrictions (net-n/sikana) + if(preg_match("/.*Routeru.*/", $changes)) { + $work_output[] = $this->work_handler("1"); //reinhard-3 (ros) - restrictions (net-n/sikana) + $work_output[] = $this->work_handler("20"); //reinhard-3 (ros) - shaper (client's tariffs) - // Aglobal::work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart + $work_output[] = $this->work_handler("24"); //reinhard-5 (ros) - restrictions (net-n/sikana) + $work_output[] = $this->work_handler("23"); //reinhard-5 (ros) - shaper (client's tariffs) - // } + $work_output[] = $this->work_handler("13"); //reinhard-wifi (ros) - shaper (client's tariffs) + $work_output[] = $this->work_handler("2"); //reinhard-wifi (ros) - restrictions (net-n/sikana) - // if(ereg(".*vlan_id.*", $pole3)) { - // Aglobal::work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update + $work_output[] = $this->work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart + } - // Aglobal::work_handler("4"); //reinhard-fiber - radius - // Aglobal::work_handler("21"); //artemis - radius (tunel. verejky, optika) - // } + if(preg_match("/.*vlan_id.*/", $changes)) { + $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update + + $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius + $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) + } // if(ereg(".*změna.*koncového.*zařízení.*", $pole3)) { - // Aglobal::work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update + // $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update - // Aglobal::work_handler("4"); //reinhard-fiber - radius - // Aglobal::work_handler("21"); //artemis - radius (tunel. verejky, optika) + // $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius + // $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) // } + + // $output .= var_export($work_output, true); + + foreach ($work_output as $id => $item) { + $output .= $item[0]; + } + + return array($output); } public function workActionTopologyNodeAdd(): void { + $this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called"); + + $output = ""; + $work_output = []; + // TODO: add work items } From d47a688c9b76e566beca82cbebcc77e4c34d8383 Mon Sep 17 00:00:00 2001 From: Patrik Majer Date: Sun, 22 Jun 2025 22:41:11 +0200 Subject: [PATCH 2/3] adminator3: add work-handlers for node-add --- .../app/Core/Topology/nodeAction.class.php | 8 +-- adminator3/app/Core/work.php | 49 +++++++++++++++---- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/adminator3/app/Core/Topology/nodeAction.class.php b/adminator3/app/Core/Topology/nodeAction.class.php index 4c565f7d..22cd92a7 100644 --- a/adminator3/app/Core/Topology/nodeAction.class.php +++ b/adminator3/app/Core/Topology/nodeAction.class.php @@ -125,8 +125,9 @@ public function add(ServerRequestInterface $request): string $vysledek_write . "') "); //automaticke restarty - $this->work->workActionTopologyNodeAdd(); - + list($work_output) = $this->work->workActionTopologyNodeAdd($pole); + $output .= $work_output; + } else { //zobrazime formular @@ -702,7 +703,8 @@ public function update(ServerRequestInterface $request): string ); //automaticke restarty - $this->work->workActionTopologyNodeDiff($pole, $id_new, $pole_puvodni_data, ); + list($work_output) = $this->work->workActionTopologyNodeDiff($pole, $pole_puvodni_data, $id_new); + $output .= $work_output; } else { //zobrazime formular diff --git a/adminator3/app/Core/work.php b/adminator3/app/Core/work.php index feed8cd4..968afe47 100644 --- a/adminator3/app/Core/work.php +++ b/adminator3/app/Core/work.php @@ -633,11 +633,11 @@ public function workActionTopologyNodeDiff(string $changes, array $origData, $it $output = ""; $work_output = []; - if(preg_match("/.*Routeru, kde se provádí filtrace.*/", $changes)) { + if (preg_match("/.*Routeru, kde se provádí filtrace.*/", $changes)) { $work_output[] = $this->work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart } - if(preg_match("/.*Routeru.*/", $changes)) { + if (preg_match("/.*Routeru.*/", $changes)) { $work_output[] = $this->work_handler("1"); //reinhard-3 (ros) - restrictions (net-n/sikana) $work_output[] = $this->work_handler("20"); //reinhard-3 (ros) - shaper (client's tariffs) @@ -650,19 +650,19 @@ public function workActionTopologyNodeDiff(string $changes, array $origData, $it $work_output[] = $this->work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart } - if(preg_match("/.*vlan_id.*/", $changes)) { + if (preg_match("/.*vlan_id.*/", $changes)) { $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) } - // if(ereg(".*změna.*koncového.*zařízení.*", $pole3)) { - // $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update + if (preg_match("/.*změna.*koncového.*zařízení.*/", $changes)) { + $work_output[] = $this->work_handler("7"); //(trinity) - sw.h3c.vlan.set.pl update - // $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius - // $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) - // } + $work_output[] = $this->work_handler("4"); //reinhard-fiber - radius + $work_output[] = $this->work_handler("21"); //artemis - radius (tunel. verejky, optika) + } // $output .= var_export($work_output, true); @@ -673,14 +673,43 @@ public function workActionTopologyNodeDiff(string $changes, array $origData, $it return array($output); } - public function workActionTopologyNodeAdd(): void + public function workActionTopologyNodeAdd(string $changes): array { $this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called"); $output = ""; $work_output = []; - // TODO: add work items + // wifi + if (preg_match("/.*\[typ_nodu\]=> 1.*/", $changes)) { + $work_output[] = $this->work_handler("1"); + $work_output[] = $this->work_handler("20"); + + $work_output[] = $this->work_handler("24"); + $work_output[] = $this->work_handler("23"); + + $work_output[] = $this->work_handler("13"); + $work_output[] = $this->work_handler("2"); + + $work_output[] = $this->work_handler("14"); + + $work_output[] = $this->work_handler("21"); + } + + //optika + if (preg_match("/.*\[typ_nodu\]=> 2.*/", $changes)) { + $work_output[] = $this->work_handler("7"); + + $work_output[] = $this->work_handler("4"); + $work_output[] = $this->work_handler("21"); + } + // $output .= var_export($work_output, true); + + foreach ($work_output as $id => $item) { + $output .= $item[0]; + } + + return array($output); } } From cb7147ffa02206d9143752ceafc8fc75a9529934 Mon Sep 17 00:00:00 2001 From: Patrik Majer Date: Sun, 22 Jun 2025 23:20:19 +0200 Subject: [PATCH 3/3] fix format --- adminator3/app/Core/Topology/nodeAction.class.php | 2 +- adminator3/app/Core/work.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adminator3/app/Core/Topology/nodeAction.class.php b/adminator3/app/Core/Topology/nodeAction.class.php index 22cd92a7..326b1430 100644 --- a/adminator3/app/Core/Topology/nodeAction.class.php +++ b/adminator3/app/Core/Topology/nodeAction.class.php @@ -127,7 +127,7 @@ public function add(ServerRequestInterface $request): string //automaticke restarty list($work_output) = $this->work->workActionTopologyNodeAdd($pole); $output .= $work_output; - + } else { //zobrazime formular diff --git a/adminator3/app/Core/work.php b/adminator3/app/Core/work.php index 968afe47..3ce00f57 100644 --- a/adminator3/app/Core/work.php +++ b/adminator3/app/Core/work.php @@ -637,7 +637,7 @@ public function workActionTopologyNodeDiff(string $changes, array $origData, $it $work_output[] = $this->work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart } - if (preg_match("/.*Routeru.*/", $changes)) { + if (preg_match("/.*Routeru<\/b>.*/", $changes)) { $work_output[] = $this->work_handler("1"); //reinhard-3 (ros) - restrictions (net-n/sikana) $work_output[] = $this->work_handler("20"); //reinhard-3 (ros) - shaper (client's tariffs) @@ -702,7 +702,7 @@ public function workActionTopologyNodeAdd(string $changes): array $work_output[] = $this->work_handler("4"); $work_output[] = $this->work_handler("21"); - } + } // $output .= var_export($work_output, true); foreach ($work_output as $id => $item) {