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.
29
29
use Data::Dumper;
30
30
use warnings;
31
31
use strict;
32
+ use version;
32
33
33
34
my $abspath = $FindBin::Bin ;
34
35
50
51
my $diff = 60;
51
52
52
53
GetOptions(
53
- ' help|?' => \(my $help ),
54
- ' d|engine=s' => \(my $dx_host ),
55
- ' action=s' => \(my $action ),
54
+ ' help|?' => \(my $help ),
55
+ ' d|engine=s' => \(my $dx_host ),
56
+ ' action=s' => \(my $action ),
56
57
' template_name=s' => \(my $template_name ),
57
58
' container_name=s' => \(my $container_name ),
58
59
' bookmark_name=s' => \(my $bookmark_name ),
72
73
) or pod2usage(-verbose => 1, -input => \*DATA );
73
74
74
75
pod2usage(-verbose => 2, -input => \*DATA ) && exit if $help ;
75
- die " $version \n " if $print_version ;
76
+ die " $version \n " if $print_version ;
76
77
77
78
my $engine_obj = new Engine ($dever , $debug );
78
79
$engine_obj -> load_config($config_file );
126
127
if (defined ($snapshots ) && (!defined ($source ))) {
127
128
print " Option snapshot require a source to be defined \n " ;
128
129
pod2usage(-verbose => 1, -input => \*DATA );
129
- exit (1);
130
+ exit (1);
130
131
}
131
132
132
133
145
146
}
146
147
147
148
# this array will have all engines to go through (if -d is specified it will be only one engine)
148
- my $engine_list = Toolkit_helpers::get_engine_list($all , $dx_host , $engine_obj );
149
+ my $engine_list = Toolkit_helpers::get_engine_list($all , $dx_host , $engine_obj );
149
150
150
151
my $ret = 0;
151
152
168
169
if (defined ($container_name )) {
169
170
$datalayout = new JS_container_obj ( $engine_obj , $datalayout_ref , $debug );
170
171
$datalayout_ref = $datalayout -> getJSContainerByName($container_name );
171
- }
172
+ }
172
173
}
173
174
174
175
$bookmarks = new JS_bookmark_obj ( $engine_obj , undef , undef , $debug );
175
-
176
+
176
177
177
178
if (!defined ($datalayout_ref )) {
178
179
print " Can't find template with a name $template_name on engine $engine \n " ;
179
180
$ret = $ret + 1;
180
- next ;
181
+ next ;
181
182
}
182
183
183
-
184
+
184
185
my $branchs = new JS_branch_obj ( $engine_obj , $datalayout_ref , $debug );
185
186
186
187
my $active_branch ;
194
195
}
195
196
} else {
196
197
$active_branch = $datalayout -> getJSActiveBranch($datalayout_ref );
197
- }
198
+ }
198
199
199
200
200
201
if (lc $action eq ' create' ) {
201
202
202
203
my $datasources = new JS_datasource_obj ( $engine_obj , $datalayout_ref , undef , undef );
203
204
204
205
if ( defined ($snapshots ) ) {
205
-
206
+
206
207
207
208
my $ds_ref = $datasources -> getJSDataSourceByName($source );
208
209
222
223
for my $snapitem ( @{ $snapshot -> getSnapshots() }) {
223
224
my $time = $snapshot -> getSnapshotCreationTime($snapitem );
224
225
my $goodtime ;
225
- if ($engine_obj -> getApi() lt " 1.8" ) {
226
+ if (version -> parse( $engine_obj -> getApi()) < version -> parse( 1.8.0)) {
226
227
$goodtime = $datasources -> checkTime($datalayout_ref , $time );
227
228
} else {
228
229
$goodtime = $datasources -> checkTime($active_branch , $time );
235
236
last ;
236
237
}
237
238
}
238
- }
239
+ }
239
240
240
241
if ((lc $snapshots eq ' last' ) || (lc $snapshots eq ' both' )) {
241
242
my $last_time = (@{ $snapshot -> getSnapshots() })[-1];
242
243
243
244
my $time = $snapshot -> getSnapshotCreationTime($last_time );
244
245
my $goodtime ;
245
- if ($engine_obj -> getApi() lt " 1.8" ) {
246
+ if (version -> parse( $engine_obj -> getApi()) < version -> parse( 1.8.0)) {
246
247
$goodtime = $datasources -> checkTime($datalayout_ref , $time );
247
248
} else {
248
249
$goodtime = $datasources -> checkTime($active_branch , $time );
260
261
for my $snapitem ( @{ $snapshot -> getSnapshots() }) {
261
262
my $time = $snapshot -> getSnapshotCreationTime($snapitem );
262
263
my $goodtime ;
263
- if ($engine_obj -> getApi() lt " 1.8" ) {
264
+ if (version -> parse( $engine_obj -> getApi()) < version -> parse( 1.8.0)) {
264
265
$goodtime = $datasources -> checkTime($datalayout_ref , $time );
265
266
} else {
266
267
$goodtime = $datasources -> checkTime($active_branch , $time );
273
274
}
274
275
}
275
276
}
276
-
277
+
277
278
278
279
for my $bookname_item (sort (keys %bookmark_times_hash )) {
279
280
300
301
$bookmark_time = $operations -> getEndTime($firstop );
301
302
302
303
$zulu = 1;
303
-
304
+
304
305
} else {
305
306
print " Can't find a first operation for template or container \n " ;
306
307
$ret = $ret + 1;
336
337
337
338
if (!defined ($bookmarks )) {
338
339
$bookmarks = new JS_bookmark_obj ( $engine_obj , undef , undef , $debug );
339
- }
340
-
340
+ }
341
+
341
342
342
343
my @bookmark_array ;
343
344
@@ -386,7 +387,7 @@ sub create {
386
387
my $bookmark_time = shift ;
387
388
my $zulu = shift ;
388
389
my $expireat = shift ;
389
-
390
+
390
391
if (defined ($expireat )) {
391
392
my $tz = $engine_obj -> getTimezone();
392
393
$expireat = Toolkit_helpers::convert_to_utc($expireat , $tz , undef , 1);
@@ -417,12 +418,12 @@ =head1 SYNOPSIS
417
418
dx_ctl_js_bookmarks [ -engine|d <delphix identifier> | -all ] [ -configfile file ]
418
419
-action create | remove
419
420
-template_name template_name
420
- -container_name container_name
421
- -bookmark_name bookmark_name
421
+ -container_name container_name
422
+ -bookmark_name bookmark_name
422
423
[-bookmark_time "YYYY-MM-DD HH24:MI:SS" | first | latest ]
423
424
[-snapshots first | last | both | all]
424
425
[-source source_name]
425
- [-container_name container_name]
426
+ [-container_name container_name]
426
427
[-expireat timestamp ]
427
428
[ --help|? ] [ -debug ]
428
429
@@ -456,7 +457,7 @@ =head2 Options
456
457
=over 4
457
458
458
459
=item B<-action action_name >
459
- Action name. Allowed values are :
460
+ Action name. Allowed values are :
460
461
461
462
create - to create bookmark
462
463
@@ -506,7 +507,7 @@ =head1 OPTIONS
506
507
507
508
=over 3
508
509
509
- =item B<-help >
510
+ =item B<-help >
510
511
Print this screen
511
512
512
513
=item B<-debug >
@@ -517,8 +518,8 @@ =head1 OPTIONS
517
518
518
519
=head1 EXAMPLES
519
520
520
- Create template bookmarks for all snapshots for template "template"" and source "oracle", bookmarks name starts with prefix "pre"
521
- plus time of snapshot,
521
+ Create template bookmarks for all snapshots for template "template"" and source "oracle", bookmarks name starts with prefix "pre"
522
+ plus time of snapshot,
522
523
523
524
dx_ctl_js_bookmarks -d Landshark5 -bookmark_name "pre" -template_name template -snapshots all -source oracle -action create
524
525
Starting job JOB-7623 for bookmark pre-2016-10-12 12:02:31.
@@ -532,7 +533,7 @@ =head1 EXAMPLES
532
533
5 - 100
533
534
Job JOB-7625 finished with state: COMPLETED
534
535
535
- Create template bookmark for particular time
536
+ Create template bookmark for particular time
536
537
537
538
dx_ctl_js_bookmarks -d Landshark5 -bookmark_name "fixeddate" -template_name template -bookmark_time "2016-10-12 13:05:02" -branch_name master -action create
538
539
Starting job JOB-7626 for bookmark fixeddate.
@@ -554,6 +555,3 @@ =head1 EXAMPLES
554
555
Job JOB-7629 finished with state: COMPLETED
555
556
556
557
=cut
557
-
558
-
559
-
0 commit comments