5. WBEM server library

New in pywbem 0.9 as experimental and finalized in 0.10.

The WBEM server library API of pywbem encapsulates selected functionality of a WBEM server for use by a WBEM client application, such as determining the Interop namespace and other basic information about the server, or the management profiles advertised by the server.

This chapter has the following sections:

  • Example - An example on how to use the WBEM server library 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 and other basic information about 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  {0}".format(server_url))

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

    print("Brand:\n  {0}".format(server.brand))
    print("Version:\n  {0}".format(server.version))
    print("Interop namespace:\n  {0}".format(server.interop_ns))

    print("All namespaces:")
    for ns in server.namespaces:
        print("  {0}".format(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("  {0} {1} Profile {2}".format(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)

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 retrieving the central instances of an implementation of a management profile with one method invocation regardless of whether the profile implementation chose to implement the central or scoping class profile advertisement methodology (see section Profile advertisement methodologies).

It also provides functions to subscribe for indications.

Parameters:conn (WBEMConnection) – Connection to the WBEM server.

Methods

create_namespace Create the specified CIM namespace in the WBEM server and update this WBEMServer object to reflect the new namespace there.
delete_namespace Delete the specified CIM namespace in the WBEM server and update this WBEMServer object to reflect the removed namespace there.
get_central_instances Return the instance paths of the central instances of a management profile.
get_selected_profiles 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.

Attributes

INTEROP_NAMESPACES
NAMESPACE_CLASSNAMES
brand Brand of the WBEM server.
cimom_inst CIM instance of class CIM_ObjectManager that represents the WBEM server.
conn Connection to the WBEM server.
interop_ns Name of the Interop namespace of the WBEM server.
namespace_classname Name of the CIM class that was found to represent the CIM namespaces of the WBEM server.
namespace_paths Instance paths of the CIM instances in the Interop namespace that represent the namespaces of the WBEM server.
namespaces Names of all namespaces of the WBEM server.
profiles The CIM_RegisteredProfile instances representing all management profiles advertised by the WBEM server.
url URL of the WBEM server.
version Version of the WBEM server.

Details

__repr__()

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

__str__()

Return a representation of the WBEMServer object with a subset of its attributes.

brand

Brand of the WBEM server.

The brand is determined from the CIM_ObjectManager instance in the Interop namespace, by looking at its ElementName property.

For known WBEM servers, the brand is then normalized in order to make it identifiable:

  • "OpenPegasus"
  • "SFCB" (Small Footprint CIM Broker)
  • "WBEM Solutions J WBEM Server"
  • "EMC CIM Server"
  • "FUJITSU CIM Object Manager"

For all other WBEM servers, the brand is the value of the ElementName property, or the string "unknown", if that property is not set or the empty string.

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.
Type:

string

cimom_inst

CIM instance of class CIM_ObjectManager that represents the WBEM server.

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.
Type:

CIMInstance

conn

Connection to the WBEM server.

Type:WBEMConnection
create_namespace(namespace)

Create the specified CIM namespace in the WBEM server and update this WBEMServer object to reflect the new namespace there.

This method attempts the following approaches for creating the namespace, in order, until an approach succeeds:

  1. Namespace creation as described in the WBEM Server profile (DSP1092) via CIM method CIM_WBEMServer.CreateWBEMServerNamespace().

    This is a new standard approach that is not likely to be widely implemented yet.

  2. Issuing the CreateInstance operation using the CIM class representing namespaces (‘PG_Namespace’ for OpenPegasus, and ‘CIM_Namespace’ otherwise), against the Interop namespace.

    This approach is typically supported in WBEM servers that support the creation of CIM namespaces. This approach is similar to the approach described in DSP0200.

Creating namespaces using the __Namespace pseudo-class has been deprecated already in DSP0200 1.1.0 (released in 01/2003), and pywbem does not implement that approach.

Parameters:

namespace (string) – CIM namespace name. Must not be None. The namespace may contain leading and a trailing slash, both of which will be ignored.

Returns:

The specified CIM namespace name in its standard format (i.e. without leading or trailing slash characters).

Return type:

unicode string

Raises:
delete_namespace(namespace)

Delete the specified CIM namespace in the WBEM server and update this WBEMServer object to reflect the removed namespace there.

The specified namespace must be empty (i.e. must not contain any classes, instances, or qualifier types.

This method attempts the following approaches for deleting the namespace, in order, until an approach succeeds:

  1. Issuing the DeleteInstance operation using the CIM class representing namespaces (‘PG_Namespace’ for OpenPegasus, and ‘CIM_Namespace’ otherwise), against the Interop namespace.

    This approach is typically supported in WBEM servers that support the creation of CIM namespaces. This approach is similar to the approach described in DSP0200.

The approach described in the WBEM Server profile (DSP1092) via deleting the CIM_WBEMServerNamespace instance is not implemented because that would also delete any classes, instances, and qualifier types in the namespace.

Deleting namespaces using the __Namespace pseudo-class has been deprecated already in DSP0200 1.1.0 (released in 01/2003), and pywbem does not implement that approach.

Parameters:

namespace (string) – CIM namespace name. Must not be None. The namespace may contain leading and a trailing slash, both of which will be ignored.

Returns:

The specified CIM namespace name in its standard format (i.e. without leading or trailing slash characters).

Return type:

unicode string

Raises:
  • Exceptions raised by WBEMConnection.
  • ModelError – An error with the model implemented by the WBEM server.
  • CIMError – CIM_ERR_NOT_FOUND, Specified namespace does not exist.
  • CIMError – CIM_ERR_NAMESPACE_NOT_EMPTY, Specified namespace is not empty.
get_central_instances(profile_path, central_class=None, scoping_class=None, scoping_path=None, reference_direction='dmtf', try_gci_method=False)

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

DMTF defines the following profile advertisement methodologies in DSP1033:

  • GetCentralInstances methodology (new in DSP1033 1.1, only when explicitly requested by the caller)
  • Central class methodology
  • Scoping class methodology

A brief explanation of these methodologies can be found in section Profile advertisement methodologies.

Pywbem attempts all three profile advertisement methodologies in the order listed above.

All three methodologies start from the CIM_RegisteredProfile instance referenced by the profile_path parameter. That instance represents a management profile. In case of multiple uses of a component profile in a WBEM server, one such instance is supposed to represent one such profile use.

If the profile is a component profile and its implementation does not support the GetCentralInstances or central class methodologies, the central_class, scoping_class, and scoping_path parameters are required in order for the method to attempt the scoping class methodology. The method will not fail if these parameters are not provided, as long as the profile implementation supports the GetCentralInstances or central class methodology.

Example parameters for a 1-hop scoping path:

  • central_class = "CIM_Fan"
  • scoping_path = ["CIM_SystemDevice"]
  • scoping_class = "CIM_ComputerSystem"

Example parameters for a 2-hop scoping path:

  • 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 (or its use, if there are multiple uses in a WBEM server).
  • 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.

  • reference_direction (string) –

    Defines the navigation direction across the CIM_ReferencedProfile association when navigating from the current profile to its scoping (= referencing, autonomous) profile when using the scoping class methodology, as follows:

    • ’dmtf’ (default): Assume DMTF conformance, i.e. the ‘Dependent’ end is followed.
    • ’snia’: Assume SNIA SMI-S conformance, i.e. the ‘Antecedent’ end is followed.

    This parameter supports the different definitions between DMTF and SNIA SMI-S standards regarding the use of the two ends of the CIM_ReferencedProfile association:

    • The DMTF standards define in DSP1033 and DSP1001:
      • Antecedent = referenced profile = component profile
      • Dependent = referencing profile = autonomous profile
    • The SNIA SMI-S standard defines in the “Profile Registration Profile” (in the SMI-S “Common Profiles” book):
      • Antecedent = autonomous profile
      • Dependent = component (= sub) profile

    It should be assumed that all profiles that are directly or indirectly scoped by a particular top-level (= wrapper) specification implement the reference direction that matches the registered organisation of the top-level specification.

    Examples:

    • All profiles scoped by the SNIA SMI-S top-level specification should be assumed to implement the ‘snia’ reference direction.
    • All profiles scoped by the DMTF SMASH wrapper specification should be assumed to implement the ‘dmtf’ reference direction.
  • try_gci_method (bool) – Flag indicating that the GetCentralInstances methodology should be attempted. This methodology is not expected to be implemented by WBEM servers at this point, and causes undesirable behavior with some WBEM servers, so it is not attempted by default. Note that WBEM servers are required to support the scoping class methodology.
Returns:

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

Return type:

list of CIMInstanceName

Raises:
  • Exceptions raised by WBEMConnection.
  • ModelError – An error with the model implemented by the WBEM server.
  • ValueError – User errors regarding input parameter values.
  • TypeError – User errors regarding input parameter types.
get_selected_profiles(registered_org=None, registered_name=None, registered_version=None)

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:
  • registered_org (string) – A filter for the registered organization of the profile, matching (case insensitively) the RegisteredOrganization property of the CIM_RegisteredProfile instance, via its Values qualifier. If None, this parameter is ignored for filtering.
  • registered_name (string) – A filter for the registered name of the profile, matching (case insensitively) the RegisteredName property of the CIM_RegisteredProfile instance. If None, this parameter is ignored for filtering.
  • registered_version (string) – A filter for the registered version of the profile, matching (case insensitively) the RegisteredVersion property of the CIM_RegisteredProfile instance. Note that version strings may contain aplhabetic characters to indicate the draft level. 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.
interop_ns

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.
Type:

string

namespace_classname

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

Raises:
Type:

string

namespace_paths

Instance paths of the CIM instances in the Interop namespace that represent the namespaces of the WBEM server.

Note: One WBEM server has been found to support an Interop namespace without representing it as a CIM instance. In that case, this property will not have an instance path for the Interop namespace, but the namespaces property will have the name of the Interop namespace.

Raises:
Type:

list of CIMInstanceName

namespaces

Names of all namespaces of the WBEM server.

Raises:
Type:

list of string

profiles

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.
Type:

list of CIMInstance

url

URL of the WBEM server.

Type:string
version

Version of the WBEM server.

None, if the version cannot be determined.

The version is determined from the CIM_ObjectManager instance in the Interop namespace, by looking at its ElementName property, or if that is not set, at its Description property, and by taking the string after "version" or "release" (case insensitively).

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.
Type:

string