Skip to content

Commit 4d598d6

Browse files
author
Marcin Przepiorowski
committed
db2 changes
1 parent c3247f8 commit 4d598d6

File tree

6 files changed

+185
-77
lines changed

6 files changed

+185
-77
lines changed

bin/dx_ctl_dsource.pl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
'restorejobs=n' => \(my $restorejobs),
9999
'dumpjobs=n' => \(my $dumpjobs),
100100
'customparameters=s@' => \(my $customparameters),
101+
'encryptionmklabel=s' => \(my $encryptionmklabel),
101102
'backup_dir_log=s' => \(my $backup_dir_log),
102103
'keepinsync=s' => \(my $keepinsync),
103104
'dever=s' => \(my $dever),
@@ -425,7 +426,7 @@
425426
$ret = $ret + 1;
426427
last;
427428
}
428-
$jobno = $db->addSource($sourcename,$sourceinst,$sourceenv,$source_os_user,$dbuser,$password,$dsourcename,$group,$logsync,$stageenv,$stageinst,$stage_os_user, $backup_dir, $hadr);
429+
$jobno = $db->addSource($sourcename,$sourceinst,$sourceenv,$source_os_user,$dbuser,$password,$dsourcename,$group,$logsync,$stageenv,$stageinst,$stage_os_user, $backup_dir, $hadr, $encryptionmklabel);
429430
}
430431
elsif ($type eq 'postgresql') {
431432
my $db = new PostgresVDB_obj($engine_obj,$debug);
@@ -547,6 +548,8 @@ =head1 SYNOPSIS
547548
[-dumpjobs x]
548549
[-backup_dir_log directory]
549550
[-keepinsync yes|no]
551+
[-hadr hadrPrimarySVC:XXX,hadrPrimaryHostname:hostname,hadrStandbySVC:YYY]
552+
[-encryptionmklabel label]
550553
[-debug ]
551554
[-version ]
552555
[-help|? ]
@@ -692,6 +695,11 @@ =head2 dSource arguments
692695
ex.
693696
hadrPrimarySVC:50001,hadrPrimaryHostname:marcindb2src.dcenter,hadrStandbySVC:50011,hadrTargetList:marcindb2src.dcenter:50001
694697
698+
699+
=item B<-encryptionmklabel label>
700+
Add DB2 dSource backup encryption label
701+
702+
695703
=item B<-exclude path>
696704
Exclude path for vFiles dSources
697705

lib/AppDataVDB_obj.pm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,4 +648,26 @@ sub setSource {
648648

649649
}
650650

651+
652+
# Procedure disable
653+
# parameters:
654+
# - force
655+
# Disable database
656+
# Return job number if job started or undef otherwise
657+
658+
sub disable
659+
{
660+
my $self = shift;
661+
my $force = shift;
662+
logger($self->{_debug}, "Entering AppDataVDB_obj::disable",1);
663+
664+
if (version->parse($self->{_dlpxObject}->getApi()) < version->parse(1.11.41)) {
665+
return $self->VDB_obj::disable($force,'SourceDisableParameters') ;
666+
} else {
667+
# above 29
668+
return $self->VDB_obj::disable($force,'AppDataDisableParameters') ;
669+
}
670+
671+
}
672+
651673
1;

lib/DB2VDB_obj.pm

Lines changed: 83 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use Data::Dumper;
2525
use JSON;
2626
use version;
2727
use Toolkit_helpers qw (logger);
28-
our @ISA = qw(VDB_obj);
28+
our @ISA = qw(PluginVDB_obj);
2929

3030
sub new {
3131
my $class = shift;
@@ -413,76 +413,45 @@ sub createVDB {
413413

414414
sub addSource {
415415
my $self = shift;
416-
my $source = shift;
416+
my $sourcename = shift;
417417
my $source_inst = shift;
418418
my $source_env = shift;
419419
my $source_osuser = shift;
420420
my $dbuser = shift;
421421
my $password = shift;
422-
my $dsource_name = shift;
422+
my $dsourcename = shift;
423423
my $group = shift;
424424
my $logsync = shift;
425-
my $env = shift;
426-
my $inst = shift;
427-
my $stage_osuser = shift;
425+
my $stageenv = shift;
426+
my $stageinst = shift;
427+
my $stage_os_user = shift;
428428
my $backup_dir = shift;
429429
my $hadr = shift;
430+
my $encryptionMasterKeyLabel = shift;
430431

431432
logger($self->{_debug}, "Entering DB2VDB_obj::addSource",1);
432-
433-
my $config = $self->setConfig($source, $inst, $env);
434-
435-
if (! defined($config)) {
436-
print "Source database $source not found\n";
437-
return undef;
438-
}
439-
440-
if ( $self->setGroup($group) ) {
441-
print "Group $group not found. dSource won't be created\n";
442-
return undef;
443-
}
444-
445-
if ( $self->setEnvironment($env) ) {
446-
print "Staging environment $env not found. dSource won't be created\n";
447-
return undef;
448-
}
449-
450-
if ( $self->setHome($inst) ) {
451-
print "Staging instance $inst in environment $env not found. dSource won't be created\n";
452-
return undef;
453-
}
454-
455-
my $stage_osuser_ref = $self->{_environment}->getEnvironmentUserByName($env,$stage_osuser);
456-
457-
if (!defined($stage_osuser_ref)) {
458-
print "Source OS user $stage_osuser not found\n";
459-
return undef;
460-
}
461-
433+
462434
my @configset;
463435

464-
my %dsource_params = (
465-
"type" => "LinkParameters",
466-
"group" => $self->{"NEWDB"}->{"container"}->{"group"},
467-
"name" => $dsource_name,
468-
"linkData" => {
469-
"type" => "AppDataStagedLinkData",
470-
"config" => $config->{reference},
471-
"environmentUser" => $stage_osuser_ref,
472-
"stagingEnvironment" => $self->{'_newenv'},
473-
"stagingEnvironmentUser" => $stage_osuser_ref,
474-
"parameters" => {
436+
my %parameters = (
475437
"monitorHADR" => JSON::false,
476438
"toolkitHookFlag" => JSON::false,
477439
"config_settings_stg" => \@configset,
478-
"dbName" => $source,
440+
"dbName" => $sourcename,
479441
"backupPath" => $backup_dir
480-
}
481-
}
482442
);
483443

484444

485445

446+
447+
448+
if (defined($encryptionMasterKeyLabel)) {
449+
$parameters{encryptedBackup} = JSON::true;
450+
$parameters{encryptionMasterKeyLabel} = $encryptionMasterKeyLabel;
451+
452+
}
453+
454+
486455
if (defined($hadr)) {
487456
# hadr is defined - it can be used as general parameter parser
488457
# if hadr is enabled look for these parameters
@@ -499,35 +468,59 @@ sub addSource {
499468
for my $l (@hadrarray) {
500469
my @line = split(":", $l, 2);
501470
if (defined($line[0]) && defined($hadrhash{$line[0]}) ) {
502-
$dsource_params{linkData}{parameters}{$line[0]} = $line[1];
471+
$parameters{$line[0]} = $line[1];
503472
}
504473
}
505474

506-
$dsource_params{linkData}{parameters}{monitorHADR} = JSON::true;
475+
$parameters{monitorHADR} = JSON::true;
507476

508-
if (scalar(grep { ($hadrhash{$_} eq 'm') && defined($dsource_params{linkData}{parameters}{$_}) } keys (%hadrhash)) < 3) {
477+
if (scalar(grep { ($hadrhash{$_} eq 'm') && defined($parameters{$_}) } keys (%hadrhash)) < 3) {
509478
print "Please provide all HADR mandatory parameters\n";
510479
return undef;
511480
}
512481

513482
}
514483

515-
my $ds_hooks = $self->set_dsource_hooks();
516-
if (defined($ds_hooks)) {
517-
if (version->parse($self->{_dlpxObject}->getApi()) < version->parse(1.8.0)) {
518-
$dsource_params{"source"}{"operations"} = $ds_hooks;
519-
} else {
520-
$dsource_params{"linkData"}{"operations"} = $ds_hooks;
521-
}
522-
}
523-
524-
my $operation = 'resources/json/delphix/database/link';
525-
my $json_data = to_json(\%dsource_params, {pretty=>1});
526-
#my $json_data = encode_json(\%dsource_params, pretty=>1);
527-
528-
logger($self->{_debug}, $json_data, 1);
529-
530-
return $self->runJobOperation($operation,$json_data, 'ACTION');
484+
# my $ds_hooks = $self->set_dsource_hooks();
485+
# if (defined($ds_hooks)) {
486+
# if (version->parse($self->{_dlpxObject}->getApi()) < version->parse(1.8.0)) {
487+
# $dsource_params{"source"}{"operations"} = $ds_hooks;
488+
# } else {
489+
# $dsource_params{"linkData"}{"operations"} = $ds_hooks;
490+
# }
491+
# }
492+
493+
# my $operation = 'resources/json/delphix/database/link';
494+
# my $json_data = to_json(\%dsource_params, {pretty=>1});
495+
# #my $json_data = encode_json(\%dsource_params, pretty=>1);
496+
497+
# logger($self->{_debug}, $json_data, 1);
498+
499+
# return $self->runJobOperation($operation,$json_data, 'ACTION');
500+
501+
502+
return $self->PluginVDB_obj::addSource(
503+
$sourcename,
504+
$dbuser,
505+
$password,
506+
$dsourcename,
507+
$group,
508+
$logsync,
509+
$stageenv,
510+
$stageinst,
511+
$stage_os_user,
512+
$backup_dir ,
513+
$sourcehostname,
514+
$sourceport,
515+
$ingestiontype,
516+
$dumpdir,
517+
$restorejobs,
518+
$dumpjobs,
519+
$staging_port,
520+
$singledbname,
521+
$mountbase,
522+
\%parameters
523+
) ;
531524

532525
}
533526

@@ -696,4 +689,25 @@ sub getVersion {
696689

697690
}
698691

692+
693+
# parameters:
694+
# - force
695+
# Disable database
696+
# Return job number if job started or undef otherwise
697+
698+
sub disable
699+
{
700+
my $self = shift;
701+
my $force = shift;
702+
logger($self->{_debug}, "Entering DB2VDB_obj::disable",1);
703+
704+
if (version->parse($self->{_dlpxObject}->getApi()) < version->parse(1.11.41)) {
705+
return $self->VDB_obj::disable($force,'SourceDisableParameters') ;
706+
} else {
707+
# above 29
708+
return $self->VDB_obj::disable($force,'AppDataDisableParameters') ;
709+
}
710+
711+
}
712+
699713
1;

lib/Databases.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ use OracleVDB_obj;
4040
use MSSQLVDB_obj;
4141
use SybaseVDB_obj;
4242
use AppDataVDB_obj;
43-
use DB2VDB_obj;
4443
use PluginVDB_obj;
44+
use DB2VDB_obj;
4545
use PostgresVDB_obj;
4646
use Toolkit_obj;
4747
use Toolkit_helpers qw (logger);

lib/PluginVDB_obj.pm

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,48 @@ sub addSource
113113

114114

115115

116-
my %dsource_params = (
116+
# my %dsource_params = (
117+
# "type" => "LinkParameters",
118+
# "group" => $self->{"NEWDB"}->{"container"}->{"group"},
119+
# "name" => $dsourcename,
120+
# "linkData" => {
121+
# "type" => "AppDataStagedLinkData",
122+
# "config" => $config->{reference},
123+
# "environmentUser" => $stage_osuser_ref,
124+
# "stagingEnvironment" => $self->{'_newenv'},
125+
# "stagingEnvironmentUser" => $stage_osuser_ref,
126+
# "parameters" => $plugin_parameters,
127+
# "syncParameters" => {
128+
# "type"=> "AppDataSyncParameters",
129+
# "parameters" => {
130+
# "resync" => JSON::true
131+
# }
132+
# }
133+
# }
134+
# );
135+
136+
137+
my %dsource_params;
138+
139+
if (version->parse($self->{_dlpxObject}->getApi()) < version->parse(1.11.5)) {
140+
# until 6.0.5
141+
%dsource_params = (
142+
"type" => "LinkParameters",
143+
"group" => $self->{"NEWDB"}->{"container"}->{"group"},
144+
"name" => $dsourcename,
145+
"linkData" => {
146+
"type" => "AppDataStagedLinkData",
147+
"config" => $config->{reference},
148+
"environmentUser" => $stage_osuser_ref,
149+
"stagingEnvironment" => $self->{'_newenv'},
150+
"stagingEnvironmentUser" => $stage_osuser_ref,
151+
"parameters" => $plugin_parameters
152+
}
153+
);
154+
} else {
155+
# for 6.0.6 and higher
156+
157+
%dsource_params = (
117158
"type" => "LinkParameters",
118159
"group" => $self->{"NEWDB"}->{"container"}->{"group"},
119160
"name" => $dsourcename,
@@ -125,13 +166,15 @@ sub addSource
125166
"stagingEnvironmentUser" => $stage_osuser_ref,
126167
"parameters" => $plugin_parameters,
127168
"syncParameters" => {
128-
"type"=> "AppDataSyncParameters",
129-
"parameters" => {
130-
"resync" => JSON::true
131-
}
169+
"type"=> "AppDataSyncParameters",
170+
"parameters" => {
171+
"resync" => JSON::true
172+
}
132173
}
133174
}
134-
);
175+
);
176+
177+
}
135178

136179

137180
my $ds_hooks = $self->set_dsource_hooks();

lib/PostgresVDB_obj.pm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,27 @@ sub getDatabaseName
626626
return $self->{source}->{name};
627627
}
628628

629+
# Procedure disable
630+
# parameters:
631+
# - force
632+
# Disable database
633+
# Return job number if job started or undef otherwise
634+
635+
sub disable
636+
{
637+
my $self = shift;
638+
my $force = shift;
639+
logger($self->{_debug}, "Entering PostgresVDB_obj::disable",1);
640+
641+
if (version->parse($self->{_dlpxObject}->getApi()) < version->parse(1.11.41)) {
642+
return $self->VDB_obj::disable($force,'SourceDisableParameters') ;
643+
} else {
644+
# above 29
645+
return $self->VDB_obj::disable($force,'AppDataDisableParameters') ;
646+
}
647+
648+
}
649+
629650
#
630651
# End of package
631652

0 commit comments

Comments
 (0)