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.
@@ -32,7 +32,7 @@ use JSON;
32
32
use Toolkit_helpers qw ( logger) ;
33
33
34
34
# constructor
35
- # parameters
35
+ # parameters
36
36
# - dlpxObject - connection to DE
37
37
# - debug - debug flag (debug on if defined)
38
38
@@ -48,81 +48,81 @@ sub new {
48
48
_dlpxObject => $dlpxObject ,
49
49
_debug => $debug
50
50
};
51
-
51
+
52
52
bless ($self ,$classname );
53
-
53
+
54
54
$self -> loadTemplateList($debug );
55
55
return $self ;
56
56
}
57
57
58
58
59
59
# Procedure getTemplateByName
60
- # parameters:
61
- # - name
60
+ # parameters:
61
+ # - name
62
62
# Return template reference for particular name
63
63
64
64
sub getTemplateByName {
65
65
my $self = shift ;
66
66
my $name = shift ;
67
- logger($self -> {_debug }, " Entering Template_obj::getTemplateByName" ,1);
67
+ logger($self -> {_debug }, " Entering Template_obj::getTemplateByName" ,1);
68
68
my $ret ;
69
69
70
70
# print Dumper $$config;
71
71
72
72
for my $templateitem ( sort ( keys %{$self -> {_templates }} ) ) {
73
73
74
74
if ( $self -> getName($templateitem ) eq $name ) {
75
- $ret = $templateitem ;
75
+ $ret = $templateitem ;
76
76
}
77
77
}
78
78
79
79
return $ret ;
80
80
}
81
81
82
82
# Procedure getTemplate
83
- # parameters:
83
+ # parameters:
84
84
# - reference
85
85
# Return template hash for specific template reference
86
86
87
87
sub getTemplate {
88
88
my $self = shift ;
89
89
my $reference = shift ;
90
-
91
- logger($self -> {_debug }, " Entering Template_obj::getTemplate" ,1);
90
+
91
+ logger($self -> {_debug }, " Entering Template_obj::getTemplate" ,1);
92
92
93
93
my $templates = $self -> {_templates };
94
94
return $templates -> {$reference };
95
95
}
96
96
97
97
98
98
# Procedure getTemplateParameters
99
- # parameters:
99
+ # parameters:
100
100
# - reference
101
101
# Return template parmeters for specific template reference
102
102
103
103
sub getTemplateParameters {
104
104
my $self = shift ;
105
105
my $reference = shift ;
106
-
107
- logger($self -> {_debug }, " Entering Template_obj::getTemplateParameters" ,1);
106
+
107
+ logger($self -> {_debug }, " Entering Template_obj::getTemplateParameters" ,1);
108
108
109
109
my $templates = $self -> {_templates };
110
110
return $templates -> {$reference }-> {parameters };
111
111
}
112
112
113
113
# Procedure compare
114
- # parameters:
114
+ # parameters:
115
115
# - reference
116
116
# - hash with init.ora
117
- # Return three sets - array existing in template but not in VDB and
117
+ # Return three sets - array existing in template but not in VDB and
118
118
# array existing in VDB but not in template, hash differences
119
119
120
120
sub compare {
121
121
my $self = shift ;
122
122
my $reference = shift ;
123
123
my $init = shift ;
124
-
125
- logger($self -> {_debug }, " Entering Template_obj::compare" ,1);
124
+
125
+ logger($self -> {_debug }, " Entering Template_obj::compare" ,1);
126
126
127
127
my %restricted = (
128
128
active_instance_count => 1,
@@ -172,7 +172,7 @@ sub compare {
172
172
__streams_pool_size => 1,
173
173
_omf => 1
174
174
);
175
-
175
+
176
176
my %settodefault = (
177
177
filesystemio_options => 1,
178
178
audit_file_dest => 1,
@@ -192,7 +192,7 @@ sub compare {
192
192
log_archive_dest_6 => 1,
193
193
log_archive_dest_7 => 1,
194
194
log_archive_dest_8 => 1,
195
- log_archive_dest_9 => 1,
195
+ log_archive_dest_9 => 1,
196
196
log_archive_dest_10 => 1,
197
197
log_archive_dest_11 => 1,
198
198
log_archive_dest_12 => 1,
@@ -249,13 +249,13 @@ sub compare {
249
249
remote_listener => 1,
250
250
user_dump_dest => 1,
251
251
);
252
-
252
+
253
253
my %notintemplate ;
254
254
my %notininit ;
255
255
my %different ;
256
-
256
+
257
257
my $templatepar = $self -> getTemplateParameters($reference );
258
-
258
+
259
259
for my $par (sort keys %{$templatepar }) {
260
260
if (defined ($init -> {$par })) {
261
261
$init -> {$par } =~ s / ['|"]// g ;
@@ -269,9 +269,9 @@ sub compare {
269
269
} else {
270
270
$notininit {$par } = $templatepar -> {$par };
271
271
}
272
-
272
+
273
273
}
274
-
274
+
275
275
for my $par (sort keys %{$init }) {
276
276
if (!defined ($restricted {$par })) {
277
277
if (!defined ($templatepar -> {$par })) {
@@ -280,46 +280,46 @@ sub compare {
280
280
}
281
281
}
282
282
}
283
-
283
+
284
284
}
285
-
285
+
286
286
return (\%notininit , \%notintemplate , \%different );
287
-
288
-
287
+
288
+
289
289
}
290
290
291
291
292
292
# Procedure getTemplateList
293
- # parameters:
293
+ # parameters:
294
294
# Return template list
295
295
296
296
sub getTemplateList {
297
297
my $self = shift ;
298
298
my $reference = shift ;
299
-
300
- logger($self -> {_debug }, " Entering Template_obj::getTemplateList" ,1);
299
+
300
+ logger($self -> {_debug }, " Entering Template_obj::getTemplateList" ,1);
301
301
302
302
return keys %{$self -> {_templates }};
303
303
}
304
304
305
305
306
306
# Procedure getName
307
- # parameters:
307
+ # parameters:
308
308
# - reference
309
309
# Return template name for specific template reference
310
310
311
311
sub getName {
312
312
my $self = shift ;
313
313
my $reference = shift ;
314
-
315
- logger($self -> {_debug }, " Entering Template_obj::getName" ,1);
314
+
315
+ logger($self -> {_debug }, " Entering Template_obj::getName" ,1);
316
316
317
317
my $templates = $self -> {_templates };
318
318
return $templates -> {$reference }-> {name };
319
319
}
320
320
321
321
# Procedure exportTemplate
322
- # parameters:
322
+ # parameters:
323
323
# - reference
324
324
# - location - directory
325
325
# Return 0 if no errors
@@ -329,7 +329,7 @@ sub exportTemplate {
329
329
my $reference = shift ;
330
330
my $location = shift ;
331
331
332
- logger($self -> {_debug }, " Entering Template_obj::exportTemplate" ,1);
332
+ logger($self -> {_debug }, " Entering Template_obj::exportTemplate" ,1);
333
333
334
334
my $filename = $location . " /" . $self -> getName($reference ) . " .template" ;
335
335
@@ -347,15 +347,15 @@ sub exportTemplate {
347
347
}
348
348
349
349
# Procedure importTemplate
350
- # parameters:
350
+ # parameters:
351
351
# - location - file name
352
352
# Return 0 if no errors
353
353
354
354
sub importTemplate {
355
355
my $self = shift ;
356
356
my $location = shift ;
357
357
358
- logger($self -> {_debug }, " Entering Template_obj::importTemplate" ,1);
358
+ logger($self -> {_debug }, " Entering Template_obj::importTemplate" ,1);
359
359
360
360
my $filename = $location ;
361
361
@@ -366,14 +366,18 @@ sub importTemplate {
366
366
local $/ = undef ;
367
367
my $json = JSON-> new();
368
368
$loadedTemplate = $json -> decode(<$FD >);
369
-
369
+
370
370
close $FD ;
371
371
372
372
373
373
374
374
delete $loadedTemplate -> {reference };
375
375
delete $loadedTemplate -> {namespace };
376
376
377
+ if (!defined ($loadedTemplate -> {description })) {
378
+ delete $loadedTemplate -> {description };
379
+ };
380
+
377
381
$self -> loadTemplateList();
378
382
379
383
if (defined ($self -> getTemplateByName($loadedTemplate -> {name }))) {
@@ -387,7 +391,7 @@ sub importTemplate {
387
391
388
392
my $operation = ' resources/json/delphix/database/template' ;
389
393
390
- my ($result , $result_fmt , $retcode ) = $self -> {_dlpxObject }-> postJSONData($operation , $json_data );
394
+ my ($result , $result_fmt , $retcode ) = $self -> {_dlpxObject }-> postJSONData($operation , $json_data );
391
395
392
396
if ($result -> {status } eq ' OK' ) {
393
397
print " Import completed\n " ;
@@ -400,15 +404,15 @@ sub importTemplate {
400
404
401
405
402
406
# Procedure updateTemplate
403
- # parameters:
407
+ # parameters:
404
408
# - location - file name
405
409
# Return 0 if no errors
406
410
407
411
sub updateTemplate {
408
412
my $self = shift ;
409
413
my $location = shift ;
410
414
411
- logger($self -> {_debug }, " Entering Template_obj::updateTemplate" ,1);
415
+ logger($self -> {_debug }, " Entering Template_obj::updateTemplate" ,1);
412
416
413
417
my $filename = $location ;
414
418
@@ -419,7 +423,7 @@ sub updateTemplate {
419
423
local $/ = undef ;
420
424
my $json = JSON-> new();
421
425
$loadedTemplate = $json -> decode(<$FD >);
422
-
426
+
423
427
close $FD ;
424
428
425
429
delete $loadedTemplate -> {reference };
@@ -432,7 +436,7 @@ sub updateTemplate {
432
436
if (! defined ($self -> getTemplateByName($loadedTemplate -> {name }))) {
433
437
print " Template " . $loadedTemplate -> {name } . " from file $filename doesn't exist. Can't update.\n " ;
434
438
return 1;
435
- }
439
+ }
436
440
437
441
my $reference = $self -> getTemplateByName($loadedTemplate -> {name });
438
442
@@ -442,7 +446,7 @@ sub updateTemplate {
442
446
443
447
my $operation = ' resources/json/delphix/database/template/' . $reference ;
444
448
445
- my ($result , $result_fmt , $retcode ) = $self -> {_dlpxObject }-> postJSONData($operation , $json_data );
449
+ my ($result , $result_fmt , $retcode ) = $self -> {_dlpxObject }-> postJSONData($operation , $json_data );
446
450
447
451
if ($result -> {status } eq ' OK' ) {
448
452
print " Update completed\n " ;
@@ -458,10 +462,10 @@ sub updateTemplate {
458
462
# parameters: none
459
463
# Load a list of template objects from Delphix Engine
460
464
461
- sub loadTemplateList
465
+ sub loadTemplateList
462
466
{
463
467
my $self = shift ;
464
- logger($self -> {_debug }, " Entering Template_obj::loadTemplateList" ,1);
468
+ logger($self -> {_debug }, " Entering Template_obj::loadTemplateList" ,1);
465
469
466
470
my $operation = " resources/json/delphix/database/template" ;
467
471
my ($result , $result_fmt ) = $self -> {_dlpxObject }-> getJSONResult($operation );
@@ -473,10 +477,10 @@ sub loadTemplateList
473
477
474
478
for my $templateitem (@res ) {
475
479
$templates -> {$templateitem -> {reference }} = $templateitem ;
476
- }
480
+ }
477
481
} else {
478
482
print " No data returned for $operation . Try to increase timeout \n " ;
479
483
}
480
484
}
481
485
482
- 1;
486
+ 1;
0 commit comments