47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
from django.apps import AppConfig
|
|
from django.http import HttpResponse
|
|
from django.shortcuts import render
|
|
import requests
|
|
from proxmoxer import ProxmoxAPI
|
|
import docker
|
|
|
|
class BackofficeConfig(AppConfig):
|
|
default_auto_field = 'django.db.models.BigAutoField'
|
|
name = 'backoffice'
|
|
|
|
def hello(request):
|
|
return HttpResponse('<h1>Start bookstack!</h1>')
|
|
|
|
def http_call_test(request):
|
|
url = 'http://portainer.zeus.geeraert.eu/api/auth/'
|
|
myobj = {'Username': 'admin','Password':'Xtm78*CX3mJ54g'}
|
|
|
|
x = requests.post(url, json = myobj)
|
|
|
|
print(x.text)
|
|
return HttpResponse(x.text)
|
|
|
|
def proxmox(request):
|
|
proxmox = ProxmoxAPI("proxmox.zeus.geeraert.eu", user="root@pam", password="dinner_sl@v3", verify_ssl=False)
|
|
return HttpResponse(proxmox)
|
|
|
|
def docker_call(request,action,id_docker):
|
|
print(action)
|
|
print(id_docker)
|
|
client = docker.from_env()
|
|
if action == "start":
|
|
print("nous allons start")
|
|
client.containers.get(id_docker).start()
|
|
if action == "stop":
|
|
print("nous allons stop")
|
|
client.containers.get(id_docker).stop()
|
|
|
|
return HttpResponse(client.containers.get(id_docker).status)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|