Added a custom uknown_host_cb function to overcome ssh key errors v0.7.9
authorLeonidas Poulopoulos <leopoul@noc.grnet.gr>
Thu, 9 Feb 2012 08:12:23 +0000 (10:12 +0200)
committerLeonidas Poulopoulos <leopoul@noc.grnet.gr>
Thu, 9 Feb 2012 08:12:23 +0000 (10:12 +0200)
utils/proxy.py

index 9257c3d..488bf98 100644 (file)
@@ -22,6 +22,9 @@ handler = logging.FileHandler(LOG_FILENAME)
 handler.setFormatter(formatter)
 logger.addHandler(handler)
 
+def fod_unknown_host_cb(host, fingerprint):
+    return True
+
 class Retriever(object):
     def __init__(self, device=settings.NETCONF_DEVICE, username=settings.NETCONF_USER, password=settings.NETCONF_PASS, filter=settings.ROUTES_FILTER, route_name=None, xml=None):
         self.device = device
@@ -33,7 +36,7 @@ class Retriever(object):
             self.filter = settings.ROUTE_FILTER%route_name
     
     def fetch_xml(self):
-        with manager.connect(host=self.device, port=830, username=self.username, password=self.password) as m:
+        with manager.connect(host=self.device, port=830, username=self.username, password=self.password, unknown_host_cb=fod_unknown_host_cb) as m:
             xmlconfig = m.get_config(source='running', filter=('subtree',self.filter)).data_xml
         return xmlconfig
     
@@ -161,7 +164,7 @@ class Applier(object):
         commit_confirmed_is_successful = False
         commit_is_successful = False
         if configuration:
-            with manager.connect(host=self.device, port=830, username=self.username, password=self.password) as m:
+            with manager.connect(host=self.device, port=830, username=self.username, password=self.password, unknown_host_cb=fod_unknown_host_cb) as m:
                 assert(":candidate" in m.server_capabilities)
                 with m.locked(target='candidate'):
                     m.discard_changes()