Making Connections

Once PyWBEM has been installed, the next stage is to learn how to make connections to WBEM servers. A client's connection to a WBEM server is represented by an instance of the pywbem.WBEMConnection Python class.

Creating a connection is quite simple. All that is required is a URL for the WBEM server, and a set of credentials. The following code creates an SSL-encrypted connection to a WBEM server running on your local system, using a dummy user and dummy password:


In [ ]:
import pywbem

server_url = 'https://localhost'
user = 'user'
password = 'password'

conn = pywbem.WBEMConnection(server_url, (user, password))

After creating a connection, various methods may be called on the pywbem.WBEMConnection object, which causes remote calls to the WBEM server.

As usual in HTTP, there is no persistent TCP connection; the connectedness provided by this class is only conceptual. That is, the creation of the connection object does not cause any interaction with the WBEM server, and each subsequent operation performs an independent, state-less HTTP/HTTPS request, setting up and tearing down a new TCP connection.