Skip to content

Commit

Permalink
voucher can now be set via config file to allow auto-registering with…
Browse files Browse the repository at this point in the history
…out any command-line input
  • Loading branch information
s3inlc committed Jan 27, 2018
1 parent 0278062 commit 3a85109
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/htpclient/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def __update_information(self):

def __check_token(self):
if len(self.config.get_value('token')) == 0:
voucher = input("No token found! Please enter a voucher to register your agent:\n").strip()
if len(self.config.get_value('voucher')) > 0:
# voucher is set in config and can be used to autoregister
voucher = self.config.get_value('voucher')
else:
voucher = input("No token found! Please enter a voucher to register your agent:\n").strip()
name = platform.node()
req = JsonRequest({'action': 'register', 'voucher': voucher, 'name': name})
ans = req.execute()
Expand All @@ -125,6 +129,7 @@ def __check_token(self):
self.__check_token()
else:
token = ans['token']
self.config.set_value('voucher', '')
self.config.set_value('token', token)
logging.info("Successfully registered!")

Expand Down

0 comments on commit 3a85109

Please sign in to comment.