Skip to content

Commit f938538

Browse files
committed
added automating server management tutorial
1 parent ea081e7 commit f938538

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
5151
- [How to Compress and Decompress Files in Python](https://www.thepythoncode.com/article/compress-decompress-files-tarfile-python). ([code](general/compressing-files))
5252
- [How to Extract PDF Tables in Python](https://www.thepythoncode.com/article/extract-pdf-tables-in-python-camelot). ([code](general/pdf-table-extractor))
5353
- [How to Use Pickle for Object Serialization in Python](https://www.thepythoncode.com/article/object-serialization-saving-and-loading-objects-using-pickle-python). ([code](general/object-serialization))
54+
- [How to Automate your VPS or Dedicated Server Management in Python](https://www.thepythoncode.com/article/automate-veesp-server-management-in-python). ([code](general/automating-server-management))
5455

5556
- ### [Web Scraping](https://www.thepythoncode.com/topic/web-scraping)
5657
- [How to Access Wikipedia in Python](https://www.thepythoncode.com/article/access-wikipedia-python). ([code](web-scraping/wikipedia-extractor))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# [How to Automate your VPS or Dedicated Server Management in Python](https://www.thepythoncode.com/article/automate-veesp-server-management-in-python)
2+
To run this:
3+
- `pip3 install -r requirements.txt`
4+
- Edit `automate.py` and run the code line by line.
5+
- This tutorial introduces you to web APIs, feel free to make your own scripts of your own needs.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import requests
2+
from pprint import pprint
3+
4+
# email and password
5+
auth = ("[email protected]", "ffffffff")
6+
7+
# get the HTTP Response
8+
res = requests.get("https://secure.veesp.com/api/details", auth=auth)
9+
10+
# get the account details
11+
account_details = res.json()
12+
13+
pprint(account_details)
14+
15+
# get the bought services
16+
services = requests.get('https://secure.veesp.com/api/service', auth=auth).json()
17+
pprint(services)
18+
19+
# get the upgrade options
20+
upgrade_options = requests.get('https://secure.veesp.com/api/service/32723/upgrade', auth=auth).json()
21+
pprint(upgrade_options)
22+
23+
# list all bought VMs
24+
all_vms = requests.get("https://secure.veesp.com/api/service/32723/vms", auth=auth).json()
25+
pprint(all_vms)
26+
27+
# stop a VM automatically
28+
stopped = requests.post("https://secure.veesp.com/api/service/32723/vms/18867/stop", auth=auth).json()
29+
print(stopped)
30+
# {'status': True}
31+
32+
# start it again
33+
started = requests.post("https://secure.veesp.com/api/service/32723/vms/18867/start", auth=auth).json()
34+
print(started)
35+
# {'status': True}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests

0 commit comments

Comments
 (0)