6507: Remove unused imports, move _init_ssh_key() into base, set hostname tag on...
[arvados.git] / services / nodemanager / arvnodeman / computenode / driver / __init__.py
index 042f6a57cd95eff95e9c931ec96680d57d978488..e3298a70fac47e420c83c505bc1dd54681c7e335 100644 (file)
@@ -56,7 +56,12 @@ class BaseComputeNodeDriver(object):
     def _init_ping_host(self, ping_host):
         self.ping_host = ping_host
 
-    def search_for(self, term, list_method, key=attrgetter('id')):
+    def _init_ssh_key(self, filename):
+        with open(filename) as ssh_file:
+            key = cloud_base.NodeAuthSSHKey(ssh_file.read())
+        return 'auth', key
+
+    def search_for(self, term, list_method, key=attrgetter('id'), **kwargs):
         """Return one matching item from a list of cloud objects.
 
         Raises ValueError if the number of matching objects is not exactly 1.
@@ -71,7 +76,8 @@ class BaseComputeNodeDriver(object):
         """
         cache_key = (list_method, term)
         if cache_key not in self.SEARCH_CACHE:
-            results = [item for item in getattr(self.real, list_method)()
+            items = getattr(self.real, list_method)(**kwargs)
+            results = [item for item in items
                        if key(item) == term]
             count = len(results)
             if count != 1: