On Thu, Apr 22, 2010 at 02:38:12PM +0100, Matthew Booth wrote:
Update ESX to work with newer and older LWP::UserAgent api. --- lib/Sys/VirtV2V/Transfer/ESX.pm | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/Sys/VirtV2V/Transfer/ESX.pm b/lib/Sys/VirtV2V/Transfer/ESX.pm index 705ca25..4d65d5e 100644 --- a/lib/Sys/VirtV2V/Transfer/ESX.pm +++ b/lib/Sys/VirtV2V/Transfer/ESX.pm @@ -59,21 +59,15 @@ sub new { agent => 'virt-v2v/'.$Sys::VirtV2V::VERSION, protocols_allowed => [ 'https' ] ); - $self->show_progress(1);
- $self->add_handler(response_header => sub { - my ($response, $self, $h) = @_; - - if ($response->is_success) { - $self->verify_certificate($response) unless ($noverify); - $self->create_volume($response); - } - }); + # Older versions of LWP::UserAgent don't support show_progress + $self->show_progress(1) if ($self->can('show_progress'));
$self->{_v2v_server} = $server; $self->{_v2v_target} = $target; $self->{_v2v_username} = $username; $self->{_v2v_password} = $password; + $self->{_v2v_noverify} = $noverify;
if ($noverify) { # Unset HTTPS_CA_DIR if it is already set @@ -177,6 +171,12 @@ sub handle_data
my ($data, $response) = @_;
+ # Create the volume if it hasn't been created already + if (!defined($self->{_v2v_vol}) && $response->is_success) { + $self->verify_certificate($response) unless ($self->{_v2v_noverify}); + $self->create_volume($response); + } + $self->{_v2v_received} += length($data); $self->{_v2v_vol}->write($data); } -- 1.6.6.1
There seem to be several different changes mixed in here, but I guess it's OK ... ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top