diff options
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs/__init__.py')
-rw-r--r-- | openshift-storage-libs/openshiftstoragelibs/__init__.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/__init__.py b/openshift-storage-libs/openshiftstoragelibs/__init__.py index e69de29b..8d4d25c6 100644 --- a/openshift-storage-libs/openshiftstoragelibs/__init__.py +++ b/openshift-storage-libs/openshiftstoragelibs/__init__.py @@ -0,0 +1,25 @@ +from glusto.core import Glusto +from six import add_metaclass + + +def monkeypatch_class(name, bases, namespace): + assert len(bases) == 1, "Only 1 parent class is supported." + base = bases[0] + for name, value in namespace.items(): + if not name.startswith("__"): + setattr(base, name, value) + return base + + +@add_metaclass(monkeypatch_class) +class MonkeyPatchedGlusto(Glusto): + @classmethod + def _get_ssh_connection(cls, host, user=None): + ssh = super(MonkeyPatchedGlusto, cls)._get_ssh_connection( + host=host, user=user) + if not ssh: + super(MonkeyPatchedGlusto, cls).ssh_close_connection( + host=host, user=user) + ssh = super(MonkeyPatchedGlusto, cls)._get_ssh_connection( + host=host, user=user) + return ssh |