Ejemplo n.º 1
0
 def update(self, health=None):
     if not health:
         health = elb_client.describe_target_health(
             TargetGroupArn=self.group_arn,
             Targets=[{
                 'Id': self.instance.instance_id
             }])['TargetHealthDescriptions'][0]
     self.instance.load()
     self.elb_health = health['TargetHealth']['State']
     if can_ssh_to(self):
         try:
             self.service_status = {
                 key: value
                 for key, value in (
                     s.split("=", 1)
                     for s in exec_remote(self, [
                         'sudo', 'systemctl', 'show', 'compiler-explorer'
                     ]).split("\n") if "=" in s)
             }
             self.running_version = exec_remote(self, [
                 'bash', '-c', 'if [[ -f /infra/.deploy/s3_key ]]; '
                 'then cat /infra/.deploy/s3_key; fi'
             ]).strip()
         except subprocess.CalledProcessError as e:
             logger.warning("Failed to execute on remote host: %s", e)
Ejemplo n.º 2
0
 def elb_instances(group_arn):
     return [
         Instance(health, group_arn)
         for health in elb_client.describe_target_health(
             TargetGroupArn=group_arn)['TargetHealthDescriptions']
     ]