Wbem Servers class
##Overview
## 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
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)))
## Get the Interop Namespace from the WBEM Server
print("Interop namespace: %s" % svr.interop_ns)
## Get the brand and version information from the WBEM Server
print("Brand:\n %s" % svr.brand)
print("Version:\n %s" % svr.version)
## Get the WBEM Server Profiles
TODO: Define the concept of value mapping and point to the method.
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)
## Getting profiles for defined organizations, profiles and versions
The `get_selected_profiles method allows filtering profiles by organization, profile name and even version
server_profiles = svr.get_selected_profiles('SNIA', 'Server')
print('Profiles for SNIA:Server')
for inst in server_profiles:
print_profile_info(org_vm, inst)
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)