1111# See the License for the specific language governing permissions and
1212# limitations under the License.
1313#
14- # Copyright (c) 2014,2016 by Delphix. All rights reserved.
14+ # Copyright (c) 2014,2019 by Delphix. All rights reserved.
1515#
1616# Program Name : dx_ctl_env.pl
1717# Description : Get database and host information
4848 ' name|n=s' => \(my $envname ),
4949 ' reference|r=s' => \(my $reference ),
5050 ' action=s' => \(my $action ),
51+ ' host=s' => \(my $host ),
52+ ' newhost=s' => \(my $newhost ),
5153 ' username=s' => \(my $username ),
5254 ' authtype=s' => \(my $authtype ),
5355 ' password=s' => \(my $password ),
98100 (lc $action eq ' addrepo' ) || (lc $action eq ' deleterepo' ) ||
99101 (lc $action eq ' adddatabase' ) || (lc $action eq ' deletedatabase' ) ||
100102 (lc $action eq ' addlistener' ) || (lc $action eq ' deletelistener' ) ||
101- (lc $action eq ' adduser' ) || (lc $action eq ' deleteuser' )
103+ (lc $action eq ' adduser' ) || (lc $action eq ' deleteuser' ) ||
104+ (lc $action eq ' updatehost' )
102105 ))
103106 {
104107 print " Unknown action $action \n " ;
105108 pod2usage(-verbose => 1, -input => \*DATA );
106109 exit (1);
107110}
108111
112+ if (lc $action eq ' updatehost' ) {
113+ if (!defined ($newhost )) {
114+ print " New host has to be set\n " ;
115+ exit 1;
116+ }
117+ if ((!defined ($envname )) && (!defined ($host ))) {
118+ print " Environment name or an existing host name has to be set for updatehost action\n " ;
119+ exit 1;
120+ }
121+ }
122+
109123if (lc $action eq ' addrepo' ) {
110124 if (!defined ($repotype )) {
111125 print " Repository type has to be set\n " ;
203217
204218 my @env_list ;
205219 my @jobs ;
220+ my $hostupdate ;
206221
207222 if (defined ($reference )) {
208223 push (@env_list , $reference );
227242
228243 my $env_name = $environments -> getName($envitem );
229244
230- if ((lc $action eq ' enable' ) || (lc $action eq ' disable' ) || (lc $action eq ' refresh' )) {
245+ if ((lc $action eq ' enable' ) || (lc $action eq ' disable' ) || (lc $action eq ' refresh' ) ||
246+ (lc $action eq ' updatehost' ) ) {
231247
232248 if ( $action eq ' enable' ) {
233249 if ( $environments -> getStatus($envitem ) eq ' enabled' ) {
254270 $jobno = $environments -> refresh($envitem );
255271 }
256272
273+ if ( lc $action eq ' updatehost' ) {
274+ print " Checking environment for host update $env_name " ;
275+ $jobno = $environments -> updatehost($envitem , $host , $newhost );
276+ if (defined ($jobno )) {
277+ $hostupdate = 1;
278+ }
279+ }
280+
257281 if (defined ($jobno ) ) {
258282 print " Starting job $jobno for environment $env_name .\n " ;
259283 my $job = new Jobs_obj($engine_obj , $jobno , ' true' , $debug );
393417 }
394418 }
395419
420+
421+
396422 }
397423
398424 if (defined ($parallel ) && (scalar (@jobs ) > 0)) {
402428 }
403429 }
404430
431+ if (!defined ($hostupdate )) {
432+ # no environment found with a IP - need to report an error
433+ $ret = $ret + 1;
434+ }
435+
405436}
406437
407438exit $ret ;
@@ -413,7 +444,8 @@ =head1 SYNOPSIS
413444
414445 dx_ctl_env [ -engine|d <delphix identifier> | -all ] [ -configfile file ]
415446 [ -name env_name | -reference reference ]
416- -acton <enable|disable|refresh|adduser|addrepo|adddatabase|addlistener|deleteuser|deleterepo|deletedatabase|deletelistener>
447+ -acton <enable|disable|refresh|adduser|addrepo|adddatabase|addlistener
448+ |deleteuser|deleterepo|deletedatabase|deletelistener|updatehost>
417449 [-dbname dbname]
418450 [-instancename instancename]
419451 [-uniquename db_unique_name]
@@ -425,6 +457,8 @@ =head1 SYNOPSIS
425457 [-password password]
426458 [-repotype oracle|vfiles]
427459 [-repopath ORACLE_HOME]
460+ [-host name/ip of existing host to update]
461+ [-newhost new name/ip of the host]
428462 [-help|? ]
429463 [-debug ]
430464
@@ -457,7 +491,7 @@ =head2 Actions
457491
458492=over 1
459493
460- =item B<-action > <enable|disable|refresh|adduser|addrepo|adddatabase|addlistener|deleteuser|deleterepo|deletedatabase|deletelistener>
494+ =item B<-action > <enable|disable|refresh|adduser|addrepo|adddatabase|addlistener|deleteuser|deleterepo|deletedatabase|deletelistener|updatehost >
461495Run an action specified for environments selected by filter or all environments deployed on Delphix Engine
462496
463497=back
@@ -517,6 +551,13 @@ =head1 OPTIONS
517551=item B<-oraclebase path >
518552Oracle Base path
519553
554+ =item B<-host hostname/IP >
555+ Host name or IP from an environment to be updated.
556+ Not required if environment name is specified
557+
558+ =item B<-newhost hostname/IP >
559+ New Host name or IP of host being updated
560+
520561=item B<-help >
521562Print this screen
522563
@@ -608,4 +649,23 @@ =head1 EXAMPLES
608649 Deleting vfiles swingbench from environment LINUXSOURCE
609650 Database swingbench deleted from Unstructured Files
610651
652+ Chaging an IP of the environment
653+
654+ dx_ctl_env -d 53 -name linuxsource -newhost 172.16.200.130 -action updatehost
655+ Checking environment for host update linuxsource Starting job JOB-2850 for environment linuxsource.
656+ 0 - 30 - 40 - 80 - 100
657+ Job JOB-2850 finished with state: COMPLETED
658+
659+ Chaging an IP of particular host
660+
661+ dx_ctl_env -d 53 -host 172.16.200.130 -newhost 172.16.180.129 -action updatehost
662+ Checking environment for host update racattack121 Host with IP 172.16.200.130 not found
663+ Checking environment for host update racattack Host with IP 172.16.200.130 not found
664+ Checking environment for host update oracle18tgt Host with IP 172.16.200.130 not found
665+ Checking environment for host update oracle18 Host with IP 172.16.200.130 not found
666+ Checking environment for host update linuxsource Starting job JOB-2852 for environment linuxsource.
667+ 0 - 30 - 40 - 80 - 100
668+ Job JOB-2852 finished with state: COMPLETED
669+ Checking environment for host update linuxtarget Host with IP 172.16.200.130 not found
670+
611671=cut
0 commit comments