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.
2929use Data::Dumper;
3030use warnings;
3131use strict;
32+ use version;
3233
3334my $abspath = $FindBin::Bin ;
3435
5051my $diff = 60;
5152
5253GetOptions(
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 ),
5657 ' template_name=s' => \(my $template_name ),
5758 ' container_name=s' => \(my $container_name ),
5859 ' bookmark_name=s' => \(my $bookmark_name ),
7273) or pod2usage(-verbose => 1, -input => \*DATA );
7374
7475pod2usage(-verbose => 2, -input => \*DATA ) && exit if $help ;
75- die " $version \n " if $print_version ;
76+ die " $version \n " if $print_version ;
7677
7778my $engine_obj = new Engine ($dever , $debug );
7879$engine_obj -> load_config($config_file );
126127 if (defined ($snapshots ) && (!defined ($source ))) {
127128 print " Option snapshot require a source to be defined \n " ;
128129 pod2usage(-verbose => 1, -input => \*DATA );
129- exit (1);
130+ exit (1);
130131 }
131132
132133
145146}
146147
147148# 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 );
149150
150151my $ret = 0;
151152
168169 if (defined ($container_name )) {
169170 $datalayout = new JS_container_obj ( $engine_obj , $datalayout_ref , $debug );
170171 $datalayout_ref = $datalayout -> getJSContainerByName($container_name );
171- }
172+ }
172173 }
173174
174175 $bookmarks = new JS_bookmark_obj ( $engine_obj , undef , undef , $debug );
175-
176+
176177
177178 if (!defined ($datalayout_ref )) {
178179 print " Can't find template with a name $template_name on engine $engine \n " ;
179180 $ret = $ret + 1;
180- next ;
181+ next ;
181182 }
182183
183-
184+
184185 my $branchs = new JS_branch_obj ( $engine_obj , $datalayout_ref , $debug );
185186
186187 my $active_branch ;
194195 }
195196 } else {
196197 $active_branch = $datalayout -> getJSActiveBranch($datalayout_ref );
197- }
198+ }
198199
199200
200201 if (lc $action eq ' create' ) {
201202
202203 my $datasources = new JS_datasource_obj ( $engine_obj , $datalayout_ref , undef , undef );
203204
204205 if ( defined ($snapshots ) ) {
205-
206+
206207
207208 my $ds_ref = $datasources -> getJSDataSourceByName($source );
208209
222223 for my $snapitem ( @{ $snapshot -> getSnapshots() }) {
223224 my $time = $snapshot -> getSnapshotCreationTime($snapitem );
224225 my $goodtime ;
225- if ($engine_obj -> getApi() lt " 1.8" ) {
226+ if (version -> parse( $engine_obj -> getApi()) < version -> parse( 1.8.0)) {
226227 $goodtime = $datasources -> checkTime($datalayout_ref , $time );
227228 } else {
228229 $goodtime = $datasources -> checkTime($active_branch , $time );
235236 last ;
236237 }
237238 }
238- }
239+ }
239240
240241 if ((lc $snapshots eq ' last' ) || (lc $snapshots eq ' both' )) {
241242 my $last_time = (@{ $snapshot -> getSnapshots() })[-1];
242243
243244 my $time = $snapshot -> getSnapshotCreationTime($last_time );
244245 my $goodtime ;
245- if ($engine_obj -> getApi() lt " 1.8" ) {
246+ if (version -> parse( $engine_obj -> getApi()) < version -> parse( 1.8.0)) {
246247 $goodtime = $datasources -> checkTime($datalayout_ref , $time );
247248 } else {
248249 $goodtime = $datasources -> checkTime($active_branch , $time );
260261 for my $snapitem ( @{ $snapshot -> getSnapshots() }) {
261262 my $time = $snapshot -> getSnapshotCreationTime($snapitem );
262263 my $goodtime ;
263- if ($engine_obj -> getApi() lt " 1.8" ) {
264+ if (version -> parse( $engine_obj -> getApi()) < version -> parse( 1.8.0)) {
264265 $goodtime = $datasources -> checkTime($datalayout_ref , $time );
265266 } else {
266267 $goodtime = $datasources -> checkTime($active_branch , $time );
273274 }
274275 }
275276 }
276-
277+
277278
278279 for my $bookname_item (sort (keys %bookmark_times_hash )) {
279280
300301 $bookmark_time = $operations -> getEndTime($firstop );
301302
302303 $zulu = 1;
303-
304+
304305 } else {
305306 print " Can't find a first operation for template or container \n " ;
306307 $ret = $ret + 1;
336337
337338 if (!defined ($bookmarks )) {
338339 $bookmarks = new JS_bookmark_obj ( $engine_obj , undef , undef , $debug );
339- }
340-
340+ }
341+
341342
342343 my @bookmark_array ;
343344
@@ -386,7 +387,7 @@ sub create {
386387 my $bookmark_time = shift ;
387388 my $zulu = shift ;
388389 my $expireat = shift ;
389-
390+
390391 if (defined ($expireat )) {
391392 my $tz = $engine_obj -> getTimezone();
392393 $expireat = Toolkit_helpers::convert_to_utc($expireat , $tz , undef , 1);
@@ -417,12 +418,12 @@ =head1 SYNOPSIS
417418 dx_ctl_js_bookmarks [ -engine|d <delphix identifier> | -all ] [ -configfile file ]
418419 -action create | remove
419420 -template_name template_name
420- -container_name container_name
421- -bookmark_name bookmark_name
421+ -container_name container_name
422+ -bookmark_name bookmark_name
422423 [-bookmark_time "YYYY-MM-DD HH24:MI:SS" | first | latest ]
423424 [-snapshots first | last | both | all]
424425 [-source source_name]
425- [-container_name container_name]
426+ [-container_name container_name]
426427 [-expireat timestamp ]
427428 [ --help|? ] [ -debug ]
428429
@@ -456,7 +457,7 @@ =head2 Options
456457=over 4
457458
458459=item B<-action action_name >
459- Action name. Allowed values are :
460+ Action name. Allowed values are :
460461
461462create - to create bookmark
462463
@@ -506,7 +507,7 @@ =head1 OPTIONS
506507
507508=over 3
508509
509- =item B<-help >
510+ =item B<-help >
510511Print this screen
511512
512513=item B<-debug >
@@ -517,8 +518,8 @@ =head1 OPTIONS
517518
518519=head1 EXAMPLES
519520
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,
522523
523524 dx_ctl_js_bookmarks -d Landshark5 -bookmark_name "pre" -template_name template -snapshots all -source oracle -action create
524525 Starting job JOB-7623 for bookmark pre-2016-10-12 12:02:31.
@@ -532,7 +533,7 @@ =head1 EXAMPLES
532533 5 - 100
533534 Job JOB-7625 finished with state: COMPLETED
534535
535- Create template bookmark for particular time
536+ Create template bookmark for particular time
536537
537538 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
538539 Starting job JOB-7626 for bookmark fixeddate.
@@ -554,6 +555,3 @@ =head1 EXAMPLES
554555 Job JOB-7629 finished with state: COMPLETED
555556
556557=cut
557-
558-
559-
0 commit comments