VMware {code} Community
wdecker
Contributor
Contributor

uploading vmdk file to nfc server using url given by importvapp

hi all

I'm running into an issue uploading a local vmdk file to an esx server using the url given by the importvapp call.

using the code below I try to do this but I get an immediate

500 write failed:

error

if I change the url address from

$thisURL = https://esxreal/nfc/8f088c50-6b02-4a3d-8997-5e11bea82538/disk-0.vmdk

to

$thisURL = 'https://esxreal/folder/testNamexxa/testNamexxa-flat.vmdk?dcPath=ha-datacenter&dsName=datastore1' ;

I am able to move the .vmdk file to the esxi host but the vmdk is different compared to a vmdk imported using the infrastructure client

I'm not clear as to why I can not move this file to the nfc server

this is the url given back to me to use

$thisURL = https://esxreal/nfc/8f088c50-6b02-4a3d-8997-5e11bea82538/disk-0.vmdk

my $service = Vim::get_vim_service( );

my $user_agent = $service -> -> ;

my $totalREad = 0;

my $lengthis = -s $theFile;

open( CONTENT , '< :raw' , $theFile );

sub content_source {

my $buffer;

my $num_read = read( CONTENT , $buffer , 102400 );

$totalREad += $num_read;

my $percentIs = int( ( $totalREad / $lengthis ) * 100 );

$holdView -> HttpNfcLeaseProgress( percent => $percentIs );

if ( $num_read == 0 ) {

return "";

} else {

print " how many read $totalREad $lengthis\n";

return $buffer;

}

}

my $request = HTTP::Request -> new( 'PUT' , $thisURL );

$request -> content( \&content_source );

$request -> header( 'Content-Type' , 'application/octet-stream' );

$request -> header( 'Content-Length' , -s $theFile );

my $response = $user_agent -> request( $request );

close( CONTENT );

if ( $response -> is_success ) {

print $response -> content;

}else {

print $response -> status_line , "\n";

}

thanks in advance

Tags (4)
Reply
0 Kudos
2 Replies
MikeMatczynski
Contributor
Contributor

Did you ever find a solution for this problem?

Thanks!

Mike

Reply
0 Kudos
gr8warrior
Contributor
Contributor

I am facing the same problem. I am usng curl command to upload the vmdk file. NFC URL is returned by importVApp API.

I am using --data-binary to POST the file. Also setting headers for keep-alive and application/x-vnd.vmware-streamVmdk .

Can anyone provide any help on this?

Reply
0 Kudos