Revision 049a5a10

b/accounts/models.py
6 6
class UserProfile(models.Model):
7 7
    user = models.OneToOneField(User)
8 8
    peer = models.ForeignKey(Peer)
9
    
10
    def __unicode__(self):
11
        return "%s:%s" %(self.user.username, self.peer.peer_name)
9 12

  
10 13
    def get_address_space(self):
11 14
        networks = self.domain.networks.all()
b/cron_fetch_networks.py
1
from django.core.management import setup_environ  
2
import settings
3
setup_environ(settings)
4
from django.core.mail import send_mail
5
from flowspy.peers.models import *
6

  
7

  
8
def populate_networks():
9
    peers = Peer.objects.all()
10
    for peer in peers:
11
        peer.fill_networks()
12
#    if peer_networks > 0:
13
#        send_mail('Peer networks added , 'noreply@grnet.gr', ['leopoul@noc.grnet.gr'])
14

  
15

  
16
if __name__ == "__main__":
17
    populate_networks()
b/djangobackends/shibauthBackend.py
24 24

  
25 25
        try:
26 26
            user = User.objects.get(username__exact=username)
27
            user.mail = mail
28
            user.first_name = firstname
29
            user.last_name = lastname
30
            user.save()
31 27
        # The user did not exist. Create one with no privileges
32 28
        except:
33 29
            user = User.objects.create_user(username, mail, None)
b/flowspec/models.py
143 143

  
144 144
    def commit_delete(self, *args, **kwargs):
145 145
        reason_text = ''
146
        reason = ''
146 147
        if "reason" in kwargs:
147 148
            reason = kwargs['reason']
148 149
            reason_text = "Reason: %s. " %reason
149 150
        peer = self.applier.get_profile().peer.domain_name
150
        send_message("[%s] Removing route %s. %sPlease wait..." %(self.applier.username, self.name, reason), peer)
151
        send_message("[%s] Removing route %s. %sPlease wait..." %(self.applier.username, self.name, reason_text), peer)
151 152
        response = delete.delay(self, reason=reason)
152 153
        logger.info("Got delete job id: %s" %response)
153 154

  
b/flowspec/views.py
41 41
    return render_to_response('user_routes.html', {'routes': user_routes},
42 42
                              context_instance=RequestContext(request))
43 43

  
44
def welcome(request):
45
    return render_to_response('welcome.html', context_instance=RequestContext(request))
46

  
44 47
@login_required
45 48
@never_cache
46 49
def group_routes(request):
......
194 197
        if error_username or error_orgname or error_affiliation:
195 198
            return render_to_response('error.html', {'error': error,},
196 199
                                  context_instance=RequestContext(request))
197
        user = authenticate(username=username, firstname=firstname, lastname=lastname, mail=mail, organization=organization, affiliation)
200
        user = authenticate(username=username, firstname=firstname, lastname=lastname, mail=mail, organization=organization, affiliation=affiliation)
198 201
        if user is not None:
199 202
            login(request, user)
203
            update_user_attributes(user, firstname=firstname, lastname=lastname, mail=mail)
200 204
            return HttpResponseRedirect(reverse("group-routes"))
201 205
                # Redirect to a success page.
202 206
                # Return a 'disabled account' error message
......
232 236
        else:
233 237
            return render_to_response('add_rate_limit.html', {'form': form,},
234 238
                                      context_instance=RequestContext(request))
239
            
240
def update_user_attributes(user, firstname, lastname, mail):
241
    user.first_name = firstname
242
    user.last_name = lastname
243
    user.email = mail
244
    user.save()
235 245

  
236 246
@login_required
237 247
@never_cache
......
258 268
def user_logout(request):
259 269
    return HttpResponseRedirect(settings.SHIB_LOGOUT_URL)
260 270
    
261
    
271
@never_cache
262 272
def load_jscript(request, file):
263 273
    return render_to_response('%s.js' % file, context_instance=RequestContext(request), mimetype="text/javascript")
b/settings.py.dist
7 7
    # ('Your Name', 'your_email@domain.com'),
8 8
)
9 9

  
10
import djcelery
11
djcelery.setup_loader()
12

  
13

  
10 14
MANAGERS = ADMINS
11 15

  
12 16
DATABASES = {
13 17
    'default': {
14
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
15
        'NAME': 'flowspec',                      # Or path to database file if using sqlite3.
18
        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
19
        'NAME': '',                      # Or path to database file if using sqlite3.
16 20
        'USER': '',                      # Not used with sqlite3.
17 21
        'PASSWORD': '',                  # Not used with sqlite3.
18 22
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
19 23
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
24
        'OPTIONS':  {
25
        "init_command": "SET storage_engine=INNODB",
26
}
20 27
    }
21 28
}
22 29

  
......
27 34
# timezone as the operating system.
28 35
# If running in a Windows environment this must be set to the same as your
29 36
# system time zone.
30
TIME_ZONE = 'America/Chicago'
37
TIME_ZONE = 'Europe/Athens'
38

  
39
# Language code for this installation. All choices can be found here:
40
# http://www.i18nguy.com/unicode/language-identifiers.html
41
_ = lambda s: s
42

  
43
LANGUAGES = (
44
    ('el', _('Greek')),
45
    ('en', _('English')),
46
)
31 47

  
32 48
# Language code for this installation. All choices can be found here:
33 49
# http://www.i18nguy.com/unicode/language-identifiers.html
......
55 71
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
56 72
# trailing slash.
57 73
# Examples: "http://foo.com/media/", "/media/".
58
ADMIN_MEDIA_PREFIX = '/media/'
74
ADMIN_MEDIA_PREFIX = '/admin/media/'
59 75

  
60 76
# Make this unique, and don't share it with anybody.
61 77
SECRET_KEY = 'fju0e4zu-thi7qf@93voi5eeot21@a*e54)%89xe-7iorqcimk'
......
67 83
#     'django.template.loaders.eggs.Loader',
68 84
)
69 85

  
86
TEMPLATE_CONTEXT_PROCESSORS = (
87
    "django.contrib.auth.context_processors.auth",
88
    "django.core.context_processors.debug",
89
    "django.core.context_processors.i18n",
90
    "django.core.context_processors.media",
91
    "django.contrib.messages.context_processors.messages"
92
)
93

  
70 94
MIDDLEWARE_CLASSES = (
95
    'django.middleware.cache.UpdateCacheMiddleware',
71 96
    'django.middleware.common.CommonMiddleware',
72 97
    'django.contrib.sessions.middleware.SessionMiddleware',
73 98
    'django.middleware.csrf.CsrfViewMiddleware',
74 99
    'django.contrib.auth.middleware.AuthenticationMiddleware',
75 100
    'django.contrib.messages.middleware.MessageMiddleware',
101
    'django.middleware.cache.FetchFromCacheMiddleware',
102
)
103

  
104
AUTHENTICATION_BACKENDS = (
105
    'flowspy.djangobackends.shibauthBackend.shibauthBackend',
106
    'django.contrib.auth.backends.ModelBackend',
76 107
)
77 108

  
78 109
ROOT_URLCONF = 'flowspy.urls'
79 110

  
111
STATIC_URL = '/home/leopoul/projects/flowspy/static'
112

  
80 113
TEMPLATE_DIRS = (
114
    '/home/leopoul/projects/flowspy/templates/',
81 115
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
82 116
    # Always use forward slashes, even on Windows.
83 117
    # Don't forget to use absolute paths, not relative paths.
84 118
)
85 119

  
86 120
INSTALLED_APPS = (
121
    'monkey_patch',
87 122
    'django.contrib.auth',
88 123
    'django.contrib.contenttypes',
89 124
    'django.contrib.sessions',
90 125
    'django.contrib.sites',
91 126
    'django.contrib.messages',
92 127
    'flowspec',
93
    'south',
128
    'poller',
129
#    'south',
94 130
    # Uncomment the next line to enable the admin:
95
    # 'django.contrib.admin',
131
    'django.contrib.admin',
96 132
    # Uncomment the next line to enable admin documentation:
97
    # 'django.contrib.admindocs',
133
    'django.contrib.admindocs',
134
    'django_extensions',
135
    'djcelery',
136
    'peers',
137
    'accounts'
98 138
)
139

  
140
LOGIN_URL = '/fod/welcome'
141

  
142
CACHE_BACKEND = "memcached://127.0.0.1:11211/?timeout=600"
143

  
144
AUTH_PROFILE_MODULE = 'accounts.UserProfile'
145

  
146
NETCONF_DEVICE = ""
147
NETCONF_USER = ""
148
NETCONF_PASS = ""
149
ROUTES_FILTER = "<configuration><routing-options><flow/></routing-options></configuration>"
150
ROUTE_FILTER = "<configuration><routing-options><flow><route><name>%s</name></route></flow></routing-options></configuration>"
151
COMMIT_CONFIRMED_TIMEOUT = "120"
152
EXPIRATION_DAYS_OFFSET = 7
153
COMMIT = True
154

  
155
USE_X_FORWARDED_HOST = True
156

  
157
BROKER_HOST = "localhost"
158
BROKER_PORT = 11300
159
POLLS_TUBE = 'polls'
160
BROKER_VHOST = "/"
161
CELERY_CONCURRENCY = 1
162

  
163
# List of modules to import when celery starts.
164
CELERY_IMPORTS = ("flowspec.tasks", )
165

  
166
## Result store settings.
167
#CELERY_RESULT_BACKEND = "database"
168
#CELERY_RESULT_DBURI = "sqlite:///flowspec_dev.db"
169

  
170
## Broker settings.
171
BROKER_URL = "beanstalk://localhost:11300//"
172

  
173
SHIB_AUTH_AFFILIATION = ''
174
SHIB_ADMIN_DOMAIN = ''
175
SHIB_LOGOUT_URL = 'https://netdev.grnet.gr/Shibboleth.sso/Logout'
b/templates/base.html
9 9
<link rel="stylesheet" type="text/css" href="/static/css/base.css">
10 10
<link rel="stylesheet" type="text/css" href="/static/css/smoothness/jquery-ui-1.8.13.custom.css">
11 11
<script type="text/javascript" src="/static/js/jquery-ui-1.8.12.custom.min.js"></script>
12
{% if user.is_authenticated %}
12 13
<script type="text/javascript" src="{% url load-js 'poller' %}"></script>
14
{% endif %}
13 15
<script type="text/javascript">
14 16

  
15 17
  	function setlang(lang){
......
72 74
						{% endif %}
73 75
						<span class="topmenuaction"><a href="{% url logout %}">{% trans "Logout" %}</a></span>
74 76
						{% else %}
75
						<span class="topmenuaction"><a href="{% url login %}">{% trans "Login" %}</a></span>
77
						<span class="topmenuaction"><a href="{% url login %}">{% trans "Shibboleth Login" %}</a></span>
76 78
						{% endif %}
77 79
					</div>
78 80
					
b/templates/error.html
58 58
				{% endblock %}
59 59
				{% block content %}
60 60
				A required shibboleth attribute was not released towards this service<br>
61
				{% if error %}Details: {{error}}<br>{% endif %}
61 62
				Required shibboleth attributes:<br>
62 63
				<strong>HTTP_EPPN</strong><br>
63 64
				<strong>HTTP_SHIB_HOMEORGANIZATION</strong>
b/templates/poll.html
2 2
	{% for message in messages %}
3 3
          {% include "poll_message.html" %}
4 4
	{% endfor %}
5
	<input type="hidden" name="hid_mid" id="hid_mid" value=''/>
5 6
</div>
b/templates/poller.js
141 141
	for (var i = 0; i < messages.length; i++) {
142 142
	    updater.showMessage(messages[i]);
143 143
	}
144
	$("#hid_mid").val('UPDATED');
144 145
	if (($('#console').dialog('isOpen')) == false){
145 146
		blink("#consolebutton");
147
		window.setTimeout('location.reload()', 3000);
146 148
	}
147 149
    },
148 150

  
b/templates/user_routes.html
4 4
<script type="text/javascript" src="/static/js/jquery.dataTables.js"></script>
5 5
<script type="text/javascript">
6 6
	$(document).ready( function(){
7
		$("#hid_mid").val('');
7 8
		$('#dialog').dialog({
8 9
			height: 220,
9 10
            width: 300,
......
19 20
			cache: false,
20 21
			success: function(data) {
21 22
				$('#dialog').dialog('close');
23
				window.setTimeout('location.reload()', 1000);
22 24
			  }
23 25
		});
24 26
		},
25 27
		Cancel: function() {
26 28
			$('#dialog').dialog('close');
29
		},
30
		
31

  
32
	},
33
	close: function() {
34
        update_val = $("#hid_mid").val();
35
		if (update_val == 'UPDATED'){
36
			$("#hid_mid").val('');
37
			window.setTimeout('location.reload()', 500);
27 38
		}
28
	}
39
    }
29 40
		});
30 41
		$('#console').dialog({
31 42
			height: 250,
32 43
            width: 800,
33 44
			modal: true,
34
			autoOpen: false
35
			});
36
			$('#routes_table').dataTable( {
45
			autoOpen: false,
46
			close: function() {
47
		        update_val = $("#hid_mid").val();
48
				if (update_val == 'UPDATED'){
49
					$("#hid_mid").val('');
50
					window.setTimeout('location.reload()', 500);
51
				}
52
		    }
53
		});
54
			
55
		$('#routes_table').dataTable( {
37 56
			"bJQueryUI": true,
38 57
			"oLanguage": {
39 58
				"sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> routes'
......
70 89
				$('#console').dialog('open');
71 90
				return false;
72 91
			});
92

  
73 93
		});
74 94
		
75 95
function delete_route(route){
b/templates/welcome.html
1
{% extends "base.html" %}
2
{% load i18n %}
3
{% block title %}{% trans "Login" %}{% endblock %}
4
{% block brcrmb_container %}{% endblock %}
5
{% block content %}
6
<div id="welcome">
7
<h3>{% trans "Welcome" %}</h3>
8
{% blocktrans %}
9
<p>Welcome to GRNET's FoD service.</p>
10
<p>If you are new to the service, take some time to read the service description <a href="/about/info">here</a>.</p>
11
<p>For troubleshooting info and remarks do not hesitate to contact GRNET's Helpdesk.</p>
12
{% endblocktrans %}</p>
13
</div>
14

  
15
<div id="loginform">
16
					<a href="{% url login %}">
17
					<img src="/static/shib_login.png" style="border:none;">
18
					<p>Shibboleth Login</p>
19
				</a>
20
</div>
21
{% endblock %}
b/urls.py
17 17
    url(r'^fod/edit/(?P<route_slug>\w+)/$', 'flowspy.flowspec.views.edit_route', name="edit-route"),
18 18
    url(r'^fod/delete/(?P<route_slug>\w+)/$', 'flowspy.flowspec.views.delete_route', name="delete-route"),
19 19
    url(r'^fod/login/?', 'flowspy.flowspec.views.user_login', name="login"),
20
    url(r'^fod/welcome/?', 'flowspy.flowspec.views.welcome', name="welcome"),
20 21
    url(r'^fod/logout/?', 'flowspy.flowspec.views.user_logout', name="logout"),
21 22
    (r'^fod/setlang/?$', 'django.views.i18n.set_language'),
22 23
    # Uncomment the admin/doc line below to enable admin documentation:
b/utils/whois.py
8 8
def query(query, hostname, flags):
9 9
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
10 10
    s.connect((hostname, 43))
11
    s.send(" -i origin -r -K -T route -T route6 " + query + "\r\n")
11
    # as IPv6 is not supported by flowspec for the time ommit -T route6 
12
    s.send(" -i origin -r -K -T route " + query + "\r\n")
12 13
    response = ''
13 14
    while True:
14 15
        d = s.recv(4096)

Also available in: Unified diff