|
|
|
@ -2,7 +2,7 @@ import { RequestHandler } from 'express'; |
|
|
|
|
|
|
|
|
|
// import SERVER_PATHS from '../../consts/SERVER_PATHS';
|
|
|
|
|
|
|
|
|
|
import { sub } from '../../accessModule'; |
|
|
|
|
import { dbQuery, sub } from '../../accessModule'; |
|
|
|
|
|
|
|
|
|
export const createServer: RequestHandler = ({ body }, response) => { |
|
|
|
|
console.log('Creating server.'); |
|
|
|
@ -19,27 +19,44 @@ export const createServer: RequestHandler = ({ body }, response) => { |
|
|
|
|
optimizeForOS, |
|
|
|
|
} = body; |
|
|
|
|
|
|
|
|
|
console.dir(body, { depth: null }); |
|
|
|
|
|
|
|
|
|
const provisionServerJobData = ` |
|
|
|
|
server_name=${serverName} |
|
|
|
|
os=${optimizeForOS} |
|
|
|
|
cpu_cores=${cpuCores} |
|
|
|
|
ram=${memory} |
|
|
|
|
storage_group_uuid=${storageGroupUUID} |
|
|
|
|
storage_size=${storageSize} |
|
|
|
|
install_iso=${installISOFileUUID} |
|
|
|
|
driver_iso=${driverISOFileUUIDs}`;
|
|
|
|
|
|
|
|
|
|
console.log(`provisionServerJobData: ${provisionServerJobData}`); |
|
|
|
|
|
|
|
|
|
const { stdout: provisionServerJobHostUUID } = sub( |
|
|
|
|
'get_primary_host_uuid', |
|
|
|
|
{ |
|
|
|
|
subModuleName: 'Cluster', |
|
|
|
|
subParams: { anvil_uuid: anvilUUID }, |
|
|
|
|
server_name=${serverName} |
|
|
|
|
os=${optimizeForOS} |
|
|
|
|
cpu_cores=${cpuCores} |
|
|
|
|
ram=${memory} |
|
|
|
|
storage_group_uuid=${storageGroupUUID} |
|
|
|
|
storage_size=${storageSize} |
|
|
|
|
install_iso=${installISOFileUUID} |
|
|
|
|
driver_iso=${driverISOFileUUIDs}`;
|
|
|
|
|
|
|
|
|
|
console.log(`provisionServerJobData: [${provisionServerJobData}]`); |
|
|
|
|
|
|
|
|
|
let provisionServerJobHostUUID: string; |
|
|
|
|
|
|
|
|
|
({ stdout: provisionServerJobHostUUID } = sub('get_primary_host_uuid', { |
|
|
|
|
subModuleName: 'Cluster', |
|
|
|
|
subParams: { |
|
|
|
|
anvil_uuid: anvilUUID, |
|
|
|
|
test_access_user: 'admin', |
|
|
|
|
}, |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
console.log( |
|
|
|
|
`provisionServerJobHostUUID from Cluster->get_primary_host_uuid(): [${provisionServerJobHostUUID}]`, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
console.log(`provisionServerJobHostUUID: [${provisionServerJobHostUUID}]`); |
|
|
|
|
if (provisionServerJobHostUUID === '') { |
|
|
|
|
[[provisionServerJobHostUUID]] = dbQuery(` |
|
|
|
|
SELECT anvil_node1_host_uuid |
|
|
|
|
FROM anvils |
|
|
|
|
WHERE anvil_uuid = '${anvilUUID}'`).stdout;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log( |
|
|
|
|
`provisionServerJobHostUUID from DB: [${provisionServerJobHostUUID}]`, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// sub('insert_or_update_jobs', {
|
|
|
|
|
// subParams: {
|
|
|
|
|