{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "Wbem Servers class" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "##Overview" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Getting Namespace Information\n", "\n", "The namespaces property of the WBEMServer gets the namespaces from the WBEM Server and returns them as a list of string.\n", "\n", "The namespaces are retained in the WBEMServer objects as for the lifecycle of that object\n", "\n" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "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:\n", "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\n" ] } ], "source": [ "from __future__ import print_function\n", "import pywbem\n", "\n", "username = 'user'\n", "password = 'password'\n", "classname = 'CIM_ComputerSystem'\n", "namespace = 'root/cimv2'\n", "server = 'http://localhost'\n", "max_obj_cnt = 100\n", "\n", "from __future__ import print_function\n", "import pywbem\n", "\n", "username = 'user'\n", "password = 'password'\n", "classname = 'CIM_ComputerSystem'\n", "namespace = 'root/cimv2'\n", "server = 'http://localhost'\n", "max_obj_cnt = 100\n", "\n", "conn = pywbem.WBEMConnection(server, (username, password),\n", " default_namespace=namespace,\n", " no_verification=True)\n", "\n", "svr = pywbem.WBEMServer(conn)\n", "print('Server %s namespaces:\\n%s' % (server, ', '.join(svr.namespaces)))" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Get the Interop Namespace from the WBEM Server" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Interop namespace: root/PG_InterOp\n" ] } ], "source": [ "\n", "print(\"Interop namespace: %s\" % svr.interop_ns)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Get the brand and version information from the WBEM Server" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Brand:\n", " OpenPegasus\n", "Version:\n", " 2.15.0\n" ] } ], "source": [ "print(\"Brand:\\n %s\" % svr.brand)\n", "print(\"Version:\\n %s\" % svr.version)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Get the WBEM Server Profiles\n", "\n", "TODO: Define the concept of value mapping and point to the method." ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Advertised management profiles:\n", " SNIA Array Profile 1.1.0\n", " Other SomeSystemProfile Profile 0.1.0\n", " SNIA Profile Registration Profile 1.0.0\n", " SNIA SMI-S Profile 1.2.0\n", " SNIA Server Profile 1.1.0\n", " SNIA Server Profile 1.2.0\n", " DMTF Fan Profile 1.0.0\n", " DMTF Ethernet Port Profile 1.0.0\n", " DMTF CPU Profile 1.0.0\n", " DMTF Computer System Profile 1.0.0\n", " DMTF Profile Registration Profile 1.0.0\n", " DMTF Indications Profile 1.1.0\n", " SNIA Block Server Performance Profile 1.1.0\n", " SNIA Disk Drive Lite Profile 1.1.0\n", " SNIA Indication Profile 1.1.0\n", " Other Some Subprofile Profile 0.1.0\n", " Other Some Other Subprofile Profile 0.1.0\n", " SNIA Indication Profile 1.2.0\n", " SNIA Software Profile 1.1.0\n", " SNIA Software Profile 1.2.0\n" ] } ], "source": [ "def print_profile_info(org_vm, profile_instance):\n", " \"\"\"\n", " Print information on a profile defined by profile_instance.\n", "\n", " Parameters:\n", "\n", " org_vm: The value mapping for CIMRegisterdProfile and\n", " RegisteredOrganization so that the value and not value mapping\n", " is displayed.\n", "\n", " profile_instance: instance of a profile to be printed\n", " \"\"\"\n", " org = org_vm.tovalues(profile_instance['RegisteredOrganization'])\n", " name = profile_instance['RegisteredName']\n", " vers = profile_instance['RegisteredVersion']\n", " print(\" %s %s Profile %s\" % (org, name, vers))\n", " \n", "# create the CIMRegisterd Profile ValueMapping for the\n", "# defined server. This can be used to\n", "org_vm = pywbem.ValueMapping.for_property(svr, svr.interop_ns,\n", " 'CIM_RegisteredProfile',\n", " 'RegisteredOrganization')\n", "\n", "print(\"Advertised management profiles:\")\n", "org_vm = pywbem.ValueMapping.for_property(svr, svr.interop_ns,\n", " 'CIM_RegisteredProfile',\n", " 'RegisteredOrganization')\n", "\n", "for inst in svr.profiles:\n", " print_profile_info(org_vm, inst)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Getting profiles for defined organizations, profiles and versions\n", "\n", "The `get_selected_profiles method allows filtering profiles by organization, profile name and even version" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Profiles for SNIA:Server\n", " SNIA Server Profile 1.1.0\n", " SNIA Server Profile 1.2.0\n" ] } ], "source": [ " server_profiles = svr.get_selected_profiles('SNIA', 'Server')\n", "\n", " print('Profiles for SNIA:Server')\n", " for inst in server_profiles:\n", " print_profile_info(org_vm, inst)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Profiles for SNIA:Server\n", " SNIA Server Profile 1.1.0\n" ] } ], "source": [ " server_profiles = svr.get_selected_profiles('SNIA', 'Server', '1.1.0')\n", "\n", " print('Profiles for SNIA:Server')\n", " for inst in server_profiles:\n", " print_profile_info(org_vm, inst)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 1 }