(redata, jdata, logger)
Perform EC2 Actions
Perform EC2 Actions
Perform EC2 Actions
def actionPDTrigger(redata, jdata, logger):
    ''' Perform EC2 Actions '''
    try:
        pager = pygerduty.PagerDuty(
            redata['data']['subdomain'],
            redata['data']['api_key'])
        try:
            service_key=redata['data']['service_key']
            description=redata['data']['incident_description']
            details=redata['data']['details']
            incident_key=redata['data']['incident_key']

            # Should I test if incident_key is empty string or null?

            new_incident_key=pager.trigger_incident(service_key, description, incident_key, details)

            # What do I do with new_incident_key?

            return True
        except:
            return False
    except:
        line = "pagerduty-notification: Could not connect to PagerDuty for monitor %s" % jdata['cid']
        logger.info(line)
        return False
def actionPDTrigger ( redata , jdata , logger ) : try : pager = pygerduty . PagerDuty ( redata [ 'data' ] [ 'subdomain' ] , redata [ 'data' ] [ 'api_key' ] ) try : service_key = redata [ 'data' ] [ 'service_key' ] description = redata [ 'data' ] [ 'incident_description' ] details = redata [ 'data' ] [ 'details' ] incident_key = redata [ 'data' ] [ 'incident_key' ] # Should I test if incident_key is empty string or null? new_incident_key = pager . trigger_incident ( service_key , description , incident_key , details ) # What do I do with new_incident_key? return True except : return False except : line = "pagerduty-notification: Could not connect to PagerDuty for monitor %s" % jdata [ 'cid' ] logger . info ( line ) return False