33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
import requests
|
|
import time
|
|
|
|
url = "https://navi-pay-deployment-portal.cmd.navi-tech.in"
|
|
s = requests.Session()
|
|
cookie = "" # FILL ME
|
|
x_xsrf_token = "" # FILL ME
|
|
s.headers.update({'cookie': cookie, 'x-xsrf-token': x_xsrf_token})
|
|
list_manifest_path = "/api/manifest/list"
|
|
env = "qa"
|
|
r = s.get(url + list_manifest_path)
|
|
manifest_list = r.json()
|
|
env_manifest_list = [manifest for manifest in manifest_list if manifest['environment'] == env]
|
|
for i in env_manifest_list:
|
|
perform_post = False
|
|
r = s.get(url + "/api/manifest/"+str(i['id']))
|
|
manifest = r.json()
|
|
if 'deployment' in manifest:
|
|
deployment = manifest['deployment']
|
|
if 'isVpaEnabled' in deployment:
|
|
print("vpa already enabled for {}".format(i['id']))
|
|
continue
|
|
if 'hpa' in deployment:
|
|
mxReplicas = deployment['hpa']['maxReplicas']
|
|
mnReplicas = deployment['hpa']['minReplicas']
|
|
if mxReplicas != mnReplicas:
|
|
print("cannot enable vpa for {}, hpa is already enabled".format(i['id']))
|
|
continue
|
|
deployment['isVpaEnabled'] = True
|
|
response = s.post(url + "/api/manifest", json=manifest)
|
|
print("{} response of post is {}".format(i['id'], response.json()))
|
|
time.sleep(2)
|