#!/usr/bin/python3 from bottle import run, route, request, template,get ,post import libvirt session = libvirt.open('qemu:///system') def listVDS(): VdsListVar = list() for i in session.listDefinedDomains(): VdsListVar.append(i) return VdsListVar # Главная страница @route('/') def index(): # return template('index.html') # return 'Привет, мир!' return listVDS() @get('/action') # or @route('/login') def login(): return '''
VDS Name:
Action (start/stop):
Start
Stop
''' @post('/action') # or @route('/login', method='POST') def do_action(): act = request.forms.get('act') dom = session.lookupByName(request.forms.get('username')) if (act == "start"): dom.create() return "

Started succesfully!

" elif (act == "stop"): dom.shutdown() return "

Stopped