Revision cb0e212e

b/flowspec/views.py
37 37
LOG_FILENAME = os.path.join(settings.LOG_FILE_LOCATION, 'celery_jobs.log')
38 38
#FORMAT = '%(asctime)s %(levelname)s: %(message)s'
39 39
#logging.basicConfig(format=FORMAT)
40
formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
40
formatter = logging.Formatter('%(asctime)s %(levelname)s %(clientip)s %(user)s: %(message)s')
41 41

  
42 42
logger = logging.getLogger(__name__)
43 43
logger.setLevel(logging.DEBUG)
......
90 90
            route.save()
91 91
            form.save_m2m()
92 92
            route.commit_add()
93
            requesters_address = request.META['HTTP_X_FORWARDED_FOR']
93 94
            mail_body = render_to_string("rule_add_mail.txt",
94
                                             {"route": route})
95
                                             {"route": route, "address": requesters_address})
95 96
            send_mail(settings.EMAIL_SUBJECT_PREFIX + "Rule %s creation request submitted by %s" %(route.name, route.applier.username),
96 97
                              mail_body, settings.SERVER_EMAIL,
97 98
                              get_peer_techc_mails(route.applier), fail_silently=True)
98
            logger.info(mail_body)
99
            d = { 'clientip' : "%s"%requesters_address, 'user' : route.applier.username }
100
            logger.info(mail_body, extra=d)
99 101
            return HttpResponseRedirect(reverse("group-routes"))
100 102
        else:
101 103
            return render_to_response('apply.html', {'form': form, 'applier':applier},
......
135 137
            route.save()
136 138
            form.save_m2m()
137 139
            route.commit_edit()
140
            requesters_address = request.META['HTTP_X_FORWARDED_FOR']
138 141
            mail_body = render_to_string("rule_edit_mail.txt",
139
                                             {"route": route})
142
                                             {"route": route, "address": requesters_address})
140 143
            send_mail(settings.EMAIL_SUBJECT_PREFIX + "Rule %s edit request submitted by %s" %(route.name, route.applier.username),
141 144
                              mail_body, settings.SERVER_EMAIL,
142 145
                              get_peer_techc_mails(route.applier), fail_silently=True)
143
            logger.info(mail_body)
144

  
146
            d = { 'clientip' : requesters_address, 'user' : route.applier.username }
147
            logger.info(mail_body, extra=d)
145 148
            return HttpResponseRedirect(reverse("group-routes"))
146 149
        else:
147 150
            return render_to_response('apply.html', {'form': form, 'edit':True, 'applier': applier},
......
164 167
            route.status = "PENDING"
165 168
            route.save()
166 169
            route.commit_delete()
170
            requesters_address = request.META['HTTP_X_FORWARDED_FOR']
167 171
            mail_body = render_to_string("rule_delete_mail.txt",
168
                                             {"route": route})
172
                                             {"route": route, "address": requesters_address})
169 173
            send_mail(settings.EMAIL_SUBJECT_PREFIX + "Rule %s removal request submitted by %s" %(route.name, route.applier.username),
170 174
                              mail_body, settings.SERVER_EMAIL,
171
                             get_peer_techc_mails(route.applier), fail_silently=True)            
172
            logger.info(mail_body)
175
                             get_peer_techc_mails(route.applier), fail_silently=True)
176
            d = { 'clientip' : requesters_address, 'user' : route.applier.username }
177
            logger.info(mail_body, extra=d)            
173 178
        html = "<html><body>Done</body></html>"
174 179
        return HttpResponse(html)
175 180
    else:
b/templates/rule_add_mail.txt
1 1
A new rule creation job has spawned
2 2

  
3 3
Peer: {{route.applier.get_profile.peer.peer_name}}
4
User {{route.applier.username}} requested the application of the following rule:
4
User {{route.applier.username}} requested the application of the following rule from address {{address}} :
5 5

  
6 6
Match
7 7
* Dst Addr:{{route.destination}}
b/templates/rule_delete_mail.txt
1 1
A new rule removal job has spawned
2 2

  
3 3
Peer: {{route.applier.get_profile.peer.peer_name}}
4
User {{route.applier.username}} requested the removal of the following rule:
4
User {{route.applier.username}} requested the removal of the following rule from address {{address}} :
5 5

  
6 6
Match
7 7
* Dst Addr:{{route.destination}}
b/templates/rule_edit_mail.txt
1 1
A new rule edit job has spawned
2 2

  
3 3
Peer: {{route.applier.get_profile.peer.peer_name}}
4
User {{route.applier.username}} requested the application of the following rule:
4
User {{route.applier.username}} requested the application of the following rule from address {{address}} :
5 5

  
6 6
Match
7 7
* Dst Addr:{{route.destination}}
b/templates/rule_expiration.txt
11 11

  
12 12
*Then:{% for then in route.then.all %}{{ then }}{% if not forloop.last %}, {% endif %}{% endfor %}
13 13

  
14

  
15
Visit {{url}} to edit the rule.
14
Visit {{url}} to edit the rule.

Also available in: Unified diff