fix(striker-ui-api): add enterpriseUUID to prepareHost

main
Tsu-ba-me 2 years ago
parent 63d0bdc1a4
commit 6d114b6d99
  1. 18
      striker-ui-api/src/lib/request_handlers/host/prepareHost.ts
  2. 1
      striker-ui-api/src/types/UpdateHostRequestBody.d.ts

@ -20,6 +20,7 @@ export const prepareHost: RequestHandler<
> = (request, response) => {
const {
body: {
enterpriseUUID,
hostIPAddress,
hostName,
hostPassword,
@ -32,15 +33,18 @@ export const prepareHost: RequestHandler<
} = {},
} = request;
const isHostUUIDProvided = hostUUID !== undefined;
const isEnterpriseUUIDProvided = Boolean(enterpriseUUID);
const isHostUUIDProvided = Boolean(hostUUID);
const isRedhatAccountProvided =
redhatPassword !== undefined || redhatUser !== undefined;
Boolean(redhatPassword) || Boolean(redhatUser);
const dataEnterpriseUUID = sanitize(enterpriseUUID, 'string');
const dataHostIPAddress = sanitize(hostIPAddress, 'string');
const dataHostName = sanitize(hostName, 'string');
const dataHostPassword = sanitize(hostPassword, 'string');
const dataHostSSHPort = sanitize(hostSSHPort, 'number') || 22;
const dataHostType = sanitize(hostType, 'string');
// Host user is unused at the moment.
const dataHostUser = sanitize(hostUser, 'string');
const dataHostUUID = sanitize(hostUUID, 'string');
const dataRedhatPassword = sanitize(redhatPassword, 'string');
@ -72,6 +76,13 @@ export const prepareHost: RequestHandler<
`Data host user must be a peaceful string; got [${dataHostUser}]`,
);
if (isEnterpriseUUIDProvided) {
assert(
REP_UUID.test(dataEnterpriseUUID),
`Data enterprise UUID must be a valid UUIDv4; got [${dataEnterpriseUUID}]`,
);
}
if (isHostUUIDProvided) {
assert(
REP_UUID.test(dataHostUUID),
@ -115,7 +126,8 @@ export const prepareHost: RequestHandler<
job({
file: __filename,
job_command: SERVER_PATHS.usr.sbin['striker-initialize-host'].self,
job_data: `host_ip_address=${dataHostIPAddress}
job_data: `enterprise_uuid=${dataEnterpriseUUID}
host_ip_address=${dataHostIPAddress}
host_name=${dataHostName}
password=${dataHostPassword}
rh_password=${dataRedhatPassword}

@ -3,6 +3,7 @@ type SetHostInstallTargetRequestBody = {
};
type PrepareHostRequestBody = {
enterpriseUUID?: string;
hostIPAddress: string;
hostName: string;
hostPassword: string;

Loading…
Cancel
Save