Files
deployment-portal-be/scripts/dashboard_migration.py

57 lines
4.3 KiB
Python
Raw Permalink Normal View History

import requests
url = "https://gi-deployment-portal.cmd.navi-tech.in"
s = requests.Session()
cookie = "" # FILL cookie
x_xsrf_token = "" # FILL token
s.headers.update({'cookie': cookie, 'x-xsrf-token': x_xsrf_token})
list_manifest_path = "/api/grafana/dashboards"
r = s.post(url + list_manifest_path , json = {
"clusterId": 6,
"displayName": "Horizontal Pod Autoscaler",
"url": "https://grafana.prod.navi-gi.in/d/alJY6yWZz/kubernetes-horizontal-pod-autoscaler?orgId=1&var-datasource=000000001&var-namespace=${$.deployment.namespace}&var-hpa=${$.name}-navi-service&var-show_desired=or&var-show_max=or&var-show_min=or&kiosk=true",
"conditions": [
#{"path": "$.deployment", "value": "NULL", "operator": "exist"},
#{"path": "$.[?(@.extraResources.database || @.extraResources.docdb)]", "value": "NULL", "operator": "exist"}
#{"path": "$.metadata.language", "operator": "equal", "value": "Java"}
#{"path": "$.extraResources.dynamodb", "operator": "exist", "value": "NULL"}
#{"path": "$.flink", "value": "NULL", "operator": "exist"}
#{"path": "$.deployment.elasticSearch", "operator": "exist", "value": "NULL"}
#{"path": "$.deployment.efs", "operator": "exist", "value": "NULL"}
#{"path": "$.extraResources.elasticCache", "operator": "exist", "value": "NULL"}
{"path": "$.deployment.hpa.type", "value": "metrics", "operator": "equal"}
]
,"params" : []
})
t = s.post(url + list_manifest_path , json = {
"clusterId": 6,
"displayName": "VPA Recommendations",
"url": "https://grafana.prod.navi-gi.in/d/_BFbbSg7k/vpa-recommendations?orgId=1&refresh=5s&var-datasource=000000001&var-recommendation=target&var-namespace=${$.deployment.namespace}&var-targetName=${$.name}-navi-service&kiosk=true",
"conditions": [
#{"path": "$.deployment", "value": "NULL", "operator": "exist"},
#{"path": "$.[?(@.extraResources.database || @.extraResources.docdb)]", "value": "NULL", "operator": "exist"}
#{"path": "$.metadata.language", "operator": "equal", "value": "Java"}
#{"path": "$.extraResources.dynamodb", "operator": "exist", "value": "NULL"}
#{"path": "$.flink", "value": "NULL", "operator": "exist"}
#{"path": "$.deployment.elasticSearch", "operator": "exist", "value": "NULL"}
#{"path": "$.deployment.efs", "operator": "exist", "value": "NULL"}
#{"path": "$.extraResources.elasticCache", "operator": "exist", "value": "NULL"}
# {"path": "$.deployment.commonApiGateways[*]", "value": "NULL", "operator": "exist"}
{"path": "$.deployment[?(@.isVpaEnabled == true)]", "value": "NULL", "operator": "exist"}
]
,"params" : []
})
# r = s.post(url + list_manifest_path, json=["PODS"])
#r = s.post(url + list_manifest_path, json = {"paramName" : "TABLES"})
#r = s.delete(url + list_manifest_path)
print(r.json())
print(t.json())