diff options
author | Michal Minar <miminar@redhat.com> | 2013-09-13 08:47:05 +0200 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2013-09-13 08:54:03 +0200 |
commit | 9e6ae8c53846bde8f5814bd655cd9f17e441026e (patch) | |
tree | 9e5dbb36dd749214d29f690837b4ce4ac367a315 | |
parent | 083de6a52ccbaa9c5f2843bd3b3b4031eda16acb (diff) | |
download | openlmi-scripts-9e6ae8c53846bde8f5814bd655cd9f17e441026e.tar.gz openlmi-scripts-9e6ae8c53846bde8f5814bd655cd9f17e441026e.tar.xz openlmi-scripts-9e6ae8c53846bde8f5814bd655cd9f17e441026e.zip |
fixed detection of older shell when making a connection
correctly detect which of the following should be passed to connect
method:
verify_certificate - older versions
verify_server_cert - newer versions
-rw-r--r-- | lmi/scripts/common/session.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lmi/scripts/common/session.py b/lmi/scripts/common/session.py index 5924dbb..0d3568f 100644 --- a/lmi/scripts/common/session.py +++ b/lmi/scripts/common/session.py @@ -114,14 +114,18 @@ class Session(object): # TODO: remove inspect magic and add dependency on particular # version of openlmi-tools, when its released kwargs = dict(interactive=interactive) - if inspect.getargspec(connect).args: + con_argspec = inspect.getargspec(connect) + if 'verify_server_cert' in con_argspec.args or con_argspec.keywords: # newer name kwargs['verify_server_cert'] = self._app.config.verify_server_cert - else: # older one + elif 'verify_certificate' in con_argspec.args: + # older one kwargs['verify_certificate'] = self._app.config.verify_server_cert + # else: this must be very old and bearded shell - if len(self._connections) > 1 \ - and 'prompt_prefix' in inspect.getargspec(connect).args: + if ( len(self._connections) > 1 \ + and ( 'prompt_prefix' in con_argspec.args + or con_argspec.keywords)): kwargs['prompt_prefix'] = '[%s] ' % hostname connection = connect(hostname, username, password, **kwargs) if connection is not None: |