6060 ' uniquename=s' => \(my $uniquename ),
6161 ' instancename=s' => \(my $instancename ),
6262 ' jdbc=s' => \(my $jdbc ),
63+ ' plugin_params=s' => \(my $plugin_params ),
6364 ' listenername=s' => \(my $listenername ),
6465 ' endpoint=s@' => \(my $endpoint ),
6566 ' bits=n' => \(my $bits ),
134135 }
135136}
136137
138+ if (!((lc $repotype eq ' oracle' ) || (lc $repotype eq ' vfiles' ) || (lc $repotype eq ' postgresql' ) || (lc $repotype eq ' db2' ) || (lc $repotype eq ' plugin' ))) {
139+ print " Unknown repository type $repotype \n " ;
140+ exit 1;
141+ }
142+
137143if (lc $action eq ' adddatabase' ) {
138144 if (defined ($repotype )) {
139145 if (lc $repotype eq ' oracle' ) {
158164 print " vfilepath has to be set\n " ;
159165 exit 1;
160166 }
161- } else {
162- print " Repotype parameter $repotype unknown. Use oracle or vfiles\n " ;
163- exit 1;
167+ } elsif (lc $repotype eq ' plugin' ) {
168+ if (!defined ($plugin_params )) {
169+ print " plugin_params has to be set\n " ;
170+ exit 1;
171+ }
164172 }
165173 } else {
166174 print " Repotype parameter is required with adddatabase\n " ;
351359 my $sourceconfig_obj = new SourceConfig_obj($engine_obj , $debug );
352360
353361 if (lc $repotype eq ' oracle' ) {
354- if ($sourceconfig_obj -> createSourceConfig(' oracleSI' , $repo -> {reference }, $dbname , $uniquename , $instancename , $jdbc )) {
362+ my %native_params = (
363+ " uniquename" => $uniquename ,
364+ " instancename" => $instancename ,
365+ " jdbc" => $jdbc
366+ );
367+ if ($sourceconfig_obj -> createSourceConfig(' oracleSI' , $repo -> {reference }, $dbname , \%native_params )) {
355368 print " Can't add database $dbname \n " ;
356369 $ret = $ret + 1;
357370 } else {
358371 print " Database $dbname added into $repopath \n " ;
359372 }
360373 } elsif (lc $repotype eq ' vfiles' ) {
361- if ($sourceconfig_obj -> createSourceConfig(' vfiles' , $repo -> {reference }, $dbname , undef , undef , undef , $vfilepath )) {
374+ my %native_params = (
375+ " path" => $vfilepath
376+ );
377+
378+ my %plugin_params = ();
379+
380+ if ($sourceconfig_obj -> createSourceConfig(' vfiles' , $repo -> {reference }, $dbname , \%native_params )) {
362381 print " Can't add directory $vfilepath as $dbname \n " ;
363382 $ret = $ret + 1;
364383 } else {
365384 print " vFiles source $vfilepath added into environment $env_name \n " ;
366385 }
386+ } elsif (lc $repotype eq ' db2' ) {
387+ my %native_params ;
388+ my %plugin_params_hash = (
389+ " prettyName" => $dbname ,
390+ " dbName" => $dbname
391+ );
392+ if ($sourceconfig_obj -> createSourceConfig(' plugin' , $repo -> {reference }, $dbname , \%native_params , \%plugin_params_hash )) {
393+ print " Can't add DB2 $dbname \n " ;
394+ $ret = $ret + 1;
395+ } else {
396+ print " DB2 $dbname added into environment $env_name \n " ;
397+ }
398+ } elsif (lc $repotype eq ' postgresql' ) {
399+ my %native_params ;
400+ my %plugin_params_hash = (
401+ " prettyName" => $dbname
402+ );
403+ if ($sourceconfig_obj -> createSourceConfig(' plugin' , $repo -> {reference }, $dbname , \%native_params , \%plugin_params_hash )) {
404+ print " Can't add Postgresql $dbname \n " ;
405+ $ret = $ret + 1;
406+ } else {
407+ print " Postgresql $dbname added into environment $env_name \n " ;
408+ }
409+ } elsif (lc $repotype eq ' plugin' ) {
410+ my $native_params ;
411+ my $plugin_params_hash ;
412+ eval {
413+ $plugin_params_hash = from_json($plugin_params );
414+ } or do {
415+ my $e = $@ ;
416+ print " Problem with JSON $e \n " ;
417+ };
418+
419+ if ($sourceconfig_obj -> createSourceConfig(' plugin' , $repo -> {reference }, $dbname , $native_params , $plugin_params_hash )) {
420+ print " Can't add plugin database $dbname \n " ;
421+ $ret = $ret + 1;
422+ } else {
423+ print " Plugin database $dbname added into environment $env_name \n " ;
424+ }
367425 }
368426
369427
370428 } else {
371429 print " Can't find repository path $repopath \n " ;
372430 $ret = $ret + 1;
373431 }
432+
374433 }
375434
376435 if ( lc $action eq ' deletedatabase' ) {
416475 $ret = $ret + 1;
417476 }
418477 }
419-
420-
421-
422478 }
423479
424480 if (defined ($parallel ) && (scalar (@jobs ) > 0)) {
428484 }
429485 }
430486
431- if (!defined ($hostupdate )) {
487+ if (( lc $action eq ' updatehost ' ) && ( !defined ($hostupdate ) )) {
432488 # no environment found with a IP - need to report an error
433489 $ret = $ret + 1;
434490 }
@@ -455,8 +511,9 @@ =head1 SYNOPSIS
455511 [-username name]
456512 [-authtype password|systemkey]
457513 [-password password]
458- [-repotype oracle|vfiles]
514+ [-repotype oracle|vfiles|db2|postgresql|plugin ]
459515 [-repopath ORACLE_HOME]
516+ [-plugin_params JSON_parameters]
460517 [-host name/ip of existing host to update]
461518 [-newhost new name/ip of the host]
462519 [-help|? ]
@@ -536,11 +593,12 @@ =head1 OPTIONS
536593=item B<-password password >
537594Password for user (use with adduser)
538595
539- =item B<-repotype oracle|vfiles >
540- Repository type to add (only Oracle and vFiles support for now - use with addrepo or adddatabase)
596+ =item B<-repotype oracle|vfiles|db2|postgresql|plugin >
597+ Repository type.
598+ The following types oracle and vfiles can be used to add repository manually.
541599
542600=item B<-repopath ORACLE_HOME >
543- Oracle Home to add (use with addrepo )
601+ Repository name ( Oracle Home, plugin name, vfiles directory )
544602
545603=item B<-bits 32|64 >
546604Oracle Home binary bit version (32/64)
@@ -558,6 +616,9 @@ =head1 OPTIONS
558616=item B<-newhost hostname/IP >
559617New Host name or IP of host being updated
560618
619+ =item B<-plugin_params JSON_parameters >
620+ New Host name or IP of host being updated
621+
561622=item B<-help >
562623Print this screen
563624
@@ -668,4 +729,18 @@ =head1 EXAMPLES
668729 Job JOB-2852 finished with state: COMPLETED
669730 Checking environment for host update linuxtarget Host with IP 172.16.200.130 not found
670731
732+ Adding the Postgresql database posttest into environment
733+
734+ dx_ctl_env -d 53 -name linuxsource -action adddatabase -dbname posttest -repotype postgresql -repopath "Postgres vFiles (9.6)"
735+ Adding database posttest into Postgres vFiles (9.6) on environment linuxsource
736+ Postgresql posttest added into environment linuxsource
737+
738+ Adding the MySQL database using EDSI plugin
739+
740+ dx_ctl_env -d 53 -action adddatabase -repotype plugin -repopath "/usr/sbin (MySQL Community Server (GPL)) 5.6.29" \
741+ -dbname testmysql -name linuxtarget \
742+ -plugin_params '{ "dbName": "testmysql", "baseDir":"/usr/sbin" }'
743+ Adding database testmysql into /usr/sbin (MySQL Community Server (GPL)) 5.6.29 on environment linuxtarget
744+ Plugin database testmysql added into environment linuxtarget
745+
671746=cut
0 commit comments