{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Wbem Servers class" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "##Overview" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "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": null, "metadata": {}, "outputs": [], "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": {}, "outputs": [], "source": [ "## Get the Interop Namespace from the WBEM Server" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "print(\"Interop namespace: %s\" % svr.interop_ns)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "## Get the brand and version information from the WBEM Server" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(\"Brand:\\n %s\" % svr.brand)\n", "print(\"Version:\\n %s\" % svr.version)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "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": null, "metadata": { "scrolled": true }, "outputs": [], "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": {}, "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": null, "metadata": { "scrolled": true }, "outputs": [], "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": null, "metadata": {}, "outputs": [], "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 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 1 }