2023-04-06 21:22:24 +05:30
|
|
|
import requests
|
|
|
|
|
import time
|
|
|
|
|
import boto3
|
|
|
|
|
|
2023-04-06 23:33:02 +05:30
|
|
|
url = "https://navi-pay-deployment-portal.cmd.navi-tech.in"
|
|
|
|
|
aws_profile = "navi-pay-nonprod"
|
|
|
|
|
cookie = "paste your cookie here"
|
|
|
|
|
x_xrf_token = 'paste xsrf_token here'
|
2023-04-06 21:22:24 +05:30
|
|
|
|
|
|
|
|
s = requests.Session()
|
|
|
|
|
s.headers.update({"cookie": cookie, 'x-xsrf-token': x_xrf_token})
|
2023-04-06 23:33:02 +05:30
|
|
|
instance_version_map = {}
|
2023-04-06 21:22:24 +05:30
|
|
|
rds_client = boto3.session.Session(profile_name=aws_profile).client("rds", region_name="ap-south-1")
|
2023-04-07 17:54:09 +05:30
|
|
|
for instance in rds_client.get_paginator('describe_db_instances').paginate().build_full_result()['DBInstances']:
|
2023-04-06 23:33:02 +05:30
|
|
|
instance_version_map[instance['DBInstanceIdentifier']] = instance['EngineVersion']
|
|
|
|
|
print(instance_version_map)
|
2023-04-06 21:22:24 +05:30
|
|
|
print("\n")
|
|
|
|
|
|
|
|
|
|
list_manifest_path = "/api/manifest/list"
|
|
|
|
|
r = s.get(url + list_manifest_path)
|
|
|
|
|
manifest_list = r.json()
|
|
|
|
|
for i in manifest_list:
|
2023-04-07 14:29:52 +05:30
|
|
|
perform_post = False
|
2023-04-06 21:22:24 +05:30
|
|
|
r = s.get(url + "/api/manifest/" + str(i['id']))
|
|
|
|
|
manifest = r.json()
|
|
|
|
|
if ('extraResources' in manifest) and ('database' in manifest['extraResources']):
|
|
|
|
|
instance_name = manifest['extraResources']['database']['instanceName']
|
|
|
|
|
print("manifest name is", manifest['name'], "instance name is", instance_name)
|
2023-04-06 23:33:02 +05:30
|
|
|
if instance_name not in instance_version_map:
|
2023-04-06 21:22:24 +05:30
|
|
|
continue
|
|
|
|
|
database = manifest['extraResources']['database']
|
2023-04-06 23:33:02 +05:30
|
|
|
database['PsqlEngineVersion'] = instance_version_map[instance_name]
|
2023-04-07 14:29:52 +05:30
|
|
|
perform_post = True
|
2023-04-06 23:33:02 +05:30
|
|
|
|
2023-04-06 21:22:24 +05:30
|
|
|
print("\n")
|
|
|
|
|
if perform_post:
|
|
|
|
|
response = s.post(url + "/api/manifest", json=manifest)
|
2023-04-06 23:33:02 +05:30
|
|
|
print(response.json())
|
2023-04-06 21:22:24 +05:30
|
|
|
time.sleep(2)
|