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)[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 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.

Attributes:

INTEROP_NAMESPACES

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

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.

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.

Methods:

__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.

create_namespace(namespace[, verbose])

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

delete_namespace(namespace[, verbose])

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

get_central_instances(profile_path[, ...])

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

get_selected_profiles([registered_org, ...])

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.

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', 'CIM_WBEMServerNamespace', '__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.

__str__()[source]

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

property 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.: :raises CIMError: CIM_ERR_NOT_FOUND, Interop namespace could not be determined. :raises CIMError: CIM_ERR_NOT_FOUND, Unexpected number of CIM_ObjectManager instances.

Type:

string

property cimom_inst

CIM instance of class CIM_ObjectManager that represents the WBEM server.

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

Type:

CIMInstance

property conn

Connection to the WBEM server.

Type:

WBEMConnection

create_namespace(namespace, verbose=False)[source]

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

This method cannot create an Interop namespace because creating the an Interop namespace with client operations depends on the prior existence of an Interop namespace, and creating additional Interop namespaces if one already exists is usually prevented by servers.

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 in the WBEM server, against the Interop namespace.

    An exception is OpenPegasus, where ‘PG_Namespace’ is used instead of ‘CIM_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.

  • verbose (bool) – Verbose mode: Print a message about the namespace creation.

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.: :raises ModelError: An error with the model implemented by the WBEM server.

delete_namespace(namespace, verbose=False)[source]

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 cannot delete the Interop namespace because servers will usually prevent their deletion.

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.

  • verbose (bool) – Verbose mode: Print a message about the namespace creation.

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.: :raises ModelError: An error with the model implemented by the WBEM server. :raises CIMError: CIM_ERR_NOT_FOUND, Specified namespace does not exist. :raises 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)[source]

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.: :raises ModelError: An error with the model implemented by the WBEM server. :raises ValueError: User errors regarding input parameter values. :raises TypeError: User errors regarding input parameter types.

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:
  • 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.: :raises CIMError: CIM_ERR_NOT_FOUND, Interop namespace could not be determined. :raises ModelError: If an instance in the list of profiles is incomplete and does not include the required properties.

property interop_ns

Name of the Interop namespace of the WBEM server.

:raises Exceptions raised by WBEMConnection.: :raises CIMError: CIM_ERR_NOT_FOUND, Interop namespace could not be determined.

Type:

string

property namespace_classname

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

:raises Exceptions raised by WBEMConnection.: :raises ModelError: An error with the model implemented by the WBEM server.

Type:

string

property 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 Exceptions raised by WBEMConnection.: :raises ModelError: An error with the model implemented by the WBEM server.

Type:

list of CIMInstanceName

property namespaces

Names of all namespaces of the WBEM server.

:raises Exceptions raised by WBEMConnection.: :raises ModelError: An error with the model implemented by the WBEM server.

Type:

list of string

property profiles

The CIM_RegisteredProfile instances representing all management profiles advertised by the WBEM server.

:raises Exceptions raised by WBEMConnection.: :raises CIMError: CIM_ERR_NOT_FOUND, Interop namespace could not be determined.

Type:

list of CIMInstance

property url

URL of the WBEM server.

Type:

string

property 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.: :raises CIMError: CIM_ERR_NOT_FOUND, Interop namespace could not be determined. :raises CIMError: CIM_ERR_NOT_FOUND, Unexpected number of CIM_ObjectManager instances.

Type:

string