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

testing a session

$
0
0

Hi,

 

I would like to load a session, and test if it's still active or not.

if so, the script use it and keep going, if not, the script connect to vcenter as usual, and save session file for re-using it next time.

 

Is there an return code for $vim->load_session(session_file => '.mysession');

 

here is my code:

 

 

my $service_url = "https://$server/sdk/vimService";
my $vim = Vim->new(service_url => $service_url);
$vim->load_session(session_file => '.mysession');
######
# here I would like to have something like
######
if ($error) {
    $vim->login(user_name => $username, password => $password); 
    # save session $vim in file .mysession
    $vim->save_session(session_file => '.mysession');
}

 

But as soon as I used an inactive session, script ends with:

 

Error while testing status of connection 'https://X.X.X.X/sdk/webService': The session is not authenticated.

looked for SessionIsActive, but can't find how to use it
Do you have any clue to help me please?
Rgds

Viewing all articles
Browse latest Browse all 179681

Trending Articles



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