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
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,

@ -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: {

Loading…
Cancel
Save