-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-Update-MGN-Cutover-Status-Terminate-Test.py
More file actions
executable file
·44 lines (33 loc) · 1.38 KB
/
3-Update-MGN-Cutover-Status-Terminate-Test.py
File metadata and controls
executable file
·44 lines (33 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import csv
import boto3
session = boto3.session.Session()
client_mgn = session.client('mgn')
input_file = csv.DictReader(open("./servers.csv"))
# For loop through CSV file
for each_row in input_file:
# Declare variables
server = (each_row["Server"])
source_servers = client_mgn.describe_source_servers()['items']
# For loop through all MGN source servers to change cutover status
for each_item in source_servers:
if each_item['tags']['Name'] == server:
print("\nGetting source server ID for {}...".format(server))
print("\nChanging cutover status for {}...".format(server))
response = client_mgn.change_server_life_cycle_state(
lifeCycle={
'state': 'READY_FOR_CUTOVER'
},
sourceServerID=each_item['sourceServerID']
)
print(response)
# For loop through all MGN source servers to terminate test instances
for each_item in source_servers:
if each_item['tags']['Name'] == server:
print("\nGetting source server ID for {}...".format(server))
print("\nTerminating test instance for {}...".format(server))
response = client_mgn.terminate_target_instances(
sourceServerIDs=[
each_item['sourceServerID'],
],
)
print(response)