當前位置: 首頁>>代碼示例>>Python>>正文


Python paramiko.HostKeys方法代碼示例

本文整理匯總了Python中paramiko.HostKeys方法的典型用法代碼示例。如果您正苦於以下問題:Python paramiko.HostKeys方法的具體用法?Python paramiko.HostKeys怎麽用?Python paramiko.HostKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在paramiko的用法示例。


在下文中一共展示了paramiko.HostKeys方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_4_dict_set

# 需要導入模塊: import paramiko [as 別名]
# 或者: from paramiko import HostKeys [as 別名]
def test_4_dict_set(self):
        hostdict = paramiko.HostKeys('hostfile.temp')
        key = paramiko.RSAKey(data=decodebytes(keyblob))
        key_dss = paramiko.DSSKey(data=decodebytes(keyblob_dss))
        hostdict['secure.example.com'] = {
            'ssh-rsa': key,
            'ssh-dss': key_dss
        }
        hostdict['fake.example.com'] = {}
        hostdict['fake.example.com']['ssh-rsa'] = key
        
        self.assertEqual(3, len(hostdict))
        self.assertEqual(2, len(list(hostdict.values())[0]))
        self.assertEqual(1, len(list(hostdict.values())[1]))
        self.assertEqual(1, len(list(hostdict.values())[2]))
        fp = hexlify(hostdict['secure.example.com']['ssh-rsa'].get_fingerprint()).upper()
        self.assertEqual(b'7EC91BB336CB6D810B124B1353C32396', fp)
        fp = hexlify(hostdict['secure.example.com']['ssh-dss'].get_fingerprint()).upper()
        self.assertEqual(b'4478F0B9A23CC5182009FF755BC1D26C', fp) 
開發者ID:hpe-storage,項目名稱:python-hpedockerplugin,代碼行數:21,代碼來源:test_hostkeys.py

示例2: __init__

# 需要導入模塊: import paramiko [as 別名]
# 或者: from paramiko import HostKeys [as 別名]
def __init__(self, capabilities):
        Session.__init__(self, capabilities)
        self._host_keys = paramiko.HostKeys()
        self._transport = None
        self._connected = False
        self._channel = None
        self._buffer = StringIO() # for incoming data
        # parsing-related, see _parse()
        self._parsing_state = 0
        self._parsing_pos = 0 
開發者ID:OpenState-SDN,項目名稱:ryu,代碼行數:12,代碼來源:ssh.py

示例3: __init__

# 需要導入模塊: import paramiko [as 別名]
# 或者: from paramiko import HostKeys [as 別名]
def __init__(self):
        '''
        initialize
        '''
        self.__t = None
        self.__chan = None
        self.__sock = None
        self.__temp_buf = ""
        Thread.__init__(self)
        self.setDaemon(True)
        self.__host_keys = paramiko.HostKeys()
        self.__wait_resp = Event()
        self.__wait_resp.clear()
        self.__wait_rept = Event()
        self.__wait_rept.clear()
        self.__response_buffer = ""
        self.__hello_buffer = ""
        self.__session_id = None
        self.__isCOMPLD = False
        self.__error_message = ""
        self.__isOpen = False
        self.__send_data = ""
        self.__protocol_ver = "1.0"
        self.__notification_list = []
        self.__wait_string = ("", {})
        self.__host_name = ""
        self.__exp_protocol_version = ""
        self.__notification_list_print = [] 
開發者ID:warriorframework,項目名稱:warriorframework,代碼行數:30,代碼來源:netconf.py

示例4: test_1_load

# 需要導入模塊: import paramiko [as 別名]
# 或者: from paramiko import HostKeys [as 別名]
def test_1_load(self):
        hostdict = paramiko.HostKeys('hostfile.temp')
        self.assertEqual(2, len(hostdict))
        self.assertEqual(1, len(list(hostdict.values())[0]))
        self.assertEqual(1, len(list(hostdict.values())[1]))
        fp = hexlify(hostdict['secure.example.com']['ssh-rsa'].get_fingerprint()).upper()
        self.assertEqual(b'E6684DB30E109B67B70FF1DC5C7F1363', fp) 
開發者ID:hpe-storage,項目名稱:python-hpedockerplugin,代碼行數:9,代碼來源:test_hostkeys.py

示例5: test_2_add

# 需要導入模塊: import paramiko [as 別名]
# 或者: from paramiko import HostKeys [as 別名]
def test_2_add(self):
        hostdict = paramiko.HostKeys('hostfile.temp')
        hh = '|1|BMsIC6cUIP2zBuXR3t2LRcJYjzM=|hpkJMysjTk/+zzUUzxQEa2ieq6c='
        key = paramiko.RSAKey(data=decodebytes(keyblob))
        hostdict.add(hh, 'ssh-rsa', key)
        self.assertEqual(3, len(list(hostdict)))
        x = hostdict['foo.example.com']
        fp = hexlify(x['ssh-rsa'].get_fingerprint()).upper()
        self.assertEqual(b'7EC91BB336CB6D810B124B1353C32396', fp)
        self.assertTrue(hostdict.check('foo.example.com', key)) 
開發者ID:hpe-storage,項目名稱:python-hpedockerplugin,代碼行數:12,代碼來源:test_hostkeys.py

示例6: test_3_dict

# 需要導入模塊: import paramiko [as 別名]
# 或者: from paramiko import HostKeys [as 別名]
def test_3_dict(self):
        hostdict = paramiko.HostKeys('hostfile.temp')
        self.assertTrue('secure.example.com' in hostdict)
        self.assertTrue('not.example.com' not in hostdict)
        self.assertTrue('secure.example.com' in hostdict)
        self.assertTrue('not.example.com' not in hostdict)
        x = hostdict.get('secure.example.com', None)
        self.assertTrue(x is not None)
        fp = hexlify(x['ssh-rsa'].get_fingerprint()).upper()
        self.assertEqual(b'E6684DB30E109B67B70FF1DC5C7F1363', fp)
        i = 0
        for key in hostdict:
            i += 1
        self.assertEqual(2, i) 
開發者ID:hpe-storage,項目名稱:python-hpedockerplugin,代碼行數:16,代碼來源:test_hostkeys.py

示例7: test_delitem

# 需要導入模塊: import paramiko [as 別名]
# 或者: from paramiko import HostKeys [as 別名]
def test_delitem(self):
        hostdict = paramiko.HostKeys('hostfile.temp')
        target = 'happy.example.com'
        entry = hostdict[target] # will KeyError if not present
        del hostdict[target]
        try:
            entry = hostdict[target]
        except KeyError:
            pass # Good
        else:
            assert False, "Entry was not deleted from HostKeys on delitem!" 
開發者ID:hpe-storage,項目名稱:python-hpedockerplugin,代碼行數:13,代碼來源:test_hostkeys.py


注:本文中的paramiko.HostKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。