### Provider Post Register Setup Method Example Source: https://pywbem.readthedocs.io/en/latest/_sources/mockwbemserver.rst.txt An optional post_register_setup method for a provider to perform specific setup tasks after registration. It receives the connection object as a parameter. ```python def post_register_setup(self, conn): # code that performs post registration setup for the provider ``` -------------------------------- ### Create and Run WBEMListener Source: https://pywbem.readthedocs.io/en/latest/indication.html This example demonstrates how to create, configure, and start a WBEMListener. It includes setting up logging, specifying certificate files, and adding a callback function to process received indications. Ensure the `certkeyfile` exists and is accessible. ```python import logging from pywbem import WBEMListener def process_indication(indication, host): '''This function gets called when an indication is received.''' print(f"Received CIM indication from {host}: {indication!r}") def main(): # Configure logging of the listener via the Python root logger logging.basicConfig( filename='listener.log', level=logging.WARNING, format='%(asctime)s - %(levelname)s - %(message)s') certkeyfile = 'listener.pem' # Set host name to wildcard host address to recieve indications on # any network address defined for this system. listener = WBEMListener(host="", http_port=5990, https_port=5991, certfile=certkeyfile, keyfile=certkeyfile) listener.add_callback(process_indication) try: listener.start() # process_indication() will be called for each received indication . . . # wait for some condition to end listening finally: listener.stop() ``` -------------------------------- ### Create and Run a WBEM Listener Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem/_listener.html This example demonstrates how to set up and start a WBEMListener. It configures logging, specifies certificate files, and adds a callback function to process received indications. The listener is started within a try-finally block to ensure it is stopped properly. ```python import logging from pywbem import WBEMListener def process_indication(indication, host): '''This function gets called when an indication is received.''' print(f"Received CIM indication from {host}: {indication!r}") def main(): # Configure logging of the listener via the Python root logger logging.basicConfig( filename='listener.log', level=logging.WARNING, format='%(asctime)s - %(levelname)s - %(message)s') certkeyfile = 'listener.pem' # Set host name to wildcard host address to recieve indications on # any network address defined for this system. listener = WBEMListener(host="", http_port=5990, https_port=5991, certfile=certkeyfile, keyfile=certkeyfile) listener.add_callback(process_indication) try: listener.start() # process_indication() will be called for each received indication . . . # wait for some condition to end listening finally: listener.stop() ``` -------------------------------- ### Create and Run a WBEM Listener Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem/_listener.html This example demonstrates how to set up and start a WBEM listener. It includes configuring logging, defining a callback function to process incoming indications, and specifying listener parameters like host, ports, and certificate files. Ensure the certificate file exists and is accessible. ```python import logging from pywbem import WBEMListener def process_indication(indication, host): """This function gets called when an indication is received.""" print(f"Received CIM indication from {host}: {indication!r}") def main(): # Configure logging of the listener via the Python root logger logging.basicConfig( filename='listener.log', level=logging.WARNING, format='%(asctime)s - %(levelname)s - %(message)s') certkeyfile = 'listener.pem' # Set host name to wildcard host address to recieve indications on # any network address defined for this system. listener = WBEMListener(host="", http_port=5990, https_port=5991, certfile=certkeyfile, keyfile=certkeyfile) listener.add_callback(process_indication) listener.start() # process_indication() will be called for each received indication . . . # wait for some condition to end listening listener.stop() ``` -------------------------------- ### WBEMListener Class Usage Source: https://pywbem.readthedocs.io/en/latest/indication.html Demonstrates how to create and run a WBEMListener instance to receive and process CIM indications. It shows basic setup, adding a callback function, starting the listener, and stopping it. ```APIDOC ## WBEMListener Class Usage ### Description This example shows how to instantiate and use the `WBEMListener` class to listen for WBEM indications. It includes setting up logging, defining a callback function to process indications, and managing the listener's lifecycle. ### Method ```python import logging from pywbem import WBEMListener def process_indication(indication, host): """This function gets called when an indication is received.""" print(f"Received CIM indication from {host}: {indication!r}") def main(): # Configure logging of the listener via the Python root logger logging.basicConfig( filename='listener.log', level=logging.WARNING, format='%(asctime)s - %(levelname)s - %(message)s') certkeyfile = 'listener.pem' # Set host name to wildcard host address to recieve indications on # any network address defined for this system. listener = WBEMListener(host="", http_port=5990, https_port=5991, certfile=certkeyfile, keyfile=certkeyfile) listener.add_callback(process_indication) try: listener.start() # process_indication() will be called for each received indication # ... # wait for some condition to end listening finally: listener.stop() ``` ### Context Manager Usage Alternatively, the `WBEMListener` can be used as a context manager, which automatically handles stopping the listener. ```python with WBEMListener(...) as listener: listener.add_callback(process_indication) listener.start() # process_indication() will be called for each received indication # ... # wait for some condition to end listening # listener.stop() has been called automatically ``` ### Parameters for WBEMListener constructor: - **host** (str): The host address to bind the listener to. An empty string binds to all available network interfaces. - **http_port** (int): The HTTP port to listen on. - **https_port** (int): The HTTPS port to listen on. - **certfile** (str): Path to the SSL certificate file. - **keyfile** (str): Path to the SSL key file. ### Methods: - **add_callback(callback_func)**: Registers a function to be called when an indication is received. - **start()**: Starts the listener thread. - **stop()**: Stops the listener thread. ``` -------------------------------- ### Provider Registration Setup Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem_mock/_namespaceprovider.html Method called after required classes are installed to complete provider initialization. This is necessary because pywbem_mock does not allow user-defined classes directly. ```python def post_register_setup(self, conn): """ Method called by FakedWBEMConnection.register_provider to complete initialization of this provider. This method is called after the required classes are installed in the cim_repository This is necessary because pywbem_mock does not allow user-defined ``` -------------------------------- ### Start Jupyter Notebook Source: https://pywbem.readthedocs.io/en/latest/tutorial.html Use this command to start Jupyter Notebook, specifying the directory where your downloaded notebooks are located. Ensure Jupyter Notebook and pywbem are installed, preferably in a virtual environment. ```bash jupyter notebook --notebook-dir={your-notebook-dir} ``` -------------------------------- ### Start IPython/Jupyter Notebook Server Source: https://pywbem.readthedocs.io/en/latest/_sources/development.rst.txt Use this command to start the local notebook server and access pywbem notebooks for editing or creation. ```bash $ ipython notebook docs/notebooks or $ jupyter notebook docs/notebooks ``` -------------------------------- ### Provider __init__ Method Example Source: https://pywbem.readthedocs.io/en/latest/_sources/mockwbemserver.rst.txt An example of an __init__() method for a user-defined provider that accepts the cimrepository and passes it to the superclass. This can be omitted if no additional init parameters are needed. ```python def __init__(self, cimrepository): super(MyInstanceWriteProvider, self).__init__(cimrepository) ``` -------------------------------- ### Install pywbem using uv Source: https://pywbem.readthedocs.io/en/latest/_sources/intro.rst.txt Installs the latest version of pywbem and its prerequisites using the uv package installer. ```bash uv pip install pywbem ``` -------------------------------- ### Install pywbem 1.0.0b1 Beta Source: https://pywbem.readthedocs.io/en/latest/changes.html Use these commands to install the beta version of pywbem. Pip will only install this version if explicitly requested. ```bash $ pip install pywbem==1.0.0b1 ``` ```bash $ pip install --pre pywbem ``` -------------------------------- ### CIM Class Path Examples Source: https://pywbem.readthedocs.io/en/latest/client/objects.html Examples demonstrating different formats for CIM class paths, including host, namespace, and canonical variations. ```plaintext //ACME.com/cimv2/Test:CIM_RegisteredProfile ``` ```plaintext //acme.com/cimv2/test:cim_registeredprofile ``` ```plaintext /cimv2/Test:CIM_RegisteredProfile ``` ```plaintext /cimv2/test:cim_registeredprofile ``` ```plaintext /:CIM_RegisteredProfile ``` -------------------------------- ### Example Implementation of Method1 Source: https://pywbem.readthedocs.io/en/latest/mockwbemserver.html This example demonstrates how to implement the 'Method1' for the 'CIM_Foo_sub_sub' class. It modifies the 'cimfoo_sub_sub' property of the instance and returns its new value. ```APIDOC ## MethodProvider.Method1 ### Description Implementation of CIM method 'Method1'. This method modifies a property of the instance and returns it. ### Method `Method1(self, localobject, params)` ### Parameters - **localobject** (CIMInstanceName): The instance on which the method was invoked. - **params** (dict): A dictionary of input parameters for the method. ### Response - **return_value** (uint32): The return value of the CIM method (0 indicates success). - **out_params** (list): A list of CIMParameter objects representing the output parameters. In this case, it contains 'OutputParam2'. ### Request Example (Not directly applicable as this is a server-side implementation) ### Response Example ```python # Assuming localobject is an instance of CIM_Foo_sub_sub # and params contains any input parameters (none in this case) return_value, out_params = provider_instance.Method1(localobject, params) # Example of out_params structure: # out_params = [ # CIMParameter('OutputParam2', type='string', value='new++') # ] ``` ``` -------------------------------- ### Prepare for Starting a New Version Tag Source: https://pywbem.readthedocs.io/en/latest/_sources/development.rst.txt Updates and cleans up the local repository for starting a new version tag. This command checks out and pulls the relevant branch. ```sh VERSION=M.N.U make start_tag ``` ```sh VERSION=M.N.0 BRANCH=stable_M.N make start_tag ``` -------------------------------- ### CIMInstanceName WBEM URI Examples Source: https://pywbem.readthedocs.io/en/latest/client/objects.html Examples of CIM instance paths formatted as WBEM URIs, including variations with and without host and namespace. ```text //acme.com/cimv2/test:CIM_RegisteredProfile.InstanceID="acme.1" ``` ```text cimv2/test:CIM_RegisteredProfile.InstanceID="acme.1" ``` ```text CIM_RegisteredProfile.InstanceID="acme.1" ``` -------------------------------- ### Install Pywbem with Test Dependencies Source: https://pywbem.readthedocs.io/en/latest/_sources/development.rst.txt Install pywbem along with its dependent packages and testing packages using the 'test' extra. This prepares the environment for running tests. ```bash $ pip install .[test] ``` -------------------------------- ### Example DMTF CIM Schema MOF File Path Source: https://pywbem.readthedocs.io/en/latest/mockwbemserver.html Provides a concrete example of a schema PRAGMA file path, showing versioning and directory structure. ```text schemas/dmtf/moffinal2490/cim_schema_2.49.0.mof ``` -------------------------------- ### Install Specific urllib3 Version Source: https://pywbem.readthedocs.io/en/latest/_sources/appendix.rst.txt Install a specific version of urllib3, for example, to downgrade to a version less than 2.0 to resolve compatibility issues. ```bash pip install urllib3 < 2.0 ``` -------------------------------- ### Example of Externally-managed-environment error Source: https://pywbem.readthedocs.io/en/latest/_sources/appendix.rst.txt This is an example of the error message encountered when pip refuses to install packages into a system Python environment due to PEP 668 compliance. ```text error: externally-managed-environment × This environment is externally managed . . . . . . ``` -------------------------------- ### Implement post_register_setup Method Source: https://pywbem.readthedocs.io/en/latest/mockwbemserver.html Optional method to perform setup after the provider is registered. It receives the current connection object. ```python def post_register_setup(self, conn): # code that performs post registration setup for the provider pass ``` -------------------------------- ### PyWBEM Repository Initialization and Usage Example Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem_mock/_baserepository.html Demonstrates how to initialize a custom repository, add a namespace, retrieve an object store, create a CIM class, add it to the store, and check for its existence. ```python # MyRepository is a class derived from BaseRepository repo = MyRepository() # create the repo repo.add_namespace("root/cimv2") # add a namespace class_store = .repo.get_class_store("root/cimv2") # get class obj store test_class = CIMClass('CIM_Blah', ...) # create a class class_store.add(test_class) # add to xxxrepo classes if 'CIM_Blah' in class_store: # test if class exists klass = class_store.get('CIM_Blah;) # get the class ``` -------------------------------- ### Setup Mock WBEM Server and Populate CIM Repository Source: https://pywbem.readthedocs.io/en/latest/mockwbemserver.html Demonstrates initializing a mock WBEM server, compiling MOF to define CIM classes and instances, and adding them to the server's repository. This setup is essential before performing WBEM operations against the mock server. ```python import pywbem import pywbem_mock # MOF string defining qualifiers, class, and instance mof = ''' Qualifier Key : boolean = false, Scope(property, reference), Flavor(DisableOverride, ToSubclass); Qualifier Description : string = null, Scope(any), Flavor(EnableOverride, ToSubclass, Translatable); Qualifier In : boolean = true, Scope(parameter), Flavor(DisableOverride, ToSubclass); [Description ("This is a dumb test class")] class CIM_Foo { [Key, Description ("This is key prop")] string InstanceID; [Description ("This is some simplistic data")] Uint32 SomeData; [Description ("This is a method without parameters")] string Fuzzy(); [Description ("This is a second method with parameter")] uint32 Delete([IN, Description('blahblah'] boolean Immediate); }; instance of CIM_Foo as $I1 { InstanceID = "I1"; SomeData=3 }; ''' # Create a faked connection including a mock WBEM server with a CIM repo conn = pywbem_mock.FakedWBEMConnection(default_namespace='root/cimv2') # Compile the MOF string and add its CIM objects to the default namespace # of the CIM repository conn.compile_mof_string(mof) # Perform a few operations on the faked connection: # Enumerate top-level classes in the default namespace (without subclasses) classes = conn.EnumerateClasses(); for cls in classes: print(cls.tomof()) # Get the 'Description' qualifier type in the default namespace qd = conn.GetQualifier('Description') # Enumerate subclasses of 'CIM_Foo' in the default namespace (without subclasses) classes2 = conn.EnumerateClasses(classname='CIM_Foo') # Get 'CIM_Foo' class in the default namespace my_class = conn.GetClass('CIM_Foo') ``` -------------------------------- ### Setup Mock WBEM Server and Compile MOF Source: https://pywbem.readthedocs.io/en/latest/_sources/mockwbemserver.rst.txt Demonstrates setting up a mock WBEM server, adding CIM objects from a MOF string to its repository, and preparing for WBEM operations. ```python import pywbem import pywbem_mock # MOF string defining qualifiers, class, and instance mof = ''' Qualifier Key : boolean = false, Scope(property, reference), Flavor(DisableOverride, ToSubclass); Qualifier Description : string = null, Scope(any), Flavor(EnableOverride, ToSubclass, Translatable); Qualifier In : boolean = true, Scope(parameter), Flavor(DisableOverride, ToSubclass); [Description ("This is a dumb test class")] class CIM_Foo { [Key, Description ("This is key prop")] string InstanceID; [Description ("This is some simplistic data")] Uint32 SomeData; [Description ("This is a method without parameters")] string Fuzzy(); [Description ("This is a second method with parameter")] uint32 Delete([IN, Description('blahblah'] boolean Immediate); }; instance of CIM_Foo as $I1 { InstanceID = "I1"; SomeData=3 }; ''' # Create a faked connection including a mock WBEM server with a CIM repo conn = pywbem_mock.FakedWBEMConnection(default_namespace='root/cimv2') # Compile the MOF string and add its CIM objects to the default namespace # of the CIM repository conn.compile_mof_string(mof) # Perform a few operations on the faked connection: # Enumerate top-level classes in the default namespace (without subclasses) ``` -------------------------------- ### Clean Build Artifacts Source: https://pywbem.readthedocs.io/en/latest/_sources/development.rst.txt Remove all generated build artifacts to ensure a fresh start for the make process, especially when switching between installed and local pywbem versions. ```bash $ make clobber ``` -------------------------------- ### Get pywbem Package Version Source: https://pywbem.readthedocs.io/en/latest/_sources/intro.rst.txt Determines the installed version of the pywbem package. This command works for all released versions and handles cases where __version__ might not be directly available. ```python python -c "import pywbem; print(getattr(pywbem, '__version__', None) or '0.7.0')" ``` -------------------------------- ### post_register_setup Source: https://pywbem.readthedocs.io/en/latest/mockwbemserver.html Completes the initialization of the CIM_Namespace provider after required classes are installed. ```APIDOC ## post_register_setup(_conn_) ### Description Method called by FakedWBEMConnection.register_provider to complete initialization of this provider. This method is called after the required classes are installed in the cim_repository. This is necessary because pywbem-mock does not allow user-defined providers for the instance read operations such as EnumerateInstances so the instance for each namespace must be exist in the repository. This method inserts instances of CIM_Namespace for every namespace in the CIM repository. ### Parameters #### Path Parameters - **conn** - The FakedWBEMConnection object. ``` -------------------------------- ### Log Configuration String Examples Source: https://pywbem.readthedocs.io/en/latest/client/logging.html Examples demonstrating various ways to format the log configuration string to control logger behavior, including destination, detail level, and enabling/disabling logging. ```python 'api=stderr:summary' # Set 'pywbem.api' logger to stderr output with # summary detail level. ``` ```python 'http=file' # Set 'pywbem.http' logger to file output with # default detail level. ``` ```python 'api=stderr:summary' # Set 'pywbem.api' logger to file output with # summary output level. ``` ```python 'all=file:1000' # Set both pywbem loggers to file output with # a maximum of 1000 characters per log record. ``` ```python 'api=stderr,http=file' # Set 'pywbem.api' logger to stderr output and # 'pywbem.http' logger to file output, both # with default detail level. ``` ```python 'all=off' # Disables logging for both pywbem loggers. ``` -------------------------------- ### Log Configuration String Examples Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem/_logging.html Illustrates various formats for the log configuration string used with `configure_loggers_from_string`. These examples show how to set different loggers to specific destinations and detail levels. ```text 'api=stderr:summary' ``` ```text 'http=file' ``` ```text 'api=file:summary' ``` ```text 'all=file:1000' ``` -------------------------------- ### Post Registration Setup Callback Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem_mock/_methodprovider.html This method is called after a provider is successfully registered. Override it to perform actions like modifying the CIM repository. ```python def post_register_setup(self, conn): """ Method called by provider registration after registation of provider is successful. Using this method is optional for registration cases where the provider must execute some activity (ex. modify the CIM repository after successful provider registration). Override this method in the user-defined provider subclass to execute this method. Parameters: conn (:class:`~pywbem.WBEMConnection`): Current connection which allows client methods to be executed from within this method. """ pass ``` -------------------------------- ### Initialize and Register Server with Subscription Manager Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem/_subscription_manager.html Demonstrates initializing a WBEMSubscriptionManager and registering a WBEM server with it. The server is identified by a WBEMConnection object. ```python from pywbem import WBEMConnection, WBEMServer, WBEMSubscriptionManager server_url = 'http://myserver' server_credentials = ('myuser', 'mypassword') listener_url = 'http://mylistener' conn = WBEMConnection(server_url, server_credentials) server = WBEMServer(conn) sub_mgr = WBEMSubscriptionManager(subscription_manager_id='fred') # Register the server in the subscription manager: server_id = sub_mgr.add_server(server) ``` -------------------------------- ### Install PyWBEM with Pip Source: https://pywbem.readthedocs.io/en/latest/intro.html Installs PyWBEM and its prerequisite Python packages into the active Python environment. Ensure setuptools, wheel, and pip are installed. ```bash $ pip install pywbem ``` -------------------------------- ### Run Installed pywbem Tests Source: https://pywbem.readthedocs.io/en/latest/_sources/development.rst.txt Execute pywbem tests against the installed version by setting the TEST_INSTALLED environment variable. This ensures the installed package is used for testing. ```bash $ TEST_INSTALLED=1 make test ``` -------------------------------- ### Create and Run a pywbem Listener Source: https://pywbem.readthedocs.io/en/latest/indication.html This example demonstrates how to set up a pywbem listener with a callback function to process incoming indications. Ensure you have a valid SSL certificate and key file (listener.pem) for secure communication. ```python import logging from pywbem import WBEMListener def process_indication(indication, host): '''This function gets called when an indication is received.''' print(f"Received CIM indication from {host}: {indication!r}") def main(): # Configure logging of the listener via the Python root logger logging.basicConfig( filename='listener.log', level=logging.WARNING, format='%(asctime)s - %(levelname)s - %(message)s') certkeyfile = 'listener.pem' # Set host name to wildcard host address to recieve indications on # any network address defined for this system. listener = WBEMListener(host="", http_port=5990, https_port=5991, certfile=certkeyfile, keyfile=certkeyfile) listener.add_callback(process_indication) listener.start() # process_indication() will be called for each received indication . . . # wait for some condition to end listening listener.stop() ``` -------------------------------- ### Install SOCKS Support for Requests Source: https://pywbem.readthedocs.io/en/latest/_sources/client/proxy.rst.txt To use SOCKS proxies with pywbem, you must install the 'socks' extra for the 'requests' package. This command installs the necessary dependencies. ```bash $ pip install requests[socks] ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://pywbem.readthedocs.io/en/latest/_sources/development.rst.txt Set up a virtual Python environment using system site packages and activate it for pywbem development and testing. ```bash $ virtualenv --system-site-packages .virtualenv/test $ source .virtualenv/test/bin/activate ``` -------------------------------- ### Install Python wheel package Source: https://pywbem.readthedocs.io/en/latest/_sources/appendix.rst.txt Install the Python 'wheel' package if the installation fails with 'invalid command "bdist_wheel"'. This package is required for building wheels. ```bash pip install wheel ``` -------------------------------- ### Install pywbem using pip Source: https://pywbem.readthedocs.io/en/latest/_sources/intro.rst.txt Installs the latest version of pywbem and its prerequisites into the active Python environment. ```bash pip install pywbem ``` -------------------------------- ### Complete Namespace and Host for Instances Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem/_cim_operations.html Ensures that each instance path has a complete namespace and host, defaulting to the connection's namespace and host if not provided. ```python for inst in enum_rslt: if inst.path.namespace is None: inst.path.namespace = namespace if inst.path.host is None: inst.path.host = self.host ``` -------------------------------- ### Set up Qualifier Types and Classes in DMTF CIM Schema Source: https://pywbem.readthedocs.io/en/latest/mockwbemserver.html This example demonstrates setting up a mock WBEM server by initializing a FakedWBEMConnection with a default namespace and compiling specific leaf classes along with their dependent classes and qualifier types from a DMTF CIM schema version. ```python import pywbem import pywbem_mock conn = pywbem_mock.FakedWBEMConnection(default_namespace='root/interop') # Leaf classes that are to be compiled along with their dependent classes leaf_classes = ['CIM_RegisteredProfile', 'CIM_Namespace', 'CIM_ObjectManager', 'CIM_ElementConformsToProfile', 'CIM_ReferencedProfile'] ``` -------------------------------- ### pywbem.ListenerQueueFullError Source: https://pywbem.readthedocs.io/en/latest/indication.html Starting with pywbem 1.8.0, this exception indicated that the indication delivery queue has reached its maximum size. Starting with pywbem 1.9.0, this exception is no longer raised. New in pywbem 1.8; No longer used starting with pywbem 1.9.0. ```APIDOC class pywbem.ListenerQueueFullError(message) Starting with pywbem 1.8.0, this exception indicated that the indication delivery queue has reached its maximum size. Starting with pywbem 1.9.0, this exception is no longer raised. New in pywbem 1.8; No longer used starting with pywbem 1.9.0 Derived from ListenerError. Parameters: message (str) – Error message (will be put into args[0]). Variables: args – A tuple (message, ) set from the corresponding init argument. Methods: add_note(note) -- add a note to the exception with_traceback(tb) -- set self.__traceback__ to tb and return self. ``` -------------------------------- ### Install Latest pywbem from PyPI Source: https://pywbem.readthedocs.io/en/latest/intro.html Installs the most recent version of pywbem available on the Python Package Index (PyPI). ```bash $ pip install pywbem ``` -------------------------------- ### Implement CreateInstance for CIM_Foo and CIM_FooFoo Source: https://pywbem.readthedocs.io/en/latest/mockwbemserver.html This example shows a user-defined instance write provider that serves 'CIM_Foo' and 'CIM_FooFoo' classes. It implements the CreateInstance method to set a value for the 'InstanceID' key property using a UUID. ```python import uuid from pywbem_mock import InstanceWriteProvider class MyInstanceProvider(InstanceWriteProvider): # CIM classes served by this provider provider_classnames = ['CIM_Foo', 'CIM_FooFoo'] def CreateInstance(self, namespace, new_instance): new_instance.properties["InstanceID"] = \ f"{new_instance.classname}.{uuid.uuid4()}" return super(MyInstanceProvider, self).CreateInstance( namespace, new_instance) ``` -------------------------------- ### Show Installed pywbem Version Source: https://pywbem.readthedocs.io/en/latest/_sources/development.rst.txt Verify that the pywbem package within the activated virtual environment is from the intended installation. ```bash $ pip show pywbem ``` -------------------------------- ### Initialize Uint8 with different inputs Source: https://pywbem.readthedocs.io/en/latest/_modules/pywbem/_cim_types.html Demonstrates various ways to initialize a Uint8 object, including using integers, strings, and specifying the base. It also shows examples of invalid inputs that raise ValueErrors or TypeErrors. ```python >>> pywbem.Uint8(42) Uint8(cimtype='uint8', 42) >>> pywbem.Uint8('42') Uint8(cimtype='uint8', 42) >>> pywbem.Uint8('2A', 16) Uint8(cimtype='uint8', 42) >>> pywbem.Uint8('2A', base=16) Uint8(cimtype='uint8', 42) >>> pywbem.Uint8(x='2A', base=16) Uint8(cimtype='uint8', 42) >>> pywbem.Uint8('100', 16) Traceback (most recent call last): . . . ValueError: Integer value 256 is out of range for CIM datatype uint8 >>> pywbem.Uint8(100, 10) Traceback (most recent call last): . . . TypeError: int() can't convert non-string with explicit base ``` -------------------------------- ### Install a specific version of pywbem Source: https://pywbem.readthedocs.io/en/latest/_sources/intro.rst.txt Installs a specific older version of pywbem (e.g., version 0.10.0) from PyPI. ```bash pip install pywbem==0.10.0 ``` -------------------------------- ### Install pywbem into a virtual environment Source: https://pywbem.readthedocs.io/en/latest/_sources/intro.rst.txt Installs pywbem into the currently active virtual Python environment (e.g., 'myenv'). ```bash (myenv)$ pip install pywbem ``` -------------------------------- ### CIMClassName Examples Source: https://pywbem.readthedocs.io/en/latest/client/objects.html Examples demonstrating the historical WBEM URI format for CIMClassName objects with different combinations of host and namespace. ```python //acme.com/cimv2/test:CIM_RegisteredProfile ``` ```python cimv2/test:CIM_RegisteredProfile ``` ```python CIM_RegisteredProfile ``` -------------------------------- ### Install Specific pywbem Version from PyPI Source: https://pywbem.readthedocs.io/en/latest/intro.html Installs a specific older version of pywbem from PyPI by appending '==version' to the package name. ```bash $ pip install pywbem==0.10.0 ```