1- #
1+ #
22# Licensed under the Apache License, Version 2.0 (the "License");
33# you may not use this file except in compliance with the License.
44# You may obtain a copy of the License at
5- #
5+ #
66# http://www.apache.org/licenses/LICENSE-2.0
7- #
7+ #
88# Unless required by applicable law or agreed to in writing, software
99# distributed under the License is distributed on an "AS IS" BASIS,
1010# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111# See the License for the specific language governing permissions and
1212# limitations under the License.
1313#
1414# Copyright (c) 2015,2016 by Delphix. All rights reserved.
15- #
15+ #
1616# Program Name : dx_ctl_replication.pl
1717# Description : Get information about replication
1818# Author : Marcin Przepiorowski
1919# Created : 28 Sept 2016 (v2.2.0)
2020#
21- #
21+ #
2222
2323use strict;
2424use warnings;
4040my $version = $Toolkit_helpers::version ;
4141
4242GetOptions(
43- ' help|?' => \(my $help ),
43+ ' help|?' => \(my $help ),
4444 ' d|engine=s' => \(my $dx_host ),
4545 ' profilename=s' => \(my $profilename ),
46- ' nowait' => \(my $nowait ),
47- ' debug:i' => \(my $debug ),
46+ ' nowait' => \(my $nowait ),
47+ ' debug:i' => \(my $debug ),
4848 ' dever=s' => \(my $dever ),
49+ ' safe' => \(my $safe ),
4950 ' all' => (\my $all ),
5051 ' version' => \(my $print_version ),
5152 ' configfile|c=s' => \(my $config_file )
5253) or pod2usage(-verbose => 1, -input => \*DATA );
5354
5455pod2usage(-verbose => 2, -input => \*DATA ) && exit if $help ;
55- die " $version \n " if $print_version ;
56+ die " $version \n " if $print_version ;
5657
5758my $engine_obj = new Engine ($dever , $debug );
5859$engine_obj -> load_config($config_file );
6768if (!defined ($profilename )) {
6869 print " Profile name is mandatory. Please specify -profilename parameter \n " ;
6970 pod2usage(-verbose => 1, -input => \*DATA );
70- exit (1);
71+ exit (1);
7172}
7273
7374
7475# this array will have all engines to go through (if -d is specified it will be only one engine)
75- my $engine_list = Toolkit_helpers::get_engine_list($all , $dx_host , $engine_obj );
76+ my $engine_list = Toolkit_helpers::get_engine_list($all , $dx_host , $engine_obj );
7677
7778my $ret = 0;
7879
9293 }
9394 my $jobno ;
9495 if (defined ($ref )) {
95- $jobno = $replication -> replicate($ref );
96- }
97-
98- if (defined ($nowait )) {
99- if (defined ($jobno )) {
100- print " Replication job $jobno started in background\n " ;
101- } else {
102- print " Problem with defining a replication job. Please run with -debug\n " ;
96+
97+ if (defined ($safe )) {
98+ my $lastjob = $replication -> getLastJob($ref , 1);
99+ my $actions = new Action_obj($engine_obj , $lastjob -> {StartTime }, undef , undef , undef , $debug );
100+ $actions -> loadActionList();
101+ my @deletelist = @{$actions -> getActionList(' asc' , ' DB_DELETE' , undef )};
102+
103+ if (scalar (@deletelist )>0) {
104+ print " There was a delete database operation on primary engine. List of databases:\n " ;
105+ my $name ;
106+ for my $ar (@deletelist ) {
107+ $name = $actions -> getDetails($ar );
108+ $name =~ s / Delete dataset// ;
109+ $name =~ s / "// g ;
110+ $name =~ s /\. // ;
111+ print Toolkit_helpers::trim($name ) . " \n " ;
112+ }
113+ print " Replication won't be kicked off\n " ;
114+ $ret = $ret + 1;
115+ next ;
116+ }
117+
103118 }
104- } else {
105- if (defined ($jobno )) {
106- print " Starting replication job $jobno \n " ;
107- $ret = $ret + Toolkit_helpers::waitForJob($engine_obj , $jobno , " Replication job finished" ," Problem with replication" );
119+
120+ $jobno = $replication -> replicate($ref );
121+ if (defined ($nowait )) {
122+ if (defined ($jobno )) {
123+ print " Replication job $jobno started in background\n " ;
124+ } else {
125+ print " Problem with defining a replication job. Please run with -debug\n " ;
126+ }
108127 } else {
109- print " Problem with defining a replication job. Please run with -debug\n " ;
128+ if (defined ($jobno )) {
129+ print " Starting replication job $jobno \n " ;
130+ $ret = $ret + Toolkit_helpers::waitForJob($engine_obj , $jobno , " Replication job finished" ," Problem with replication" );
131+ } else {
132+ print " Problem with defining a replication job. Please run with -debug\n " ;
133+ }
110134 }
111135 }
112136
113137
114138
139+
140+
115141}
116142
117143
122148
123149=head1 SYNOPSIS
124150
125- dx_ctl_replication [-engine|d <delphix identifier> | -all ]
126- -profilename profile
127- [-nowait]
128- [-help|?]
151+ dx_ctl_replication [-engine|d <delphix identifier> | -all ]
152+ -profilename profile
153+ [-nowait]
154+ [-help|?]
129155 [-debug ]
130156
131157=head1 DESCRIPTION
@@ -160,10 +186,10 @@ =head1 OPTIONS
160186
161187=over 3
162188
163- =item B<-nowait >
189+ =item B<-nowait >
164190Don't wait for a replication job to complete. Job will be running in backgroud.
165191
166- =item B<-help >
192+ =item B<-help >
167193Print this screen
168194
169195=item B<-debug >
@@ -179,6 +205,3 @@ =head1 Example
179205 Replication job JOB-7425 started in background
180206
181207=cut
182-
183-
184-
0 commit comments