5. WBEM server API

New in pywbem 0.9 as experimental and finalized in 0.10.

The WBEM server API encapsulates certain functionality of a WBEM server for use by a WBEM client application, such as determining the Interop namespace of the server, or the management profiles advertised by the server.

This chapter has the following sections:

  • Example - An example on how to use the API.
  • WBEMServer - The WBEMServer class serves as a general access point for clients to WBEM servers. It allows determining the Interop namespace of the server, or the advertised management profiles.

5.1. Example

The following example code displays some information about a WBEM server:

from pywbem import WBEMConnection, WBEMServer, ValueMapping

def explore_server(server_url, username, password):

    print("WBEM server URL:\n  %s" % server_url)

    conn = WBEMConnection(server_url, (username, password))
    server = WBEMServer(conn)

    print("Brand:\n  %s" % server.brand)
    print("Version:\n  %s" % server.version)
    print("Interop namespace:\n  %s" % server.interop_ns)

    print("All namespaces:")
    for ns in server.namespaces:
        print("  %s" % ns)

    print("Advertised management profiles:")
    org_vm = ValueMapping.for_property(server, server.interop_ns,
        'CIM_RegisteredProfile', 'RegisteredOrganization')
    for inst in server.profiles:
        org = org_vm.tovalues(inst['RegisteredOrganization'])
        name = inst['RegisteredName']
        vers = inst['RegisteredVersion']
        print("  %s %s Profile %s" % (org, name, vers))

Example output:

WBEM server URL:
  http://0.0.0.0
Brand:
  OpenPegasus
Version:
  2.12.0
Interop namespace:
  root/PG_Interop
All namespaces:
  root/PG_InterOp
  root/PG_Internal
  root/cimv2
  root
Advertised management profiles:
  SNIA Indication Profile 1.1.0
  SNIA Indication Profile 1.2.0
  SNIA Software Profile 1.1.0
  SNIA Software Profile 1.2.0
  SNIA Profile Registration Profile 1.0.0
  SNIA SMI-S Profile 1.2.0
  SNIA Server Profile 1.1.0
  SNIA Server Profile 1.2.0
  DMTF Profile Registration Profile 1.0.0
  DMTF Indications Profile 1.1.0

5.2. WBEMServer

class pywbem.WBEMServer(conn)[source]

New in pywbem 0.9 as experimental and finalized in 0.10.

A representation of a WBEM server that serves as a general access point to a client.

It supports determining the Interop namespace of the server, all namespaces, its brand and version, the advertised management profiles and finally allows to retrieve the central instances of a management profile with one method invocation regardless of whether the profile implementation chose the central or scoping class profile advertisement methodology (see DSP1033).

It also provides functions to subscribe for indications.

Parameters:conn (WBEMConnection) – Connection to the WBEM server.
INTEROP_NAMESPACES = ['interop', 'root/interop', 'root/PG_Interop']

A class variable with the possible names of Interop namespaces that should be tried when determining the Interop namespace on the WBEM server.

NAMESPACE_CLASSNAMES = ['CIM_Namespace', '__Namespace']

A class variable with the possible names of CIM classes for representing CIM namespaces, that should be tried when determining the namespaces on the WBEM server.

__repr__()[source]

Return a representation of the WBEMServer object with all attributes, that is suitable for debugging.

url

string – URL of the WBEM server.

conn

WBEMConnection – Connection to the WBEM server.

interop_ns

string – Name of the Interop namespace of the WBEM server.

Raises:
  • Exceptions raised by WBEMConnection.
  • CIMError – CIM_ERR_NOT_FOUND, Interop namespace could not be determined.
namespace_classname

string – Name of the CIM class that was found to represent the CIM namespaces of the WBEM server.

Raises:
  • Exceptions raised by WBEMConnection.
  • CIMError – CIM_ERR_NOT_FOUND, Interop namespace could not be determined.
  • CIMError – CIM_ERR_NOT_FOUND, Namespace class could not be determined.
namespaces

list of string – Names of all namespaces of the WBEM server.

Raises:
  • Exceptions raised by WBEMConnection.
  • CIMError – CIM_ERR_NOT_FOUND, Interop namespace could not be determined.
  • CIMError – CIM_ERR_NOT_FOUND, Namespace class could not be determined.
brand

string – Brand of the WBEM server.

The brand will be one of the following:

  • "OpenPegasus", for OpenPegasus
  • "SFCB", for SFCB
  • First word of the value of the ElementName property of the CIM_ObjectManager instance, for any other WBEM servers.
  • "unknown", if the ElementName property is NULL.
Raises:
  • Exceptions raised by WBEMConnection.
  • CIMError – CIM_ERR_NOT_FOUND, Interop namespace could not be determined.
  • CIMError – CIM_ERR_NOT_FOUND, Unexpected number of CIM_ObjectManager instances.
version

string – Version of the WBEM server. None, if the version cannot be determined.

Raises:
  • Exceptions raised by WBEMConnection.
  • CIMError – CIM_ERR_NOT_FOUND, Interop namespace could not be determined.
  • CIMError – CIM_ERR_NOT_FOUND, Unexpected number of CIM_ObjectManager instances.
profiles

list of CIMInstance – The CIM_RegisteredProfile instances representing all management profiles advertised by the WBEM server.

Raises:
  • Exceptions raised by WBEMConnection.
  • CIMError – CIM_ERR_NOT_FOUND, Interop namespace could not be determined.
get_selected_profiles(registered_org=None, registered_name=None, registered_version=None)[source]

Return the CIM_RegisteredProfile instances representing a filtered subset of the management profiles advertised by the WBEM server, that can be filtered by registered organization, registered name, and/or registered version.

Parameters:
  • profile_org (string) – A filter for the registered organization of the profile, matching (case sensitively) the RegisteredOrganization property of the CIM_RegisteredProfile instance, via its Values qualifier. If None, this parameter is ignored for filtering.
  • profile_name (string) – A filter for the registered name of the profile, matching (case sensitively) the RegisteredName property of the CIM_RegisteredProfile instance. If None, this parameter is ignored for filtering.
  • profile_version (string) – A filter for the registered version of the profile, matching (case sensitively) the RegisteredVersion property of the CIM_RegisteredProfile instance. If None, this parameter is ignored for filtering.
Returns:

The CIM_RegisteredProfile instances representing the filtered subset of the management profiles advertised by the WBEM server.

Return type:

list of CIMInstance

Raises:
  • Exceptions raised by WBEMConnection.
  • CIMError – CIM_ERR_NOT_FOUND, Interop namespace could not be determined.
  • KeyError – If an instance in the list of profiles is incomplete and does not include the required properties.
get_central_instances(profile_path, central_class=None, scoping_class=None, scoping_path=None)[source]

Return the instance paths of the central instances of a management profile.

This method supports the following profile advertisement methodologies (see DSP1033), and attempts them in this order:

  • GetCentralInstances methodology (new in DSP1033 1.1)
  • Central class methodology
  • Scoping class methodology

Use of the scoping class methodology requires specifying the central class, scoping class and scoping path defined by the profile. If any of them is None, this method will attempt only the GetCentralInstances and central class methodologies, but not the scoping class methodology. If using these two methodologies does not result in any central instances, and the scoping class methodology cannot be used, an exception is raised.

The scoping path is a directed traversal path from the central instances to the scoping instances. Its first list item is always the association class name of the traversal hop starting at the central instances. For each further traversal hop, the list contains two more items: The class name of the near end of that hop, and the class name of the traversed association. As a result, the class names of the central instances and scoping instances are not part of the list.

Example for a 1-hop traversal:

  • central class: "CIM_Fan"
  • scoping path: ["CIM_SystemDevice"]
  • scoping class: "CIM_ComputerSystem"

Example for a 2-hop traversal:

  • central class: "CIM_Sensor"
  • scoping path: ["CIM_AssociatedSensor", "CIM_Fan", "CIM_SystemDevice"]
  • scoping class: "CIM_ComputerSystem"
Parameters:
  • profile_path (CIMInstanceName) – Instance path of the CIM_RegisteredProfile instance representing the management profile.
  • central_class (string) –

    Class name of central class defined by the management profile.

    Will be ignored, unless the profile is a component profile and its implementation supports only the scoping class methodology. None will cause the scoping class methodology not to be attempted.

  • scoping_class (string) –

    Class name of scoping class defined by the management profile.

    Will be ignored, unless the profile is a component profile and its implementation supports only the scoping class methodology. None will cause the scoping class methodology not to be attempted.

  • scoping_path (list of string) –

    Scoping path defined by the management profile.

    Will be ignored, unless the profile is a component profile and its implementation supports only the scoping class methodology. None will cause the scoping class methodology not to be attempted.

Returns:

The instance paths of the central instances of the management profile.

Return type:

list of CIMInstanceName

Raises: