Skip to main content
Solved

Executing QCommand qoperation execscript from Ansible API URI module


Forum|alt.badge.img+2

Can anyone help me with the Ansible uri module syntax to run a qscript? Specifically I’d like to be able to execute the AuxCopyReport
https://documentation.commvault.com/2023/expert/AuxCopyReport.html

 

- name: "Run aux copy report"
  uri:
    url: "https://{{ cv_server }}/webconsole/api/QCommand/qoperation%20execute"
    method: POST
    body_format: json
    body:
      "what goes here?"
    force_basic_auth: yes
    headers:
      AuthToken: "{{ auth_token }}"
      Content-Type: "application/json"
      Accept: "application/json "
    validate_certs: no
  register: cv_auxcopy

 

Best answer by M0nda

Thanks for the guidance @clecky here’s the final answer for anyone who comes past this in the future

  - name: "Run aux copy report"
    uri:
      url: "https://{{ cv_server }}/webconsole/api/QCommand/qoperation%20execscript{{ qcmd | urlencode }}"
      method: POST
      headers:
        AuthToken: "{{ auth_token }}"
        Accept: "application/json "
    register: cv_auxcopy
    vars:
      qcmd: " -sn QS_AuxCopyReport"

On a side note if you get the following @errorCode: 2 response check the credentials have the necessary permissions to execute the script
 

"json": {
    "CVGui_GenericResp": {
        "@errorCode": "2",
        "@errorMessage": "Operation failed"
    }
},

 

View original
Did this answer your question?

2 replies

clecky
Vaulter
Forum|alt.badge.img+11
  • Vaulter
  • 95 replies
  • May 12, 2023

You are using the wrong api.

You are using qoperation execute

You need qoperation execscript.

nothing goes in the body everything is submitted in the uri.


Forum|alt.badge.img+2
  • Author
  • Bit
  • 2 replies
  • Answer
  • May 15, 2023

Thanks for the guidance @clecky here’s the final answer for anyone who comes past this in the future

  - name: "Run aux copy report"
    uri:
      url: "https://{{ cv_server }}/webconsole/api/QCommand/qoperation%20execscript{{ qcmd | urlencode }}"
      method: POST
      headers:
        AuthToken: "{{ auth_token }}"
        Accept: "application/json "
    register: cv_auxcopy
    vars:
      qcmd: " -sn QS_AuxCopyReport"

On a side note if you get the following @errorCode: 2 response check the credentials have the necessary permissions to execute the script
 

"json": {
    "CVGui_GenericResp": {
        "@errorCode": "2",
        "@errorMessage": "Operation failed"
    }
},

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings