Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Search instead for
Did you mean:
Tech Tip: Using the RESTful Control API with Python - startstopvs
The following code uses Stingray's RESTful API to enable or disabled a specific Virtual Server. The code is written in Python. This program checks to see if the Virtual Server "test vs" is enabled and if it is, it disables it and if it is disabled, it enables it. A GET is done to retrieve the configuration data for the Virtual Server and the "enabled" value in the "basic" properties section is checked. This is a boolean value, so if it is true it is set to false and if it is false it is set to true. The changed data is then sent to the server using a PUT.
This code was tested with Python 2.7.3 and version 1.1.0 of the requests library.
Run the Python script as follows:
test vs is enabled. Disable it.
This program it is sending only the 'enabled' value to the server by creating a new dictionary with just this value in the 'basic' properties section. Alternatively, the entire Virtual Server configuration could have been returned to the server with just the enabled value changed. Sending just the data that has changed reduces the chances of overwriting another user's changes if multiple programs are concurrently accessing the RESTful API.