def get_autoscaling_group()

in src/cloudwatch/modules/client/ec2getclient.py [0:0]


    def get_autoscaling_group(self, instanceId):
        """
        Fetches the autoscaling group name from EC2. Defatuls to NONE if an error occours
        """
        request_map = {}
        request_map["Filter.1.Name"] = "key"
        request_map["Filter.1.Value.1"] = "aws:autoscaling:groupName"
        request_map["Filter.2.Name"] = "resource-id"
        request_map["Filter.2.Value.1"] = instanceId
        request = self.request_builder.create_signed_request(request_map)
        try:
            xml_content = self._run_request(request).content
            xmldoc = ET.fromstring(xml_content)
            ns={'ec2': 'http://ec2.amazonaws.com/doc/2016-11-15/'}
            return xmldoc.findall('ec2:tagSet/ec2:item[0]/ec2:value',ns)[0].text
        except Exception as e:
            self._LOGGER.warning("Could not get the autoscalig group name using the following endpoint: '" + self.endpoint +"'. [Exception: " + str(e) + "]")
            self._LOGGER.warning("Request details: '" + request + "'")
            return "NONE"