fix(striker-ui-api): get NICs on specified host

main
Tsu-ba-me 2 years ago
parent f4c171b44f
commit 32c32350bd
  1. 10
      striker-ui-api/src/lib/request_handlers/network-interface/getNetworkInterface.ts
  2. 2
      striker-ui-api/src/routes/network-interface.ts

@ -1,10 +1,10 @@
import { getLocalHostUUID } from '../../accessModule'; import { toHostUUID } from '../../convertHostUUID';
import buildGetRequestHandler from '../buildGetRequestHandler'; import buildGetRequestHandler from '../buildGetRequestHandler';
export const getNetworkInterface = buildGetRequestHandler( export const getNetworkInterface = buildGetRequestHandler(
(request, buildQueryOptions) => { ({ params: { hostUUID: rawHostUUID } }, buildQueryOptions) => {
const localHostUUID: string = getLocalHostUUID(); const hostUUID = toHostUUID(rawHostUUID ?? 'local');
if (buildQueryOptions) { if (buildQueryOptions) {
buildQueryOptions.afterQueryReturn = (queryStdout) => { buildQueryOptions.afterQueryReturn = (queryStdout) => {
@ -48,7 +48,7 @@ export const getNetworkInterface = buildGetRequestHandler(
network_interface_speed, network_interface_speed,
ROW_NUMBER() OVER(ORDER BY modified_date ASC) AS network_interface_order ROW_NUMBER() OVER(ORDER BY modified_date ASC) AS network_interface_order
FROM network_interfaces FROM network_interfaces
WHERE network_interface_operational != 'DELETE' WHERE network_interface_operational != 'DELETED'
AND network_interface_host_uuid = '${localHostUUID}';`; AND network_interface_host_uuid = '${hostUUID}';`;
}, },
); );

@ -4,6 +4,6 @@ import { getNetworkInterface } from '../lib/request_handlers/network-interface';
const router = express.Router(); const router = express.Router();
router.get('/', getNetworkInterface); router.get('/', getNetworkInterface).get('/:hostUUID', getNetworkInterface);
export default router; export default router;

Loading…
Cancel
Save