Random Project

Work around for “Server version unavailable”

Here is a work around for everyone who can’t make check_vmware_api work on recent OS with new perl and recent VMware Perl SDK.

Prerequisites:
– Ubuntu 14.04 Server (perl v5.18.2)
– VMware-vSphere-Perl-SDK-5.5.0-2043780
– check_vmware_api.pl 0.7.1

Basic installation:

apt-get install perl-doc libssl-dev libxml-libxml-perl libarchive-zip-perl libcrypt-ssleay-perl libclass-methodmaker-perl libuuid-perl libdata-dump-perl libsoap-lite-perl libio-compress-perl
tar -xf VMware-vSphere-Perl-SDK-5.5.0-2043780.x86_64.tar.gz -C /tmp
cd /tmp/vmware-vsphere-cli-distrib
./vmware-install.pl

Work around for “Server version unavailable”:

patch -b /usr/share/perl/5.18/VMware/VICommon.pm new(agent => “VI Perl”);
+ $user_agent->ssl_opts( SSL_verify_mode => 0 );
my $cookie_jar = HTTP::Cookies->new(ignore_discard => 1);
$user_agent->cookie_jar($cookie_jar);
$user_agent->protocols_allowed([‘http’, ‘https’]);
@@ -502,7 +503,7 @@
sub query_server_version {
BEGIN {
#To remove SSL Warning, switching from IO::Socket::SSL to Net::SSL
– $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = “Net::SSL”;
+ #$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = “Net::SSL”;
#To remove host verification
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
}
@@ -526,6 +527,7 @@
}
}
my $user_agent = LWP::UserAgent->new(agent => “VI Perl”);
+ $user_agent->ssl_opts( SSL_verify_mode => 0 );
my $cookie_jar = HTTP::Cookies->new(ignore_discard => 1);
$user_agent->cookie_jar($cookie_jar);
$user_agent->protocols_allowed([‘http’, ‘https’]);
@@ -2108,6 +2110,7 @@
sub new {
my ($class, $url) = @_;
my $user_agent = LWP::UserAgent->new(agent => “VI Perl”);
+ $user_agent->ssl_opts( SSL_verify_mode => 0 );
my $cookie_jar = HTTP::Cookies->new(ignore_discard => 1);
$user_agent->cookie_jar( $cookie_jar );
$user_agent->protocols_allowed( [‘http’, ‘https’] );
*****************************************************************