code: def connect(nickname, server_def, debug=None, timeout=10):
      
      url = server_def.url
      conn = pywbem.WBEMConnection(
          url,
          (server_def.user, server_def.password),
          default_namespace=server_def.implementation_namespace,
          no_verification=server_def.no_verification,
          timeout=timeout)
      if debug:
          conn.debug = True
  
      ns = server_def.implementation_namespace if \
          server_def.implementation_namespace \
          else 'interop'
      try:
          conn.GetQualifier('Association', namespace=ns)
          return conn
      except pywbem.ConnectionError as exc:
          print("Test server {0} at {1!r} cannot be reached. {2}: {3}".
                format(nickname, url, exc.__class__.__name__, exc))
          return None
      except pywbem.AuthError as exc:
          print("Test server {0} at {1!r} cannot be authenticated with. "
                "{2}: {3}". format(nickname, url,
                                   exc.__class__.__name__, exc))
          return None
      except pywbem.CIMError as ce:
          if ce.status_code == pywbem.CIM_ERR_NAMESPACE_NOT_FOUND or \
                  ce.status.code == pywbem.CIM_ERR_NOT_FOUND:
              return conn
          else:
              return None
      except pywbem.Error as exc:
          print("Test server {0} at {1!r} returned exception. {2}: {3}".
                format(nickname, url, exc.__class__.__name__, exc))
      return None
docs: Connect and confirm server works by testing for a known class in
      the default namespace or if there is no default namespace defined,
      in all the possible interop namespaces.
  
      returns a WBEMConnection object or None if the connection fails.