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

Draft: Feature: Make authsource an optional parameter - for current upstream #283

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def parse_params(logger):
parser = OptionParser()
parser.add_option("-u", "--user", help="specify user to log in", action="store", dest="user")
parser.add_option("-p", "--password", help="specify password to log in", action="store", dest="password")
parser.add_option("-a", "--authsource", help="specify auth source to authenticate against", action="store", dest="authsource")
parser.add_option("-o", "--port", help="specify inventory port", action="store", dest="port")
parser.add_option("-m", "--config", help="Path to the configuration to set properties of the resources kept in "
"the inventory", action="store", dest="config")
Expand All @@ -37,6 +38,10 @@ def parse_params(logger):
os.environ['USER'] = options.user
if options.password:
os.environ['PASSWORD'] = options.password
if options.authsource:
os.environ['AUTHSOURCE'] = options.authsource
elif "AUTHSOURCE" not in os.environ:
os.environ['AUTHSOURCE'] = 'Local'
if options.info:
logger.setLevel(logging.INFO)
ConsoleHandler.setLevel(logging.INFO)
Expand Down
2 changes: 2 additions & 0 deletions tests/TestLaunchInventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_with_cli_and_env_params(self):
'-s', '180']
os.environ['USER'] = 'env_testuser'
os.environ['PASSWORD'] = 'testps31!_2'
os.environ['AUTHSOURCE'] = 'Local'
os.environ['PORT'] = '1123'
os.environ['TARGET'] = '/wrong/path/to/atlas.yaml'
os.environ['INVENTORY_CONFIG'] = 'wrong/path/to/config.yaml'
Expand All @@ -78,6 +79,7 @@ def test_env_params(self):
os.environ.clear()
os.environ['USER'] = 'testuser'
os.environ['PASSWORD'] = 'testpw31!'
os.environ['AUTHSOURCE'] = 'Local'
os.environ['PORT'] = '1234'
os.environ['TARGET'] = 'vrops-vcenter-test.company.com'
os.environ['INVENTORY_CONFIG'] = 'tests/inventory_config.yaml'
Expand Down
2 changes: 1 addition & 1 deletion tools/Vrops.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_token(target):
}
payload = {
"username": os.environ['USER'],
"authSource": "Local",
"authSource": os.environ['AUTHSOURCE'],
"password": os.environ['PASSWORD']
}
disable_warnings(exceptions.InsecureRequestWarning)
Expand Down