Dakota House
Dakota House

Reputation: 1

Is it possible to bulk configure Axis cameras via a python script using SOAP API commands?

I have about 200 Axis brand cameras which I am having to move over to an Avigilon system. None of these cameras have ONVIF profiles set up in them yet, as well as a few things like turning on the microphone etc. I am trying to create a python script which applies a template to each camera via IP address when you run it, so I don't have to manually configure every camera. I am unable to get any SOAP commands to function except a basic login, after that I am either sending an incorrect command to create an ONVIF profile or it is timing out.

Current Code:

import requests
from requests.auth import HTTPDigestAuth

# Axis camera WebUI credentials
username = 'root'    # Replace with your WebUI username
password = 'tent'    # Replace with your WebUI password

# Axis camera IP address and VAPIX endpoint for adding a user
camera_ip = '10.5.66.10'
url = f'http://{camera_ip}/axis-cgi/pwdgrp.cgi?action=add'

# Data for the new user (ensure valid username and password)
new_user_data = {
    'user': 'onvifuser',       # Ensure a valid username
    'pwd': 'onvifpassword',    # Password for the ONVIF account
    'grp': 'admin'             # Assign the group to 'admin'
}

# Send the request
try:
    response = requests.post(url, auth=HTTPDigestAuth(username, password), data=new_user_data)

    # Check if the request was successful
    if response.status_code == 200:
        print("ONVIF user created successfully.")
    else:
        print(f"Failed to create user. Status code: {response.status_code}")
        print(f"Response content: {response.text}")

except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

Output from running my current code:

ONVIF user created successfully.

It is returning a successful request, but not creating an ONVIF account. I don't really know if creating an ONVIF user is even possible by using VAPIX or the default WebUI login, but I would really like this to work so I don't have to manually set up profiles on every single camera. This is the first time I have ever tried to do anything like this, so I really have only been trying for a few hours so far.

Thanks!

Upvotes: 0

Views: 141

Answers (1)

Sriram
Sriram

Reputation: 38

You cannot use vapix to create onvif user! you should use onvif CreateUsers interface to make one.

<Envelope
xmlns="http://www.w3.org/2003/05/soap-envelope">
<Header/>
<Body>
    <CreateUsers
        xmlns="http://www.onvif.org/ver10/device/wsdl"
        xmlns:tt="http://www.onvif.org/ver10/schema">
        <User>
            <tt:Username>
                test
                </tt:Username>
            <tt:Password>
                test
                </tt:Password>
            <tt:UserLevel>
                User
                </tt:UserLevel>
            </User>
        </CreateUsers>
    </Body>
</Envelope>

Upvotes: 0

Related Questions