Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-12739

REST API allows to import a requistion from XML with same services

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 26.1.0
    • Fix Version/s: 27.1.0
    • Component/s: None
    • Security Level: Default (Default Security Scheme)
    • Labels:
    • Sprint:
      Horizon 2021 - Feb 3 - Feb 17, Horizon 2021 - Feb 17 - Mar 3

      Description

      Our model does not allow create two services with the same name on an IP interface. The Web UI doesn't allow it but if you provision from a file it is possible we get the following error messages in provisiond.log

      2020-06-02 17:09:20,856 WARN  [importExecutor-2] o.h.u.JDBCExceptionReporter: SQL Error: 0, SQLState: 23505
      2020-06-02 17:09:20,857 ERROR [importExecutor-2] o.h.u.JDBCExceptionReporter: ERROR: duplicate key value violates unique constraint "ifservices_ipinterfaceid_svc_unique"
        Detail: Key (ipinterfaceid, serviceid)=(1, 3) already exists.
      

      The behavior can be replicated with:

      File: test-nodes.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <model-import xmlns="http://xmlns.opennms.org/xsd/config/model-import" date-stamp="2016-10-28T10:50:02.025Z" foreign-source="test-nodes" last-import="2016-10-28T10:51:29.354Z">
        <node building="test-node-01" foreign-id="test-node-01" node-label="test-node-01">
          <interface ip-addr="127.0.0.1" status="1" snmp-primary="P">
            <monitored-service service-name="ICMP"/>
            <monitored-service service-name="ICMP"/>
          </interface>
        </node>
      </model-import>
      
      curl -u admin:admin \
           -X POST \
           -H "Content-Type: application/xml" \
           -H "Accept: application/xml" \
           -d @test-nodes.xml \
           http://localhost:8980/opennms/rest/requisitions
      

      The request is accepted with HTTP/1.1 202 Accepted and should be rejected.

        Attachments

          Activity

            People

            Assignee:
            jane.hou Jane Hou
            Reporter:
            indigo Ronny Trommer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration