IPAM REST API questions

Hello everyone,
I have never touched SolarWinds before and now I have a task to automate some IPAM tasks using ansible.

I cannot find any useful documentation on this, apart from some Github pages. If anyone can point me to the right document I would appreciate it.

From what I have read so far, my understanding is that the REST API uses SWQL to perform the required action. Is that true? If yes, is there any other method?

What I want to achieve is:


1. Reserve an IP from a specific subnet.
All the information I have here is the subnet. Is it sufficient?

2. Release (Delete reservation, return IP to pool) IP.
In this case I only have the IP. Is it sufficient?

Has anyone examples of those actions using Ansible or Curl?

Parents
  • Hello.

    For your inspiration, I have been doing some lookups in SolarWinds with Ansible:

    - name: Prepare SWQL query for SolarWinds search by vlan_id
      ansible.builtin.set_fact:
        solarwinds_query: >
          SELECT
              sn.Address as "network_address",
              sn.AddressMask,
              sn.CIDR as "cidr",
              sn.VLAN AS "vlan_id",
              sn.location AS vlanLocation
          FROM
              IPAM.Subnet AS sn
          WHERE
              sn.VLAN = '{{ solarwinds_search_vlan_id }}'
              AND sn.location LIKE '%{{ solarwinds_search_location }}%'
              
    - name: Post request to SolarWinds API
      ansible.builtin.uri:
        url: "{{ solarwinds.url }}"
        method: POST
        body_format: json
        body:
          query: "{{ solarwinds_query }}"
        headers:
          Content-Type: "application/json"
        user: "{{ solarwinds.username }}"
        password: "{{ solarwinds.password }}"
        validate_certs: false
      register: solarwinds_response
    
    - name: Check response and print data
      ansible.builtin.debug:
        msg: "{{ solarwinds_response.json }}"
      when: solarwinds_response.status == 200
    
    - name: Handle failed API request
      ansible.builtin.fail:
        msg: "Failed to retrieve data: {{ solarwinds_response.status }} {{ solarwinds_response.content }}"
      when: solarwinds_response.status != 200

Reply
  • Hello.

    For your inspiration, I have been doing some lookups in SolarWinds with Ansible:

    - name: Prepare SWQL query for SolarWinds search by vlan_id
      ansible.builtin.set_fact:
        solarwinds_query: >
          SELECT
              sn.Address as "network_address",
              sn.AddressMask,
              sn.CIDR as "cidr",
              sn.VLAN AS "vlan_id",
              sn.location AS vlanLocation
          FROM
              IPAM.Subnet AS sn
          WHERE
              sn.VLAN = '{{ solarwinds_search_vlan_id }}'
              AND sn.location LIKE '%{{ solarwinds_search_location }}%'
              
    - name: Post request to SolarWinds API
      ansible.builtin.uri:
        url: "{{ solarwinds.url }}"
        method: POST
        body_format: json
        body:
          query: "{{ solarwinds_query }}"
        headers:
          Content-Type: "application/json"
        user: "{{ solarwinds.username }}"
        password: "{{ solarwinds.password }}"
        validate_certs: false
      register: solarwinds_response
    
    - name: Check response and print data
      ansible.builtin.debug:
        msg: "{{ solarwinds_response.json }}"
      when: solarwinds_response.status == 200
    
    - name: Handle failed API request
      ansible.builtin.fail:
        msg: "Failed to retrieve data: {{ solarwinds_response.status }} {{ solarwinds_response.content }}"
      when: solarwinds_response.status != 200

Children
No Data