39 QEMU virtual machines
This commit is contained in:
parent
c44c890cde
commit
23b7670131
2 changed files with 17 additions and 15 deletions
|
@ -34,3 +34,8 @@ class ControllerVMS(object):
|
||||||
if Vms.select().where(Vms.user == self.user_id, Vms.id == vm_id).count() == 0:
|
if Vms.select().where(Vms.user == self.user_id, Vms.id == vm_id).count() == 0:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def set_status(self, vm_id, status):
|
||||||
|
x = Vms.update(status=status).where(Vms.id == vm_id)
|
||||||
|
x.execute()
|
||||||
|
return True
|
|
@ -191,34 +191,31 @@ def delete(vm_id):
|
||||||
if not ControllerUsers().auth(session['email'], session['password']):
|
if not ControllerUsers().auth(session['email'], session['password']):
|
||||||
return redirect(url_for("account.logout"))
|
return redirect(url_for("account.logout"))
|
||||||
#
|
#
|
||||||
containers = ControllerContainers(session['user_id'])
|
vms = ControllerVMS(session['user_id'])
|
||||||
# check the user have a selected rule
|
# check the user have a selected rule
|
||||||
# if user not have a container then redirect to the container list
|
# if user not have a container then redirect to the container list
|
||||||
if not containers.check_exists_item(container_id):
|
if not vms.exists(vm_id):
|
||||||
return redirect(url_for('containers.index'))
|
return redirect(url_for('vms.index'))
|
||||||
|
|
||||||
# get container details
|
# get container details
|
||||||
container_details = ControllerContainers(session['user_id']).get_item(container_id)
|
vm_details = vms.get(vm_id)
|
||||||
# POST
|
# POST
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
# Обновляем статус "5" для правила
|
# Обновляем статус "5" для правила
|
||||||
containers.set_status(container_id, 5)
|
vms.set_status(vm_id, 5)
|
||||||
# Создание задания
|
# Создание задания
|
||||||
ControllerTasks(session['user_id']).create(
|
ControllerTasks(session['user_id']).create(
|
||||||
container_details.datacenter.id,
|
vm_details.datacenter.id,
|
||||||
container_details.server.id,
|
vm_details.server.id,
|
||||||
'container_delete',
|
'vm_delete',
|
||||||
0,
|
0,
|
||||||
container_id=container_id
|
vm_id=vm_id
|
||||||
)
|
)
|
||||||
# TODO: send email container was deleted about
|
# TODO: send email container was deleted about
|
||||||
# Редиректим на страницу со всеми правилами
|
# Редиректим на страницу со всеми правилами
|
||||||
flash(u'Контейнер был удалён')
|
flash(u'Виртуальная машина будет удалена')
|
||||||
return redirect(url_for('containers.index'))
|
return redirect(url_for('vms.index'))
|
||||||
return render_template(
|
return render_template('default/vms/delete.html', vm=vm_details)
|
||||||
'default/containers/delete.html',
|
|
||||||
container=container_details
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@viewVMs.route('/settings/<uuid:vm_id>.html', methods=['GET', 'POST'])
|
@viewVMs.route('/settings/<uuid:vm_id>.html', methods=['GET', 'POST'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue