from __future__ import absolute_import, print_function
import libcloud.common.types as cloud_types
+from libcloud.compute.base import NodeDriver
from ...config import NETWORK_ERRORS
def _init_ping_host(self, ping_host):
self.ping_host = ping_host
- def __getattr__(self, name):
- # Proxy non-extension methods to the real driver.
- if (not name.startswith('_') and not name.startswith('ex_')
- and hasattr(self.real, name)):
- return getattr(self.real, name)
- else:
- return super(BaseComputeNodeDriver, self).__getattr__(name)
-
def search_for(self, term, list_method, key=lambda item: item.id):
cache_key = (list_method, term)
if cache_key not in self.SEARCH_CACHE:
# information back to the cloud node appropriately.
raise NotImplementedError("BaseComputeNodeDriver.sync_node")
+ @classmethod
+ def node_fqdn(cls, node):
+ # This method should return the FQDN of the node object argument.
+ # Different clouds store this in different places.
+ raise NotImplementedError("BaseComputeNodeDriver.node_fqdn")
+
@classmethod
def node_start_time(cls, node):
raise NotImplementedError("BaseComputeNodeDriver.node_start_time")
# exactly an Exception, or a better-known higher-level exception.
return (isinstance(exception, cls.CLOUD_ERRORS) or
getattr(exception, '__class__', None) is Exception)
+
+ # Now that we've defined all our own methods, delegate generic, public
+ # attributes of libcloud drivers that we haven't defined ourselves.
+ def _delegate_to_real(attr_name):
+ return property(
+ lambda self: getattr(self.real, attr_name),
+ lambda self, value: setattr(self.real, attr_name, value),
+ doc=getattr(getattr(NodeDriver, attr_name), '__doc__', None))
+
+ _locals = locals()
+ for _attr_name in dir(NodeDriver):
+ if (not _attr_name.startswith('_')) and (_attr_name not in _locals):
+ _locals[_attr_name] = _delegate_to_real(_attr_name)