INFRA-1847 | Ashvin | Create migration script from sharedAlb

This commit is contained in:
Ashvin Sharma
2023-05-22 15:35:19 +05:30
parent f571407ef5
commit d49a316053

View File

@@ -0,0 +1,36 @@
import time
import requests
url = "https://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 'loadBalancers' in deployment:
load_balancers = deployment['loadBalancers']
for lb in load_balancers:
if lb['type'] == 'sharedAlb':
perform_post = True
print(f"{manifest['environment']}/{manifest['name']} has a "
f"sharedAlb: {lb['endpoint']}")
lb['type'] = 'sharedAlbAcrossNamespace'
lb['groupName'] = f"{manifest['namespace']}-internal"
if perform_post:
response = s.post(f"{url}/api/manifest", json=manifest)
print(f"{i['id']} response of post is {response.json()}")
time.sleep(2)
else:
print(f"{i['id']} is not updated.")