Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 193198

uploading vmdk file to nfc server using url given by importvapp

$
0
0

 

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

 

 


Viewing all articles
Browse latest Browse all 193198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>