Skip to content

Commit

Permalink
Merge d6f1bc2 into b1c5d95
Browse files Browse the repository at this point in the history
  • Loading branch information
carlochess committed Jul 5, 2018
2 parents b1c5d95 + d6f1bc2 commit 4eaf2a2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions License2Deploy/rolling_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self,
self.only_new_wait = only_new_wait
self.existing_instance_ids = []
self.new_desired_capacity = None
self.sc_proc = ['ReplaceUnhealthy', 'AZRebalance', 'AlarmNotification', 'ScheduledActions']

def get_ami_id_state(self, ami_id):
try:
Expand Down Expand Up @@ -337,6 +338,18 @@ def enable_project_cloudwatch_alarms(self):
logging.error("Unable to enable the cloud-watch alarm, please investigate: {0}".format(e))
exit(self.exit_error_code)

def suspend_process(self, group_name):
self.conn_auto.suspend_processes(
AutoScalingGroupName=group_name,
ScalingProcesses=self.sc_proc
)

def resume_processes(self, group_name):
self.conn_auto.resume_processes(
AutoScalingGroupName=group_name,
ScalingProcesses=self.sc_proc
)

def is_redeploy(self):
current_reservations = self.get_reservations(self.existing_instance_ids)
current_build_numbers = [instance.tags['BUILD']
Expand All @@ -361,6 +374,7 @@ def deploy(self): # pragma: no cover
self.log_instances_ips(self.existing_instance_ids, group_name)
if not self.force_redeploy and self.is_redeploy():
self.stop_deploy('You are attempting to redeploy the same build. Please pass the force_redeploy flag if a redeploy is desired')
self.suspend_process(group_name)
self.disable_project_cloudwatch_alarms()
self.new_desired_capacity = self.calculate_autoscale_desired_instance_count(group_name, 'increase')
self.set_autoscale_instance_desired_count(self.new_desired_capacity, group_name)
Expand All @@ -369,6 +383,7 @@ def deploy(self): # pragma: no cover
self.confirm_lb_has_only_new_instances()
self.tag_ami(self.ami_id, self.env)
self.enable_project_cloudwatch_alarms()
self.resume_processes(group_name)
logging.info("Deployment Complete!")

def revert_deployment(self): #pragma: no cover
Expand Down

0 comments on commit 4eaf2a2

Please sign in to comment.