Solved

Convert Commvault actions to Python command

  • 19 May 2022
  • 6 replies
  • 333 views

Badge +5
  • Commvault Certified Expert
  • 17 replies

We’re a Service Provider and want to automate reoccurring tasks using Python, so we can integrate these in our business processes. (examples: creating new schedule policy, creating new storage pool, create scheduled report)

As I’m new to Python it would be really handy to have some way of converting a Commvault action to a finished Python script/command, similar to how you can see certain API equivalents or save certain actions as a script from within the Java Console.

Is that possible or some other way to get the Python command equivalent without having to manually put it together?

I’m aware of the info on the documentation online and GitHub, but it would be great to have more examples than the ones on the documentation site so they can be used as a guideline for non-Python pros. For example for each option a quick example, as it is done with the qcommands.

icon

Best answer by christopherlecky 31 May 2022, 18:46

View original

6 replies

Badge +3

Hi @ChrisK,

 

Can you please take a look at our Python SDK? I feel this could be something which could help you.

https://github.com/Commvault/cvpysdk

 

Thanks,

Sachin

Badge +5

Thank you for the reply @Sachin 

I’ve seen that and also checked the individual .py files so I got an idea which ones I could use for our tasks. However, what I’m looking for are two things:

  1. Samples for these .py files / classes especially about creating things (e.g. creating a new schedule policy, storage pool, etc.). The samples on the main page there are mainly about “get” or “run”, which is nice but not exactly what I’m after.
  2. if there is a way to automatically generate python commands from the Java Console or Command Center, like:
    1. go through the wizard of creating a new schedule policy, enter the details etc.
    2. instead of creating it directly, saving that info/details as a python command or script (as opposed to saving it as a .bat/shell script)
    3. taking that python command and only having to change the parameters such as the name of the schedule name, frequency, association etc.
    4. integrating that python script with the variable parameters into our system to run in dynamically.

Maybe someone here has already created such python scripts themselves and is happy to share.

Badge +3

Hi @ChrisK,

 

Can you please take a look at below URL? if this can help your use case?

https://api.commvault.com/#c17db10c-3752-4a16-81f7-2260fd3f411b

 

Thanks,

Sachin

Badge +5

@Sachin Thank you for the link, that does give a bit more insight.

Do you know if the commands keep getting updated / extended with the new releases? Or on which release they are based on?

Badge +3

Hi @ChrisK,

 

This gets updated as and when any new API is documented. If you are looking for any specific API which is not available on this site, may be you can reach out to support@commvault.com.

 

Thanks

Userlevel 5
Badge +16

@Sachin , is correct but rather than referring the online API, this api also exists in your environment.

Since API versions are iterative it makes more sense to reference your local api endpoint than the online version as the internal api will actually be supported by any call you make, and won’t require fixing the urls that you are copying and pasting.

 

You local api is found under /webconsole/sandbox/apiexplorer

 

https://documentation.commvault.com/11.24/essential/107352_accessing_apiexplorer.html

Reply