@@ -145,14 +145,20 @@ sub getConfig
145145
146146 my $config = ' ' ;
147147 my $joinsep ;
148+ my $vcdb ;
149+
150+ if (!defined ($self -> {_databases }-> {_vcdblist })) {
151+ my %vcdblist ;
152+ $self -> {_databases }-> {_vcdblist } = \%vcdblist ;
153+ }
154+
148155
149156 if (defined ($backup )) {
150157 $joinsep = ' ' ;
151158 } else {
152159 $joinsep = ' ,' ;
153160 }
154161
155-
156162 if ($self -> getType() eq ' VDB' ) {
157163
158164 my $mntpoint = $self -> getMountPoint();
@@ -171,16 +177,17 @@ sub getConfig
171177
172178 my $sourceobj = $self -> {_source }-> getSourceByConfig($cdbref );
173179
174- if ($sourceobj -> {type } eq ' OracleVirtualSource' ) {
180+ if (( $sourceobj -> {type } eq ' OracleVirtualSource' ) && (! defined ( $self -> { _databases } -> { _vcdblist } -> { $cdbref })) ) {
175181 # this is a vCDB
182+ # it is first time we see it
183+ $self -> {_databases }-> {_vcdblist }-> {$cdbref } = 1;
176184
177185 if (defined ($sourceobj -> {configTemplate })) {
178186 my $vcdbtempname = $templates -> getTemplate($sourceobj -> {configTemplate })-> {name };
179187 $config = join ($joinsep ,($config , " -vcdbtemplate \" $vcdbtempname \" " ));
180188 }
181189
182190
183-
184191 my $dbobj = $self -> {_databases }-> getDB($sourceobj -> {container });
185192
186193 if (defined ($dbobj )) {
@@ -204,6 +211,17 @@ sub getConfig
204211 }
205212 }
206213
214+ $vcdb = 1;
215+
216+ if (defined ($dbobj -> {sourceConfig }-> {" tdeKeystorePassword" })) {
217+ $config = join ($joinsep ,($config , " -vdbtdepassword xxxxxxxx" ));
218+ }
219+
220+
221+ if (defined ($self -> {" source" }-> {" targetVcdbTdeKeystorePath" })) {
222+ $config = join ($joinsep ,($config , " -vcdbtdekeystore " . $self -> {" source" }-> {" targetVcdbTdeKeystorePath" }));
223+ }
224+
207225
208226 $config = join ($joinsep ,($config , " -vcdbname $vcdbname -vcdbdbname $vcdbdbname -vcdbuniqname $vcdbuniqname -vcdbgroup \" $vcdbgroupname \" " ));
209227 } else {
@@ -264,7 +282,7 @@ sub getConfig
264282 $config = join ($joinsep ,($config , $cust ));
265283 }
266284
267- my $tde = $self -> getTDE($joinsep );
285+ my $tde = $self -> getTDE($joinsep , $vcdb );
268286 if ($tde ne ' ' ) {
269287 $config = join ($joinsep ,($config , $tde ));
270288 }
@@ -1599,6 +1617,55 @@ sub snapshot
15991617 return $self -> VDB_obj::snapshot(\%snapshot_type ) ;
16001618}
16011619
1620+
1621+ sub setConfig {
1622+ my $self = shift ;
1623+ my $name = shift ;
1624+ my $source_inst = shift ;
1625+ my $source_env = shift ;
1626+ my $cdbcont = shift ;
1627+
1628+ logger($self -> {_debug }, " Entering OracleVDB_obj::setConfig" ,1);
1629+
1630+ logger($self -> {_debug }, " name: " . Dumper $name , 2);
1631+ logger($self -> {_debug }, " source_inst: " . Dumper $source_inst , 2);
1632+ logger($self -> {_debug }, " source_env: " . Dumper $source_env , 2);
1633+ logger($self -> {_debug }, " cdbcont: " . Dumper $cdbcont , 2);
1634+
1635+
1636+ my $dlpxObject = $self -> {_dlpxObject };
1637+ my $debug = $self -> {_debug };
1638+
1639+ my $sourceconfig ;
1640+
1641+
1642+ if (!defined ($self -> {_sourceconfig })) {
1643+ $sourceconfig = new SourceConfig_obj($dlpxObject , $debug );
1644+ $self -> {_sourceconfig } = $sourceconfig ;
1645+ }
1646+
1647+ my $ret ;
1648+
1649+
1650+ if (defined ($cdbcont )) {
1651+ my $container_obj = $self -> {_sourceconfig }-> getSourceConfigByName($cdbcont );
1652+ $ret = $self -> {_sourceconfig }-> getSourceByCDB($name , $container_obj -> {reference });
1653+ } else {
1654+ my $sourceconfig_db = $self -> {_sourceconfig }-> getSourceConfigByName($name );
1655+ if ($sourceconfig_db -> {" type" } ne ' OraclePDBConfig' ) {
1656+ if (!defined ($sourceconfig_db )) {
1657+ print " Source database $name not found\n " ;
1658+ } else {
1659+ $ret = $sourceconfig_db ;
1660+ }
1661+ } else {
1662+ print " Oracle PDB specified without CDB. Please add -cdbcont parameter\n " ;
1663+ }
1664+ }
1665+
1666+ return $ret
1667+ }
1668+
16021669# Procedure attach_dsource
16031670# parameters:
16041671# - dbuser
@@ -1618,27 +1685,28 @@ sub attach_dsource
16181685 my $source_osuser = shift ;
16191686 my $dbuser = shift ;
16201687 my $password = shift ;
1688+ my $cdbcont = shift ;
16211689
16221690 logger($self -> {_debug }, " Entering OracleVDB_obj::attach_dsource" ,1);
16231691
1624- my $config = $self -> setConfig($source , $source_inst , $source_env );
1692+ my $config = $self -> setConfig($source , $source_inst , $source_env , $cdbcont );
16251693
16261694 if (! defined ($config )) {
1627- print " Source database $source not found\n " ;
16281695 return undef ;
16291696 }
16301697
1631-
16321698 my $source_env_ref = $self -> {_repository }-> getEnvironment($config -> {repository });
16331699 my $source_os_ref = $self -> {_environment }-> getEnvironmentUserByName($source_env_ref ,$source_osuser );
16341700
16351701 my $authtype = $self -> {_environment }-> getEnvironmentUserAuth($source_env_ref , $source_os_ref );
16361702
16371703 if ($authtype ne ' kerberos' ) {
16381704 # assuming we have kerberos and no dbuser is enabled
1639- if ($self -> {_sourceconfig }-> validateDBCredentials($config -> {reference }, $dbuser , $password )) {
1640- print " Username or password is invalid.\n " ;
1641- return undef ;
1705+ if (defined ($dbuser )) {
1706+ if ($self -> {_sourceconfig }-> validateDBCredentials($config -> {reference }, $dbuser , $password )) {
1707+ print " Username or password is invalid.\n " ;
1708+ return undef ;
1709+ }
16421710 }
16431711 }
16441712
@@ -1697,26 +1765,32 @@ sub attach_dsource
16971765 " attachData" => {
16981766 " type" => " OracleAttachData" ,
16991767 " config" => $config -> {reference },
1700- " oracleFallbackCredentials" => $password ,
1701- " oracleFallbackUser" => $dbuser ,
17021768 " environmentUser" => $source_os_ref
17031769 }
17041770 );
1771+
1772+ if (defined ($dbuser )) {
1773+ $attach_data {" attachData" }{" oracleFallbackUser" } = $dbuser ;
1774+ $attach_data {" attachData" }{" oracleFallbackCredentials" } = $password ;
1775+ }
1776+
17051777 } else {
17061778 # 6.0.4 and above so far
17071779 %attach_data = (
17081780 " type" => " AttachSourceParameters" ,
17091781 " attachData" => {
17101782 " type" => " OracleAttachData" ,
17111783 " config" => $config -> {reference },
1712- " oracleFallbackCredentials" => {
1713- " type" => " PasswordCredential" ,
1714- " password" => $password
1715- },
1716- " oracleFallbackUser" => $dbuser ,
17171784 " environmentUser" => $source_os_ref
17181785 }
17191786 );
1787+
1788+ if (defined ($dbuser )) {
1789+ $attach_data {" attachData" }{" oracleFallbackUser" } = $dbuser ;
1790+ $attach_data {" attachData" }{" oracleFallbackCredentials" }{" type" } = " PasswordCredential" ;
1791+ $attach_data {" attachData" }{" oracleFallbackCredentials" }{" password" } = $password ;
1792+ }
1793+
17201794 }
17211795
17221796 if ($config -> {type } eq ' OraclePDBConfig' ) {
@@ -1909,11 +1983,12 @@ sub addSource {
19091983 my $dsource_name = shift ;
19101984 my $group = shift ;
19111985 my $logsync = shift ;
1986+ my $cdbcont = shift ;
19121987
19131988
19141989 logger($self -> {_debug }, " Entering OracleVDB_obj::addSource" ,1);
19151990
1916- my $config = $self -> setConfig($source , $source_inst , $source_env );
1991+ my $config = $self -> setConfig($source , $source_inst , $source_env , $cdbcont );
19171992
19181993 if (! defined ($config )) {
19191994 print " Source database $source not found\n " ;
@@ -2274,6 +2349,8 @@ sub setupVCDB {
22742349 my $vcdbuniqname = shift ;
22752350 my $vcdbtemplate = shift ;
22762351 my $vcdbrac_instance = shift ;
2352+ my $vcdbtdepassword = shift ;
2353+ my $vcdbtdekeystore = shift ;
22772354 logger($self -> {_debug }, " Entering OracleVDB_obj::setupVCDB" ,1);
22782355
22792356 $self -> {_vcdbname } = $vcdbname ;
@@ -2284,6 +2361,12 @@ sub setupVCDB {
22842361 $self -> {_vcdbtemplate } = $vcdbtemplate ;
22852362 $self -> {_vcdbtemplate } = $vcdbtemplate ;
22862363 $self -> {_vcdbrac_instance } = $vcdbrac_instance ;
2364+
2365+ if (version-> parse($self -> {_dlpxObject }-> getApi()) >= version-> parse(1.11.18)) {
2366+ $self -> {_vcdbtdepassword } = $vcdbtdepassword ;
2367+ $self -> {_vcdbtdekeystore } = $vcdbtdekeystore ;
2368+ }
2369+
22872370}
22882371
22892372
@@ -2489,6 +2572,13 @@ sub createVDB {
24892572 $virtcdbhash {" source" }{" configTemplate" } = $vcdbtemplateref ;
24902573 }
24912574
2575+
2576+ if (defined ($self -> {_vcdbtdepassword })) {
2577+ $self -> {" NEWDB" }{" source" }{" targetVcdbTdeKeystorePath" } = $self -> {_vcdbtdekeystore };
2578+ $virtcdbhash {" sourceConfig" }{" tdeKeystorePassword" } = $self -> {_vcdbtdepassword };
2579+ }
2580+
2581+
24922582 $self -> {" NEWDB" }-> {" virtualCdb" } = \%virtcdbhash ;
24932583
24942584 }
@@ -2685,18 +2775,21 @@ sub setupTDE {
26852775sub getTDE {
26862776 my $self = shift ;
26872777 my $separator = shift ;
2778+ my $vcdb = shift ;
26882779 logger($self -> {_debug }, " Entering OracleVDB_obj::getTDE" ,1);
26892780 my $ret = ' ' ;
26902781 if (defined ($self -> {" source" }-> {" parentTdeKeystorePath" })) {
26912782 $ret = " -tdeparentpath " . $self -> {" source" }-> {" parentTdeKeystorePath" };
2692- $ret = $ret . " -tdeparentpassword xxxxxx -tdeexportsecret xxxxxxx -tdecdbpassword xxxxxxx" ;
2783+ $ret = $ret . " -tdeparentpassword xxxxxx -tdeexportsecret xxxxxxx " ;
2784+ if (defined ($vcdb )) {
2785+ } else {
2786+ $ret = $ret . " -tdecdbpassword xxxxxxx" ;
2787+ }
26932788 if (defined ($self -> {" source" }-> {" tdeKeyIdentifier" })) {
26942789 $ret = $ret . " -tdekeyid " . $self -> {" source" }-> {" tdeKeyIdentifier" };
26952790 }
26962791 }
26972792
2698-
2699-
27002793 return $ret ;
27012794}
27022795
0 commit comments