My application needs to login to Xen Server, perform an
operation, and then logout. Eventually, I need to login back
in using the same connection.
Can I login/logout using the same connection object?
See the code snippet below.
Code Snippet:
Connection conn = null;
Session sess = null;
void initialize()
{
try {
//
Make connection using username/password – THIS WORKS
conn
= new Connection(ipaddress, username, password);
sess = Session.loginWithPassword(conn, username, password);
}
catch(Exception ex) {
// Process Error
}
}
void performOperation()
{
try {
//
Application requires logout/login
Session.logout(conn);
//
Successful
Session
= Session.loginWithPassword(conn, username, password );
// The following line of code throws
the exception.
//
XEN Exception: com.xensource.xenapi.Types$BadServerResponse [SESSION_INVALID,
OpaqueRef:d8458e2f-cbd4-ed89-73df-fb03e303f908]
//
It seems that the Connection object is now longer valid
Session.Record
sr = session.getRecord(conn);
}
catch(Exception ex) {
}
}
Thanks,
Joe