diff --git a/Anvil/Tools/Cluster.pm b/Anvil/Tools/Cluster.pm index 15c0990d..1db6b883 100644 --- a/Anvil/Tools/Cluster.pm +++ b/Anvil/Tools/Cluster.pm @@ -2150,10 +2150,11 @@ This is the Anvil! UUID we're looking for the primary node in. =cut sub get_primary_host_uuid { - my $self = shift; - my $parameter = shift; - my $anvil = $self->parent; - my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; + my $self = shift; + my $parameter = shift; + my $anvil = $self->parent; + my $test_access_user = defined $parameter->{test_access_user} ? $parameter->{test_access_user} : undef; + my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Cluster->get_primary_host_uuid()" }}); my $anvil_uuid = defined $parameter->{anvil_uuid} ? $parameter->{anvil_uuid} : ""; @@ -2201,11 +2202,13 @@ sub get_primary_host_uuid debug => $debug, target => $node1_target_ip, password => $password, + user => $test_access_user, }); my $node2_access = $anvil->Remote->test_access({ debug => $debug, target => $node2_target_ip, password => $password, + user => $test_access_user, }); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { node1_access => $node1_access, diff --git a/striker-ui-api/src/lib/request_handlers/server/createServer.ts b/striker-ui-api/src/lib/request_handlers/server/createServer.ts index 6ee9a196..c660f9d0 100644 --- a/striker-ui-api/src/lib/request_handlers/server/createServer.ts +++ b/striker-ui-api/src/lib/request_handlers/server/createServer.ts @@ -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: {