#!/usr/bin/env python # coding: utf-8 # 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[ ]: 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))) # In[ ]: ## Get the Interop Namespace from the WBEM Server # In[ ]: print("Interop namespace: %s" % svr.interop_ns) # In[ ]: ## Get the brand and version information from the WBEM Server # In[ ]: print("Brand:\n %s" % svr.brand) print("Version:\n %s" % svr.version) # In[ ]: ## Get the WBEM Server Profiles TODO: Define the concept of value mapping and point to the method. # In[ ]: 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) # 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[ ]: server_profiles = svr.get_selected_profiles('SNIA', 'Server') print('Profiles for SNIA:Server') for inst in server_profiles: print_profile_info(org_vm, inst) # In[ ]: 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)