microsoft / omi-script-provider

Script Provider for the OMI Project
Other
8 stars 7 forks source link

Fix findClassDecl in mi_schema.cpp #52

Closed JumpingYang001 closed 7 years ago

JumpingYang001 commented 7 years ago

I have fixed issue #26 , but now I meet a problem: Anyone know why I get 2 "" nodes in log? it should only show the first node.

/tmp/Build-omi-script-provider/omi/Unix/output/bin
root@omi64-cent7-02  # ./omicli ei root/cimv2 XYZ_ColorBase
instance of XYZ_ColorBase
{
    [Key] Id=1000
}
instance of XYZ_Color
{
    [Key] Id=1001
    Caption=This is Red
    Name=Red
}
instance of XYZ_Color
{
    [Key] Id=1002
    Caption=This is Green
    Name=Green
}
instance of XYZ_Color
{
    [Key] Id=1003
    Caption=This is Blue
    Name=Blue
}
instance of XYZ_Color
{
    [Key] Id=1004
    Caption=This is Yellow
    Name=Yellow
}
<Server::Load (index)>
  index: 1
  class: XYZ_ColorBase
    an opcode was read
    CLASS_LOAD
    <Client::handle_class_load>
      <MI_Value<MI_STRING>::recv>
      </MI_Value<MI_STRING>::recv>
      class name: "XYZ_ColorBase"
      MI_ClassDecl was found
      <MI_FunctionTable::Load>
        <XYZ_ColorBase_Load>
          <MI_Context::postResult>
          </MI_Context::postResult>
        </XYZ_ColorBase_Load>
      </MI_FunctionTable::Load>
    </Client::handle_class_load>
  rec'ved POST_RESULT
  <handle_post_result>
    rec'd result
  </handle_post_result>
</Server::Load (index)>
<Server::EnumerateInstances>
  <Server::findClassDecl>
    <ClassFinder::operator ()>
      m_Name: "XYZ_ColorBase"
      pClass->name: "XYZ_Color"
    </ClassFinder::operator ()>
    <ClassFinder::operator ()>
      m_Name: "XYZ_ColorBase"
      pClass->name: "XYZ_ColorBase"
    </ClassFinder::operator ()>
  </Server::findClassDecl>
  namespace: "root/cimv2"
  className: "XYZ_ColorBase"

  <send (MI_PropertySet)>
    property set is NULL
  </send (MI_PropertySet)>
  <handle_return>
    an opcode was read
    ENUMERATE_INSTANCES
    <Client::handle_class_enumerate_instances>
      <MI_Value<MI_STRING>::recv>
      </MI_Value<MI_STRING>::recv>
      <MI_Value<MI_STRING>::recv>
      </MI_Value<MI_STRING>::recv>
      <MI_PropertySet::recv>
        read property count
        property set is NULL
      </MI_PropertySet::recv>
      <MI_Value<MI_BOOLEAN>::recv>
      </MI_Value<MI_BOOLEAN>::recv>
      class name: "XYZ_ColorBase"
      MI_ClassDecl was found
      <MI_FunctionTable::EnumerateInstances>
        namespace: "root/cimv2"
        classname: "XYZ_ColorBase"
        pPropertySet: is NULL
        pKeysOnly: NULL
        m_pEnumerateInstances: is NOT NULL
        <XYZ_ColorBase_EnumerateInstances>
          <MI_Context::newInstance>
          </MI_Context::newInstance>
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          <MI_Context::postResult>
          </MI_Context::postResult>
        </XYZ_ColorBase_EnumerateInstances>
      </MI_FunctionTable::EnumerateInstances>
    </Client::handle_class_enumerate_instances>
    rec'ved POST_INSTANCE
    <handle_post_instance>
      <protocol::recv (MI_Instance)>
        <recv flags>
          flags: "0"
        </recv flags>
        <recv class name>
          class name: "XYZ_ColorBase"
        </recv class name>
        <recv item count>
          item count: "1"
        </recv item count>
        <recv_values>
          <recv value>
            recv key
            key: "Id"
            recv type
            type: 5
            recv value
            recv value SUCCEEDED
          </recv value>
        </recv_values>
        <mi_script_extensions.cpp findClassDecl>
        </mi_script_extensions.cpp findClassDecl>
        MI_ClassDecl was found
        MI_Context_NewInstance
        MI_Instance was created
        <-value->
          pos->key: Id
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        recv MI_Instance succeeded
      </protocol::recv (MI_Instance)>
      recv instance succeeded
      PostInstance succeeded
    </handle_post_instance>
    rec'ved POST_RESULT
    <handle_post_result>
      rec'd result
    </handle_post_result>
  </handle_return>
</Server::EnumerateInstances>
<Server::EnumerateInstances>
  <Server::findClassDecl>
    <ClassFinder::operator ()>
      m_Name: "XYZ_Color"
      pClass->name: "XYZ_Color"
    </ClassFinder::operator ()>
  </Server::findClassDecl>
  namespace: "root/cimv2"
  className: "XYZ_Color"

  <send (MI_PropertySet)>
    property set is NULL
  </send (MI_PropertySet)>
  <handle_return>
    an opcode was read
    ENUMERATE_INSTANCES
    <Client::handle_class_enumerate_instances>
      <MI_Value<MI_STRING>::recv>
      </MI_Value<MI_STRING>::recv>
      <MI_Value<MI_STRING>::recv>
      </MI_Value<MI_STRING>::recv>
      <MI_PropertySet::recv>
        read property count
        property set is NULL
      </MI_PropertySet::recv>
      <MI_Value<MI_BOOLEAN>::recv>
      </MI_Value<MI_BOOLEAN>::recv>
      class name: "XYZ_Color"
      MI_ClassDecl was found
      <MI_FunctionTable::EnumerateInstances>
        namespace: "root/cimv2"
        classname: "XYZ_Color"
        pPropertySet: is NULL
        pKeysOnly: NULL
        m_pEnumerateInstances: is NOT NULL
        <XYZ_Color_EnumerateInstances>
          <MI_Context::newInstance>
          </MI_Context::newInstance>
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          <MI_Context::postResult>
          </MI_Context::postResult>
        </XYZ_Color_EnumerateInstances>
      </MI_FunctionTable::EnumerateInstances>
    </Client::handle_class_enumerate_instances>
JumpingYang001 commented 7 years ago

I see another log which shows it call XYZ_Color class when I ran ./omicli ei root/cimv2 XYZ_ColorBase:

    an opcode was read
    CLASS_LOAD
    <Client::handle_class_load>
      <MI_Value<MI_STRING>::recv>
      </MI_Value<MI_STRING>::recv>
      class name: "XYZ_Color"
      MI_ClassDecl was found
      <MI_FunctionTable::Load>
        <XYZ_Color_Load>
          <MI_Context::postResult>
          </MI_Context::postResult>
        </XYZ_Color_Load>
      </MI_FunctionTable::Load>
    </Client::handle_class_load>
  rec'ved POST_RESULT
  <handle_post_result>
    rec'd result
  </handle_post_result>
</Server::Load (index)>
<Server::EnumerateInstances>
  <Server::findClassDecl>
    <ClassFinder::operator ()>
      m_Name: "XYZ_Color"
      pClass->name: "XYZ_Color"
    </ClassFinder::operator ()>
  </Server::findClassDecl>
  namespace: "root/cimv2"
  className: "XYZ_Color"

  <send (MI_PropertySet)>
    property set is NULL
  </send (MI_PropertySet)>
  <handle_return>
    an opcode was read
    ENUMERATE_INSTANCES
    <Client::handle_class_enumerate_instances>
      <MI_Value<MI_STRING>::recv>
      </MI_Value<MI_STRING>::recv>
      <MI_Value<MI_STRING>::recv>
      </MI_Value<MI_STRING>::recv>
      <MI_PropertySet::recv>
        read property count
        property set is NULL
      </MI_PropertySet::recv>
      <MI_Value<MI_BOOLEAN>::recv>
      </MI_Value<MI_BOOLEAN>::recv>
      class name: "XYZ_Color"
      MI_ClassDecl was found
      <MI_FunctionTable::EnumerateInstances>
        namespace: "root/cimv2"
        classname: "XYZ_Color"
        pPropertySet: is NULL
        pKeysOnly: NULL
        m_pEnumerateInstances: is NOT NULL
        <XYZ_Color_EnumerateInstances>
          <MI_Context::newInstance>
          </MI_Context::newInstance>
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          the parameter does exist
          the type matches
          <MI_Context::postInstance>
            <MI_Instance::send>
              <send flags>
              </send flags>
              <send Name>
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Name>
              <send Size>
              </send Size>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
              </send Value>
              <send Value>
                -- name --
                -- type --
                -- value --
                <MI_Value<MI_STRING>::send>
                </MI_Value<MI_STRING>::send>
              </send Value>
            </MI_Instance::send>
          </MI_Context::postInstance>
          <MI_Context::postResult>
          </MI_Context::postResult>
        </XYZ_Color_EnumerateInstances>
      </MI_FunctionTable::EnumerateInstances>
    </Client::handle_class_enumerate_instances>
    rec'ved POST_INSTANCE
    <handle_post_instance>
      <protocol::recv (MI_Instance)>
        <recv flags>
          flags: "0"
        </recv flags>
        <recv class name>
          class name: "XYZ_Color"
        </recv class name>
        <recv item count>
          item count: "3"
        </recv item count>
        <recv_values>
          <recv value>
            recv key
            key: "Caption"
            recv type
            type: 13
            recv value
            recv value SUCCEEDED
          </recv value>
          <recv value>
            recv key
            key: "Id"
            recv type
            type: 5
            recv value
            recv value SUCCEEDED
          </recv value>
          <recv value>
            recv key
            key: "Name"
            recv type
            type: 13
            recv value
            recv value SUCCEEDED
          </recv value>
        </recv_values>
        <mi_script_extensions.cpp findClassDecl>
        </mi_script_extensions.cpp findClassDecl>
        MI_ClassDecl was found
        MI_Context_NewInstance
        MI_Instance was created
        <-value->
          pos->key: Caption
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        <-value->
          pos->key: Id
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        <-value->
          pos->key: Name
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        recv MI_Instance succeeded
      </protocol::recv (MI_Instance)>
      recv instance succeeded
      PostInstance succeeded
    </handle_post_instance>
    rec'ved POST_INSTANCE
    <handle_post_instance>
      <protocol::recv (MI_Instance)>
        <recv flags>
          flags: "0"
        </recv flags>
        <recv class name>
          class name: "XYZ_Color"
        </recv class name>
        <recv item count>
          item count: "3"
        </recv item count>
        <recv_values>
          <recv value>
            recv key
            key: "Caption"
            recv type
            type: 13
            recv value
            recv value SUCCEEDED
          </recv value>
          <recv value>
            recv key
            key: "Id"
            recv type
            type: 5
            recv value
            recv value SUCCEEDED
          </recv value>
          <recv value>
            recv key
            key: "Name"
            recv type
            type: 13
            recv value
            recv value SUCCEEDED
          </recv value>
        </recv_values>
        <mi_script_extensions.cpp findClassDecl>
        </mi_script_extensions.cpp findClassDecl>
        MI_ClassDecl was found
        MI_Context_NewInstance
        MI_Instance was created
        <-value->
          pos->key: Caption
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        <-value->
          pos->key: Id
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        <-value->
          pos->key: Name
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        recv MI_Instance succeeded
      </protocol::recv (MI_Instance)>
      recv instance succeeded
      PostInstance succeeded
    </handle_post_instance>
    rec'ved POST_INSTANCE
    <handle_post_instance>
      <protocol::recv (MI_Instance)>
        <recv flags>
          flags: "0"
        </recv flags>
        <recv class name>
          class name: "XYZ_Color"
        </recv class name>
        <recv item count>
          item count: "3"
        </recv item count>
        <recv_values>
          <recv value>
            recv key
            key: "Caption"
            recv type
            type: 13
            recv value
            recv value SUCCEEDED
          </recv value>
          <recv value>
            recv key
            key: "Id"
            recv type
            type: 5
            recv value
            recv value SUCCEEDED
          </recv value>
          <recv value>
            recv key
            key: "Name"
            recv type
            type: 13
            recv value
            recv value SUCCEEDED
          </recv value>
        </recv_values>
        <mi_script_extensions.cpp findClassDecl>
        </mi_script_extensions.cpp findClassDecl>
        MI_ClassDecl was found
        MI_Context_NewInstance
        MI_Instance was created
        <-value->
          pos->key: Caption
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        <-value->
          pos->key: Id
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        <-value->
          pos->key: Name
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        recv MI_Instance succeeded
      </protocol::recv (MI_Instance)>
      recv instance succeeded
      PostInstance succeeded
    </handle_post_instance>
    rec'ved POST_INSTANCE
    <handle_post_instance>
      <protocol::recv (MI_Instance)>
        <recv flags>
          flags: "0"
        </recv flags>
        <recv class name>
          class name: "XYZ_Color"
        </recv class name>
        <recv item count>
          item count: "3"
        </recv item count>
        <recv_values>
          <recv value>
            recv key
            key: "Caption"
            recv type
            type: 13
            recv value
            recv value SUCCEEDED
          </recv value>
          <recv value>
            recv key
            key: "Id"
            recv type
            type: 5
            recv value
            recv value SUCCEEDED
          </recv value>
          <recv value>
            recv key
            key: "Name"
            recv type
            type: 13
            recv value
            recv value SUCCEEDED
          </recv value>
        </recv_values>
        <mi_script_extensions.cpp findClassDecl>
        </mi_script_extensions.cpp findClassDecl>
        MI_ClassDecl was found
        MI_Context_NewInstance
        MI_Instance was created
        <-value->
          pos->key: Caption
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        <-value->
          pos->key: Id
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        <-value->
          pos->key: Name
          pNewInstance is not NULL
          mark 1
          GetElement succeeded
          SetElement succeeded
        </-value->
        recv MI_Instance succeeded
      </protocol::recv (MI_Instance)>
      recv instance succeeded
      PostInstance succeeded
    </handle_post_instance>
    rec'ved POST_RESULT
    <handle_post_result>
      rec'd result
    </handle_post_result>
  </handle_return>
</Server::EnumerateInstances>
JumpingYang001 commented 7 years ago

From omiagent.root.root.log:

Line 79: 2017/10/26 00:02:00 [42641,42641] DEBUG: provmgr.c(487): EventId=45173 Priority=DEBUG _GetProviderByClassName{XYZ_ColorBase}
Line 102: 2017/10/26 00:04:34 [42641,42641] DEBUG: provmgr.c(1702): EventId=45182 Priority=DEBUG enumerate instances of XYZ_ColorBase
Line 264: 2017/10/26 00:04:34 [42641,42641] DEBUG: provmgr.c(487): EventId=45173 Priority=DEBUG _GetProviderByClassName{XYZ_Color}
Line 284: 2017/10/26 00:04:34 [42641,42641] DEBUG: provmgr.c(1702): EventId=45182 Priority=DEBUG enumerate instances of XYZ_Color