コード例 #1
0
ファイル: views.py プロジェクト: mylxiaoyi/LuoYunCloud
    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)
コード例 #2
0
ファイル: views.py プロジェクト: woerwin/LuoYunCloud
    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)
コード例 #3
0
ファイル: views.py プロジェクト: alayasix/LuoYunCloud
    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)
コード例 #4
0
ファイル: views.py プロジェクト: alayasix/LuoYunCloud
    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)
コード例 #5
0
ファイル: views.py プロジェクト: alayasix/LuoYunCloud
    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)