Conversation
| */ | ||
| class GatewayController extends ApiControllerBase | ||
| { | ||
| /* XXX No callers in core. Deprecate for 26.7? */ |
There was a problem hiding this comment.
Review note: there don't seem to be any active consumers, also the endpoint is misaligned with the rest of the gateways namespace.
Added the comment for discussion purposes, we can also ditch it or do nothing ;)
There was a problem hiding this comment.
More or less superseded by /api/routing/settings/search_gateway it seems, but now killed due to the change in gateway_status.php.
We should either keep the script as is or make sure callers are refactored to cope with the change.
There was a problem hiding this comment.
I'll interpret this as keep it around. It wasn't killed, but the output changed indeed which should be addressed with 2b5ef1f
| $this_gw_status = $gateways_status[$gateway['name']] ?? []; | ||
| $gateways[$idx]['status'] = $this_gw_status['status_translated'] ?? gettext('Pending'); | ||
| foreach (['delay', 'stddev', 'loss'] as $status_kw) { | ||
| $gateways[$idx][$status_kw] = $i !== false ? $gateways_status[$i][$status_kw] : '~'; | ||
| $gateways[$idx][$status_kw] = $this_gw_status[$status_kw] ?? '~'; | ||
| } | ||
| $gateways[$idx]['label_class'] = 'fa fa-plug text-default'; | ||
| if ($i !== false) { | ||
| if (str_contains($gateways_status[$i]['status'], 'down')) { | ||
| if (!empty($this_gw_status)) { | ||
| if (str_contains($this_gw_status['status'], 'down')) { | ||
| $gateways[$idx]['label_class'] = 'fa fa-plug text-danger'; | ||
| } elseif (str_contains($gateways_status[$i]['status'], 'loss') || str_contains($gateways_status[$i]['status'], 'delay')) { | ||
| } elseif (str_contains($this_gw_status['status'], 'loss') || str_contains($this_gw_status['status'], 'delay')) { | ||
| $gateways[$idx]['label_class'] = 'fa fa-plug text-warning'; | ||
| } elseif (str_contains($gateways_status[$i]['status'], 'none')) { | ||
| } elseif (str_contains($this_gw_status['status'], 'none')) { |
There was a problem hiding this comment.
Review note: backend script gateway_status.php now indexes by gateway name, which simplifies the logic above a bit.
| */ | ||
| class GatewayController extends ApiControllerBase | ||
| { | ||
| /* XXX No callers in core. Deprecate for 26.7? */ |
There was a problem hiding this comment.
More or less superseded by /api/routing/settings/search_gateway it seems, but now killed due to the change in gateway_status.php.
We should either keep the script as is or make sure callers are refactored to cope with the change.
| { | ||
| $gateways_status = json_decode((new Backend())->configdRun('interface gateways status'), true) ?? []; | ||
| $config = (new GatewayGroups())->getGroupsConfig(); | ||
| $result = $this->searchBase('gateway_group'); |
There was a problem hiding this comment.
you can probably use a $filter_funct to merge $gateways_status with the usual content.
There was a problem hiding this comment.
$record in $filter_func is of type BaseField, unlike searchRecordSetBase which makes property assignment a bit more difficult here as far as I know
…call to optionally exclude localhost,inactive,disabled
…nd backend call to ease parsing for the group settings
…fied gateway representation
Important notices
Before you submit a pull request, we ask you kindly to acknowledge the following:
If AI was used, please disclose:
Describe the problem
Gateway Groups are part of the legacy code base
Describe the proposed solution
Code performs an inline migration and updates only some callers that directly depended on the old configuration bits. Some convenience functions have been added to
GatewayGroups.phpto allow for easy configuration access and to satisfy some of the caller demands.In addition, this code Adjusts the
gateway_watcherto now trigger based on Gateway Group trigger level as well, limiting the amount of times alarms/alerts are being generated (and thus potentially unnecessary fw reconfigurations).Related issue
#9944