예제 #1
0
 def catch_ssh_connect(self):
     target = paramiko.SSHClient()
     target.set_missing_host_key_policy(paramiko.AutoAddPolicy())
     flag = 'host-none'
     msg = Message()
     for group in self.groups.all():
         msg, sship, sshport = group.catch_ssh_connect
         if msg.last_result == 'jumper-success':
             try:
                 transport = msg.instance.get_transport()
                 jumperchannel = transport.open_channel(
                     "direct-tcpip", (self.service_ip, self.sshport),
                     (sship, sshport))
                 hostssh = target.connect(self.service_ip,
                                          username=self.normal_user,
                                          key_filename=settings.RSA_KEY,
                                          sock=jumperchannel,
                                          port=self.sshport,
                                          password=aes.decrypt(
                                              self.sshpasswd))
                 return msg.fuse_msg('host-success', hostssh)
             except socket.timeout:
                 flag = 'host-timeout'
                 msg
                 continue
             except Exception, ex:
                 flag = 'host-exception'
                 continue
         else:
             continue
예제 #2
0
 def set_all_variable(self):
     self.set_variable('ansible_host', self.name)
     self.set_variable('ansible_port', self.port)
     self.set_variable('ansible_user', self.host.normal_user)
     # self.set_variable('ansible_ssh_pass', self.host.sshpasswd) #密码登陆
     self.set_variable("ansible_become", True)
     self.set_variable("ansible_become_method", 'sudo')
     self.set_variable("ansible_become_user", 'root')
     self.set_variable("ansible_become_pass", decrypt(self.host.sshpasswd))
예제 #3
0
 def set_all_variable(self):
     self.set_variable('ansible_host', self.name)
     self.set_variable('ansible_port', self.port)
     self.set_variable('ansible_user', self.host.sys_user.username)
     # self.set_variable('ansible_ssh_pass', self.host.sshpasswd) #密码登陆
     self.set_variable("ansible_become", True)
     self.set_variable("ansible_become_method", 'sudo')
     self.set_variable("ansible_become_user", 'root')
     self.set_variable("ansible_become_pass", decrypt(self.host.sshpasswd))
예제 #4
0
 def catch_ssh_connect(self):
     msg = Message()
     if self.check_status == True:
         try:
             jumper = paramiko.SSHClient()
             jumper.set_missing_host_key_policy(paramiko.AutoAddPolicy())
             jumper.connect(self.service_ip, username=self.normal_user,
                               key_filename=settings.RSA_KEY, port=self.sshport,
                               password=aes.decrypt(self.sshpasswd))
             return msg.fuse_msg('jumper-success',jumper)
         except socket.timeout:
             return msg.fuse_msg('jumper-timeout',None)
         except Exception,ex:
             return msg.fuse_msg('jumper-exception',None)
예제 #5
0
 def private_key(self):
     if self._private_key:
         key_str = aes.decrypt(self._private_key)
         return key_str
     else:
         return None
예제 #6
0
 def password(self):
     if self._passwd:
         return aes.decrypt(self._passwd)
     else:
         return 'nopassword'
예제 #7
0
 def get_form(self, form_class=None):
     form = super(ApplicationRedisUpdateView, self).get_form(form_class)
     form.initial['redis_passwd'] = aes.decrypt(form.instance.redis_passwd)
     return form
예제 #8
0
 def catch_ssh_connect(self):
     target = paramiko.SSHClient()
     target.set_missing_host_key_policy(paramiko.AutoAddPolicy())
     flag = 'host-none'
     msg = Message()
     for group in self.groups.all():
         msg,sship,sshport = group.catch_ssh_connect
         if msg.last_result == 'jumper-success':
             try:
                 transport = msg.instance.get_transport()
                 jumperchannel = transport.open_channel("direct-tcpip",
                                                              (self.service_ip, self.sshport),
                                                              (sship, sshport))
                 hostssh = target.connect(self.service_ip,username=self.normal_user,key_filename=settings.RSA_KEY,
                                          sock=jumperchannel,port=self.sshport,password=aes.decrypt(self.sshpasswd))
                 return msg.fuse_msg('host-success',hostssh)
             except socket.timeout:
                 flag='host-timeout'
                 msg
                 continue
             except Exception, ex:
                 flag='host-exception'
                 continue
         else:
             continue
예제 #9
0
 def password_get(self):
     return aes.decrypt(self.sshpasswd)
예제 #10
0
 def password_get(self):
     return aes.decrypt(self.sshpasswd)
예제 #11
0
파일: views.py 프로젝트: caroid/DevOps
 def get_form(self, form_class=None):
     form = super(UtilsJumperUpdateView, self).get_form(form_class)
     form.initial['sshpasswd'] = aes.decrypt(form.initial['sshpasswd'])
     return form
예제 #12
0
 def public_key(self):
     return aes.decrypt(self._public_key)
예제 #13
0
 def password(self):
     if self._admin_passwd:
         return aes.decrypt(self._admin_passwd)
     else:
         return ''
예제 #14
0
 def get_form(self, form_class=None):
     form = super(ApplicationRedisUpdateView, self).get_form(form_class)
     form.initial['redis_passwd'] = aes.decrypt(form.instance.redis_passwd)
     return form
예제 #15
0
 def get_form(self, form_class=None):
     form = super(UtilsJumperUpdateView,self).get_form(form_class)
     form.initial['sshpasswd'] = aes.decrypt(form.initial['sshpasswd'])
     return form
예제 #16
0
 def private_key(self):
     if self._private_key:
         key_str = aes.decrypt(self._private_key)
         return sshkey.ssh_private_key2obj(key_str)
     else:
         return None
예제 #17
0
 def reco_private_key(self):
     return aes.decrypt(self._private_key)[0:7]
예제 #18
0
파일: db.py 프로젝트: sjkcdpc/DevOps-1
 def get_form(self, form_class=None):
     form = super(ApplicationDBUpdateView, self).get_form(form_class)
     root_passwd = form.initial['root_passwd']
     form.initial['root_passwd'] = aes.decrypt(root_passwd)
     return form
예제 #19
0
파일: host.py 프로젝트: sansom/AiDevOps
 def get_form(self, form_class=None):
     form = super(ManagerHostUpdateView,self).get_form(form_class)
     sshpasswd = form.initial['sshpasswd']
     form.initial['sshpasswd'] = aes.decrypt(sshpasswd)
     return form
예제 #20
0
 def get_form(self, form_class=None):
     form = super(ManagerHostUpdateView,self).get_form(form_class)
     #
     # sshpasswd = ''
     form.initial['sshpasswd'] = aes.decrypt(form.initial['sshpasswd'])
     return form