Esempio n. 1
0
 def clean_redis_passwd(self):
     redis_passwd = self.cleaned_data['redis_passwd']
     if checkpass.checkPassword(redis_passwd):
         self.instance.root_passwd = aes.encrypt(redis_passwd)
         return aes.encrypt(redis_passwd)
     else:
         raise forms.ValidationError(u'密码复杂度不足')
Esempio n. 2
0
 def clean_redis_passwd(self):
     redis_passwd = self.cleaned_data['redis_passwd']
     if checkpass.checkPassword(redis_passwd):
         self.instance.root_passwd = aes.encrypt(redis_passwd)
         return aes.encrypt(redis_passwd)
     else:
         raise forms.ValidationError(u'密码复杂度不足')
Esempio n. 3
0
def get_qrcode(user):
    if not user.qrcode:
        user.qrcode = pyotp.random_base32()
        user.save()
    file_name = str(aes.encrypt(user.qrcode), encoding='utf-8')
    file = settings.QCODE_ROOT + '/' + file_name + '.png'
    if not os.path.exists(file):
        data = pyotp.totp.TOTP(user.qrcode).provisioning_uri(
            user.username, issuer_name="devEops")
        qr = QRCode(
            version=1,
            error_correction=constants.ERROR_CORRECT_L,
            box_size=6,
            border=4,
        )
        try:
            qr.add_data(data)
            qr.make(fit=True)
            img = qr.make_image()
            img.save(file)
            return '/media/qrcode/' + file_name + '.png'
        except Exception as e:
            return '/media/qrcode/' + file_name + '.png'
    else:
        return '/media/qrcode/' + file_name + '.png'
Esempio n. 4
0
def ToDictFromExcelForGroup(rowdata):
    service_ip = 0
    server_position = 1
    normal_user = 2
    sshport = 3
    sshpasswd = 4
    info = 5
    manage_ip = 7
    outer_ip = 7
    hostname = 8
    systemtype = 9
    if Host.objects.filter(service_ip=rowdata[service_ip].value).exists():
        return {}
    else:
        return {
            'service_ip': rowdata[service_ip].value,
            'server_position': rowdata[server_position].value,
            'normal_user': rowdata[normal_user].value,
            'sshpasswd': aes.encrypt(rowdata[sshpasswd].value),
            'sshport': int(rowdata[sshport].value),
            'info': rowdata[info].value,
            'manage_ip': rowdata[manage_ip].value,
            'outer_ip': rowdata[outer_ip].value,
            'hostname': rowdata[hostname].value,
            'systemtype': rowdata[systemtype].value,
        }
Esempio n. 5
0
def ToDictFromExcelForGroup(rowdata):
    service_ip = 0
    server_position = 1
    normal_user = 2
    sshport = 3
    sshpasswd = 4
    info = 5
    manage_ip = 7
    outer_ip = 7
    hostname = 8
    systemtype = 9
    if Host.objects.filter(service_ip=rowdata[service_ip].value).exists():
        return {}
    else:
        return {
            'service_ip':rowdata[service_ip].value,'server_position':rowdata[server_position].value,
            'normal_user':rowdata[normal_user].value,'sshpasswd':aes.encrypt(rowdata[sshpasswd].value),
            'sshport':int(rowdata[sshport].value),'info':rowdata[info].value,
            'manage_ip':rowdata[manage_ip].value,'outer_ip':rowdata[outer_ip].value,
            'hostname':rowdata[hostname].value,'systemtype':rowdata[systemtype].value,
            }
Esempio n. 6
0
 def password(self, password):
     self._passwd = aes.encrypt(password).decode()
Esempio n. 7
0
 def clean_sshpasswd(self):
     sshpasswd = self.cleaned_data['sshpasswd']
     if checkpass.checkPassword(sshpasswd):
         return aes.encrypt(sshpasswd)
     else:
         raise forms.ValidationError(u'密码复杂度不足')
Esempio n. 8
0
 def public_key(self, public_key):
     print('pub',aes.encrypt(public_key).decode())
     self._public_key = aes.encrypt(public_key).decode()
Esempio n. 9
0
 def clean_sshpasswd(self):
     sshpasswd = self.cleaned_data['sshpasswd']
     if checkpass.checkPassword(sshpasswd):
         return aes.encrypt(sshpasswd)
     else:
         raise forms.ValidationError(u'密码复杂度不足')
Esempio n. 10
0
 def private_key(self, private_key):
     self._private_key = aes.encrypt(private_key.encode('utf-8'))
Esempio n. 11
0
 def password(self, password):
     self._passwd = aes.encrypt(password.encode('utf-8'))
Esempio n. 12
0
 def private_key(self,pri_key):
     self._private_key = aes.encrypt(pri_key)
Esempio n. 13
0
 def password(self,passwd):
     self._password = aes.encrypt(passwd)
Esempio n. 14
0
 def public_key(self, pub_key):
     self._public_key = aes.encrypt(pub_key)
Esempio n. 15
0
 def private_key(self, private_key):
     self._private_key = aes.encrypt(private_key).decode()
Esempio n. 16
0
 def public_key(self, public_key):
     self._public_key = aes.encrypt(public_key).decode()
Esempio n. 17
0
 def public_key(self, public_key):
     self._public_key = aes.encrypt(public_key.encode('utf-8'))