Skip to content

Commit 0f67b20

Browse files
author
Marcin Przepiorowski
committed
Fix for filemapping issue #50
1 parent 3c75174 commit 0f67b20

File tree

3 files changed

+81
-69
lines changed

3 files changed

+81
-69
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.3.6
2+
3+
### Changed
4+
- fix for file mapping API changes in 5.2
5+
6+
17
## 2.3.6-rc2
28

39
### Added

bin/dx_v2p.pl

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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.
@@ -45,15 +45,15 @@
4545
my $timestamp = 'LATEST_SNAPSHOT';
4646

4747
GetOptions(
48-
'help|?' => \(my $help),
49-
'd|engine=s' => \(my $dx_host),
48+
'help|?' => \(my $help),
49+
'd|engine=s' => \(my $dx_host),
5050
'sourcename=s' => \(my $sourcename),
51-
'srcgroup=s' => \(my $srcgroup),
52-
'dbname=s' => \(my $dbname),
53-
'instname=s' => \(my $instname),
54-
'uniqname=s' => \(my $uniqname),
55-
'environment=s' => \(my $environment),
56-
'type=s' => \(my $type),
51+
'srcgroup=s' => \(my $srcgroup),
52+
'dbname=s' => \(my $dbname),
53+
'instname=s' => \(my $instname),
54+
'uniqname=s' => \(my $uniqname),
55+
'environment=s' => \(my $environment),
56+
'type=s' => \(my $type),
5757
'envinst=s' => \(my $envinst),
5858
'template=s' => \(my $template),
5959
'mapfile=s' =>\(my $map_file),
@@ -71,7 +71,7 @@
7171
'dspusecompression' => \(my $dspusecompression),
7272
'dspuseencryption' => \(my $dspuseencryption),
7373
'dever=s' => \(my $dever),
74-
'debug:n' => \(my $debug),
74+
'debug:n' => \(my $debug),
7575
'all' => (\my $all),
7676
'version' => \(my $print_version),
7777
'configfile|c=s' => \(my $config_file)
@@ -80,7 +80,7 @@
8080

8181

8282
pod2usage(-verbose => 2, -input=>\*DATA) && exit if $help;
83-
die "$version\n" if $print_version;
83+
die "$version\n" if $print_version;
8484

8585

8686
my $engine_obj = new Engine ($dever, $debug);
@@ -109,12 +109,12 @@
109109
if ( ( ( $type eq 'oracle') || ( $type eq 'mssql') ) && (! defined($targetDirectory)) ) {
110110
print "Option targetDirectory is required. \n";
111111
pod2usage(-verbose => 1, -input=>\*DATA);
112-
exit (1);
112+
exit (1);
113113
}
114114

115115

116116
# this array will have all engines to go through (if -d is specified it will be only one engine)
117-
my $engine_list = Toolkit_helpers::get_engine_list($all, $dx_host, $engine_obj);
117+
my $engine_list = Toolkit_helpers::get_engine_list($all, $dx_host, $engine_obj);
118118

119119
my $ret = 0;
120120

@@ -150,7 +150,7 @@
150150
}
151151

152152
my $source = ($databases->getDB($source_ref->[0]));
153-
153+
154154

155155
# create a new DB object
156156
if ( $type eq 'oracle' ) {
@@ -186,13 +186,13 @@
186186
if ( $db->setTemplate($template) ) {
187187
print "Template $template not found. V2P process won't be created\n";
188188
exit(1);
189-
}
189+
}
190190
}
191191

192192
if ( defined($map_file) ) {
193193
my $filemap_obj = new FileMap($engine_obj,$debug);
194194
$filemap_obj->loadMapFile($map_file);
195-
$filemap_obj->setSource($sourcename);
195+
$filemap_obj->setSource($source);
196196
if ($filemap_obj->validate()) {
197197
die ("Problem with mapping file. V2P process won't be created.")
198198
}
@@ -215,28 +215,28 @@
215215
$db->setDSP($dspconnections, $dspusecompression, $dspuseencryption);
216216
$jobno = $db->v2pSI($environment,$envinst);
217217

218-
}
218+
}
219219
elsif ($type eq 'mssql') {
220220

221221
if ( $db->setFileSystemLayout($targetDirectory,$archiveDirectory,$dataDirectory,$externalDirectory,$scriptDirectory,$tempDirectory) ) {
222222
print "Problem with export file system layout. Is targetDiretory and dataDirectory set ?\n";
223223
exit(1);
224224
}
225-
225+
226226
if (defined($norecovery)) {
227227
$db->setNoRecovery();
228228
}
229229
$jobno = $db->v2p($environment,$envinst);
230-
}
230+
}
231231
elsif ($type eq 'sybase') {
232232
if (defined($norecovery)) {
233233
$db->setNoRecovery();
234234
}
235235
$jobno = $db->v2p($environment,$envinst);
236-
}
236+
}
237237

238238
$ret = $ret + Toolkit_helpers::waitForJob($engine_obj, $jobno, "V2P finished.","Problem with V2P process");
239-
239+
240240
}
241241

242242

@@ -247,28 +247,28 @@
247247
=head1 SYNOPSIS
248248
249249
dx_v2p [ -engine|d <delphix identifier> | -all ] [ -configfile file ]
250-
-sourcename src_name
251-
-dbname db_name
252-
-environment environment_name
253-
-type oracle|mssql|sybase
250+
-sourcename src_name
251+
-dbname db_name
252+
-environment environment_name
253+
-type oracle|mssql|sybase
254254
-envinst OracleHome/MSSQLinstance/SybaseInstance
255-
[ -targetDirectory target_directory ]
255+
[ -targetDirectory target_directory ]
256256
[ -timestamp LATEST_SNAPSHOT|LATEST_POINT|time_stamp ]
257-
[ -template template_name ]
258-
[ -mapfile mapping_file ]
257+
[ -template template_name ]
258+
[ -mapfile mapping_file ]
259259
[ -norecovery ]
260260
[ -noopen ]
261-
[ -instname SID ]
262-
[ -uniqname db_unique_name ]
263-
[ -archiveDirectory arch_directory ]
261+
[ -instname SID ]
262+
[ -uniqname db_unique_name ]
263+
[ -archiveDirectory arch_directory ]
264264
[ -dataDirectory data_dir ]
265-
[ -externalDirectory external_dir ]
265+
[ -externalDirectory external_dir ]
266266
[ -tempDirectory temp_dir ]
267267
[ -dspconnections=n ]
268268
[ -dspusecompression ]
269269
[ -dspuseencryption ]
270270
[ -concurrentfiles=n ]
271-
[ -help]
271+
[ -help]
272272
[ -debug]
273273
274274
@@ -373,7 +373,7 @@ =head1 OPTIONS
373373
374374
=over 2
375375
376-
=item B<-help>
376+
=item B<-help>
377377
Print this screen
378378
379379
=item B<-debug>
@@ -383,10 +383,10 @@ =head1 OPTIONS
383383
384384
=head1 EXAMPLES
385385
386-
Oracle V2P process
386+
Oracle V2P process
387387
388388
dx_v2p -d Landshark -sourcename testdx -dbname v2p -environment LINUXTARGET -type oracle -envinst "/u01/app/oracle/product/11.2.0/dbhome_1" -targetDirectory /data/u02/v2p
389-
Starting provisioning job - JOB-231
389+
Starting provisioning job - JOB-231
390390
0 - 2 - 3 - 5 - 6 - 7 - 8 - 9 - 10 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 25 - 26 - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - 39 - 40 - 41 - 42 - 43 - 44 - 46 - 47 - 49 - 50 - 51 - 52 - 54 - 55 - 56 - 57 - 58 - 59 - 60 - 61 - 62 - 63 - 64 - 65 - 66 - 67 - 68 - 69 - 70 - 71 - 72 - 73 - 74 - 75 - 76 - 77 - 78 - 79 - 80 - 81 - 82 - 83 - 84 - 85 - 86 - 87 - 88 - 89 - 90 - 92 - 93 - 94 - 95 - 96 - 97 - 98 - 99 - 100
391391
Job JOB-231 finised with state: COMPLETED
392392
V2P job finished with COMPLETED status.
@@ -408,5 +408,3 @@ =head1 EXAMPLES
408408
V2P finished..
409409
410410
=cut
411-
412-

lib/FileMap.pm

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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.
@@ -30,7 +30,7 @@ use JSON;
3030
use Toolkit_helpers qw (logger);
3131

3232
# constructor
33-
# parameters
33+
# parameters
3434
# - dlpxObject - connection to DE
3535
# - debug - debug flag (debug on if defined)
3636

@@ -39,29 +39,29 @@ sub new {
3939
my $dlpxObject = shift;
4040
my $debug = shift;
4141
logger($debug, "Entering FileMap::constructor",1);
42-
42+
4343
my %hosts;
4444
my $self = {
4545
_hosts => \%hosts,
4646
_dlpxObject => $dlpxObject,
4747
_debug => $debug
4848
};
49-
49+
5050
bless($self,$classname);
51-
51+
5252
return $self;
5353
}
5454

5555
# Procedure setMapFile
56-
# parameters:
56+
# parameters:
5757
# - mapfile - hash with map file
5858
# Set a map file rules for object
5959

6060
sub setMapFile {
6161
my $self = shift;
6262
my $mapfile = shift;
63-
64-
logger($self->{_debug}, "Entering FileMap::setMapFile",1);
63+
64+
logger($self->{_debug}, "Entering FileMap::setMapFile",1);
6565

6666
$self->{_mapping_rule_hash} = $mapfile;
6767

@@ -71,7 +71,7 @@ sub setMapFile {
7171
if ($mapping_rule_de eq '') {
7272
$mapping_rule_de = $key . ":" . $value;
7373
} else {
74-
$mapping_rule_de = $mapping_rule_de . "\n" . $key . ":" . $value;
74+
$mapping_rule_de = $mapping_rule_de . "\n" . $key . ":" . $value;
7575
}
7676
}
7777

@@ -80,7 +80,7 @@ sub setMapFile {
8080
}
8181

8282
# Procedure loadMapFile
83-
# parameters:
83+
# parameters:
8484
# - file - name of files with rules (format orig:replace, each rule in separated line)
8585
# Set a map file rules for object
8686

@@ -89,7 +89,7 @@ sub loadMapFile {
8989
my $file = shift;
9090
my %map_hash;
9191

92-
logger($self->{_debug}, "Entering FileMap::loadMapFile",1);
92+
logger($self->{_debug}, "Entering FileMap::loadMapFile",1);
9393

9494
open (my $FD, $file) or die ("Can't open file $file : $!");
9595

@@ -109,7 +109,7 @@ sub loadMapFile {
109109
}
110110

111111
$map_hash{$line_split[0]} = $line_split[1];
112-
112+
113113
}
114114

115115
close $FD;
@@ -120,20 +120,16 @@ sub loadMapFile {
120120

121121

122122
# Procedure setSource
123-
# parameters:
123+
# parameters:
124124
# - source - name of source db
125125
# Set a reference for a source db
126126

127127
sub setSource {
128128
my $self = shift;
129129
my $source = shift;
130-
131-
logger($self->{_debug}, "Entering FileMap::setSource",1);
132-
133-
my $sources = new Source_obj($self->{_dlpxObject}, $self->{_debug});
134-
my $sourceitem = $sources->getSourceByName($source);
135130

136-
$self->{_source_ref} = $sourceitem->{container};
131+
logger($self->{_debug}, "Entering FileMap::setSource",1);
132+
$self->{_source_ref} = $source->{container}->{reference};
137133
}
138134

139135
# Procedure validate
@@ -144,12 +140,24 @@ sub setSource {
144140
sub validate {
145141
my $self = shift;
146142
my %fileMapping_request;
147-
logger($self->{_debug}, "Entering FileMap::validate",1);
143+
logger($self->{_debug}, "Entering FileMap::validate",1);
148144

149-
$fileMapping_request{"type"} = "FileMappingParameters";
150-
$fileMapping_request{"mappingRules"} = $self->{_mapping_rule};
151-
$fileMapping_request{"timeflowPointParameters"}{"type"} = "TimeflowPointSemantic";
152-
$fileMapping_request{"timeflowPointParameters"}{"container"} = $self->{_source_ref};
145+
if ($self->{_dlpxObject}->getApi() lt '1.9.0' ) {
146+
$fileMapping_request{"type"} = "FileMappingParameters";
147+
$fileMapping_request{"mappingRules"} = $self->{_mapping_rule};
148+
$fileMapping_request{"timeflowPointParameters"}{"type"} = "TimeflowPointSemantic";
149+
$fileMapping_request{"timeflowPointParameters"}{"container"} = $self->{_source_ref};
150+
} else {
151+
$fileMapping_request{"type"} = "FileMappingParameters";
152+
$fileMapping_request{"mappingRules"} = $self->{_mapping_rule};
153+
my %timeflowhash = (
154+
"type"=>"TimeflowPointSemantic",
155+
"container" => $self->{_source_ref},
156+
"location" => "LATEST_POINT"
157+
);
158+
my @timeflowarray = (\%timeflowhash);
159+
$fileMapping_request{"timeflowPointParameters"} = \@timeflowarray;
160+
}
153161

154162
my $json_data = to_json(\%fileMapping_request);
155163

@@ -173,7 +181,7 @@ sub validate {
173181

174182
sub GetMapping_rule {
175183
my $self = shift;
176-
logger($self->{_debug}, "Entering FileMap::GetMapping_rule",1);
184+
logger($self->{_debug}, "Entering FileMap::GetMapping_rule",1);
177185
return $self->{_mapping_rule};
178186
}
179187

@@ -183,8 +191,8 @@ sub GetMapping_rule {
183191

184192
sub GetMappedFiles {
185193
my $self = shift;
186-
logger($self->{_debug}, "Entering FileMap::GetMappedFiles",1);
194+
logger($self->{_debug}, "Entering FileMap::GetMappedFiles",1);
187195
return $self->{mappedFiles};
188196
}
189197

190-
1;
198+
1;

0 commit comments

Comments
 (0)