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

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

Loading…
Cancel
Save