{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Making Connections"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a href=\"#\" onclick=\"history.back()\">&lt;--- Back</a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once PyWBEM has been [installed](https://pywbem.github.io/pywbem/installation.html), 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`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.WBEMConnection) Python class.\n",
    "\n",
    "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:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import pywbem\n",
    "\n",
    "server_url = 'https://localhost'\n",
    "user = 'user'\n",
    "password = 'password'\n",
    "\n",
    "conn = pywbem.WBEMConnection(server_url, (user, password))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "After creating a connection, various methods may be called on the [`pywbem.WBEMConnection`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.WBEMConnection) object, which causes remote calls to the WBEM server.\n",
    "\n",
    "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."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a href=\"#\" onclick=\"history.back()\">&lt;--- Back</a>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
