fix(striker-ui-api): remove map network flag command

main
Tsu-ba-me 7 months ago
parent fab0fdeb84
commit bc30cae0f7
  1. 1
      striker-ui-api/src/lib/request_handlers/command/index.ts
  2. 70
      striker-ui-api/src/lib/request_handlers/command/setMapNetwork.ts
  3. 3
      striker-ui-api/src/routes/command.ts
  4. 9
      striker-ui-api/src/routes/init.ts
  5. 4
      striker-ui-api/src/types/ApiCommand.d.ts

@ -4,7 +4,6 @@ export * from './leaveAn';
export * from './poweroffStriker';
export * from './rebootStriker';
export * from './runManifest';
export * from './setMapNetwork';
export * from './startAn';
export * from './startServer';
export * from './startSubnode';

@ -1,70 +0,0 @@
import assert from 'assert';
import { RequestHandler } from 'express';
import { LOCAL, REP_UUID } from '../../consts';
import { variable } from '../../accessModule';
import { toHostUUID } from '../../convertHostUUID';
import { sanitize } from '../../sanitize';
import { perr, poutvar } from '../../shell';
export const setMapNetwork: RequestHandler<
{ uuid: string },
undefined,
SetMapNetworkRequestBody
> = async (request, response) => {
const {
body: { value: rValue } = {},
params: { uuid: rHostUuid },
} = request;
const value = sanitize(rValue, 'number');
let hostUuid = sanitize(rHostUuid, 'string', { fallback: LOCAL });
hostUuid = toHostUUID(hostUuid);
poutvar({ hostUuid, value }, `Set map network variable with: `);
try {
assert(
value in [0, 1],
`Variable value must be a number boolean (0 or 1); got [${value}]`,
);
assert(
REP_UUID.test(hostUuid),
`Host UUID must be a valid UUIDv4; got [${hostUuid}]`,
);
} catch (error) {
perr(`Assert failed when set map network variable; CAUSE: ${error}`);
return response.status(400).send();
}
try {
const result = await variable({
file: __filename,
variable_default: 0,
varaible_description: 'striker_0202',
variable_name: 'config::map_network',
variable_section: 'config',
variable_source_table: 'hosts',
variable_source_uuid: hostUuid,
variable_value: value,
});
assert(
REP_UUID.test(result),
`Result must be UUID of modified record; got: [${result}]`,
);
} catch (error) {
perr(
`Failed to set map network variable for host ${hostUuid}; CAUSE: ${error}`,
);
return response.status(500).send();
}
return response.status(204).send();
};

@ -7,7 +7,6 @@ import {
poweroffStriker,
rebootStriker,
runManifest,
setMapNetwork,
startAn,
startServer,
startSubnode,
@ -26,8 +25,6 @@ router
.put('/poweroff-host', poweroffStriker)
.put('/reboot-host', rebootStriker)
.put('/run-manifest/:manifestUuid', runManifest)
.put('/set-map-network', setMapNetwork)
.put('/set-map-network/:uuid', setMapNetwork)
.put('/start-an/:uuid', startAn)
.put('/start-server/:uuid', startServer)
.put('/start-subnode/:uuid', startSubnode)

@ -2,7 +2,6 @@ import express from 'express';
import { assertInit } from '../middlewares';
import { setMapNetwork } from '../lib/request_handlers/command';
import { configStriker } from '../lib/request_handlers/host';
import { getJob } from '../lib/request_handlers/job';
import { getNetworkInterface } from '../lib/request_handlers/network-interface';
@ -45,14 +44,6 @@ router
response.redirect(307, `/api/host?handler=striker`),
}),
configStriker,
)
.put(
'/set-map-network',
assertInit({
fail: ({ path }, response) =>
response.redirect(307, `/api/command${path}`),
}),
setMapNetwork,
);
export default router;

@ -13,7 +13,3 @@ type GetHostSshResponseBody = {
isInetConnected: boolean;
isOSRegistered: boolean;
};
type SetMapNetworkRequestBody = {
value: number;
};

Loading…
Cancel
Save