@@ -52,6 +52,7 @@ def main():
52
52
if execution_type == "deploy" or execution_type == "full" :
53
53
print ("\n \n \n ------------------ Stating Deployment Step 1 --------------------- \n " )
54
54
print ("------------------ Creating Green Env --------------------- \n \n \n " )
55
+
55
56
# Step 1: Cloning the blue env into green env.
56
57
try :
57
58
print ("Clonning the blue environment..." )
@@ -74,6 +75,7 @@ def main():
74
75
boto_authenticated_client = aws_authentication .get_boto_client ()
75
76
print ("\n \n \n ------------------ Stating Step 2 ---------------------\n " )
76
77
print ("------------------ Swapping Domains --------------------- \n \n \n " )
78
+
77
79
# Step 2: Swapping blue and green envs URL's.
78
80
try :
79
81
print ("Swapping environment Domains..." )
@@ -89,7 +91,6 @@ def main():
89
91
boto_authenticated_client , S3_ARTIFACTS_BUCKET , GREEN_ENV_NAME , BLUE_ENV_NAME )
90
92
clone_blue_environment .rollback_created_env (
91
93
boto_authenticated_client , GREEN_ENV_NAME )
92
-
93
94
e = sys .exc_info ()[0 ]
94
95
print (e )
95
96
traceback .print_exc ()
@@ -98,7 +99,8 @@ def main():
98
99
boto_authenticated_client = aws_authentication .get_boto_client ()
99
100
print ("\n \n \n ------------------ Stating Step 3 --------------------- \n " )
100
101
print ("----------------- New release Deployment --------------------- \n \n \n " )
101
- # ## Step 3: Deploying the new release into the blue env.
102
+
103
+ ## Step 3: Deploying the new release into the blue env.
102
104
try :
103
105
print ("New release deployment initiated." )
104
106
start_3 = time .time ()
@@ -148,46 +150,47 @@ def main():
148
150
print (e )
149
151
traceback .print_exc ()
150
152
sys .exit (1 )
151
- # if execution_type == "rollback":
152
- # try:
153
- # print("Rolling back the blue environment to the previous version.")
154
- # deploy_release.main(previous_release_key, previous_release_bucket,
155
- # BLUE_ENV_NAME, BEANSTALK_APP_NAME, boto_authenticated_client)
156
- #
157
- # except Exception as err:
158
- # print("Rolling back the blue environment has failed!")
159
- # print(("Error: " + str(err)))
160
- # e = sys.exc_info()[0]
161
- # print(e)
162
- # traceback.print_exc()
163
- # sys.exit(1)
164
- # try:
165
- # print("Re-swapping the URL's and terminating the green environment.")
166
- # swap_environment.re_swap_dns(
167
- # boto_authenticated_client, S3_ARTIFACTS_BUCKET, GREEN_ENV_NAME, BLUE_ENV_NAME)
168
- # except Exception as err:
169
- # print(
170
- # "Re-swapping the URL's and terminating the green environment has failed!")
171
- # print(("Error: " + str(err)))
172
- # e = sys.exc_info()[0]
173
- # print(e)
174
- # traceback.print_exc()
175
- # sys.exit(1)
176
- # try:
177
- # print("Rolling back the blue environment.")
178
- # clone_blue_environment.rollback_created_env(
179
- # boto_authenticated_client, GREEN_ENV_NAME
180
- # )
181
- # except Exception as err:
182
- # print("Rolling back the blue environment has failed!")
183
- # print(("Error: " + str(err)))
184
- # e = sys.exc_info()[0]
185
- # print(e)
186
- # traceback.print_exc()
187
- # sys.exit(1)
188
153
154
+ # Start rollback phase
155
+ if execution_type == "rollback" :
156
+ try :
157
+ print ("Rolling back the blue environment to the previous version." )
158
+ deploy_release .rollback_release (boto_authenticated_client , BEANSTALK_APP_NAME , BLUE_ENV_NAME )
159
+ except Exception as err :
160
+ print ("Rolling back the blue environment has failed!" )
161
+ print (("Error: " + str (err )))
162
+ e = sys .exc_info ()[0 ]
163
+ print (e )
164
+ traceback .print_exc ()
165
+ sys .exit (1 )
189
166
167
+ try :
168
+ print ("Re-swapping the URL's and terminating the green environment." )
169
+ swap_environment .re_swap_dns (
170
+ boto_authenticated_client , S3_ARTIFACTS_BUCKET , GREEN_ENV_NAME , BLUE_ENV_NAME )
171
+ except Exception as err :
172
+ print (
173
+ "Re-swapping the URL's ..." )
174
+ print (("Error: " + str (err )))
175
+ e = sys .exc_info ()[0 ]
176
+ print (e )
177
+ traceback .print_exc ()
178
+ sys .exit (1 )
190
179
180
+ try :
181
+ print ("Rolling back the blue environment." )
182
+ clone_blue_environment .rollback_created_env (
183
+ boto_authenticated_client , GREEN_ENV_NAME
184
+ )
185
+ except Exception as err :
186
+ print ("Rolling back the blue environment has failed!" )
187
+ print (("Error: " + str (err )))
188
+ e = sys .exc_info ()[0 ]
189
+ print (e )
190
+ traceback .print_exc ()
191
+ sys .exit (1 )
192
+ print ("Rollback has finished successfully!" )
193
+ print ("Deployment has finished successfully!" )
191
194
192
195
if __name__ == "__main__" :
193
196
try :
@@ -222,5 +225,4 @@ def main():
222
225
e = sys .exc_info ()[0 ]
223
226
traceback .print_exc ()
224
227
sys .exit (1 )
225
- main ()
226
-
228
+ main ()
0 commit comments