Exploring the Veeam API with Python

I have recently been experimenting and testing the Veeam API, however, I have noticed that there is a lack of information on how to work with it especially if you are new to the subject.

I love Python so it made sense to explorer the API using this, however, trying to communicate how to use it is a bit of a challenge. Enter Jupyter Notebooks.

If you are not already familiar with these, they essentially allow you to enter both markdown text and executeable python code into notebook ‘cells’.

The Markdown areas allow you to provide explaination of what you are doing in a logical fashion which makes it ideal for this type of use.

You can install Jupyter Labs which is the latest incarnation of Notebooks using:

pip install jupyterlab

You will need Python installed on your system (with it included in your PATH variables) for this to work. You then just need to run:

jupyter-lab

Alternativtley VS Code has direct support for Jupyter Notebooks so you can run them in there if you wish. Personally I find the Labs looks nicer but VS Code has intellisense which can be very useful.

I have uploaded a JP Notebook to my github which can be viewed here:

https://github.com/shapedthought/juypter_veeam_api

Paramiko to grab Linux host data

I’ve been trying to figure out a way of gathering host data from Linux systems for a while. I’ve explored different avenues and the obvious protocol is ssh, however, automating ssh isn’t straight forward.

As I like Python I looked into how this could be achived using it and found the Paramiko library. This has now lead on to me writting a mini app that allows for disk info to be pulled from Linux systems with a PySimpleGUI front-end.

https://github.com/shapedthought/ssh_grab

All you need to do is provide a text file with the IP addresses of each of the servers, one-per-line and provide a username and password. However, what I found out when using it is that Paramiko will try to any ssh keys it finds in the .ssh directory of the host. The SSH key field is only when you have a key that is not in the .ssh directory.

This is a work in progress and I’ll add updates as things progress.

I have also been looking into PyWinRM to do WinRM assessments on Windows hosts. This has proven a lot more tricky in Python and PoSH is far better suited to the job. This is mainly due to the fact that PoSH commands return actual objects where PyWinRM returns a string which is a lot more tricky to work with.

In addition to this I have also been looking at using Python Requests again coupled with PySimpleGUI and the VMware vCenter API to pull down VM information. This is similar to RvTools but more cut back and specific to just the data is needed from a data protection POV. This again has been challenging as the returned data from {}/vcenter/vm/{}/guest/local-filesystem endpoint comes back as a list of dictionaries. Unpacking that lot has been a bit challenging without it looking like loop hell. I’m sure a lamda function using .map would help but still working it out. I have to say that JS arrow functions make a lot more sense to me () => 😉

Keep coding 🙂