Esempio n. 1
0
    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)
Esempio n. 2
0
    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)