Blog Standards-based Management in Windows Server “8” gives overview of standard-based management and architecture of the new management stack introduced in Windows 8 and Windows Server 2012. “Implementing MI Provider” series blogs are about to discuss how to implement MI provider step by step, including a brief tutorial on implementing a MI provider; an introduction to MI API; preparations for writing a MI provider; defining schema; generating provider skeleton code; implementing MI provider skeleton; registering a MI provider; and debugging MI provider(s).

This blog is about to discuss the concept of MI provider; availability of MI API; and preparations for writing a MI provider.

What is MI Provider?

Before introducing MI Provider, I assume you have the knowledge about “what is WMI” and “how to write WMI provider”. Similar to a WMI provider, MI provider(s) are used to expose data and operations to client applications and/or administrators via CIMOM server, which is WMI on windows OS.

A MI provider implements MI provider interface, which is C based and compliant with CIM standard. A MI provider exposes both schema (CIM class) information of the manageable objects and operations against the manageable objects. Generally, MI provider can be divided into 3 categories, instance provider; association provider; and indication provider.

An instance MI provider supports intrinsic methods, including enumerate instance, get instance, create instance, delete instance and modify instance; and extrinsic methods, including instance method and static method.

An association MI provider is similar to WMI association provider, which is used to associate instances of different classes. Details will be discussed in the following blogs.

An indication MI provider is similar to WMI Event provider, which delivers notifications about the changes of manageable objects from server to client. A specific indication class provides notification when specific events occur. An indication provider may implements multiple indication classes. Details will be discussed in the following blogs.

 

Availability of MI provider API

Windows 8 and Windows Server 2012 introduce a new set of management APIs, called the Windows Management Infrastructure (MI) APIs. This includes MI provider C APIs, client C APIs, and client .Net APIs. These set of new APIs are more tightly aligned with the CIM standard that is the basis for WMI, and provide support for the standard WS-Man protocol via WinRM.

These new APIs will interoperate directly with existing Windows Management Instrumentation (WMI) clients and providers. An application written using the new client APIs work with pre-existing WMI providers as well as providers based on the new MI C APIs. Likewise, providers written using the new APIs can be called from client applications written using the older version of the WMI .Net and C APIs.

Table 1.0 contains list of terms that might be useful to understand the content of the blog.

Name

Definition

CIM Class

A schema that represents a managed resource type on server

CIM Instance

A snapshot representation of an instance of a CIM class on a CIMOM server

CIM Provider

Provides set of CIM standard operations of a CIM class

CIMOM server

A process which responds to the client CIOMI request to any managed resources

Table 1.0 Terminologies

 

MI provider development process

Windows 8 and Windows Server 2012 introduce a new provider model, with code generation and provider registration tools, which works seamlessly with MI provider API.

A C based provider code skeleton can be generated from user-defined schema in the form of a MOF file, using the tool called Convert-MofToProvider.exe, which ships in the Windows 8 SDK.

Register-CimProvider.exe is a new provider registration tool, and ships with Windows 8 and Windows Server 2012, and is used to register a MI provider into WMI. These tools work only for providers based on the new APIs.

Figure 1.0 shows steps of writing a CIM provider, the remaining content of the blog serials follows exactly those steps.

 

Figure 1.0 MI provider development process

Assume you have your MI provider ready, then, you may ask a question - how do I access the data and operations exposed by the CIM provider(s)? The short answer is "many ways". You could use MI C API, MI .Net API, and of course Powershell cmdlets.

Powershell Cmdlets

There are two types of cmdlets introduced by windows 8 and windows server 2012, CIM-Based cmdlets and generic CIM cmdlets.

A CIM-Based Cmdlet model was introduced to support creation of PowerShell cmdlets, which expose the data and the operations of any provider to PowerShell users. It introduces a new way to create cmdlets by using an XML file to describe the cmdlet functionality, and then importing the new module into PowerShell. This new way of writing cmdlets works with both new providers written using the MI APIs, and providers written using the older WMI APIs.

A set of generic cmdlets called CIM Cmdlets, which are based on the MI client .Net API, and help to consume the data and operations from any new or existing providers.

In order to provide seamless Powershell Cmdlet experiences, a set of Powershell semantics specific provider APIs were introduced to allow MI provider to write verbose message to Powershell, update operation progress data, ask user confirmation for dangerous operations, etc. Those APIs will be discussed in following blogs.

To start writing a CIM provider, following are the preparation steps.

Preparation

First of all, there are set of tools to help implementing and debugging a CIM provider. For each step of figure 1.0, there are some tools available.

(1)  For schema defining, you can use CIM IDE. Of course, you can create the mof in any text editor.

(2)  Convert-MofToProvider.exe is used to generating provider skeleton code, which is shipped as of windows 8 SDK.

(3)  You need visual studio 2012 and windows 8 SDK to implement and build the provider MI API sample, which contains a set of MI provider samples.

(4)  Register-CimProvider.exe is the tool used for registering CIM provider(s) into WMI.

(5)  For debugging a provider, you can use either visual studio 2012 or Windbg.

 

To setup a development environment, you may need to,

(1) Install visual studio 2012

(2) Install windows 8 SDK, which contains set of tools listed above; MI API header file as well as lib file, called mi.h and mi.lib respectively; and mi.net api.

(3) Install MI API sample, which contains several MI provider samples.

(4) If your class derives from DMTF standard class, then you may have to download the CIM standard schema from DMTF website.

 

Haowei Qin [MSFT]
Senior SDE
Standards Based Management