From: Alfredo Deza Date: Thu, 13 Aug 2015 12:22:49 +0000 (-0400) Subject: [RM-11115] allow a list of callbacks when creating a connection X-Git-Tag: v1.5.28~4^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4e122d13c09119a9db7963dc1a350287e69f0524;p=ceph-deploy.git [RM-11115] allow a list of callbacks when creating a connection Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/hosts/__init__.py b/ceph_deploy/hosts/__init__.py index 17aa99e..a5f9fcb 100644 --- a/ceph_deploy/hosts/__init__.py +++ b/ceph_deploy/hosts/__init__.py @@ -17,7 +17,8 @@ def get(hostname, username=None, fallback=None, detect_sudo=True, - use_rhceph=False): + use_rhceph=False, + callbacks=None): """ Retrieve the module that matches the distribution of a ``hostname``. This function will connect to that host and retrieve the distribution @@ -36,6 +37,10 @@ def get(hostname, :param use_rhceph: Whether or not to install RH Ceph on a RHEL machine or the community distro. Changes what host module is returned for RHEL. + :params callbacks: A list of callables that accept one argument (the actual + module that contains the connection) that will be + called, in order at the end of the instantiation of the + module. """ conn = get_connection( hostname, @@ -71,6 +76,10 @@ def get(hostname, module.machine_type = machine_type module.init = module.choose_init(module) module.packager = module.get_packager(module) + # execute each callback if any + if callbacks: + for c in callbacks: + c(module) return module