Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def needs_update(self):
"""
If our desired scaling policy or associated CloudWatch alarm is
different than what actually exists in AWS, return ``True``, else return
``False``.
:rtype: boolean
"""
if self == ScalingPolicy(self.serviceName, self.clusterName, aws=self.__aws_scaling_policy):
if self.alarm.needs_update():
return True
return False
return True
def from_yaml(self, yml):
"""
Load our configuration from the config read from ``deployfish.yml``.
:param yml: a application-scaling level entry from the ``deployfish.yml`` file
:type yml: dict
"""
if yml:
self.__yml = yml
self.MinCapacity = yml['min_capacity']
self.MaxCapacity = yml['max_capacity']
self._RoleARN = yml['role_arn']
self.policies['scale-up'] = ScalingPolicy(self.serviceName, self.clusterName, yml['scale-up'])
self.policies['scale-down'] = ScalingPolicy(self.serviceName, self.clusterName, yml['scale-down'])
def update(self):
"""
If our desired scaling policy or associated CloudWatch alarm is
different than what actually exists in AWS, delete them and recreate
them with the config we want.
"""
if self != ScalingPolicy(self.serviceName, self.clusterName, aws=self.__aws_scaling_policy):
# The scaling policy itself needs updating
self.delete()
self.create()
else:
# The scaling policy doesn't need updating, but maybe the alarm does
self.alarm.update()