Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Unable to utilize any properties on a HostSnmpSystem object #125

Open
nmaludy opened this issue Nov 21, 2017 · 6 comments
Open

Unable to utilize any properties on a HostSnmpSystem object #125

nmaludy opened this issue Nov 21, 2017 · 6 comments

Comments

@nmaludy
Copy link

nmaludy commented Nov 21, 2017

  vim = RbVmomi::VIM.connect(credentials)

  # find the first datacenter
  rootFolder = vim.serviceInstance.content.rootFolder
  datacenter_array = rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter)
  @datacenter = datacenter_array.first

  # ESX Hosts SNMP config
  host_folder = @datacenter.hostFolder
  compute_resources_array = host_folder.childEntity.grep(RbVmomi::VIM::ComputeResource).find
  compute_resources_array.each do |compute_resource|
    host_array = compute_resource.host
    host_array.each do |host|
      snmp_sys = host.configManager.snmpSystem
      puts snmp_sys.configuration
    end
  end

This raises the following exception:

$ ./rbvmomi_test.rb 
[SystemError: ]
/home/nmaludy/.gem/ruby/gems/rbvmomi-1.11.3/lib/rbvmomi/basic_types.rb:200:in `_get_property'
/home/nmaludy/.gem/ruby/gems/rbvmomi-1.11.3/lib/rbvmomi/basic_types.rb:37:in `block (2 levels) in init'
./rbvmomi_test.rb:73:in `block (2 levels) in <main>'
./rbvmomi_test.rb:70:in `each'
./rbvmomi_test.rb:70:in `block in <main>'
./rbvmomi_test.rb:68:in `each'
./rbvmomi_test.rb:68:in `find'
./rbvmomi_test.rb:68:in `each'
./rbvmomi_test.rb:68:in `<main>'

According to the documentation here: https://code.vmware.com/doc/preview?id=4206#/doc/vim.host.SnmpSystem.html i should be able to access the configuration and limits properties.

System details:

OS = CentOS 7.4
Ruby = ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
rbvmomi = 1.11.3
@nmaludy nmaludy changed the title Unable to utilize an properties on a HostSnmpSystem object Unable to utilize any properties on a HostSnmpSystem object Nov 21, 2017
@nmaludy
Copy link
Author

nmaludy commented Nov 21, 2017

Did a little debugging this morning based on the stacktrace above.

Here is the JSON for the ret variable returned in rbvmomi/basic_types.ManagedObject::_get_property()

{
  "obj": "HostSnmpSystem(\"snmpSystem-2149\")",
  "propSet": [

  ],
  "missingSet": [
    {
      "path": "configuration",
      "fault": {
        "fault": {
          "faultMessage": [

          ],
          "reason": "unexpected error reading property",
          "json_class": "RbVmomi::VIM::SystemError"
        },
        "localizedMessage": "",
        "json_class": "RbVmomi::BasicTypes::LocalizedMethodFault"
      },
      "json_class": "RbVmomi::VIM::MissingProperty"
    }
  ],
  "json_class": "RbVmomi::VIM::ObjectContent"
}

So, it looks like vSphere is returning a bad response for the PropertyCollector RetrieveProperties query that is being sent.

@nmaludy
Copy link
Author

nmaludy commented Nov 21, 2017

Here is the SOAP that is being sent:

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <RetrieveProperties xmlns="urn:vim25">
      <_this type="PropertyCollector">propertyCollector</_this>
      <specSet xsi:type="PropertyFilterSpec">
        <propSet xsi:type="PropertySpec">
          <type>HostSnmpSystem</type>
          <pathSet>configuration</pathSet>
        </propSet>
        <objectSet xsi:type="ObjectSpec">
          <obj type="HostSnmpSystem">snmpSystem-2149</obj>
        </objectSet>
      </specSet>
    </RetrieveProperties>
  </env:Body>
</env:Envelope>

And the response that is being received:

<RetrievePropertiesResponse xmlns="urn:vim25">
  <returnval>
    <obj type="HostSnmpSystem">snmpSystem-2149</obj>
    <missingSet>
      <path>configuration</path>
      <fault>
        <fault xsi:type="SystemError">
          <reason>unexpected error reading property</reason>
        </fault>
        <localizedMessage/>
      </fault>
    </missingSet>
  </returnval>
</RetrievePropertiesResponse>

@nmaludy
Copy link
Author

nmaludy commented Nov 21, 2017

Looks like this is related to #89 @crayfishx @jrgarcia

@jrgarcia jrgarcia self-assigned this Nov 21, 2017
@jrgarcia
Copy link
Contributor

I wasn't ever able to recreate #89, but I'll see if your debugging helps uncover something. I'll try and get to it this week, but I'm somewhat limited with holiday time. Thanks for reporting and the debugging info, @nmaludy!

@nmaludy
Copy link
Author

nmaludy commented Nov 21, 2017

FYI, not sure why but if i point rbvmomi directly at the ESX host and run the exact same code, it works just fine. For some reason pointing at vSphere fails.

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <RetrieveProperties xmlns="urn:vim25">
      <_this type="PropertyCollector">ha-property-collector</_this>
      <specSet xsi:type="PropertyFilterSpec">
        <propSet xsi:type="PropertySpec">
          <type>HostSnmpSystem</type>
          <pathSet>configuration</pathSet>
        </propSet>
        <objectSet xsi:type="ObjectSpec">
          <obj type="HostSnmpSystem">ha-snmp-agent</obj>
        </objectSet>
      </specSet>
    </RetrieveProperties>
  </env:Body>
</env:Envelope>
<RetrievePropertiesResponse xmlns="urn:vim25">
  <returnval>
    <obj type="HostSnmpSystem">ha-snmp-agent</obj>
    <propSet>
      <name>configuration</name>
      <val xsi:type="HostSnmpConfigSpec">
        <enabled>true</enabled>
        <port>161</port>
        <readOnlyCommunities>xxx</readOnlyCommunities>
        <option>
          <key>EnvEventSource</key>
          <value>indications</value>
        </option>
        <option>
          <key>engineid</key>
          <value>00000063000000a100000000</value>
        </option>
        <option>
          <key>loglevel</key>
          <value>info</value>
        </option>
      </val>
    </propSet>
  </returnval>
</RetrievePropertiesResponse>

@jrgarcia
Copy link
Contributor

🤔 Interesting. I'm sure that has something to do with it. I'll definitely see what I can find out about that. Thanks!

@jrgarcia jrgarcia removed their assignment Apr 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants