|
|
@ -1,10 +1,32 @@ |
|
|
|
import { toHostUUID } from '../../convertHostUUID'; |
|
|
|
import { DELETED, LOCAL } from '../../consts'; |
|
|
|
|
|
|
|
|
|
|
|
import buildGetRequestHandler from '../buildGetRequestHandler'; |
|
|
|
import buildGetRequestHandler from '../buildGetRequestHandler'; |
|
|
|
|
|
|
|
import { toHostUUID } from '../../convertHostUUID'; |
|
|
|
|
|
|
|
|
|
|
|
export const getNetworkInterface = buildGetRequestHandler( |
|
|
|
export const getNetworkInterface = buildGetRequestHandler( |
|
|
|
({ params: { hostUUID: rawHostUUID } }, buildQueryOptions) => { |
|
|
|
(request, buildQueryOptions) => { |
|
|
|
const hostUUID = toHostUUID(rawHostUUID ?? 'local'); |
|
|
|
const { |
|
|
|
|
|
|
|
params: { hostUUID: rHostUUID = LOCAL }, |
|
|
|
|
|
|
|
} = request; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hostUUID = toHostUUID(rHostUUID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const query = ` |
|
|
|
|
|
|
|
SELECT |
|
|
|
|
|
|
|
network_interface_uuid, |
|
|
|
|
|
|
|
network_interface_mac_address, |
|
|
|
|
|
|
|
network_interface_name, |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
WHERE network_interface_operational != '${DELETED}' |
|
|
|
|
|
|
|
AND network_interface_host_uuid = '${hostUUID}';`;
|
|
|
|
|
|
|
|
|
|
|
|
if (buildQueryOptions) { |
|
|
|
if (buildQueryOptions) { |
|
|
|
buildQueryOptions.afterQueryReturn = (queryStdout) => { |
|
|
|
buildQueryOptions.afterQueryReturn = (queryStdout) => { |
|
|
@ -34,21 +56,6 @@ export const getNetworkInterface = buildGetRequestHandler( |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ` |
|
|
|
return query; |
|
|
|
SELECT |
|
|
|
|
|
|
|
network_interface_uuid, |
|
|
|
|
|
|
|
network_interface_mac_address, |
|
|
|
|
|
|
|
network_interface_name, |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
WHERE network_interface_operational != 'DELETED' |
|
|
|
|
|
|
|
AND network_interface_host_uuid = '${hostUUID}';`;
|
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|