def logout(self, stub_config): """ Delete session with vCenter. """ if stub_config: session_svc = cis_client.Session(stub_config) session_svc.delete()
def login(self, stub_config, user, pwd): """ Create an authenticated session with vCenter. Returns a stub_config that stores the session identifier that can be used to issue authenticated requests against vCenter. """ # Pass user credentials (user/password) in the security context to # authenticate. security_context = create_user_password_security_context(user, pwd) stub_config.connector.set_security_context(security_context) # Create the stub for the session service # and login by creating a session. session_svc = cis_client.Session(stub_config) session_id = session_svc.create() # Store the session identifier in the security # context of the stub and use that for all subsequent remote requests session_security_context = create_session_security_context(session_id) stub_config.connector.set_security_context(session_security_context) return stub_config