diff --git a/striker-ui-api/src/lib/request_handlers/host/prepareHost.ts b/striker-ui-api/src/lib/request_handlers/host/prepareHost.ts index 6f9d16bf..3b402136 100644 --- a/striker-ui-api/src/lib/request_handlers/host/prepareHost.ts +++ b/striker-ui-api/src/lib/request_handlers/host/prepareHost.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} diff --git a/striker-ui-api/src/types/UpdateHostRequestBody.d.ts b/striker-ui-api/src/types/UpdateHostRequestBody.d.ts index e06b3041..a518e2d8 100644 --- a/striker-ui-api/src/types/UpdateHostRequestBody.d.ts +++ b/striker-ui-api/src/types/UpdateHostRequestBody.d.ts @@ -3,6 +3,7 @@ type SetHostInstallTargetRequestBody = { }; type PrepareHostRequestBody = { + enterpriseUUID?: string; hostIPAddress: string; hostName: string; hostPassword: string;