-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_web_hosting.py
More file actions
64 lines (53 loc) · 2.67 KB
/
test_web_hosting.py
File metadata and controls
64 lines (53 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import asyncio
from pterodactyl_api import PterodactylAPI
from config import SERVER_TEMPLATES
async def test_web_hosting():
api = PterodactylAPI()
# Print the web-hosting template configuration
web_hosting = SERVER_TEMPLATES.get('web-hosting', {})
print(f"Web Hosting Template Configuration:")
print(f" Name: {web_hosting.get('name')}")
print(f" Description: {web_hosting.get('description')}")
print(f" Memory: {web_hosting.get('memory')} MB")
print(f" Disk: {web_hosting.get('disk')} MB")
print(f" CPU: {web_hosting.get('cpu')}")
print(f" Nest ID: {web_hosting.get('nest')}")
print(f" Egg ID: {web_hosting.get('egg')}")
print(f" Environment Variables: {web_hosting.get('env', {})}")
# Get egg details
nest_id = web_hosting.get('nest')
egg_id = web_hosting.get('egg')
if nest_id and egg_id:
egg_details = await api.get_egg_details(nest_id, egg_id)
if egg_details:
print(f"\nEgg Details:")
print(f" Name: {egg_details.get('name')}")
print(f" Docker Image: {egg_details.get('docker_image')}")
# Get environment variables
env_vars = {}
egg_variables = egg_details.get('relationships', {}).get('variables', {}).get('data', [])
if egg_variables:
print(f"\nFound {len(egg_variables)} variables for egg {egg_id}:")
for var_data in egg_variables:
var_attr = var_data.get('attributes', {})
env_name = var_attr.get('env_variable')
env_default = var_attr.get('default_value')
env_required = var_attr.get('required', False)
print(f" - {env_name}: {env_default} (Required: {env_required})")
if env_name:
env_vars[env_name] = env_default or ''
# Apply template-specific environment variables
if 'env' in web_hosting:
print(f"\nApplying template-specific environment variables:")
for key, value in web_hosting['env'].items():
env_vars[key] = value
print(f" - {key}: {value}")
print(f"\nFinal environment variables that would be used:")
for key, value in env_vars.items():
print(f" - {key}: {value}")
else:
print(f"Could not get details for egg {egg_id} in nest {nest_id}")
else:
print("Nest ID or Egg ID not specified in the web-hosting template")
if __name__ == "__main__":
asyncio.run(test_web_hosting())