-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwork.php
More file actions
715 lines (543 loc) · 24.8 KB
/
work.php
File metadata and controls
715 lines (543 loc) · 24.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
<?php
namespace App\Core;
use Psr\Container\ContainerInterface;
use SebastianBergmann\Type\VoidType;
use Illuminate\Support\Facades\Redis;
use HyssaDev\HibikenAsynqClient\Client;
use Exception;
class work extends adminator
{
// DI
public \Monolog\Logger $logger;
public \mysqli|\PDO $conn_mysql;
public \PgSql\Connection|\PDO|null $conn_pgsql;
public \PDO|null $pdoMysql;
protected $sentinel;
protected Redis $redis;
// protected $container;
protected $loggedUserEmail;
/**
* {@inheritdoc}
*/
public array $p_bs_alerts = [];
public $action_form;
public int $form_single_action;
public function __construct(ContainerInterface $container)
{
// $this->container = $container;
$this->logger = $container->get('logger');
$this->conn_mysql = $container->get('connMysql');
$this->conn_pgsql = $container->get('connPgsql');
$this->pdoMysql = $container->get('pdoMysql');
$this->sentinel = $container->get('sentinel');
// needed for activating facade
$this->redis = $container->get('redis');
$this->loggedUserEmail = $this->sentinel->getUser()->email;
$this->logger->info(message: __CLASS__ . "\\" . __FUNCTION__ . " called");
}
public function callPdoQueryAndFetch($query): array
{
$rs_error = null;
try {
$rs = $this->pdoMysql->query($query);
} catch (Exception $e) {
$rs_error = $e->getMessage();
}
if (is_object($rs)) {
$rs_data = $rs->fetchAll();
} else {
$this->logger->error(__CLASS__ . "\\" . __FUNCTION__ . ": PDO result is not object");
$rs_data = [];
}
return [$rs_data, $rs_error];
}
public function getAllItems(): array
{
$q = "SELECT id, name FROM workitems_names WHERE id > 0 ORDER BY id";
list($data_rs, $dotaz_error) = $this->callPdoQueryAndFetch($q);
if ($dotaz_error != null) {
$this->logger->error(__CLASS__ . "\\" . __FUNCTION__ . ": Caught Exception: " . var_export($dotaz_error, true));
$this->p_bs_alerts["Nelze načíst data pro výpis akcí pro manuální restart. <br>(SQL error: $dotaz_error)"] = "danger";
return [false, []];
} elseif (count($data_rs) < 1) {
$this->p_bs_alerts["Žádné data pro výpis akcí pro manuální restart."] = "warning";
return [true, []];
} else {
foreach ($data_rs as $key => $val) {
$itemsList[] = ["id" => $val["id"], "name" => $val["name"]];
}
return [true, $itemsList];
}
}
public function getItemName(int $id): string|null
{
$rs_item_name = $this->conn_mysql->query("SELECT name FROM workitems_names WHERE id = '$id' ");
$rs_item_name->data_seek(0);
list($item_name) = $rs_item_name->fetch_row();
return $item_name;
}
public function handleSingleActionForm(): void
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
// get form data
$this->action_form = $this->formInit();
$form_data = $this->action_form->validate("single_action");
$this->form_single_action = intval($form_data["single_action"]);
$this->logger->debug(__CLASS__ . "\\" . __FUNCTION__ . ": " . var_export($this->form_single_action, true));
// check if form was sended
if ($this->form_single_action > 0) {
// test if we have valid ID
$item_name = $this->getItemName($this->form_single_action);
if (is_null($item_name)) {
$this->logger->warning(message: __CLASS__ . "\\" . __FUNCTION__ . ": parsing item_name failed (item_id $this->form_single_action)");
} else {
[$queue_rs, $queue_err] = $this->taskEnqueue($this->form_single_action);
if ($queue_rs) {
$this->p_bs_alerts["Manuální přidání akce pro restart bylo provedeno úspěšně"] = "success";
} else {
$this->p_bs_alerts["Manuální přidání akce pro restart selhalo. </br> ($queue_err)"] = "danger";
$this->logger->error(message: __CLASS__ . "\\" . __FUNCTION__ . ": single_action failed ($queue_err)");
}
}
}
}
/**
* @return array [
* bool, // false if something failed
* bool|int|string, // results from asynq_client or error message
* ]
*/
public function taskEnqueue(int $item_id): array
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
try {
$asynq_client = new Client($this->redis);
$res = $asynq_client->Enqueue([
'typename' => "adminator3:workitem:basic",
'payload' => [
'item_id' => $item_id,
'createdAt' => time(),
'createdBy' => $this->loggedUserEmail,
],
'opts' => [
'timeout' => 86400,
]
], [
'queue' => "adminator3:workitem",
'group' => $item_id,
]);
} catch (\RedisException $ex) {
$m = $ex->getMessage();
$this->logger->error(__CLASS__ . "\\" . __FUNCTION__ . ": Redis error: $m");
return [false, "Redis error: $m"];
}
return [true, $res];
}
public function taskGroupList(): array
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
try {
$allGroups = $this->redis::sinter("asynq:{adminator3:workitem}:groups");
} catch (\RedisException $ex) {
$m = $ex->getMessage();
$this->logger->error(__CLASS__ . "\\" . __FUNCTION__ . ": Redis error: $m");
$this->p_bs_alerts["Nelze načíst data pro výpis tasks groups. <br>(Redis error: $m)"] = "danger";
return [false, "Redis error: $m"];
}
if (empty($allGroups)) {
$this->p_bs_alerts["Queue: Data pro výpis tasks groups nenalezeny."] = "warning";
return [false, "Redis: empty results: no data in groups"];
}
for ($i = 0; $i < count($allGroups); $i++) {
$groupId = $allGroups[$i];
$groupCount = $this->redis::zcount("asynq:{adminator3:workitem}:g:$groupId", "-inf", "+inf");
if ($groupCount == 0) {
$this->p_bs_alerts["Queue: Tasks group $groupId neobsahuje žádné úkoly."] = "warning";
}
// N.B. smarty is not displaying NULL values, so we don't care about return value of getItemName()
$r[$groupId] = ["count" => $groupCount, "name" => $this->getItemName($groupId)];
}
if (empty($r)) {
$this->p_bs_alerts["Queue: Tasks groups neobsahují žádné úkoly."] = "warning";
return [false, "Redis: empty results: no tasks in any group"];
}
return [true, $r];
}
public function work_handler($item_id): array
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
// prep vars
//item_id - cislo ktery odpovida vzdy nejaky akci :)
//seznam cisel a akcí
// 1 - osvezeni net-n/sikany na reinhard-3
// zbytek viz databáze
$item_id = intval($item_id);
$output = "";
// load workitem's name from database
$item_name = $this->getItemName($item_id);
if (is_null($item_name)) {
// TODO: check/fix rendering in objekty/topology page(s)
$this->p_bs_alerts["Nepodařilo se načíst název WorkItem položky. <br>(item_id: $item_id)"] = "warning";
$this->logger->warning(message: __CLASS__ . "\\" . __FUNCTION__ . ": parsing item_name failed (item_id $item_id)");
} else {
$this->logger->info(message: __CLASS__ . "\\" . __FUNCTION__ . ": parsed item_name: " . var_export($item_name, true));
}
// asynqClient part
[$queue_rs, $queue_err] = $this->taskEnqueue($item_id);
$this->logger->debug(__CLASS__ . "\\" . __FUNCTION__ . ": rs_queue: " . var_export($queue_rs, true));
if ($queue_rs) {
$rs_write = 1;
} else {
$rs_write = 0;
}
// save it into Archive of changes/Archiv Zmen
$akce_az = "<b>akce:</b> požadavek na restart;<br>[<b>item_id</b>] => ".$item_id;
$akce_az .= ", [<b>item_name</b>] => ".$item_name;
$sql_az = "INSERT INTO archiv_zmen (akce,provedeno_kym,vysledek) VALUES ".
"('".$this->conn_mysql->real_escape_string($akce_az)."','" .$this->loggedUserEmail . "','".$rs_write."')";
$add_az = $this->conn_mysql->query($sql_az);
// generate output view
$output .= "<div style=\"\">Požadavek na restart <b>\"".$item_name."\"</b> (No. ".$item_id.")";
if ($queue_rs) {
$output .= "<div> - <span style=\"color: green;\"> úspěšně přidán do fronty</span></div>";
} else {
$output .= "<div> - <span style=\"color: red;\"> chyba při přidání požadavku do fronty</span></div>";
}
if ($add_az) {
$output .= "<div> - <span style=\"color: green;\"> úspěšně přidán do archivu změn.</span></div>";
} else {
$output .= "<div> - <span style=\"color: red;\"> chyba při přidání požadavku do archivu změn.</span></div>";
$output .= "</div><div> sql: ".$sql_az."\n";
}
$output .= "</div>";
return array($output);
} //end of function work_handler
public function workActionObjektyFiberDiff(string $changes, array $origData, $itemId): array
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
$output = "";
$work_output = [];
//zmena sikany/NetN
if (preg_match("/.*změna.*Šikana.*z.*/", $changes)
or
preg_match("/.*změna.*Povolen.*Inet.*z.*/", $changes)
) {
$work_output[] = $this->work_handler("3");
}
//zmena IP adresy pokud je aktivni Sikana ci NetN
if ((
preg_match("/.*změna.*IP.*adresy.*z.*/", $changes)
and
(
($origData["sikana_status"] == "a")
or
($origData["dov_net"] == "n")
)
)
) {
$work_output[] = $this->work_handler("1");
$work_output[] = $this->work_handler("2");
$work_output[] = $this->work_handler("3");
$work_output[] = $this->work_handler("4");
$work_output[] = $this->work_handler("21");
$work_output[] = $this->work_handler("6");
$work_output[] = $this->work_handler("7");
} elseif (preg_match("/.*změna.*IP.*adresy.*z.*/", $changes)) {
$work_output[] = $this->work_handler("4");
$work_output[] = $this->work_handler("6");
$work_output[] = $this->work_handler("7");
}
if (preg_match("/.*změna.*MAC.*adresy.*/", $changes)) {
$work_output[] = $this->work_handler("4");
$work_output[] = $this->work_handler("21");
$work_output[] = $this->work_handler("6");
$work_output[] = $this->work_handler("7");
}
// //zmena pripojneho bodu
// //zmena tarifu
//zmena cisla portu
if (preg_match("/.*Číslo sw. portu.*/", $changes)) {
$work_output[] = $this->work_handler("4");
$work_output[] = $this->work_handler("21");
$work_output[] = $this->work_handler("7");
}
// $output .= var_export($work_output, true);
foreach ($work_output as $id => $item) {
$output .= $item[0];
}
return array($output);
}
public function workActionObjektyFiber(string $changes, int $itemId): array
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
$output = "";
$work_output = [];
$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");
// $output .= var_export($work_output, true);
foreach ($work_output as $id => $item) {
$output .= $item[0];
}
return array($output);
}
public function workActionObjektyWifiDiff(string $changes, array $origData, $itemId)
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
$output = "";
$work_output = [];
// //zjistit, krz kterého reinharda jde objekt
$reinhard_id = adminator::find_reinhard($itemId, $this->conn_mysql, $this->conn_pgsql);
// "zmena sikany" or "zmena NetN"
if (preg_match("/.*změna.*Šikana.*z.*/", $changes)
or
preg_match("/.*změna.*Povolen.*Inet.*z.*/", $changes)
) {
if ($reinhard_id == 177) {
$work_output[] = $this->work_handler("1");
} elseif ($reinhard_id == 1) {
$work_output[] = $this->work_handler("2");
} elseif ($reinhard_id == 236) {
$work_output[] = $this->work_handler("24");
} else {
//nenalezet pozadovany reinhard, takze osvezime vsechny
$work_output[] = $this->work_handler("1");
$work_output[] = $this->work_handler("2");
$work_output[] = $this->work_handler("24");
}
}
//zmena IP adresy
if (preg_match("/.*změna.*IP.*adresy.*z.*/", $changes)) {
//pokud: zmena IP adresy bez aktivovaného omezení, tak staci items nize:
$work_output[] = $this->work_handler("5");
$work_output[] = $this->work_handler("13");
$work_output[] = $this->work_handler("20");
$work_output[] = $this->work_handler("23");
$work_output[] = $this->work_handler("14");
// pokud je aktivni omezeni -> radsi vynutit restart net-n/sikany u vseho, resp i zbytku
if (($origData["sikana_status"] == "a")
or
($origData["dov_net"] == "n")) {
$work_output[] = $this->work_handler("1");
$work_output[] = $this->work_handler("2");
$work_output[] = $this->work_handler("3");
$work_output[] = $this->work_handler("24");
}
}
//zmena linky -- shaper / filtrace
if (preg_match("/.*změna.*pole.*id_tarifu.*/", $changes)
or
preg_match("/.*změna.*Tarifu.*/", $changes)
or
preg_match("/.*změna.*pole.*client_ap_ip.*/", $changes)
) {
if (preg_match("/.*změna.*pole.*client_ap_ip.*/", $changes)) {
$work_output[] = $this->work_handler("14");
}
if ($reinhard_id == 177) {
$work_output[] = $this->work_handler("20");
} elseif ($reinhard_id == 1) {
$work_output[] = $this->work_handler("13");
} elseif ($reinhard_id == 236) {
$work_output[] = $this->work_handler("23");
} else {
$work_output[] = $this->work_handler("13");
$work_output[] = $this->work_handler("20");
$work_output[] = $this->work_handler("23");
}
// filtrace asi neni treba
// $work_output[] = $this->work_handler("14");
}
//zmena tunneling_ip ci tunel záznamů
// --> radius artemis
// zde dodelat zmenu IP adresy, pokud tunelovana verejka
if (
preg_match("/.*změna.*pole.*tunnelling_ip.*/", $changes)
or
preg_match("/.*změna.*pole.*tunnel_user.*/", $changes)
or
preg_match("/.*změna.*pole.*tunnel_pass.*/", $changes)
) {
$work_output[] = $this->work_handler("21");
}
// //zmena MAC adresy .. zatim se nepouziva u wifi
//zmena DNS záznamu, asi jen u veřejných IP adresa
// --> restart DNS auth. serveru
if (preg_match("/.*změna.*pole.*dns_jmeno.*/", $changes)) {
$work_output[] = $this->work_handler("9");
$work_output[] = $this->work_handler("10");
$work_output[] = $this->work_handler("11");
$work_output[] = $this->work_handler("12");
}
// $output .= var_export($work_output, true);
foreach ($work_output as $id => $item) {
$output .= $item[0];
}
return array($output);
}
public function workActionObjektyWifi(string $changes, int $itemId, array $args): array
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
$output = "";
$work_output = [];
$reinhard_id = adminator::find_reinhard($itemId, $this->conn_mysql, $this->conn_pgsql);
if ($args['form_typ_ip'] == 4) {
//L2TP verejka
$work_output[] = $this->work_handler("21");
}
$work_output[] = $this->work_handler("14");
//zde dodat if zda-li je NetN ci SikanaA
if ((preg_match("/.*<b>\[dov_net\]<\/b> => n.*/", $changes) == 1)
or (preg_match("/.*<b>\[sikana_status\]<\/b> => a.*/", $changes) == 1)) {
if ($reinhard_id == 177) {
$work_output[] = $this->work_handler("1");
} elseif ($reinhard_id == 1) {
$work_output[] = $this->work_handler("2");
} elseif ($reinhard_id == 236) {
$work_output[] = $this->work_handler("24");
} else {
//nenalezet pozadovany reinhard, takze osvezime vsechny
$work_output[] = $this->work_handler("1");
$work_output[] = $this->work_handler("2");
$work_output[] = $this->work_handler("24");
} //end of else - if reinhard_id
}
if ($reinhard_id == 177) {
$work_output[] = $this->work_handler("20");
} elseif ($reinhard_id == 1) {
$work_output[] = $this->work_handler("13");
} elseif ($reinhard_id == 236) {
$work_output[] = $this->work_handler("23");
} else {
$work_output[] = $this->work_handler("13");
$work_output[] = $this->work_handler("20");
$work_output[] = $this->work_handler("23");
}
// $output .= var_export($work_output, true);
foreach ($work_output as $id => $item) {
$output .= $item[0];
}
return array($output);
}
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)
// Aglobal::work_handler("20"); //reinhard-3 (ros) - shaper (client's tariffs)
// Aglobal::work_handler("23"); //reinhard-5 (ros) - shaper (client's tariffs)
// Aglobal::work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart
// //automatické restarty
// if($alarm == 1) {
// //kvuli alarmu
// Aglobal::work_handler("15"); //trinity - Monitoring I - Footer-restart
// }
// if($monitoring == 1) {
// //kvuli monitoringu
// Aglobal::work_handler("18"); //monitoring - Monitoring II - Feeder-restart
// Aglobal::work_handler("22"); //monitoring - Monitoring II - checker-restart
// }
}
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) )
// {
// //kvuli alarmu
// Aglobal::work_handler("15"); //trinity - Monitoring I - Footer-restart
// }
// if( ereg(".*změna.*Monitorování.*", $pole3) or ereg(".*změna.*Monitoring kategorie.*", $pole3) )
// {
// //kvuli monitoringu - feeder asi nepovinnej
// Aglobal::work_handler("18"); //monitoring - Monitoring II - Feeder-restart
// Aglobal::work_handler("22"); //monitoring - Monitoring II - checker-restart
// }
// if( ereg(".*změna.*Nadřazený router.*", $pole3) )
// {
// Aglobal::work_handler("1"); //reinhard-3 (ros) - restrictions (net-n/sikana)
// Aglobal::work_handler("20"); //reinhard-3 (ros) - shaper (client's tariffs)
// Aglobal::work_handler("24"); //reinhard-5 (ros) - restrictions (net-n/sikana)
// Aglobal::work_handler("23"); //reinhard-5 (ros) - shaper (client's tariffs)
// Aglobal::work_handler("13"); //reinhard-wifi (ros) - shaper (client's tariffs)
// Aglobal::work_handler("2"); //reinhard-wifi (ros) - restrictions (net-n/sikana)
// Aglobal::work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart
// }
// if( ereg(".*změna.*Připojného bodu.*", $pole3) )
// {
// Aglobal::work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart
// }
// if( ereg(".*změna.*Filtrace.*", $pole3) )
// {
// Aglobal::work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart
// }
}
public function workActionTopologyNodeDiff(string $changes, array $origData, $itemId): array
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
$output = "";
$work_output = [];
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("/.*<b>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)
$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)
$work_output[] = $this->work_handler("14"); //(trinity) filtrace-IP-on-Mtik's-restart
}
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 (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)
}
// $output .= var_export($work_output, true);
foreach ($work_output as $id => $item) {
$output .= $item[0];
}
return array($output);
}
public function workActionTopologyNodeAdd(string $changes): array
{
$this->logger->info(__CLASS__ . "\\" . __FUNCTION__ . " called");
$output = "";
$work_output = [];
// 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);
}
}