diff --git a/striker-ui-api/src/lib/request_handlers/network-interface/getNetworkInterface.ts b/striker-ui-api/src/lib/request_handlers/network-interface/getNetworkInterface.ts index 9724e036..502d606a 100644 --- a/striker-ui-api/src/lib/request_handlers/network-interface/getNetworkInterface.ts +++ b/striker-ui-api/src/lib/request_handlers/network-interface/getNetworkInterface.ts @@ -1,7 +1,23 @@ +import { sub } from '../../accessModule'; + import buildGetRequestHandler from '../buildGetRequestHandler'; export const getNetworkInterface = buildGetRequestHandler( (request, buildQueryOptions) => { + let localHostUUID: string; + + try { + localHostUUID = sub('host_uuid', { + subModuleName: 'Get', + }).stdout; + } catch (subError) { + console.log(`Failed to get local host UUID; CAUSE: ${subError}`); + + throw subError; + } + + console.log(`localHostUUID=[${localHostUUID}]`); + if (buildQueryOptions) { buildQueryOptions.afterQueryReturn = (queryStdout) => { let result = queryStdout; @@ -35,9 +51,16 @@ export const getNetworkInterface = buildGetRequestHandler( network_interface_uuid, network_interface_mac_address, network_interface_name, - network_interface_operational, + CASE + WHEN network_interface_link_state = '1' + AND network_interface_operational = 'up' + THEN 'up' + ELSE 'down' + END AS network_interface_state, network_interface_speed, ROW_NUMBER() OVER(ORDER BY modified_date ASC) AS network_interface_order - FROM network_interfaces;`; + FROM network_interfaces + WHERE network_interface_operational != 'DELETE' + AND network_interface_host_uuid = '${localHostUUID}';`; }, );