def post(self, id): inst = self.get_instance(id, isowner=True) if not inst: return form = PasswordForm( self.request.arguments ) if form.validate(): # get shadow passwd import crypt, random, time salt = crypt.crypt(str(random.random()), str(time.time()))[:8] s = '$'.join(['','6', salt,'']) password = crypt.crypt(form.password.data,s) if inst.config: config = json.loads(inst.config) else: config = {} config['passwd_hash'] = password inst.config = json.dumps(config) if inst.is_running: inst.ischanged = True self.db2.commit() url = self.reverse_url('instance:view', id) url += '?view=secret' return self.redirect( url ) # Get error d = { 'title': _('Edit Root Password for Instance'), 'instance': inst, 'form': form } self.render('instance/password_edit.html', **d)
def post_password(self, I): form = PasswordForm(self) if form.validate(): # get shadow passwd import crypt, random, time salt = crypt.crypt(str(random.random()), str(time.time()))[:8] s = '$'.join(['','6', salt,'']) password = crypt.crypt(form.password.data,s) if I.config: config = json.loads(I.config) else: config = {} config['passwd_hash'] = password I.config = json.dumps(config) if I.is_running: I.ischanged = True I.set_config('use_global_passwd', False) self.db2.commit() url = self.reverse_url('myun:instance:view', I.id) url += '?tab=secret' return self.redirect( url ) self.d['form'] = form self.render('myun/instance/edit_password.html', **self.d)
def post(self, id): inst = self.get_instance(id, isowner=True) if not inst: return form = PasswordForm(self.request.arguments) if form.validate(): # get shadow passwd import crypt, random, time salt = crypt.crypt(str(random.random()), str(time.time()))[:8] s = "$".join(["", "6", salt, ""]) password = crypt.crypt(form.password.data, s) if inst.config: config = json.loads(inst.config) else: config = {} config["passwd_hash"] = password inst.config = json.dumps(config) if inst.is_running: inst.ischanged = True self.db2.commit() url = self.reverse_url("instance:view", id) url += "?view=secret" return self.redirect(url) # Get error d = {"title": _("Edit Root Password for Instance"), "instance": inst, "form": form} self.render("instance/password_edit.html", **d)
def get(self, id): inst = self.get_instance(id, isowner=True) if not inst: return form = PasswordForm() d = { 'title': _('Edit Root Password for Instance'), 'instance': inst, 'form': form } self.render('instance/password_edit.html', **d)