fix(striker-ui-api): simplify get local host UUID

main
Tsu-ba-me 2 years ago
parent 82fcb1e08e
commit a37e0e2b8a
  1. 8
      striker-ui-api/src/lib/accessModule.ts
  2. 6
      striker-ui-api/src/lib/request_handlers/network-interface/getNetworkInterface.ts
  3. 6
      striker-ui-api/src/lib/request_handlers/server/getServerDetail.ts

@ -122,10 +122,16 @@ const dbSubRefreshTimestamp = () =>
const dbWrite = (query: string, options?: SpawnSyncOptions) => const dbWrite = (query: string, options?: SpawnSyncOptions) =>
execAnvilAccessModule(['--query', query, '--mode', 'write'], options); execAnvilAccessModule(['--query', query, '--mode', 'write'], options);
const getLocalHostUUID = () =>
execModuleSubroutine('host_uuid', {
subModuleName: 'Get',
}).stdout;
export { export {
dbJobAnvilSyncShared, dbJobAnvilSyncShared,
dbQuery, dbQuery,
execModuleSubroutine as sub,
dbSubRefreshTimestamp, dbSubRefreshTimestamp,
dbWrite, dbWrite,
getLocalHostUUID,
execModuleSubroutine as sub,
}; };

@ -1,4 +1,4 @@
import { sub } from '../../accessModule'; import { getLocalHostUUID } from '../../accessModule';
import buildGetRequestHandler from '../buildGetRequestHandler'; import buildGetRequestHandler from '../buildGetRequestHandler';
@ -7,9 +7,7 @@ export const getNetworkInterface = buildGetRequestHandler(
let localHostUUID: string; let localHostUUID: string;
try { try {
localHostUUID = sub('host_uuid', { localHostUUID = getLocalHostUUID();
subModuleName: 'Get',
}).stdout;
} catch (subError) { } catch (subError) {
console.log(`Failed to get local host UUID; CAUSE: ${subError}`); console.log(`Failed to get local host UUID; CAUSE: ${subError}`);

@ -6,7 +6,7 @@ import path from 'path';
import { REP_UUID } from '../../consts/REG_EXP_PATTERNS'; import { REP_UUID } from '../../consts/REG_EXP_PATTERNS';
import SERVER_PATHS from '../../consts/SERVER_PATHS'; import SERVER_PATHS from '../../consts/SERVER_PATHS';
import { dbQuery, sub } from '../../accessModule'; import { dbQuery, getLocalHostUUID, sub } from '../../accessModule';
import { sanitizeQS } from '../../sanitizeQS'; import { sanitizeQS } from '../../sanitizeQS';
import { mkfifo, rm } from '../../shell'; import { mkfifo, rm } from '../../shell';
@ -42,9 +42,7 @@ export const getServerDetail: RequestHandler = (request, response) => {
let requestHostUUID: string, serverHostUUID: string; let requestHostUUID: string, serverHostUUID: string;
try { try {
requestHostUUID = sub('host_uuid', { requestHostUUID = getLocalHostUUID();
subModuleName: 'Get',
}).stdout;
} catch (subError) { } catch (subError) {
console.log(`Failed to get local host UUID; CAUSE: ${subError}`); console.log(`Failed to get local host UUID; CAUSE: ${subError}`);

Loading…
Cancel
Save