fix(striker-ui-api): pass Remote->test_access() user to Cluster->get_primary_host_uuid()

main
Tsu-ba-me 3 years ago
parent c074f548ed
commit c413e62798
  1. 11
      Anvil/Tools/Cluster.pm
  2. 53
      striker-ui-api/src/lib/request_handlers/server/createServer.ts

@ -2150,10 +2150,11 @@ This is the Anvil! UUID we're looking for the primary node in.
=cut =cut
sub get_primary_host_uuid sub get_primary_host_uuid
{ {
my $self = shift; my $self = shift;
my $parameter = shift; my $parameter = shift;
my $anvil = $self->parent; my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; 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()" }}); $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} : ""; my $anvil_uuid = defined $parameter->{anvil_uuid} ? $parameter->{anvil_uuid} : "";
@ -2201,11 +2202,13 @@ sub get_primary_host_uuid
debug => $debug, debug => $debug,
target => $node1_target_ip, target => $node1_target_ip,
password => $password, password => $password,
user => $test_access_user,
}); });
my $node2_access = $anvil->Remote->test_access({ my $node2_access = $anvil->Remote->test_access({
debug => $debug, debug => $debug,
target => $node2_target_ip, target => $node2_target_ip,
password => $password, password => $password,
user => $test_access_user,
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
node1_access => $node1_access, node1_access => $node1_access,

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

Loading…
Cancel
Save