Maybe you all need to pick a "real" programming language! B-)
This is a tricky function because the 3rd "in-out" parameter file_offset. I see a couple of things, that may or may not be a problem (due to my ignorance with Python).
1. The file_name parameter is not named in the call to download_file().
res = dl.download_file('/var/tmp/test-ucs.tgz',chunk_size = chunk_size,file_offset = foffset)
Shouldn't this read:
res = dl.download_file(file_name = '/var/tmp/test-ucs.tgz',chunk_size = chunk_size,file_offset = foffset)
Maybe that is handled underneath in pyControl somewhere.
2. I'd check to make sure that the foffset value is equal to the previous value plus the chunk size (or the difference between the previous offset and the end of file if it's the last request in the chain. In my examples, I throw in a print statement after the writing to file with the current file offset.
I just tested this Perl function on my 10.2 LTM and it worked regardless of the chunk size resulting in identical files.
sub downloadFile()
{
my ($configName, $localFile, $quiet) = (@_);
my $success = 0;
if ( "" eq $localFile )
{
$localFile = $configName;
}
if ( "" eq $configName )
{
&usage("download");
}
open (LOCAL_FILE, ">$localFile") or die("Can't open $localFile for output: $!");
binmode(LOCAL_FILE);
my $file_offset = 0;
my $chunk_size = 1024*64;
my $chain_type = $FILE_UNDEFINED;
my $bContinue = 1;
print "\n";
while ( 1 == $bContinue )
{
$soap_response = $ConfigSync->download_file
(
SOAP::Data->name(file_name => $configName),
SOAP::Data->name(chunk_size => $chunk_size),
SOAP::Data->name(file_offset => $file_offset)
);
if ( $soap_response->fault )
{
if ( 1 != $quiet )
{
print $soap_response->faultcode, " ", $soap_response->faultstring, "\n";
}
$bContinue = 0;
}
else
{
$FileTransferContext = $soap_response->result;
$file_data = $FileTransferContext->{"file_data"};
$chain_type = $FileTransferContext->{"chain_type"};
@params = $soap_response->paramsout;
$file_offset = @params[ 0 ];
Append Data to File
print LOCAL_FILE $file_data;
print "Bytes Transferred: $file_offset\n";
if ( ("FILE_LAST" eq $chain_type) or
("FILE_FIRST_AND_LAST" eq $chain_type) )
{
$bContinue = 0;
$success = 1;
}
}
}
print "\n";
close(LOCAL_FILE);
return $success;
}
As it runs it prints out the currently total downloaded bytes which should be "chunk_size" apart until the last entry.
Bytes Transferred: 32768
Bytes Transferred: 65536
Bytes Transferred: 98304
Bytes Transferred: 131072
Bytes Transferred: 163840
Bytes Transferred: 196608
Bytes Transferred: 229376
Bytes Transferred: 262144
Bytes Transferred: 294912
Bytes Transferred: 327680
Bytes Transferred: 360448
Bytes Transferred: 393216
Bytes Transferred: 425984
Bytes Transferred: 458752
Bytes Transferred: 491520
Bytes Transferred: 524288
Bytes Transferred: 557056
Bytes Transferred: 589824
Bytes Transferred: 622592
Bytes Transferred: 655360
Bytes Transferred: 688128
Bytes Transferred: 720896
Bytes Transferred: 753664
Bytes Transferred: 786432
Bytes Transferred: 819200
Bytes Transferred: 851968
Bytes Transferred: 884736
Bytes Transferred: 917504
Bytes Transferred: 950272
Bytes Transferred: 957225
My guess is that something is going wonky with the file_offset value.
-Joe