(redata, jdata, logger)
Perform EC2 Actions
Perform EC2 Actions
Perform EC2 Actions
def actionEC2(redata, jdata, logger):
    ''' Perform EC2 Actions '''
    try:
        conn = boto.ec2.connect_to_region(
            redata['data']['region'],
            aws_access_key_id=redata['data']['aws_access_key'],
            aws_secret_access_key=redata['data']['aws_secret_key'])
        try:
            instances = conn.get_only_instances(
                instance_ids=[redata['data']['instance_id']])
            instances[0].reboot()
            return True
        except:
            return False
    except:
        line = 'aws-ec2restart: Could not connect to AWR for \
            monitor {0}'.format(jdata['cid'])
        logger.info(line)
        return False
def actionEC2 ( redata , jdata , logger ) : try : conn = boto . ec2 . connect_to_region ( redata [ 'data' ] [ 'region' ] , aws_access_key_id = redata [ 'data' ] [ 'aws_access_key' ] , aws_secret_access_key = redata [ 'data' ] [ 'aws_secret_key' ] ) try : instances = conn . get_only_instances ( instance_ids = [ redata [ 'data' ] [ 'instance_id' ] ] ) instances [ 0 ] . reboot ( ) return True except : return False except : line = 'aws-ec2restart: Could not connect to AWR for \
            monitor {0}' . format ( jdata [ 'cid' ] ) logger . info ( line ) return False