jeisenbath / ansible-collection-solarwinds-orion

An Ansible collection for managing nodes in Solarwinds Orion
10 stars 1 forks source link

Unable to add External Node #8

Closed Andyjb8 closed 9 months ago

Andyjb8 commented 10 months ago

I am unable to add external nodes:

    - name: Add External node to Solarwinds
      solarwinds.orion.orion_node:
        <<: *solarwinds_info
        state: present
        name: "{{ inventory_hostname }}"
        ip_address: "{{ ansible_host }}"
        polling_method: External
      delegate_to: localhost

However, it adds the node as ICMP instead of external.

changed: [rtr-01 -> localhost] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "orion_hostname",
            "ip_address": "10.x.x.x",
            "name": "rtr-01",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "polling_engine": null,
            "polling_method": "External",
            "ro_community_string": null,
            "rw_community_string": null,
            "snmp_allow_64": true,
            "snmp_port": "161",
            "snmp_version": null,
            "snmpv3_auth_key": null,
            "snmpv3_auth_key_is_pwd": true,
            "snmpv3_auth_method": "SHA1",
            "snmpv3_priv_key": null,
            "snmpv3_priv_key_is_pwd": true,
            "snmpv3_priv_method": "AES128",
            "snmpv3_username": null,
            "state": "present",
            "unmanage_from": null,
            "unmanage_until": null,
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "wmi_credentials": null
        }
    },
    "orion_node": {
        "caption": "rtr-01",
        "ipaddress": "10.x.x.x",
        "netobjectid": "N:1079",
        "nodeid": 1079,
        "objectsubtype": "ICMP",
        "status": 0,
        "statusdescription": "Node status is Unknown.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://orion_hostname/Orion/Orion.Nodes/NodeID=1079"
    }
}

I see these two lines in orion_node.py which explains why its changing it to ICMP:

    if props['ObjectSubType'] == 'EXTERNAL':
        props['ObjectSubType'] = 'ICMP'

But that must be there for a reason, because if I comment those out I get this:

The full traceback is:
  File "/tmp/ansible_solarwinds.orion.orion_node_payload_drrl84eq/ansible_solarwinds.orion.orion_node_payload.zip/ansible_collections/solarwinds/orion/plugins/modules/orion_node.py", line 304, in add_node
  File "/home/********/.local/lib/python3.10/site-packages/orionsdk/swisclient.py", line 34, in create
    return self._req(
  File "/home/********/.local/lib/python3.10/site-packages/orionsdk/swisclient.py", line 63, in _req
    resp.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
fatal: [DC-RT-01 -> localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "hostname": "orion_hostname",
            "ip_address": "10.x.x.x",
            "name": "rtr-01",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "polling_engine": null,
            "polling_method": "External",
            "ro_community_string": null,
            "rw_community_string": null,
            "snmp_allow_64": true,
            "snmp_port": "161",
            "snmp_version": null,
            "snmpv3_auth_key": null,
            "snmpv3_auth_key_is_pwd": true,
            "snmpv3_auth_method": "SHA1",
            "snmpv3_priv_key": null,
            "snmpv3_priv_key_is_pwd": true,
            "snmpv3_priv_method": "AES128",
            "snmpv3_username": null,
            "state": "present",
            "unmanage_from": null,
            "unmanage_until": null,
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "wmi_credentials": null
        }
    },
    "msg": "Failed to create node: 400 Client Error: Unable to create Node. Details : Information : Assigned default value 'Orion.Nodes' for EntityType.\r\nInformation : Assigned default value 'False' for DynamicIP.\r\nInformation : Assigned default value '0' for Status.\r\nInformation : Assigned default value '' for Location.\r\nInformation : Assigned default value '' for Contact.\r\nInformation : Assigned default value '' for NodeDescription.\r\nInformation : Assigned default value '' for IOSImage.\r\nInformation : Assigned default value '' for IOSVersion.\r\nInformation : Assigned default value 'False' for UnManaged.\r\nError : In property ObjectSubType. Reason : Mismatch in Data. Expected Values are : 'ICMP,SNMP,WMI,Agent'. Actual value : EXTERNAL.\r\nInformation : Assigned default value '' for SysObjectID.\r\nInformation : Assigned default value 'Unknown' for MachineType.\r\nInformation : Assigned default value 'Unknown' for Vendor.\r\nInformation : Assigned default value 'Unknown.gif' for VendorIcon.\r\nInformation : Assigned default value '120' for PollInterval.\r\nInformation : Assigned default value '30' for RediscoveryInterval.\r\nInformation : Assigned default value '10' for StatCollection.\r\nInformation : Assigned default value '-2' for BufferBgMissThisHour.\r\nInformation : Assigned default value '-2' for BufferBgMissToday.\r\nInformation : Assigned default value '-2' for BufferHgMissThisHour.\r\nInformation : Assigned default value '-2' for BufferHgMissToday.\r\nInformation : Assigned default value '-2' for BufferLgMissThisHour.\r\nInformation : Assigned default value '-2' for BufferLgMissToday.\r\nInformation : Assigned default value '-2' for BufferMdMissThisHour.\r\nInformation : Assigned default value '-2' for BufferMdMissToday.\r\nInformation : Assigned default value '-2' for BufferNoMemThisHour.\r\nInformation : Assigned default value '-2' for BufferNoMemToday.\r\nInformation : Assigned default value '-2' for BufferSmMissThisHour.\r\nInformation : Assigned default value '-2' for BufferSmMissToday.\r\n\r\n---------------------------------- for url: https://orion_hostname:17778/SolarWinds/InformationService/v3/Json/Create/Orion.Nodes"

So it looks like the EXTERNAL value is not being accepted for an ObjectSubType?

jeisenbath commented 10 months ago

That was another bit of code/functionality that was from the original module that this forked. My guess was that 'external' nodes are essentially just an ICMP ping to some web address, but admit I have not looked into it much.

jeisenbath commented 9 months ago

v1.0.4 released with a bugfix for this. even with correctly casing the param to_upper(), the lambda function still doesn't want to work, so I separated out the logic. Should be all good now.