Move token generation vs config out of relation hook and into util
This commit is contained in:
parent
2487be48ae
commit
ab29b9de1b
@ -90,10 +90,7 @@ def identity_changed():
|
||||
relation_data["public_url"],
|
||||
relation_data["admin_url"],
|
||||
relation_data["internal_url"])
|
||||
if config["admin-token"] == "None":
|
||||
token = generate_admin_token(manager, config)
|
||||
else:
|
||||
token = config["admin-token"]
|
||||
token = generate_admin_token(manager, config)
|
||||
# we return a token and information about our API endpoints
|
||||
relation_data = {
|
||||
"admin_token": token,
|
||||
|
@ -196,8 +196,11 @@ def create_role(manager, name, user):
|
||||
|
||||
def generate_admin_token(manager, config):
|
||||
""" generate and add an admin token """
|
||||
import random
|
||||
token = random.randrange(1000000000000, 9999999999999)
|
||||
if config["admin-token"] == None:
|
||||
import random
|
||||
token = random.randrange(1000000000000, 9999999999999)
|
||||
else:
|
||||
token = config["admin-token"]
|
||||
manager.api.add_token(token, config["admin-user"], "admin", config["token-expiry"])
|
||||
juju_log("Generated and added new random admin token.")
|
||||
return token
|
||||
|
Loading…
x
Reference in New Issue
Block a user