Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShellScripHandler can't find the user name I specified in config file #16

Open
EasonLiao opened this issue May 19, 2016 · 3 comments
Open

Comments

@EasonLiao
Copy link

I wrote the username that should be used for ssh in config file like link

But ShellScriptHandler failed to use it because it's overwritten by the default parameter None in the constructor of ShellScriptHandler, see:

class ShellScriptHandler(BaseHandler):
    """ Shell Script Handler piggybacking on paramiko SSH"""

    def __init__(self, config_dir, hostname, logger_instance=None, port=22,
                 username=None, password=None, pkey=None, key_filename=None,
                 connect_timeout=None, allow_agent=True, look_for_keys=True,
                 compress=False, sock=None, verbose=False, debug=False,
                 command_timeout=None):

And I see the username and a bunch of other stuff are never passed to ShellScriptHandler, see link:

     handler = handler_class(self.config_dir, target,
                                self.logger_instance, verbose=True)

I added some ad-hoc fixes, I'm wondering what are appropriate ways to fix it? I'm happy to send a PR if you think this is something that needs to be fixed.

@sarathsreedharan
Copy link
Contributor

Hey Eason,
I see that the configs are being read in the constructor
'''

    # read in yaml configuration
    for key, val in self.config.iteritems():
        setattr(self, key, val)
    del self.config

'''
unfortunately its being rewritten by the default values, so in order to fix it all you would need to do, would be to update the initialization section to update config values only if the value being passed is not None

@EasonLiao
Copy link
Author

EasonLiao commented May 19, 2016

Hey @sarathsreedharan

Thanks for the quick reply!

I sent a PR for the fix, but unlike the proposal you suggested, I got rid of all the parameters that are related to ssh from the constructor and assumed these will be specified in config file because I don't see any reason to keep them in the constructor given that we never pass any arguments to them.

Does that look good to you? if not, I'm happy to switch to the approach you suggested :)

@sarathsreedharan
Copy link
Contributor

Hey @EasonLiao
The change looks good to me, but I would also like to take @MayureshGharat and Tofig's opinion on this change, to make sure there wasn't any specific reason for putting those default parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants