1
- #
1
+ #
2
2
# Licensed under the Apache License, Version 2.0 (the "License");
3
3
# you may not use this file except in compliance with the License.
4
4
# You may obtain a copy of the License at
5
- #
5
+ #
6
6
# http://www.apache.org/licenses/LICENSE-2.0
7
- #
7
+ #
8
8
# Unless required by applicable law or agreed to in writing, software
9
9
# distributed under the License is distributed on an "AS IS" BASIS,
10
10
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
# See the License for the specific language governing permissions and
12
12
# limitations under the License.
13
13
#
14
14
# Copyright (c) 2015,2016 by Delphix. All rights reserved.
15
- #
15
+ #
16
16
# Program Name : dx_ctl_replication.pl
17
17
# Description : Get information about replication
18
18
# Author : Marcin Przepiorowski
19
19
# Created : 28 Sept 2016 (v2.2.0)
20
20
#
21
- #
21
+ #
22
22
23
23
use strict;
24
24
use warnings;
40
40
my $version = $Toolkit_helpers::version ;
41
41
42
42
GetOptions(
43
- ' help|?' => \(my $help ),
43
+ ' help|?' => \(my $help ),
44
44
' d|engine=s' => \(my $dx_host ),
45
45
' profilename=s' => \(my $profilename ),
46
- ' nowait' => \(my $nowait ),
47
- ' debug:i' => \(my $debug ),
46
+ ' nowait' => \(my $nowait ),
47
+ ' debug:i' => \(my $debug ),
48
48
' dever=s' => \(my $dever ),
49
+ ' safe' => \(my $safe ),
49
50
' all' => (\my $all ),
50
51
' version' => \(my $print_version ),
51
52
' configfile|c=s' => \(my $config_file )
52
53
) or pod2usage(-verbose => 1, -input => \*DATA );
53
54
54
55
pod2usage(-verbose => 2, -input => \*DATA ) && exit if $help ;
55
- die " $version \n " if $print_version ;
56
+ die " $version \n " if $print_version ;
56
57
57
58
my $engine_obj = new Engine ($dever , $debug );
58
59
$engine_obj -> load_config($config_file );
67
68
if (!defined ($profilename )) {
68
69
print " Profile name is mandatory. Please specify -profilename parameter \n " ;
69
70
pod2usage(-verbose => 1, -input => \*DATA );
70
- exit (1);
71
+ exit (1);
71
72
}
72
73
73
74
74
75
# 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 );
76
77
77
78
my $ret = 0;
78
79
92
93
}
93
94
my $jobno ;
94
95
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
+
103
118
}
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
+ }
108
127
} 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
+ }
110
134
}
111
135
}
112
136
113
137
114
138
139
+
140
+
115
141
}
116
142
117
143
122
148
123
149
=head1 SYNOPSIS
124
150
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|?]
129
155
[-debug ]
130
156
131
157
=head1 DESCRIPTION
@@ -160,10 +186,10 @@ =head1 OPTIONS
160
186
161
187
=over 3
162
188
163
- =item B<-nowait >
189
+ =item B<-nowait >
164
190
Don't wait for a replication job to complete. Job will be running in backgroud.
165
191
166
- =item B<-help >
192
+ =item B<-help >
167
193
Print this screen
168
194
169
195
=item B<-debug >
@@ -179,6 +205,3 @@ =head1 Example
179
205
Replication job JOB-7425 started in background
180
206
181
207
=cut
182
-
183
-
184
-
0 commit comments