Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 179681

vimService(Vim::load_session):The session is not authenticated

$
0
0

Hi All,

 

I was trying to create a sample vSphere plugin using Perl SDK. I was able to successfully print the “Hello” statement in vSphere client after registering the plugin.

 

Now I am trying to parse the session ID from URL to connect to the vCenter server to get the vcenter time. But I am getting the below error message.

 

Error while testing status of connection 'https://<vcenterip>:443/sdk/vimService': The session is not authenticated.

 

Below is my code:

 

Configuration XML file:

<scriptConfiguration version="1.0.0">     <key>com.sample.demo2</key><description>Tab Demo1</description>     <view parent="InventoryView.VirtualMachine">       <title locale="en">VI Plugin Demo1</title>       <url>http://<IP of my webserver>/cgisc/sample.cgi?</url>     </view>    </scriptConfiguration>

 

CGI:

#sample.cgi

#!/usr/bin/perl

 

use CGI;

print "Content-type: text/html\n\n";

my $cgi = CGI->new;

 

my $param_name = 'vimSessionKey';

my $key=$cgi->param("vimSessionKey");

 

print "<BR>";

 

print "Session ID : ";

print "$key <BR>";

 

my $url_s=$cgi->param("serviceUrl");

print ("Service URL", $url_s);

print "<BR>";

 

system("/usr/bin/perl /var/www/html/cgisc/connect.pl $key $url_s");

 

 

connect.pl:

 

$Util::script_version = "1.0";

print "Session ID : ";

print "${ARGV[0]}";

print "\n Service URL : ";

print "${ARGV[1]}";

print "\n";

Vim::load_session(service_url => "${ARGV[1]}/vimService", session_id => "${ARGV[0]}");

#Util::connect();

display_servertime();

Util::disconnect();

sub display_servertime {

   Util::trace(0, "\nConnection Successful\n");

        print "success";

 

   my $si_moref = ManagedObjectReference->new(type => 'ServiceInstance',

value => 'ServiceInstance');

   my $si_view = Vim::get_view(mo_ref => $si_moref);

   Util::trace(0, "Server Time : ". $si_view->CurrentTime()."\n");

print $si_view->CurrentTime();

}

 

vSphere client has invoked my sample cgi script as below when I click the tab(my new tab).

 

[29/May/2013:17:00:21 +0530] "GET /cgisc/sample.cgi?&moref=VirtualMachine:vm-34&serverGuid=92A66055-D11B-453B-8A83-141BF374E608&locale=en_US&vimSessionKey=52b0150b-2426-db18-3917-5deeae705bf5&serviceUrl=https://<vcenter ip>/sdk HTTP/1.1" 500 615 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; AskTbORJ/5.15.23.36191)"

 

Could you please help me in connecting to the vCenter by parsing the session ID from the URL.

 

Thanks,

Kalai


Viewing all articles
Browse latest Browse all 179681

Trending Articles



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