1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-07-31 12:41:08 +00:00

User can change root password in instance

This commit is contained in:
Retspen 2015-05-20 16:44:30 +03:00
parent bbc1b26edf
commit e312fafc3c
4 changed files with 113 additions and 1 deletions

View file

@ -1,5 +1,7 @@
import time
import json
import socket
import crypt
from string import letters, digits
from random import choice
from bisect import insort
@ -261,6 +263,26 @@ def instance(request, compute_id, vname):
conn.delete()
return HttpResponseRedirect(reverse('instances'))
if 'rootpasswd' in request.POST:
passwd = request.POST.get('passwd', '')
passwd_hash = crypt.crypt(passwd, '$6$kgPoiREy')
data = {'passwd': passwd_hash, 'vname': vname}
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((compute.hostname, 16510))
s.send(json.dumps(data))
result = json.loads(s.recv(1024))
s.close()
msg = _("Reset root password")
addlogmsg(request.user.username, instance.name, msg)
if result['return'] == 'success':
messages.append(msg)
else:
error_messages(msg)
if 'resize' in request.POST:
vcpu = request.POST.get('vcpu', '')
cur_vcpu = request.POST.get('cur_vcpu', '')
@ -298,7 +320,7 @@ def instance(request, compute_id, vname):
conn.create_snapshot(name)
msg = _("New snapshot")
addlogmsg(request.user.username, instance.name, msg)
return HttpResponseRedirect(request.get_full_path() + '#takesnapshot')
return HttpResponseRedirect(request.get_full_path() + '#restoresnapshot')
if 'delete_snapshot' in request.POST:
snap_name = request.POST.get('name', '')