From d7cbbe0ad650ab2dd2edc8c569c856e2798e9a3a Mon Sep 17 00:00:00 2001 From: Subbulakshmi N Date: Fri, 22 Mar 2024 19:50:54 +0530 Subject: [PATCH 1/7] Updated dx_get_env to list OS users along with other details and also updated help section --- bin/dx_get_env.pl | 73 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/bin/dx_get_env.pl b/bin/dx_get_env.pl index 6d9bb2a..962c547 100755 --- a/bin/dx_get_env.pl +++ b/bin/dx_get_env.pl @@ -108,6 +108,7 @@ $output->addHeader( {'Appliance', 20}, {'Environment Name', 30}, + {'Environment Users', 30}, {'Type', 25}, {'Host name', 30}, {'User Name', 30}, @@ -133,6 +134,7 @@ {'Appliance', 20}, {'Environment Name', 30}, {'Type', 25}, + {'Environment Users', 30}, {'Status', 8}, {'OS Version', 50} ); @@ -251,7 +253,7 @@ $config = $environments->getConfig($envitem, $host_obj); $output->addLine( $engine, - $envname, + $envname, $envtype, $hostname, $user, @@ -262,6 +264,7 @@ } } else { my $cluster_nodes; + my $user = $environments->getPrimaryUserName($envitem); my $host_ref = $environments->getHost($envitem); my $hostos; if (($host_ref ne 'CLUSTER') && ($host_ref ne 'NA')) { @@ -285,16 +288,28 @@ $hostos, $cluster_nodes ); - } else { - $output->addLine( - $engine, - $environments->getName($envitem), - $environments->getType($envitem), - $environments->getStatus($envitem), - $hostos - ); } - } + else { + $output->addLine( + $engine, + $environments->getName($envitem), + $environments->getType($envitem), + '*' . $environments->getPrimaryUserName($envitem), + $environments->getStatus($envitem), + $hostos + ); + for my $useritem (@{$environments->getEnvironmentNotPrimaryUsers($envitem)}) { + $output->addLine( + '', + '', + '', + $environments->getEnvironmentUserNamebyRef($envitem,$useritem), + '', + '' + ); + } + } +} $save_state{$envitem} = $environments->getStatus($envitem); @@ -413,13 +428,13 @@ =head1 EXAMPLES dx_get_env -d Landshark - Appliance Reference Environment Name Type Status - -------------------- ------------------------------ ------------------------------ ------------------------- -------- - Landshark5 ORACLE_CLUSTER-11 racattack-cl rac enabled - Landshark5 UNIX_HOST_ENVIRONMENT-1 LINUXTARGET unix enabled - Landshark5 UNIX_HOST_ENVIRONMENT-44 LINUXSOURCE unix enabled - Landshark5 WINDOWS_HOST_ENVIRONMENT-48 WINDOWSTARGET windows enabled - Landshark5 WINDOWS_HOST_ENVIRONMENT-49 WINDOWSSOURCE windows enabled + Appliance Environment Name Type Environment Users Status OS Version + -------------------- ------------------------------ ------------------------- ----------------------- --------------- -------------------------------------------------------- + Landshark5 racattack-cl rac *delphix enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) + Landshark5 LINUXTARGET unix *delphix enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) + Landshark5 LINUXSOURCE unix *delphix enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) + Landshark5 WINDOWSTARGET windows *delphix enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) + Landshark5 WINDOWSSOURCE windows *delphix enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) Display all environments with repositories list @@ -446,6 +461,30 @@ =head1 EXAMPLES MSSQLSERVER MSSQL2012 +Display all environments with cluster list + +dx_get_env -d Landshark -cluster + + Appliance Environment Name Type Status OS Version Hostname + -------------------- ------------------------------ ------------------------- --------------- -------------------------------------------------------- --------------------- + Landshark5 racattack-cl rac enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) server1;10.***.**.01 + Landshark5 LINUXTARGET unix enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) server2;10.***.**.02 + Landshark5 LINUXSOURCE unix enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) server3;10.***.**.03 + Landshark5 WINDOWSTARGET windows enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) server4;10.***.**.04 + Landshark5 WINDOWSSOURCE windows enabled Red Hat Enterprise Linux Server release 7.9 (Maipo) server5;10.***.**.05 + + +Display all environments with user list + +dx_get_env -d Landshark -userlist + + Appliance Environment Name User name Status Auth Type + -------------------- ------------------------------ ----------------------- --------------- --------------- + Landshark5 racattack-cl *delphix enabled password + Landshark5 LINUXTARGET *delphix enabled password + Landshark5 LINUXSOURCE *delphix enabled systemkey + Landshark5 WINDOWSTARGET *delphix enabled password + Landshark5 WINDOWSSOURCE *delphix enabled systemkey =cut From 6a529be2950b508bac701ac7350bec327acb907a Mon Sep 17 00:00:00 2001 From: Marcin Przepiorowski Date: Tue, 25 Jun 2024 13:06:00 +0200 Subject: [PATCH 2/7] fix for self service snapshots --- bin/dx_get_js_snapshots.pl | 20 ++++++++++++----- lib/Replication_obj.pm | 40 +-------------------------------- lib/Snapshot_obj.pm | 3 +-- lib/Timeflow_obj.pm | 15 +++++++------ test/test_hierarchy/hierarchy.t | 8 ------- 5 files changed, 24 insertions(+), 62 deletions(-) diff --git a/bin/dx_get_js_snapshots.pl b/bin/dx_get_js_snapshots.pl index fd51aad..0acc14f 100644 --- a/bin/dx_get_js_snapshots.pl +++ b/bin/dx_get_js_snapshots.pl @@ -102,7 +102,8 @@ {'Bookmark snapshot', 30}, {Toolkit_helpers::get_unit('Bookmark snap size',$output_unit), 20}, {'Parent snapshot', 30}, - {Toolkit_helpers::get_unit('Parent snap size',$output_unit), 20} + {Toolkit_helpers::get_unit('Parent snap size',$output_unit), 20}, + {'Parent name', 30} ); @@ -179,8 +180,7 @@ my $tfrangearray; my %timeflowranges; - - + my $parentname; for my $dbref (keys %dbarray) { @@ -191,6 +191,7 @@ # load database snapshots for parent my $dbobj = $databases->getDB($dbref); my $snapshots = new Snapshot_obj( $engine_obj, $dbobj->getParentContainer(), undef, $debug); + $snapshots->getSnapshotList($dbobj->getParentContainer()); $snapshots->getSnapshotList(keys %dbarray); # for all timeflows generate timeflow range for bookmarks, @@ -223,6 +224,7 @@ if (!defined($snapshotname)) { $snapshotname = "deleted"; $snapsize = 'N/A'; + $parentname = 'N/A'; } else { if (!defined($snapshot_sizes{$snapref})) { $snapsize = $snapshots->getSnapshotSize($snapref); @@ -235,6 +237,7 @@ } else { $snapsize = $snapshot_sizes{$snapref}; } + $parentname = $databases->getDB($snapshots->getSnapshotContainer($snapref))->getName(); } if (defined($operation_for_conttf)) { @@ -251,7 +254,8 @@ 'N/A', 'N/A', $snapshotname, - $snapsize + $snapsize, + $parentname ); } else { $output->addLine( @@ -264,7 +268,8 @@ 'N/A', 'N/A', $snapshotname, - $snapsize + $snapsize, + $parentname ); } @@ -356,7 +361,9 @@ if (!defined($parentsnapshotname)) { $parentsnapshotname = "deleted"; $parentsnapsize = 'N/A'; + $parentname = 'N/A'; } else { + $parentname = $databases->getDB($snapshots->getSnapshotContainer($parentsnapshotref))->getName(); if (!defined($snapshot_sizes{$parentsnapshotref})) { $parentsnapsize = $snapshots->getSnapshotSize($parentsnapshotref); if (defined($parentsnapsize)) { @@ -393,7 +400,8 @@ $contsnapshotname, $snapsize, $parentsnapshotname, - $parentsnapsize + $parentsnapsize, + $parentname ); diff --git a/lib/Replication_obj.pm b/lib/Replication_obj.pm index 3c4fd4b..74c6f1d 100644 --- a/lib/Replication_obj.pm +++ b/lib/Replication_obj.pm @@ -1014,44 +1014,6 @@ sub setEnabled { } -# Procedure setType -# parameters: -# - repobj -# - type -# Set a proper objectlist type - -# sub setType { -# my $self = shift; -# my $repobj = shift; -# my $type = shift; - -# logger( $self->{_debug}, "Entering Replication_obj::setType", 1 ); -# if (lc $type eq 'replica') { -# $repobj->{"objectSpecification"}->{type} = 'ReplicationList'; -# } elsif (lc $type eq 'sdd') { -# $repobj->{"objectSpecification"}->{type} = 'ReplicationSecureList'; -# } else { -# print Dumper "wrong type"; -# return undef; -# } -# } - - -# { -# "type": "ReplicationSpec", -# "name": "dupazbita", -# "targetHost": "10.0.0.1", -# "targetPrincipal": "admin", -# "targetCredential": { -# "type": "PasswordCredential", -# "password": "dupa" -# }, -# "objectSpecification": { -# "type": "ReplicationList", -# "objects": [ -# "ORACLE_DB_CONTAINER-5" -# ] -# } -# } + 1; diff --git a/lib/Snapshot_obj.pm b/lib/Snapshot_obj.pm index 0e9ab1f..dae456d 100644 --- a/lib/Snapshot_obj.pm +++ b/lib/Snapshot_obj.pm @@ -38,7 +38,6 @@ use Toolkit_helpers qw (logger); # - container - database reference # - debug - debug flag (debug on if defined) - sub new { my $classname = shift; my $dlpxObject = shift; @@ -92,7 +91,7 @@ sub getContainer { sub getSnapshotContainer { my $self = shift; my $reference = shift; - logger($self->{_debug}, "Entering Snapshot_obj::getContainer",1); + logger($self->{_debug}, "Entering Snapshot_obj::getSnapshotContainer",1); return $self->{_snapshots}->{$reference}->{container}; } diff --git a/lib/Timeflow_obj.pm b/lib/Timeflow_obj.pm index 0b17fb5..a139d0c 100644 --- a/lib/Timeflow_obj.pm +++ b/lib/Timeflow_obj.pm @@ -95,7 +95,6 @@ sub getParentSnapshot { $snap = $self->{_timeflows}->{$reference}->{parentSnapshot}; } } - return defined($snap) ? $snap : ''; } @@ -598,13 +597,16 @@ sub findParentTimeflow my $parent; my $topchild; my $stop = 0; + my $clean_parent; - logger($self->{_debug}, "Find parent timeflow for " . $ref, 2); + my $local_ref = $ref . "\@l"; + logger($self->{_debug}, "Find parent timeflow for " . $local_ref, 2); my $ref_container = $self->getContainer($ref); do { - $parent = $hier->{$ref}->{parent}; + $parent = $hier->{$local_ref}->{parent}; + ($clean_parent) = $parent =~ /(.*)\@l/; if (!defined($parent) || ($parent eq 'deleted')) { # for JS issue - ex. parent was deleted - can happen if container created from not refreshed VDB @@ -614,14 +616,13 @@ sub findParentTimeflow $stop = 1; } else { logger($self->{_debug}, "Parent " . $parent . " for " . $ref, 2); - # print Dumper "Parent " . $parent . " for " . $ref; - if ($self->getContainer($parent) ne $ref_container) { + if ($self->getContainer($clean_parent) ne $ref_container) { $topchild = $ref; - $retparent = $parent; + $retparent = $clean_parent; $stop = 1; } else { $topchild = $ref; - $ref = $parent; + $local_ref = $parent; } } diff --git a/test/test_hierarchy/hierarchy.t b/test/test_hierarchy/hierarchy.t index 1ec60f3..8ff12db 100644 --- a/test/test_hierarchy/hierarchy.t +++ b/test/test_hierarchy/hierarchy.t @@ -21,14 +21,6 @@ $server2->host('127.0.0.1'); $server2->background(); - -# $server->set_dir('dupazbita'); -# my $ala = $server->get_dir(); -# -# print Dumper $ala; -# -# exit(1); - script_compiles('../../bin/dx_get_hierarchy.pl'); script_runs(['../../bin/dx_get_hierarchy.pl', '-d', 'local32', '-format','csv','-nohead'] , "All hierachy test"); From 33f9bd39b255dde206dc3145eec7028820b8a52a Mon Sep 17 00:00:00 2001 From: Marcin Przepiorowski Date: Wed, 26 Jun 2024 14:52:59 +0200 Subject: [PATCH 3/7] userlist / add database check --- bin/dx_ctl_env.pl | 25 ++++ bin/dx_get_env.pl | 342 +++++++++++++++++++++++++++++++++++----------- lib/Engine.pm | 2 +- 3 files changed, 290 insertions(+), 79 deletions(-) diff --git a/bin/dx_ctl_env.pl b/bin/dx_ctl_env.pl index 538f13f..0c3c936 100755 --- a/bin/dx_ctl_env.pl +++ b/bin/dx_ctl_env.pl @@ -412,6 +412,31 @@ my %plugin_params_hash = ( "name" => $dbname ); + + my $dbarray = $sourceconfig_obj->getSourceConfigsListForRepo($repo->{reference}); + my $sourceconfig; + my $existing_db_name; + my $db_exist = 0; + + for my $dbitem (@{$dbarray}) { + $sourceconfig = $sourceconfig_obj->getSourceConfig($dbitem); + if (defined($sourceconfig->{'toolkit'})) { + $existing_db_name = $sourceconfig_obj->getName($dbitem); + } else { + $existing_db_name = $sourceconfig_obj->getSourceConfig($dbitem)->{'databaseName'}; + } + if ($dbname eq $existing_db_name) { + print "Database $dbname already exist. Skipping\n"; + $ret = $ret + 1; + $db_exist = 1; + last; + } + } + + if ($db_exist == 1) { + next; + } + if ($sourceconfig_obj->createSourceConfig('plugin', $repo->{reference}, $dbname, \%native_params, \%plugin_params_hash)) { print "Can't add Postgresql $dbname \n"; $ret = $ret + 1; diff --git a/bin/dx_get_env.pl b/bin/dx_get_env.pl index 6d9bb2a..3d69f6a 100755 --- a/bin/dx_get_env.pl +++ b/bin/dx_get_env.pl @@ -40,6 +40,8 @@ use Toolkit_helpers; use Repository_obj; use Host_obj; +use SourceConfig_obj; +use Databases; my $version = $Toolkit_helpers::version; @@ -53,6 +55,8 @@ 'cluster' => \(my $cluster), 'backup=s' => \(my $backup), 'replist' => \(my $replist), + 'sourcelist' => \(my $sourcelist), + 'dbname=s' => \(my $dbname), 'nohead' => \(my $nohead), 'format=s' => \(my $format), 'debug:i' => \(my $debug), @@ -75,6 +79,12 @@ exit (1); } +if (defined($dbname) && (!defined($envname))) { + print "Option -dbname requires environemnt name -name to be specified \n"; + pod2usage(-verbose => 1, -input=>\*DATA); + exit (1); +} + # this array will have all engines to go through (if -d is specified it will be only one engine) my $engine_list = Toolkit_helpers::get_engine_list($all, $dx_host, $engine_obj); @@ -104,7 +114,17 @@ {'Environment Name', 30}, {'Repository list', 30} ); -} elsif (defined($config)) { +} elsif (defined($sourcelist)) { + $output->addHeader( + {'Appliance', 20}, + {'Environment Name', 30}, + {'Repository', 30}, + {'DB name', 30}, + {'DB type', 30}, + {'dSource/VDB', 10}, + {'dSource/VDB name', 30} + ); +}elsif (defined($config)) { $output->addHeader( {'Appliance', 20}, {'Environment Name', 30}, @@ -152,10 +172,24 @@ }; # load objects for current engine - my $environments = new Environment_obj( $engine_obj, $debug); - my $repository_obj = new Repository_obj($engine_obj, $debug); - my $host_obj = new Host_obj ( $engine_obj, $debug ); - + my $environments; + my $repository_obj; + my $host_obj; + my $toolkits; + my $sourceconfigs; + my $databases; + + if (defined($sourcelist)) { + $toolkits = new Toolkit_obj($engine_obj, $debug); + $databases = new Databases( $engine_obj, $debug ); + $sourceconfigs = $databases->{_sourceconfigs}; + $environments = $databases->{_environments}; + $repository_obj = $databases->{_repositories}; + } else { + $environments = new Environment_obj( $engine_obj, $debug); + $repository_obj = new Repository_obj($engine_obj, $debug); + $host_obj = new Host_obj ( $engine_obj, $debug ); + } # filter implementation @@ -185,81 +219,13 @@ for my $envitem ( @env_list ) { if (defined($userlist)) { - $output->addLine( - $engine, - $environments->getName($envitem), - '*' . $environments->getPrimaryUserName($envitem), - $environments->getPrimaryUserAuth($envitem) - ); - for my $useritem (@{$environments->getEnvironmentNotPrimaryUsers($envitem)}) { - $output->addLine( - '', - '', - $environments->getEnvironmentUserNamebyRef($envitem,$useritem), - $environments->getEnvironmentUserAuth($envitem,$useritem) - ); - } + print_users($output, $engine, $environments, $envitem); } elsif (defined($replist)) { - $output->addLine( - $engine, - $environments->getName($envitem), - '' - ); - my $reparray = $repository_obj->getRepositoryByEnv($envitem); - for my $repitem (@{$reparray}) { - $output->addLine( - '', - '', - $repository_obj->getName($repitem) - ); - } - + print_repo($output, $engine, $environments, $envitem, $repository_obj); + } elsif (defined($sourcelist)) { + $ret = $ret + print_source($output, $engine, $envitem, $databases, $toolkits, $dbname); } elsif (defined($config) || defined($backup)) { - - my $envtype = $environments->getType($envitem); - my $host_ref = $environments->getHost($envitem); - my $envname = $environments->getName($envitem); - my $userauth = $environments->getPrimaryUserAuth($envitem); - my $hostname; - my $user = $environments->getPrimaryUserName($envitem); - - if (($host_ref ne 'CLUSTER') && ($host_ref ne 'NA')) { - $hostname = $host_obj->getHostAddr($host_ref); - } else { - my $clusenvnode = $environments->getClusterNode($envitem); - $host_ref = $environments->getHost($clusenvnode); - $hostname = $host_obj->getHostAddr($host_ref); - } - - - - if (defined($backup)) { - - my $backup = $environments->getBackup($envitem, $host_obj, $engine, $envname, $envtype, $hostname, $user, $userauth); - $output->addLine( - $backup - ); - - #add users - - $environments->getUsersBackup($envitem,$output,$engine); - - - - } else { - - $config = $environments->getConfig($envitem, $host_obj); - $output->addLine( - $engine, - $envname, - $envtype, - $hostname, - $user, - $userauth, - $config - ); - - } + gen_backup_config($output, $engine, $environments, $envitem, $backup, $host_obj); } else { my $cluster_nodes; my $host_ref = $environments->getHost($envitem); @@ -328,7 +294,226 @@ exit $ret; +sub print_users { + my $output = shift; + my $engine = shift; + my $environments = shift; + my $envitem = shift; + + $output->addLine( + $engine, + $environments->getName($envitem), + '*' . $environments->getPrimaryUserName($envitem), + $environments->getPrimaryUserAuth($envitem) + ); + for my $useritem (@{$environments->getEnvironmentNotPrimaryUsers($envitem)}) { + $output->addLine( + '', + '', + $environments->getEnvironmentUserNamebyRef($envitem,$useritem), + $environments->getEnvironmentUserAuth($envitem,$useritem) + ); + } +} + +sub print_repo { + my $output = shift; + my $engine = shift; + my $environments = shift; + my $envitem = shift; + my $repository_obj = shift; + + $output->addLine( + $engine, + $environments->getName($envitem), + '' + ); + my $reparray = $repository_obj->getRepositoryByEnv($envitem); + for my $repitem (@{$reparray}) { + $output->addLine( + '', + '', + $repository_obj->getName($repitem) + ); + } +} + +sub print_source { + my $output = shift; + my $engine = shift; + my $envitem = shift; + my $databases = shift; + my $toolkits = shift; + my $filter_db_name = shift; + + my $sourceconfigs = $databases->{_sourceconfigs}; + my $environments = $databases->{_environments}; + my $repository_obj = $databases->{_repositories}; + my $sources = $databases->{_source}; + + my $envname = $environments->getName($envitem); + + + my $rdbms; + my $sourceconfig; + my $source; + my $dbobj; + my $reponame; + my $dbname; + my $dbtype; + my $delphixname; + my $ret = 0; + + my $reparray = $repository_obj->getRepositoryByEnv($envitem); + for my $repitem (@{$reparray}) { + $reponame = $repository_obj->getName($repitem); + my $dbarray = $sourceconfigs->getSourceConfigsListForRepo($repitem); + + my @outputdbarray; + my $outputdbarray_pointer; + if (defined($filter_db_name)) { + for my $dbitem (@{$dbarray}) { + $sourceconfig = $sourceconfigs->getSourceConfig($dbitem); + if (defined($sourceconfig->{'toolkit'})) { + $dbname = $sourceconfigs->getName($dbitem); + } else { + $dbname = $sourceconfigs->getSourceConfig($dbitem)->{'databaseName'}; + } + if ($dbname eq $filter_db_name) { + push(@outputdbarray, $dbitem); + } + } + if (scalar(@outputdbarray)>0) { + $ret = 0; + } else { + $ret = 1; + } + $outputdbarray_pointer = \@outputdbarray; + + } else { + $outputdbarray_pointer = $dbarray; + } + + for my $dbitem (@{$outputdbarray_pointer}) { + # print Dumper "databases"; + # print Dumper $dbitem; + # print Dumper $sourceconfigs->getName($dbitem); + # print Dumper $sourceconfigs->getSourceConfig($dbitem)->{'databaseName'}; + + # $dbname = 'slon'; + + $sourceconfig = $sourceconfigs->getSourceConfig($dbitem); + if (defined($sourceconfig->{'toolkit'})) { + if ($toolkits->getName($sourceconfig->{'toolkit'}) eq 'postgres-vsdk') { + $rdbms = 'postgresql'; + } elsif ($toolkits->getName($sourceconfig->{'toolkit'}) eq 'db2db') { + $rdbms = 'db2'; + } else { + $rdbms = 'unknown'; + } + $dbname = $sourceconfigs->getName($dbitem); + } else { + $dbname = $sourceconfigs->getSourceConfig($dbitem)->{'databaseName'}; + if ($dbitem =~ /^MSSQL/) { + $rdbms = "mssql"; + } elsif ($dbitem =~ /^ORACLE/) { + if (defined($sourceconfig->{'cdbType'})) { + if ($sourceconfig->{'cdbType'} eq 'NON_CDB') { + $rdbms = "oracle"; + } elsif ($sourceconfig->{'cdbType'} eq 'ROOT_CDB') { + $rdbms = "oracle CDB"; + } + } elsif (defined($sourceconfig->{'cdbConfig'})) { + $rdbms = "oracle PDB"; + } else { + $rdbms = "unknown oracle"; + } + } elsif ($dbitem =~ /^ASE/) { + $rdbms = "sybase"; + } + } + + $source = $sources->getSourceByConfig($dbitem); + if (defined($source)) { + $dbobj = $databases->getDB($source->{'container'}); + $delphixname = $dbobj->getName(); + $dbtype = $dbobj->getType(); + } else { + # not ingested + $dbtype = ''; + $delphixname = 'not ingested'; + } + + + $output->addLine( + $engine, + $envname, + $reponame, + $dbname, + $rdbms, + $dbtype, + $delphixname + ) + } + } + + return $ret; +} + +sub gen_backup_config { + my $output = shift; + my $engine = shift; + my $environments = shift; + my $envitem = shift; + my $backup = shift; + my $host_obj = shift; + + my $envtype = $environments->getType($envitem); + my $host_ref = $environments->getHost($envitem); + my $envname = $environments->getName($envitem); + my $userauth = $environments->getPrimaryUserAuth($envitem); + my $hostname; + my $user = $environments->getPrimaryUserName($envitem); + + if (($host_ref ne 'CLUSTER') && ($host_ref ne 'NA')) { + $hostname = $host_obj->getHostAddr($host_ref); + } else { + my $clusenvnode = $environments->getClusterNode($envitem); + $host_ref = $environments->getHost($clusenvnode); + $hostname = $host_obj->getHostAddr($host_ref); + } + + + + if (defined($backup)) { + + my $backup = $environments->getBackup($envitem, $host_obj, $engine, $envname, $envtype, $hostname, $user, $userauth); + $output->addLine( + $backup + ); + + #add users + + $environments->getUsersBackup($envitem,$output,$engine); + + + + } else { + + $config = $environments->getConfig($envitem, $host_obj); + $output->addLine( + $engine, + $envname, + $envtype, + $hostname, + $user, + $userauth, + $config + ); + + } +} __DATA__ =head1 SYNOPSIS @@ -337,6 +522,7 @@ =head1 SYNOPSIS [-name env_name | -reference reference ] [-backup] [-replist ] + [-userlist ] [-cluster ] [-format csv|json ] [-help|? ] diff --git a/lib/Engine.pm b/lib/Engine.pm index 888d6dc..91156bf 100644 --- a/lib/Engine.pm +++ b/lib/Engine.pm @@ -972,7 +972,7 @@ sub login { } ); } else { - # keep this for backward compability of dxtools.conf file + # keep this for backward compatibility of dxtools.conf file # if sysadmin is defined there we need to be able to login %mylogin = ( From 61967f07a530470f8335713f5a0dd6c129836afb Mon Sep 17 00:00:00 2001 From: Marcin Przepiorowski Date: Wed, 26 Jun 2024 15:52:57 +0200 Subject: [PATCH 4/7] users --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa6119..79abe6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ - support for object level stats in the dx_get_capacity_history ### Changes: -- compability with new engines (up to 16) +- compatibility with new engines (up to 16) - fixes in the timestamp support (-st) and (-et) ## 2.4.20 @@ -42,7 +42,7 @@ ### Changes: - [bug #230](https://github.com/delphix/dxtoolkit/issues/232) - example files location -- compability with new engines (up to 12) +- compatibility with new engines (up to 12) ## 2.4.19.2 From ddf97771c45dcb8cb4330b5f742c11cf06c20887 Mon Sep 17 00:00:00 2001 From: Marcin Przepiorowski Date: Thu, 27 Jun 2024 11:43:07 +0200 Subject: [PATCH 5/7] test fix --- test/test_env/env.t | 26 ++++++++++++++++++-------- test/test_env/start_server.pl | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/test/test_env/env.t b/test/test_env/env.t index 5d29648..793234e 100644 --- a/test/test_env/env.t +++ b/test/test_env/env.t @@ -1,6 +1,6 @@ use strict; use Data::Dumper; -use Test::More tests => 12; +use Test::More tests => 14; use Test::Script; use Test::Files; use File::Spec; @@ -23,9 +23,9 @@ script_compiles('../../bin/dx_get_env.pl'); script_runs(['../../bin/dx_get_env.pl', '-d', 'local', '-format','csv', "list environments"]); my $expected_stdout = <catfile( "./backup_env_orig.txt" ); compare_ok($some_file, $other_file, "backup file looks OK"); +script_runs(['../../bin/dx_get_env.pl', '-d', 'local', '-format','csv', '-userlist', "list users"]); +$expected_stdout = < Date: Thu, 27 Jun 2024 11:54:07 +0200 Subject: [PATCH 6/7] pre v2.4.24 --- CHANGELOG.md | 185 ++++++++++++++++++++--------------------- lib/Toolkit_helpers.pm | 2 +- 2 files changed, 93 insertions(+), 94 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79abe6f..c2ae081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,154 +1,155 @@ +## 2.4.24 + +### Added +- Added support to list environment users. +- Added support to list environment databases. +- Fixed self-service snapshot list issue in dx_get_js_snapshots +- Fixed dx_ctl_env to prevent adding same database twice for PostgreSQL + ## 2.4.23 ### Added -- Support for Postgresql ( dSource / VDB ) +- Support for PostgreSQL (dSource/VDB) - Data patch flag added for Oracle VDBs ## 2.4.22.1 ### Changes -- Fix to support backupuuid in dx_snapshot_db -- Fix to support dots in the user names while using @DOMAIN or @SYSTEM +- Fix to support backup UUID in dx_snapshot_db +- Fix to support dots in usernames while using @DOMAIN or @SYSTEM ## 2.4.22 ### Added -- flag -cluster for dx_get_env and dx_get_db_env to display a cluster nodes for dSources and VDBs -- support for Amazon Linux 2023 +- Flag -cluster for dx_get_env and dx_get_db_env to display cluster nodes for dSources and VDBs +- Support for Amazon Linux 2023 -### Changes: -- fix for dx_set_envpass to support MSSQL source environments -- [bug #234](https://github.com/delphix/dxtoolkit/issues/234) - dx_ctl_user - fix for setting principal +### Changes +- Fix for dx_set_envpass to support MSSQL source environments +- [Bug #234](https://github.com/delphix/dxtoolkit/issues/234) - dx_ctl_user - fix for setting principal ## 2.4.21.1 -### Changes: -- group name added to dx_get_vdbthroughput - new parameter fullname +### Changes +- Group name added to dx_get_vdbthroughput - new parameter fullname ## 2.4.21 ### Added -- support for object level stats in the dx_get_capacity_history +- Support for object level stats in dx_get_capacity_history -### Changes: -- compatibility with new engines (up to 16) -- fixes in the timestamp support (-st) and (-et) +### Changes +- Compatibility with new engines (up to 16) +- Fixes in the timestamp support (-st) and (-et) ## 2.4.20 ### Added -- support for Staging push ( MS SQL / Oracle ) -- [bug #232](https://github.com/delphix/dxtoolkit/issues/232) - dx_snapshot_db supports staging push +- Support for Staging push (MS SQL/Oracle) +- [Bug #232](https://github.com/delphix/dxtoolkit/issues/232) - dx_snapshot_db supports staging push -### Changes: -- [bug #230](https://github.com/delphix/dxtoolkit/issues/232) - example files location -- compatibility with new engines (up to 12) +### Changes +- [Bug #230](https://github.com/delphix/dxtoolkit/issues/232) - Example files location +- Compatibility with new engines (up to 12) ## 2.4.19.2 ### Added -- [bug #224](https://github.com/delphix/dxtoolkit/issues/224) - dx_get_hierarchy - print parent name +- [Bug #224](https://github.com/delphix/dxtoolkit/issues/224) - dx_get_hierarchy - print parent name ## 2.4.19 -### Changes: -- [bug #227](https://github.com/delphix/dxtoolkit/issues/227) - snapshot order fixed -- [bug #226](https://github.com/delphix/dxtoolkit/issues/226) - link / unlink (attach / detech) works for vPDB and CDB -- build fixes +### Changes +- [Bug #227](https://github.com/delphix/dxtoolkit/issues/227) - Snapshot order fixed +- [Bug #226](https://github.com/delphix/dxtoolkit/issues/226) - Link/unlink (attach/detach) works for vPDB and CDB +- Build fixes ### Added -- [bug #225](https://github.com/delphix/dxtoolkit/issues/225) - support for vPDB/vCDB with TDE - +- [Bug #225](https://github.com/delphix/dxtoolkit/issues/225) - Support for vPDB/vCDB with TDE ## 2.4.18 ### Added -- [bug #206](https://github.com/delphix/dxtoolkit/issues/206) - dsource hooks support -- [bug #217](https://github.com/delphix/dxtoolkit/issues/217) - dx_ctl_namespace added with option to failover and delete a namespace -- [bug #220](https://github.com/delphix/dxtoolkit/issues/220) - Support for different metrics - MB/TB/GB/KB added to commands displaying space - - - -### Changes: -- [bug #223](https://github.com/delphix/dxtoolkit/issues/223) - dx_ctl_js_container fix with return code -- [bug #222](https://github.com/delphix/dxtoolkit/issues/222) - db_get_db_env backup is now generating proper output for masked child VDB -- [bug #221](https://github.com/delphix/dxtoolkit/issues/221) - dbname for Oracle PDB can be now up to 30 characters -- build fixes - +- [Bug #206](https://github.com/delphix/dxtoolkit/issues/206) - dSource hooks support +- [Bug #217](https://github.com/delphix/dxtoolkit/issues/217) - dx_ctl_namespace added with options to failover and delete a namespace +- [Bug #220](https://github.com/delphix/dxtoolkit/issues/220) - Support for different metrics (MB/TB/GB/KB) added to commands displaying space +### Changes +- [Bug #223](https://github.com/delphix/dxtoolkit/issues/223) - dx_ctl_js_container fix with return code +- [Bug #222](https://github.com/delphix/dxtoolkit/issues/222) - dx_get_db_env backup is now generating proper output for masked child VDB +- [Bug #221](https://github.com/delphix/dxtoolkit/issues/221) - dbname for Oracle PDB can now be up to 30 characters +- Build fixes ## 2.4.17.2 -### Changes: +### Changes - dx_v2p - fix for MS SQL database to support file mapping -- Fix for various commands for better support of Delphix Engine timezones ( ex. dx_get_jobs and similar ) +- Fix for various commands for better support of Delphix Engine timezones (e.g., dx_get_jobs and similar) ## 2.4.17 Breaking change -If dx_ctl_replication script is used please review your scipts -and add -action replicate to keep current functionality +If dx_ctl_replication script is used, please review your scripts and add -action replicate to keep current functionality. ### Changes -- dx_ctl_replication - Breaking change - More functionality (create/update/delete profile) has been added and parameter -action is required -- dx_get_replication - backup of the replication profiles has been added -- dx_get_osversion - fix -- dx_get_config - backup of engine configuration to the JSON file has been added -- fix to issue with some database names / comments -- [bug #218](https://github.com/delphix/dxtoolkit/issues/218) - fix in dx_v2p -- [bug #214](https://github.com/delphix/dxtoolkit/issues/214) - fix to no of CPU -- [bug #208](https://github.com/delphix/dxtoolkit/issues/208) - fix to limited user privileges +- dx_ctl_replication - Breaking change - More functionality (create/update/delete profile) has been added, and parameter -action is required +- dx_get_replication - backup of the replication profiles has been added +- dx_get_osversion - fix +- dx_get_config - backup of engine configuration to the JSON file has been added +- Fix to issue with some database names/comments +- [Bug #218](https://github.com/delphix/dxtoolkit/issues/218) - Fix in dx_v2p +- [Bug #214](https://github.com/delphix/dxtoolkit/issues/214) - Fix to number of CPU +- [Bug #208](https://github.com/delphix/dxtoolkit/issues/208) - Fix to limited user privileges ### Added -- dx_ctl_config - initialise and configure engine using JSON file -- dx_get_namespace - list all replicated namespace -- dx_ctl_namespace - failover or delete namespace +- dx_ctl_config - initialize and configure engine using JSON file +- dx_get_namespace - list all replicated namespaces +- dx_ctl_namespace - failover or delete namespace + ## 2.4.16.3 ### Changes -- fix to disable debug data in various scripts -- [bug #215](https://github.com/delphix/dxtoolkit/issues/215) - v2p for MS SQL fix for 6.0.14 and higher +- Fix to disable debug data in various scripts +- [Bug #215](https://github.com/delphix/dxtoolkit/issues/215) - v2p for MS SQL fix for 6.0.14 and higher + ## 2.4.16.2 ### Added - dx_get_osversion - will report an upgrade verification status -- dx_get_appliance - will show UUID and engine type (masking / virtualisation ) +- dx_get_appliance - will show UUID and engine type (masking/virtualization) ## 2.4.16.0 ### Added - dx_get_db_env has a new column showing last VDB refresh time -- TDE support for an Oracle MT +- TDE support for Oracle MT - OAuth2 support - Bearer token access - ### Changed - - dx_get_vdbsize - documentation fix - - dx_ctl_env - set TDE password for CDB - - dx_provision_db - support for Oracle MT TDE - - dx_get_osversion - print upgrade verification results +- dx_get_vdbsize - documentation fix +- dx_ctl_env - set TDE password for CDB +- dx_provision_db - support for Oracle MT TDE +- dx_get_osversion - print upgrade verification results ## 2.4.15.1 ### Added -- [enhancement #194](https://github.com/delphix/dxtoolkit/issues/194) Last refresh date added to dx_get_db_env as a new column -- dx_get_source_info is displaying now a status for Validated Sync opertion for MS SQL and Sybase +- [Enhancement #194](https://github.com/delphix/dxtoolkit/issues/194) - Last refresh date added to dx_get_db_env as a new column +- dx_get_source_info now displays a status for Validated Sync operation for MS SQL and Sybase - dx_get_db_env has a new column showing last VDB refresh time - dx_get_vdbsize - new script to display total storage used by VDB - ### Changed -- [bug #197](https://github.com/delphix/dxtoolkit/issues/197) dx_get_db_env is displaying now a parent snapshot / time of the parent dSource / VDB - not a rollback one -- [bug #185](https://github.com/delphix/dxtoolkit/issues/185) dx_get_db_env is not displaying errors for replicated objects -- [bug #190](https://github.com/delphix/dxtoolkit/issues/190) dx_provision_db works with None snapshot policy -- [bug #198](https://github.com/delphix/dxtoolkit/issues/198) dx_get_source_info failing with vFiles dSources -- [bug #199](https://github.com/delphix/dxtoolkit/issues/199) reserved space added to dx_get_appliance - +- [Bug #197](https://github.com/delphix/dxtoolkit/issues/197) - dx_get_db_env is now displaying a parent snapshot/time of the parent dSource/VDB - not a rollback one +- [Bug #185](https://github.com/delphix/dxtoolkit/issues/185) - dx_get_db_env is not displaying errors for replicated objects +- [Bug #190](https://github.com/delphix/dxtoolkit/issues/190) - dx_provision_db works with None snapshot policy +- [Bug #198](https://github.com/delphix/dxtoolkit/issues/198) - dx_get_source_info failing with vFiles dSources +- [Bug #199](https://github.com/delphix/dxtoolkit/issues/199) - Reserved space added to dx_get_appliance ## 2.4.14.1 @@ -161,19 +162,18 @@ and add -action replicate to keep current functionality ### Added -- support for 6.0.11 engine -- dx_ctl_engine_upgrade - action apply allows to select upgrade type - deferred or full -- dx_ctl_engine_upgrade - action delete allows to delete old OS -- dx_get_db_env new flag to speed up a command output for engines with many snapshots - dx_get_db_env -snappervdb -- new filter based on repository name ( ORACLE_HOME, MS SQL instance, etc) added to dx_get_db_env and dx_ctl_db +- Support for 6.0.11 engine +- dx_ctl_engine_upgrade - action apply allows selection of upgrade type - deferred or full +- dx_ctl_engine_upgrade - action delete allows deletion of old OS +- dx_get_db_env - new flag to speed up command output for engines with many snapshots - dx_get_db_env -snappervdb +- New filter based on repository name (ORACLE_HOME, MS SQL instance, etc.) added to dx_get_db_env and dx_ctl_db ### Changed -- dx_ctl_engine_upgrade apply action fixed - it monitors now a whole upgrade process, including engine reboot -- [fix for #195](https://github.com/delphix/dxtoolkit/issues/195) - this was generic issue with snapshot paging -- [fix for #193](https://github.com/delphix/dxtoolkit/issues/193) - dx_get_env creates different envtype than what dx_create_env expects -- fix for backup metadata in dx_get_db_env -- fix for printing hierarchy in dx_get_hierarchy for objects with same reference across 2 engines - +- dx_ctl_engine_upgrade apply action fixed - it now monitors the whole upgrade process, including engine reboot +- [Fix for #195](https://github.com/delphix/dxtoolkit/issues/195) - generic issue with snapshot paging +- [Fix for #193](https://github.com/delphix/dxtoolkit/issues/193) - dx_get_env creates a different envtype than what dx_create_env expects +- Fix for backup metadata in dx_get_db_env +- Fix for printing hierarchy in dx_get_hierarchy for objects with the same reference across two engines ## 2.4.13 @@ -181,23 +181,22 @@ and add -action replicate to keep current functionality - Support for Commvault in adding MSSQL dSource ### Changed -- remove bookmark in self service fix -- fix for snapshot size reporting - +- Remove bookmark in self-service fix +- Fix for snapshot size reporting ## 2.4.12 ### Added -- skipdefault flag added to dx_ctl_policy to skip updating existing default polices -- [fix for #180](https://github.com/delphix/dxtoolkit/issues/180) - exclude parameter added to dx_ctl_dsource to ingest vfiles with exclude list -- support for password passed through environment variable - see example config file -- support for password passed via external script - see example config file +- Skipdefault flag added to dx_ctl_policy to skip updating existing default policies +- [Fix for #180](https://github.com/delphix/dxtoolkit/issues/180) - Exclude parameter added to dx_ctl_dsource to ingest vFiles with exclude list +- Support for password passed through environment variable - see example config file +- Support for password passed via external script - see example config file ### Changed -- fix for applying policy to group -- fix to uploading upgrade in engines in version 6.0.X -- fix for same users in DOMAIN and SYSTEM with dash in name -- [fix for #181](https://github.com/delphix/dxtoolkit/issues/181) Fix for disable / enbable LogSync +- Fix for applying policy to group +- Fix to uploading upgrade in engines in version 6.0.X +- Fix for same users in DOMAIN and SYSTEM with dash in the name +- [Fix for #181](https://github.com/delphix/dxtoolkit/issues/181) - Fix for disable/enable LogSync ## 2.4.11 diff --git a/lib/Toolkit_helpers.pm b/lib/Toolkit_helpers.pm index 10c462c..a3ed2eb 100644 --- a/lib/Toolkit_helpers.pm +++ b/lib/Toolkit_helpers.pm @@ -29,7 +29,7 @@ use File::Spec; use lib '../lib'; -our $version = '2.4.23'; +our $version = '2.4.24'; my $tz = new Date::Manip::TZ; my $dt = new Date::Manip::Date; From 47482a82746b89afee4abbad5da783b44d6a4319 Mon Sep 17 00:00:00 2001 From: Marcin Przepiorowski Date: Wed, 3 Jul 2024 10:16:19 +0200 Subject: [PATCH 7/7] doc fix --- bin/dx_get_env.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/dx_get_env.pl b/bin/dx_get_env.pl index 2d352b8..16d80a6 100755 --- a/bin/dx_get_env.pl +++ b/bin/dx_get_env.pl @@ -531,6 +531,7 @@ =head1 SYNOPSIS [-replist ] [-userlist ] [-cluster ] + [-sourcelist [-dbname name]] [-format csv|json ] [-help|? ] [-debug ] @@ -587,6 +588,14 @@ =head1 OPTIONS =item B<-cluster> Print ; segrageted list of cluster nodes from the environment into a new column called cluster nodes +=item B<-userlist> +Print list of user for each environment + +=item B<-sourcelist> +Print list of source databases ( discovered or added ) + +=item B<-dbname name> +Print source database(s) with the "name" =item B<-format> Display output in csv or json format