Veeam Easy Connect – Python Module

For the last few months I’ve been picking over an idea of creating a module that makes it a lot easier to work with the Veeam APIs in Python.

The result of this is a new module called Veeam Easy Connect or vec for short.

https://github.com/shapedthought/veeam-easy-connect

The module, as the name suggests, makes it easy to connect to the API, and then starting making requests. For example to log into the VBR server you would do this:

from veeam_easy_connect import VeeamEasyConnect

vec = VeeamEastConnect("username", "password")

vec.vbr().login("api_address")

So you first import the module, then instantiate an instance of the module with the administrator and password. Finally you call the api type, along with a the login method with the API address.

I should mention that the vec is available on Pypi which means that you can install the module very easily using:

pip install veeam-easy-connect

The module allows you to use it in a bunch of different ways so has several methods to get various data. For example to get and download the headers in JSON format with the access token you can do the following:

header = vec.get_request_header()
# save to variable

vec.save_headers("file_name")
# export to file_name.json

There are other methods for:

  • Getting and saving the access token
  • Getting and setting the API version
  • Getting and setting the API port

There are also some request methods included which makes it easier to send requests without having to pull out or construct the authorisation header.

data = vec.get("https://192.168.0.123:9491/api/v1/objectRestorePoints")

However, even this is a lot of effort having to remember the address, port and api version, so if you pass “False” as the second argument, you can just past the very end part of the URL (after the v1 in this case).

data = vec.get("objectRestorePoints", False)

There are also PUT and POST request methods which require a data value to be passed as well.

data = {"performActiveFull": False}
job_id_url = "jobs/{id}/start"
resp = vec.post(job_id_url, data=data, full=false)

“Full” in this case means full URL just using the named parameter syntax.

Currently the module uses “requests” under the covers so is synchronous and therefore blocking. However you could combine it with aiohttp async by getting the headers synchronously then running multiple requests to an api using aiohttp. Though I have to admit that when it comes to concurrency, Golang is probably your better bet (a module for that is also on the cards).

The module also includes login with MFA, and I’m working on SSO. I’ve hit some problems with the SSO piece, but it is still on the todo list.

Thanks for reading, and keep coding! 🤓