|
|
|
|
@ -19,7 +19,6 @@ def get_request(url, headers):
|
|
|
|
|
return "A Timeout Error occurred:" + repr(errt)
|
|
|
|
|
except requests.exceptions.RequestException as err:
|
|
|
|
|
return "An Unknown Error occurred" + repr(err)
|
|
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
def post_request(url, headers,body):
|
|
|
|
|
@ -34,7 +33,6 @@ def post_request(url, headers,body):
|
|
|
|
|
return "A Timeout Error occurred:" + repr(errt)
|
|
|
|
|
except requests.exceptions.RequestException as err:
|
|
|
|
|
return "An Unknown Error occurred" + repr(err)
|
|
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
def put_request(url, headers,body):
|
|
|
|
|
@ -49,94 +47,54 @@ def put_request(url, headers,body):
|
|
|
|
|
return "A Timeout Error occurred:" + repr(errt)
|
|
|
|
|
except requests.exceptions.RequestException as err:
|
|
|
|
|
return "An Unknown Error occurred" + repr(err)
|
|
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
def CreateToken(DTAPIToken, DTENV,nwzone, dtEnvInfo, tokenname,scope):
|
|
|
|
|
|
|
|
|
|
env = DTENV
|
|
|
|
|
DTAPIToken = DTAPIToken
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DTAPIURL = env + "/api/v2/apiTokens"
|
|
|
|
|
|
|
|
|
|
headers = {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
'Authorization': 'Api-Token ' + DTAPIToken
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DynatraceInstaller = [
|
|
|
|
|
|
|
|
|
|
"InstallerDownload",
|
|
|
|
|
"SupportAlert"
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
DevOps_Read = [
|
|
|
|
|
|
|
|
|
|
"DataExport", # Access problem and event feed, metrics, and topology.
|
|
|
|
|
|
|
|
|
|
"DTAQLAccess", # User sessions.
|
|
|
|
|
|
|
|
|
|
"ReadSyntheticData", # Read synthetic monitors, locations, and nodes.
|
|
|
|
|
|
|
|
|
|
"metrics.read", # Read metrics.
|
|
|
|
|
|
|
|
|
|
"entities.read", # Read entities.
|
|
|
|
|
|
|
|
|
|
"problems.read", # Read problems.
|
|
|
|
|
|
|
|
|
|
"syntheticLocations.read", # Read synthetic locations.
|
|
|
|
|
|
|
|
|
|
"slo.read", # Read SLO.
|
|
|
|
|
|
|
|
|
|
"releases.read", # Read releases.
|
|
|
|
|
|
|
|
|
|
"activeGates.read"
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
ReadAll = [
|
|
|
|
|
|
|
|
|
|
"DataExport", # Access problem and event feed, metrics, and topology.
|
|
|
|
|
|
|
|
|
|
"ReadConfig", # Read configuration.
|
|
|
|
|
|
|
|
|
|
"DTAQLAccess", # User sessions.
|
|
|
|
|
|
|
|
|
|
"ReadSyntheticData", # Read synthetic monitors, locations, and nodes.
|
|
|
|
|
|
|
|
|
|
"auditLogs.read", # Read audit logs.
|
|
|
|
|
|
|
|
|
|
"metrics.read", # Read metrics.
|
|
|
|
|
|
|
|
|
|
"entities.read", # Read entities.
|
|
|
|
|
|
|
|
|
|
"problems.read", # Read problems.
|
|
|
|
|
|
|
|
|
|
"networkZones.read", # Read network zones.
|
|
|
|
|
|
|
|
|
|
"activeGates.read", # Read ActiveGates.
|
|
|
|
|
|
|
|
|
|
"credentialVault.read", # Read credential vault entries.
|
|
|
|
|
|
|
|
|
|
"extensions.read", # Read extensions.
|
|
|
|
|
|
|
|
|
|
"extensionConfigurations.read", # Read extension monitoring configurations.
|
|
|
|
|
|
|
|
|
|
"extensionEnvironment.read", # Read extension environment configurations.
|
|
|
|
|
|
|
|
|
|
"securityProblems.read", # Read security problems.
|
|
|
|
|
|
|
|
|
|
"syntheticLocations.read", # Read synthetic locations.
|
|
|
|
|
|
|
|
|
|
"slo.read", # Read SLO.
|
|
|
|
|
|
|
|
|
|
"releases.read", # Read releases.
|
|
|
|
|
|
|
|
|
|
"apiTokens.read" # Read API tokens.
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
temp=[]
|
|
|
|
|
if "DynatraceInstaller" in scope:
|
|
|
|
|
temp.extend(DynatraceInstaller)
|
|
|
|
|
@ -144,7 +102,6 @@ def CreateToken(DTAPIToken, DTENV,nwzone, dtEnvInfo, tokenname,scope):
|
|
|
|
|
temp.extend(DevOps_Read)
|
|
|
|
|
if "ReadAll" in scope:
|
|
|
|
|
temp.extend(ReadAll)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not temp:
|
|
|
|
|
print("scope not supported")
|
|
|
|
|
@ -156,8 +113,8 @@ def CreateToken(DTAPIToken, DTENV,nwzone, dtEnvInfo, tokenname,scope):
|
|
|
|
|
r = post_request(DTAPIURL,headers,data)
|
|
|
|
|
print(r)
|
|
|
|
|
row = {'Environment':dtEnvInfo,'DT_API_URL':env +"/api", 'DT_[API|PAAS]_TOKEN':r.json()['token'],'DT_NETWORK_ZONE':nwzone}
|
|
|
|
|
|
|
|
|
|
return row
|
|
|
|
|
|
|
|
|
|
#################
|
|
|
|
|
##main
|
|
|
|
|
#################
|
|
|
|
|
@ -192,11 +149,9 @@ for item, doc in doc.items():
|
|
|
|
|
print("Gather data, hold on a minute")
|
|
|
|
|
DTTOKEN = config(token.get('env-token-name'))
|
|
|
|
|
DTURL = url.get('env-url')
|
|
|
|
|
|
|
|
|
|
row = CreateToken(DTTOKEN,DTURL,nwzone.get('network-zone'),dtEnvInfo.get('env-info'),tokenname,scope)
|
|
|
|
|
df = df.append(row,ignore_index=True)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
print("token not found, skipping " + item)
|
|
|
|
|
print(df)
|
|
|
|
|
df.to_excel(tokenname+".xlsx")
|
|
|
|
|
df.to_excel(tokenname+".xlsx")
|
|
|
|
|
|