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

version_check.py should have command line options to set runtime values for user, password, host, api version #9

Open
hcoyote opened this issue Aug 15, 2022 · 1 comment

Comments

@hcoyote
Copy link

hcoyote commented Aug 15, 2022

https://github.com/cloudera-labs/toolkits/blob/main/upgrade-toolkit/CDP%20Version%20Check/version_check.py

Looking through the code and readme, I see that we tell people to update the hard-coded value. It would be more user friendly if we used something like argparse to be able to set those values at runtime on the command line. The less editing people have to do to run this tool, the better the experience will be.

Something like:


class Password(argparse.Action):
    def __call__(self, parser, namespace, values, option_string):
        if values is None:
            values = getpass.getpass()

        setattr(namespace, self.dest, values)

parser = argparse.ArgumentParser()
parser.add_argument('--user', '-u', dest='username', help='user to authenticate to CM as', type=str)
parser.add_argument('--pass','-p', action=Password, nargs='?', dest='password', help='Enter your password')
parser.add_argument('--verify-ssl', dest='verifyssl', default=False, action='store_true', help='enable SSL verification for CM')
parser.add_argument('--host', '-h', dest='cmhostname', help='cm hostname to connect to')
args = parser.parse_args()

cm_client.configuration.username = args.username
cm_client.configuration.password = args.password
cm_client.configuration.verify_ssl = args.verifyssl
cm_host = args.cmhostname

Haven't tested the password part of this, but I think the rest is basically correct (although written from memory).

@hcoyote
Copy link
Author

hcoyote commented Aug 15, 2022

may also want to make the api version configurable as well.

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

No branches or pull requests

1 participant