SMI-S Simulator

SMI-S 模拟器

网上的水的论文不少,实际项目没看到,于是搞了一下,希望能有所参考

tog-pegasus

yum源里也有rpm,但release版隐藏我们需要的一个功能开关,这里我们自己编译

https://github.com/OpenPegasus/OpenPegasus

采用了rpmbuild方式,同时做了一些修改

  • tog-pegasus.spec: Version+1
  • tog-pegasus.spec: PEGASUS_REPOSITORY_DIR/PEGASUS_VARDATA_CACHE_DIR 移到了postun,否则yum remove时会报一堆repository找不到
  • rpm/wbem-redhat => rpm/wbem: 这个是pam验证的,根据自己系统的情况修改,装完再改/etc/pam.d/wbem也行
  • env_var_Linux.status: PEGASUS_USE_RELEASE_CONFIG_OPTIONS=false 以启用repositoryIsDefaultInstanceProvider等配置项

准备好tar.gz和相关重命名,然后编译rpmbuild -bb tog-pegasus.spec,rpm在rpmbuild/RPMS下,然后使用yum localinstall xxx安装

/etc/Pegasus/access.conf,wbemNetwork中去掉了root,禁止root账号远程登录

yum完跑以下命令

1
2
3
4
5
6
7
8
9
10
/usr/share/Pegasus/scripts/genOpenPegasusSSLCerts           // 生成证书
cimserver // 先开启一下进行一些配置
cimconfig -s enableHttpConnection=true -p // 启用HTTP
cimconfig -s repositoryIsDefaultInstanceProvider=true -p // 关键!省去了我们写Provider
cimconfig -s enableAuthentication=true -p // 开启认证登录
cimserver -s // 关闭重开以生效
useradd -g pegasus smissim // PAM登录的话,走的就是系统的账号
// 把要登录的账号放到pegasus组,相关组配置在access.conf
passwd smissim // 来个密码
cimserver // 启动

Class & Instance

由于开启了repositoryIsDefaultInstanceProvider,使得我们可以不用编写Provider,而对Class具有Create / Get / Enumerate操作

相关说明和更多配置见项目的doc/BuildAndReleaseOptions.html

instance以xxx.idx和xxx.instances文件的方法在于在[namespace]/instances/下

添加时只需cimmof -n[namespace] -aEV xxx.mof

提示没有相关qualifiers就去其它namespace下copy一堆来

Tips

给想进一步写Provider的一些tips

  • provider只能注册在PEGASUS_INTEROP_NAMESPACE下,一般可能为: root/PG_InterOp 或者 root/interop 或者 interop

所以要注意注册provider时的cimmof -n参数

  • create出来的instance都是浮云

REF http://cvs.opengroup.org/pegasus-doc/CIMProvider.html

virtual void initialize(CIMOMHandle & cimom) = 0
Performs any setup required before normal operation of the provider.
The initialize() function allows the provider to conduct the necessary preparations to handle requests. The initialize function is called only once during the lifetime of the provider. Note, however, that with the Pegasus automatic unload function enabled, a provider many be unloaded and loaded many times during one cycle of the CIMOM. This function must complete before the CIM server invokes any other function of the provider, other than terminate.

virtual void terminate(void) = 0
Performs any cleanup required before termination.
The terminate function allows the provider to conduct the necessary preparations for termination. This function may be called by the CIM Server at any time, including initialization. Once invoked, no other provider functions are invoked until after a call to initialize.

如果你create出来的东西没有存在什么地方,provider.so是会被随时unload再load的,所以_instances中的实例不是持久的

可以参考在项目在SDK/samples/Providers/DefaultC++/InstanceProvider中给出的例子

因为initialize方法总是会在其它方法调用前执行