parent
1b6f1c2a2e
commit
3a01052e03
10 changed files with 69 additions and 19 deletions
@ -0,0 +1,11 @@ |
|||||||
|
import { LOCAL } from './consts/LOCAL'; |
||||||
|
|
||||||
|
import { getLocalHostUUID } from './accessModule'; |
||||||
|
|
||||||
|
export const toHostUUID = (hostUUID: string) => |
||||||
|
hostUUID === LOCAL ? getLocalHostUUID() : hostUUID; |
||||||
|
|
||||||
|
export const toLocal = ( |
||||||
|
hostUUID: string, |
||||||
|
localHostUUID: string = getLocalHostUUID(), |
||||||
|
) => (hostUUID === localHostUUID ? LOCAL : hostUUID); |
@ -0,0 +1,39 @@ |
|||||||
|
import { RequestHandler } from 'express'; |
||||||
|
|
||||||
|
import { LOCAL } from '../../consts/LOCAL'; |
||||||
|
import SERVER_PATHS from '../../consts/SERVER_PATHS'; |
||||||
|
|
||||||
|
import { job } from '../../accessModule'; |
||||||
|
import { stdout } from '../../shell'; |
||||||
|
|
||||||
|
export const updateHost: RequestHandler< |
||||||
|
{ hostUUID: string }, |
||||||
|
undefined, |
||||||
|
{ isEnableInstallTarget?: boolean } |
||||||
|
> = (request, response) => { |
||||||
|
stdout( |
||||||
|
`Begin edit host properties.\n${JSON.stringify(request.body, null, 2)}`, |
||||||
|
); |
||||||
|
|
||||||
|
const { |
||||||
|
body: { isEnableInstallTarget }, |
||||||
|
params: { hostUUID: rawHostUUID }, |
||||||
|
} = request; |
||||||
|
const hostUUID: string | undefined = |
||||||
|
rawHostUUID === LOCAL ? undefined : rawHostUUID; |
||||||
|
|
||||||
|
if (isEnableInstallTarget !== undefined) { |
||||||
|
const task = isEnableInstallTarget ? 'enable' : 'disable'; |
||||||
|
|
||||||
|
job({ |
||||||
|
file: __filename, |
||||||
|
job_command: `${SERVER_PATHS.usr.sbin['striker-manage-install-target'].self} --${task}`, |
||||||
|
job_description: 'job_0016', |
||||||
|
job_host_uuid: hostUUID, |
||||||
|
job_name: `install-target::${task}`, |
||||||
|
job_title: 'job_0015', |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
response.status(200).send(); |
||||||
|
}; |
Loading…
Reference in new issue