def post(self, id): inst = self.get_instance(id, isowner=True) if not inst: return form = PublicKeyForm( self.request.arguments ) if form.validate(): if inst.config: config = json.loads(inst.config) else: config = {} config['public_key'] = form.key.data 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&saved=True' return self.redirect( url ) # Get error d = { 'title': _('Edit SSH Public Key'), 'instance': inst, 'form': form } self.render('instance/publickey_edit.html', **d)
def post(self, id): inst = self.get_instance(id, isowner=True) if not inst: return form = PublicKeyForm(self.request.arguments) if form.validate(): if inst.config: config = json.loads(inst.config) else: config = {} config["public_key"] = form.key.data 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&saved=True" return self.redirect(url) # Get error d = {"title": _("Edit SSH Public Key"), "instance": inst, "form": form} self.render("instance/publickey_edit.html", **d)
def post_public_key(self, I): form = PublicKeyForm(self) if form.validate(): if I.config: config = json.loads(I.config) else: config = {} config['public_key'] = form.key.data I.config = json.dumps(config) if I.is_running: I.ischanged = True self.db2.commit() url = self.reverse_url('myun:instance:view', I.id) url += '?tab=secret' self.redirect( url ) self.d['form'] = form self.render('myun/instance/edit_public_key.html', **self.d)
def get(self, id): inst = self.get_instance(id, isowner=True) if not inst: return form = PublicKeyForm() if inst.config: config = json.loads(inst.config) if 'public_key' in config.keys(): form.key.data = config['public_key'] d = { 'title': _('Edit SSH Public Key'), 'instance': inst, 'form': form } self.render('instance/publickey_edit.html', **d)
def get_secret(self): inst = self.inst password = '' publickey = '' form = PublicKeyForm() if inst.config: config = json.loads(inst.config) if 'passwd_hash' in config.keys(): password = config['passwd_hash'] if 'public_key' in config.keys(): form.key.data = config['public_key'] d = { 'title': _('Configure Password'), 'instance': inst, 'password': password, 'form': form, 'saved': self.get_argument('saved', None) } self.render('instance/secret.html', **d)