In [ ]:
Wbem Servers class

In [ ]:
##Overview

In [ ]:
## Getting Namespace Information

The namespaces property of the WBEMServer gets the namespaces from the WBEM Server and returns them as a list of string.

The namespaces are retained in the WBEMServer objects as for the lifecycle of that object

In [20]:
from __future__ import print_function
import pywbem

username = 'user'
password = 'password'
classname = 'CIM_ComputerSystem'
namespace = 'root/cimv2'
server = 'http://localhost'
max_obj_cnt = 100

from __future__ import print_function
import pywbem

username = 'user'
password = 'password'
classname = 'CIM_ComputerSystem'
namespace = 'root/cimv2'
server = 'http://localhost'
max_obj_cnt = 100

conn = pywbem.WBEMConnection(server, (username, password),
                             default_namespace=namespace,
                             no_verification=True)

svr = pywbem.WBEMServer(conn)
print('Server %s namespaces:\n%s' % (server, ', '.join(svr.namespaces)))


Server WBEMServer(url='http://localhost', conn=WBEMConnection(url='http://localhost', creds=('user', ...), default_namespace='root/cimv2', x509=None, verify_callback=None, ca_certs=None, no_verification=True, timeout=None, use_pull_operations=None), interop_ns=root/PG_InterOp, namespaces=[u'root/PG_InterOp', u'root/SampleProvider', u'root/benchmark', u'test/CimsubTestNS2', u'test/CimsubTestNS3', u'test/CimsubTestNS0', u'test/CimsubTestNS1', u'root/PG_Internal', u'test/WsmTest', u'test/TestIndSrcNS1', u'test/EmbeddedInstance/Static', u'test/TestINdSrcNS2', u'test/TestProvider', u'test/EmbeddedInstance/Dynamic', u'root/cimv2', u'root', u'test/cimv2', u'test/static'], namespace_classname='CIM_Namespace', brand='OpenPegasus', version=u'2.15.0', profiles=[... 20 instances]) namespaces:
root/PG_InterOp, root/SampleProvider, root/benchmark, test/CimsubTestNS2, test/CimsubTestNS3, test/CimsubTestNS0, test/CimsubTestNS1, root/PG_Internal, test/WsmTest, test/TestIndSrcNS1, test/EmbeddedInstance/Static, test/TestINdSrcNS2, test/TestProvider, test/EmbeddedInstance/Dynamic, root/cimv2, root, test/cimv2, test/static

In [ ]:
## Get the Interop Namespace from the WBEM Server

In [21]:
print("Interop namespace: %s" % svr.interop_ns)


Interop namespace: root/PG_InterOp

In [ ]:
## Get the brand and version information from the WBEM Server

In [22]:
print("Brand:\n  %s" % svr.brand)
print("Version:\n  %s" % svr.version)


Brand:
  OpenPegasus
Version:
  2.15.0

In [ ]:
## Get the WBEM Server Profiles

TODO: Define the concept of value mapping and point to the method.

In [23]:
def print_profile_info(org_vm, profile_instance):
    """
    Print information on a profile defined by profile_instance.

    Parameters:

      org_vm: The value mapping for CIMRegisterdProfile and
          RegisteredOrganization so that the value and not value mapping
          is displayed.

      profile_instance: instance of a profile to be printed
    """
    org = org_vm.tovalues(profile_instance['RegisteredOrganization'])
    name = profile_instance['RegisteredName']
    vers = profile_instance['RegisteredVersion']
    print("  %s %s Profile %s" % (org, name, vers))
    
# create the CIMRegisterd Profile ValueMapping for the
# defined server. This can be used to
org_vm = pywbem.ValueMapping.for_property(svr, svr.interop_ns,
                                   'CIM_RegisteredProfile',
                                   'RegisteredOrganization')

print("Advertised management profiles:")
org_vm = pywbem.ValueMapping.for_property(svr, svr.interop_ns,
                                       'CIM_RegisteredProfile',
                                       'RegisteredOrganization')

for inst in svr.profiles:
    print_profile_info(org_vm, inst)


Advertised management profiles:
  SNIA Array Profile 1.1.0
  Other SomeSystemProfile Profile 0.1.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 Fan Profile 1.0.0
  DMTF Ethernet Port Profile 1.0.0
  DMTF CPU Profile 1.0.0
  DMTF Computer System Profile 1.0.0
  DMTF Profile Registration Profile 1.0.0
  DMTF Indications Profile 1.1.0
  SNIA Block Server Performance Profile 1.1.0
  SNIA Disk Drive Lite Profile 1.1.0
  SNIA Indication Profile 1.1.0
  Other Some Subprofile Profile 0.1.0
  Other Some Other Subprofile Profile 0.1.0
  SNIA Indication Profile 1.2.0
  SNIA Software Profile 1.1.0
  SNIA Software Profile 1.2.0

In [ ]:
## Getting profiles for defined organizations, profiles and versions

The `get_selected_profiles method allows filtering profiles by organization, profile name and even version

In [24]:
server_profiles = svr.get_selected_profiles('SNIA', 'Server')

    print('Profiles for SNIA:Server')
    for inst in server_profiles:
        print_profile_info(org_vm, inst)


Profiles for SNIA:Server
  SNIA Server Profile 1.1.0
  SNIA Server Profile 1.2.0

In [25]:
server_profiles = svr.get_selected_profiles('SNIA', 'Server', '1.1.0')

    print('Profiles for SNIA:Server')
    for inst in server_profiles:
        print_profile_info(org_vm, inst)


Profiles for SNIA:Server
  SNIA Server Profile 1.1.0