Compare commits
No commits in common. "master" and "Tokenfix" have entirely different histories.
|
|
@ -19,6 +19,7 @@ def get_request(url, headers):
|
||||||
return "A Timeout Error occurred:" + repr(errt)
|
return "A Timeout Error occurred:" + repr(errt)
|
||||||
except requests.exceptions.RequestException as err:
|
except requests.exceptions.RequestException as err:
|
||||||
return "An Unknown Error occurred" + repr(err)
|
return "An Unknown Error occurred" + repr(err)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def post_request(url, headers,body):
|
def post_request(url, headers,body):
|
||||||
|
|
@ -33,6 +34,7 @@ def post_request(url, headers,body):
|
||||||
return "A Timeout Error occurred:" + repr(errt)
|
return "A Timeout Error occurred:" + repr(errt)
|
||||||
except requests.exceptions.RequestException as err:
|
except requests.exceptions.RequestException as err:
|
||||||
return "An Unknown Error occurred" + repr(err)
|
return "An Unknown Error occurred" + repr(err)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def put_request(url, headers,body):
|
def put_request(url, headers,body):
|
||||||
|
|
@ -47,53 +49,93 @@ def put_request(url, headers,body):
|
||||||
return "A Timeout Error occurred:" + repr(errt)
|
return "A Timeout Error occurred:" + repr(errt)
|
||||||
except requests.exceptions.RequestException as err:
|
except requests.exceptions.RequestException as err:
|
||||||
return "An Unknown Error occurred" + repr(err)
|
return "An Unknown Error occurred" + repr(err)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def CreateToken(DTAPIToken, DTENV,nwzone, dtEnvInfo, tokenname,scope):
|
def CreateToken(DTAPIToken, DTENV,nwzone, dtEnvInfo, tokenname,scope):
|
||||||
|
|
||||||
env = DTENV
|
env = DTENV
|
||||||
DTAPIToken = DTAPIToken
|
DTAPIToken = DTAPIToken
|
||||||
|
|
||||||
|
|
||||||
DTAPIURL = env + "/api/v2/apiTokens"
|
DTAPIURL = env + "/api/v2/apiTokens"
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Api-Token ' + DTAPIToken
|
'Authorization': 'Api-Token ' + DTAPIToken
|
||||||
}
|
}
|
||||||
|
|
||||||
DynatraceInstaller = [
|
DynatraceInstaller = [
|
||||||
|
|
||||||
"InstallerDownload",
|
"InstallerDownload",
|
||||||
"SupportAlert"
|
"SupportAlert"
|
||||||
]
|
|
||||||
|
]
|
||||||
|
|
||||||
DevOps_Read = [
|
DevOps_Read = [
|
||||||
|
|
||||||
"DataExport", # Access problem and event feed, metrics, and topology.
|
"DataExport", # Access problem and event feed, metrics, and topology.
|
||||||
|
|
||||||
"DTAQLAccess", # User sessions.
|
"DTAQLAccess", # User sessions.
|
||||||
|
|
||||||
"ReadSyntheticData", # Read synthetic monitors, locations, and nodes.
|
"ReadSyntheticData", # Read synthetic monitors, locations, and nodes.
|
||||||
|
|
||||||
"metrics.read", # Read metrics.
|
"metrics.read", # Read metrics.
|
||||||
|
|
||||||
"entities.read", # Read entities.
|
"entities.read", # Read entities.
|
||||||
|
|
||||||
"problems.read", # Read problems.
|
"problems.read", # Read problems.
|
||||||
|
|
||||||
"syntheticLocations.read", # Read synthetic locations.
|
"syntheticLocations.read", # Read synthetic locations.
|
||||||
|
|
||||||
"slo.read", # Read SLO.
|
"slo.read", # Read SLO.
|
||||||
|
|
||||||
"releases.read", # Read releases.
|
"releases.read", # Read releases.
|
||||||
|
|
||||||
"activeGates.read"
|
"activeGates.read"
|
||||||
]
|
|
||||||
|
]
|
||||||
ReadAll = [
|
ReadAll = [
|
||||||
|
|
||||||
"DataExport", # Access problem and event feed, metrics, and topology.
|
"DataExport", # Access problem and event feed, metrics, and topology.
|
||||||
|
|
||||||
"ReadConfig", # Read configuration.
|
"ReadConfig", # Read configuration.
|
||||||
|
|
||||||
"DTAQLAccess", # User sessions.
|
"DTAQLAccess", # User sessions.
|
||||||
|
|
||||||
"ReadSyntheticData", # Read synthetic monitors, locations, and nodes.
|
"ReadSyntheticData", # Read synthetic monitors, locations, and nodes.
|
||||||
|
|
||||||
"auditLogs.read", # Read audit logs.
|
"auditLogs.read", # Read audit logs.
|
||||||
|
|
||||||
"metrics.read", # Read metrics.
|
"metrics.read", # Read metrics.
|
||||||
|
|
||||||
"entities.read", # Read entities.
|
"entities.read", # Read entities.
|
||||||
|
|
||||||
"problems.read", # Read problems.
|
"problems.read", # Read problems.
|
||||||
|
|
||||||
"networkZones.read", # Read network zones.
|
"networkZones.read", # Read network zones.
|
||||||
|
|
||||||
"activeGates.read", # Read ActiveGates.
|
"activeGates.read", # Read ActiveGates.
|
||||||
|
|
||||||
"credentialVault.read", # Read credential vault entries.
|
"credentialVault.read", # Read credential vault entries.
|
||||||
|
|
||||||
"extensions.read", # Read extensions.
|
"extensions.read", # Read extensions.
|
||||||
|
|
||||||
"extensionConfigurations.read", # Read extension monitoring configurations.
|
"extensionConfigurations.read", # Read extension monitoring configurations.
|
||||||
|
|
||||||
"extensionEnvironment.read", # Read extension environment configurations.
|
"extensionEnvironment.read", # Read extension environment configurations.
|
||||||
|
|
||||||
"securityProblems.read", # Read security problems.
|
"securityProblems.read", # Read security problems.
|
||||||
|
|
||||||
"syntheticLocations.read", # Read synthetic locations.
|
"syntheticLocations.read", # Read synthetic locations.
|
||||||
|
|
||||||
"slo.read", # Read SLO.
|
"slo.read", # Read SLO.
|
||||||
|
|
||||||
"releases.read", # Read releases.
|
"releases.read", # Read releases.
|
||||||
|
|
||||||
"apiTokens.read" # Read API tokens.
|
"apiTokens.read" # Read API tokens.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
temp=[]
|
temp=[]
|
||||||
if "DynatraceInstaller" in scope:
|
if "DynatraceInstaller" in scope:
|
||||||
|
|
@ -103,6 +145,7 @@ def CreateToken(DTAPIToken, DTENV,nwzone, dtEnvInfo, tokenname,scope):
|
||||||
if "ReadAll" in scope:
|
if "ReadAll" in scope:
|
||||||
temp.extend(ReadAll)
|
temp.extend(ReadAll)
|
||||||
|
|
||||||
|
|
||||||
if not temp:
|
if not temp:
|
||||||
print("scope not supported")
|
print("scope not supported")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
@ -113,8 +156,8 @@ def CreateToken(DTAPIToken, DTENV,nwzone, dtEnvInfo, tokenname,scope):
|
||||||
r = post_request(DTAPIURL,headers,data)
|
r = post_request(DTAPIURL,headers,data)
|
||||||
print(r)
|
print(r)
|
||||||
row = {'Environment':dtEnvInfo,'DT_API_URL':env +"/api", 'DT_[API|PAAS]_TOKEN':r.json()['token'],'DT_NETWORK_ZONE':nwzone}
|
row = {'Environment':dtEnvInfo,'DT_API_URL':env +"/api", 'DT_[API|PAAS]_TOKEN':r.json()['token'],'DT_NETWORK_ZONE':nwzone}
|
||||||
return row
|
|
||||||
|
|
||||||
|
return row
|
||||||
#################
|
#################
|
||||||
##main
|
##main
|
||||||
#################
|
#################
|
||||||
|
|
@ -149,8 +192,10 @@ for item, doc in doc.items():
|
||||||
print("Gather data, hold on a minute")
|
print("Gather data, hold on a minute")
|
||||||
DTTOKEN = config(token.get('env-token-name'))
|
DTTOKEN = config(token.get('env-token-name'))
|
||||||
DTURL = url.get('env-url')
|
DTURL = url.get('env-url')
|
||||||
|
|
||||||
row = CreateToken(DTTOKEN,DTURL,nwzone.get('network-zone'),dtEnvInfo.get('env-info'),tokenname,scope)
|
row = CreateToken(DTTOKEN,DTURL,nwzone.get('network-zone'),dtEnvInfo.get('env-info'),tokenname,scope)
|
||||||
df = df.append(row,ignore_index=True)
|
df = df.append(row,ignore_index=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("token not found, skipping " + item)
|
print("token not found, skipping " + item)
|
||||||
print(df)
|
print(df)
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@ naprod:
|
||||||
- env-info: "E2E/PROD"
|
- env-info: "E2E/PROD"
|
||||||
cnprod:
|
cnprod:
|
||||||
- name: "cnprod"
|
- name: "cnprod"
|
||||||
- env-url: "https://dyna-synth-cn.bmwgroup.com.cn/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
|
- env-url: "https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
|
||||||
- env-token-name: "CNPROD_TOKEN_VAR"
|
- env-token-name: "CNPROD_TOKEN_VAR"
|
||||||
- network-zone: "coco.cn.aws-tsp.prod"
|
- network-zone: "coco.cn.aws-tsp.prod"
|
||||||
- env-info: "E2E/PROD"
|
- env-info: "E2E/PROD"
|
||||||
cnpreprod:
|
cnpreprod:
|
||||||
- name: "cnpreprod"
|
- name: "cnpreprod"
|
||||||
- env-url: "https://dyna-synth-cn.bmwgroup.com.cn/e/ab88c03b-b7fc-45f0-9115-9e9ecc0ced35"
|
- env-url: "https://dynatracemgd-cn.bmwgroup.net/e/b921f1b9-c00e-4031-b9d1-f5a0d530757b"
|
||||||
- env-token-name: "CNPREPROD_TOKEN_VAR"
|
- env-token-name: "CNPREPROD_TOKEN_VAR"
|
||||||
- network-zone: "coco.cn.aws-tsp.preprod"
|
- network-zone: "coco.cn.aws-tsp.preprod"
|
||||||
- env-info: "DEV/INT"
|
- env-info: "DEV/INT"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue