cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
247
Views
0
Helpful
1
Replies
Highlighted
Cisco Employee

Compliance Report via API

Hi all,

 

Assuming I am using a system install NSO, with typical cisco NEDs, and I issue a RESTCONF call like this:

curl --location --request PATCH 'https://10.10.20.49:443/restconf/data/tailf-ncs:compliance' \
--header 'Content-Type: application/yang-data+xml' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--header 'Accept: application/yang-data+json' \
--header 'Authorization: Basic ZGV2ZWxvcGVyOkMxc2NvMTIzNDU=' \
--header 'Content-Type: text/plain' \
--data-raw '<compliance xmlns="http://tail-f.com/ns/ncs">
               <reports>
                 <report>
                   <name>DNS_COMPLIANCE_REPORT</name>
                   <compare-template>
                     <template-name>SET-DNS-SERVER</template-name>
                     <device-group>ALL</device-group>
                   </compare-template>
                 </report>
               </reports>
             </compliance>'

and I have my device group set up / device template set up, where does the compliance report go?

 

I know for local install if run via CLI it goes into current working directory, but for system install and using API, not sure where to look? I checked in:

/var/opt/ncs/*

/opt/ncs/current/*

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee

I think I might have partially answered my own question. The above API call was to create the report, but not to run it. Here is what I did to run it:

curl --location --request POST 'https://10.10.20.49:443/restconf/data/tailf-ncs:compliance/reports/report=DNS_COMPLIANCE_REPORT/run' \
--header 'Content-Type: application/yang-data+xml' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--header 'Accept: application/yang-data+json' \
--header 'Authorization: Basic ZGV2ZWxvcGVyOkMxc2NvMTIzNDU=' \
--header 'Content-Type: text/plain' \
--data-raw '<input>
	<outformat>html</outformat>
</input>'

and got the following response:

{
  "tailf-ncs:output": {
    "id": 1,
    "compliance-status": "violations",
    "info": "Checking 8 devices and no services",
    "location": "https://localhost:443/compliance-reports/report_1_developer_1_2020-10-13T15:48:40:0.html"
  }
}

and found it in the running directory state:

[developer@nso compliance-reports]$ ls
report_1_developer_1_2020-10-13T15:48:40:0.html
[developer@nso compliance-reports]$ pwd
/var/opt/ncs/state/compliance-reports
[developer@nso compliance-reports]$

 

 

 

View solution in original post

1 REPLY 1
Highlighted
Cisco Employee

I think I might have partially answered my own question. The above API call was to create the report, but not to run it. Here is what I did to run it:

curl --location --request POST 'https://10.10.20.49:443/restconf/data/tailf-ncs:compliance/reports/report=DNS_COMPLIANCE_REPORT/run' \
--header 'Content-Type: application/yang-data+xml' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--header 'Accept: application/yang-data+json' \
--header 'Authorization: Basic ZGV2ZWxvcGVyOkMxc2NvMTIzNDU=' \
--header 'Content-Type: text/plain' \
--data-raw '<input>
	<outformat>html</outformat>
</input>'

and got the following response:

{
  "tailf-ncs:output": {
    "id": 1,
    "compliance-status": "violations",
    "info": "Checking 8 devices and no services",
    "location": "https://localhost:443/compliance-reports/report_1_developer_1_2020-10-13T15:48:40:0.html"
  }
}

and found it in the running directory state:

[developer@nso compliance-reports]$ ls
report_1_developer_1_2020-10-13T15:48:40:0.html
[developer@nso compliance-reports]$ pwd
/var/opt/ncs/state/compliance-reports
[developer@nso compliance-reports]$

 

 

 

View solution in original post