Added device/port_stack API endpoint

This commit is contained in:
jnewell
2016-04-05 13:03:17 -07:00
parent d0734d78b0
commit e40042bd5c
2 changed files with 22 additions and 0 deletions

View File

@ -721,6 +721,27 @@ function get_port_graphs() {
}
function get_port_stack() {
global $config;
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$hostname = $router['hostname'];
// use hostname as device_id if it's all digits
$device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname);
$mappings = dbFetchRows("SELECT * FROM `ports_stack` WHERE `device_id` = ? AND `ifStackStatus` = 'active' ORDER BY `port_id_high` ASC", array($device_id));
$total_mappings = count($mappings);
$output = array(
'status' => 'ok',
'err-msg' => '',
'count' => $total_mappings,
'mappings' => $mappings,
);
$app->response->setStatus('200');
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
function list_alert_rules() {
global $config;
$app = \Slim\Slim::getInstance();