{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Python Data Model for CIM" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "<--- Back" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One of the goals of PyWBEM is to have an understandable, well-integrated, and easy to use interface to CIM objects and operations. This is achieved by the thoughtful mapping of CIM objects such as instances, instance names, properties, classes, etc. to Python objects. There is no need to worry about the representation of CIM objects in XML, or anything related to HTTP/HTTPS.\n", "\n", "PyWBEM represents CIM objects in a generic way. For example, CIM instances are represented as objects of the Python class [`pywbem.CIMInstance`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMInstance), and CIM classes as objects of the Python class [`pywbem.CIMClass`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMClass). Thus, a CIM instance of class \"CIM_Person\" is represented as a Python object of type CIMInstance whose `classname` attribute is set to \"CIM_Person\".\n", "\n", "This approach is simple and straight forward. However, first-class object aficionados might prefer Python objects of type `CIM_Person` for CIM instances of class \"CIM_Person\", instead. Such a first-class object representation has its own complexities, however, and is not currently supported by PyWBEM." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## CIM Instances and Instance Names" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The two fundamental Python classes in PyWBEM are [`pywbem.CIMInstance`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMInstance) and [`pywbem.CIMInstanceName`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMInstanceName).\n", "\n", "A [`CIMInstance`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMInstance) object is a representation of a CIM instance in a WBEM server, which in turn represents a physical or logical resource that is under management, or an aspect thereof. Examples for such managed resources are disk drives, temperature sensors, or network cards. The most interesting part of a CIM instance is the properties and values those properties take. The properties of a [`CIMInstance`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMInstance) object can be accessed by treating the object as a Python dictionary:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pywbem\n", "\n", "inst = pywbem.CIMInstance('CIM_Person')\n", "inst['Firstname'] = 'Tim'\n", "inst['Lastname'] = 'Potter'\n", "\n", "print(inst.items())\n", "print(inst['firstname'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that the second `print()` specifies the CIM property name in a different lexical case compared to how it was created. PyWBEM supports case-insensitive access to all CIM element names, as required by the CIM standards.\n", "\n", "A [`CIMInstanceName`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMInstanceName) object is a reference to a CIM instance in a WBEM server. It may specify the location of the WBEM server, the CIM namespace within the server, the CIM class within the namespace, and identifies the CIM instance within the class by means of its key property values. These key property values are called key bindings in CIM.\n", "\n", "Similar to [`CIMInstance`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMInstance), the key bindings of a [`CIMInstanceName`](https://pywbem.readthedocs.io/en/latest/client.html#pywbem.CIMInstanceName) object can also be accessed by treating the object as a Python dictionary." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# CIM Data Types" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "CIM has a number of data types that are mostly mapped to specific Python classes, and in some cases to built-in Python types such as `bool`, `str`/`unicode` or `list`.\n", "\n", "See [CIM data types](https://pywbem.readthedocs.io/en/latest/client.html#cim-data-types) for details about the Python representation of CIM data types." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "<--- Back" ] } ], "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.6" } }, "nbformat": 4, "nbformat_minor": 1 }