commit
This commit is contained in:
+13
-6
@@ -1,9 +1,16 @@
|
||||
import os
|
||||
import requests
|
||||
import json
|
||||
from requests.exceptions import HTTPError
|
||||
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
|
||||
DASHBOARD_USER = os.getenv("DASHBOARD_USER", "admin@hpe.com")
|
||||
DASHBOARD_PASSWORD = os.getenv(
|
||||
"DASHBOARD_PASSWORD",
|
||||
"kxly7o6FboYUoQXSeLrs2xodHIeybQRwcMs33QC5#",
|
||||
)
|
||||
|
||||
def _format_ipv6(host_ip):
|
||||
"""If the host_ip is an IPv6 address, enclose it in square brackets."""
|
||||
if ":" in host_ip and not host_ip.startswith("["):
|
||||
@@ -34,11 +41,11 @@ def get_vpn_dashboard_token(base_url):
|
||||
"Content-Type": "application/json", "Accept": "*/*", "User-Agent": "Mozilla/5.0"
|
||||
})
|
||||
|
||||
credentials = {
|
||||
"user": "admin@hpe.com", "password": "JohnWayne#21",
|
||||
# "user": "admin@hpe.com", "password": "administratoR!1",
|
||||
# "user": "admin@athonet.com", "password": "administratoR!1",
|
||||
"lang": "en", "auth_provider": "enterprise"
|
||||
credentials = {
|
||||
"user": DASHBOARD_USER,
|
||||
"password": DASHBOARD_PASSWORD,
|
||||
"lang": "en",
|
||||
"auth_provider": "enterprise",
|
||||
}
|
||||
|
||||
auth_response = session.post(f"{base_url}/portal/api/session/authenticate", json=credentials, verify=False)
|
||||
@@ -56,4 +63,4 @@ def get_vpn_dashboard_token(base_url):
|
||||
if not token:
|
||||
raise ValueError("Login failed: Could not retrieve session token.")
|
||||
|
||||
return token, session
|
||||
return token, session
|
||||
|
||||
Reference in New Issue
Block a user