Closed gavmckee80 closed 7 years ago
The hostinfo.get_all()
function only collects the code it doesn't output anything. Take a look at these lines from the module:
https://github.com/networklore/ansible-snmp/blob/master/library/snmp_device_version.py#L166-L169
So you're code would have to look something like this:
print "trying..."
hostinfo.get_all()
print hostinfo.os
print hostinfo.version
For this device Nelsnmp can't identify the device and some code would need to be added to
ok: [1.1.1.6] => {"ansible_facts": {"ansible_device_os": "UNKNOWN", "ansible_device_vendor": "UNKNOWN", "ansible_device_version": "UNKNOWN"}, "changed": false}
If you want support for that device please add add a line print hostinfo.__dict__
to the above script and send me the output. You can do that in a separate issue and close this one if the above solves your problem.
Thanks for the feedback , its working well now. I'll open a new issue for the unsupported devices
Hi,
I've been testing this module standalone and as part of snmp_device_version , when I use the exact same connection parameters for the ansible task (as those below) I get data back from the device. When I run this as a simple Python test I don't. Can you offer any suggestions? --------- PLAYBOOK ------------- tasks:
------ RESULT ------- TASK [GET SNMP DISCOVERY INFORMATION] ** ok: [1.1.1.1] => {"ansible_facts": {"ansible_device_os": "nxos", "ansible_device_vendor": "cisco", "ansible_device_version": "6.2(12)"}, "changed": false} ok: [1.1.1.2] => {"ansible_facts": {"ansible_device_os": "nxos", "ansible_device_vendor": "cisco", "ansible_device_version": "7.3(1)N1(1)"}, "changed": false} ok: [1.1.1.3] => {"ansible_facts": {"ansible_device_os": "nxos", "ansible_device_vendor": "cisco", "ansible_device_version": "6.1(2)I2(1)"}, "changed": false} ok: [1.1.1.4] => {"ansible_facts": {"ansible_device_os": "nxos", "ansible_device_vendor": "cisco", "ansible_device_version": "6.0(2)A8(3)"}, "changed": false} ok: [1.1.1.5] => {"ansible_facts": {"ansible_device_os": "nxos", "ansible_device_vendor": "cisco", "ansible_device_version": "6.0(2)A8(4)"}, "changed": false} ok: [1.1.1.6] => {"ansible_facts": {"ansible_device_os": "UNKNOWN", "ansible_device_vendor": "UNKNOWN", "ansible_device_version": "UNKNOWN"}, "changed": false}
from nelsnmp.snmp import SnmpHandler from nelsnmp.hostinfo.device import HostInfo
def main(): try: dev = SnmpHandler(host='1.1.1.1', community='public', version='2c') hostinfo = HostInfo(dev)
main()