Changeset 6325
- Timestamp:
- Oct 2, 2008, 4:34:21 PM (16 years ago)
- Location:
- trunk/exodus
- Files:
-
- 1 added
- 7 deleted
- 3 edited
- 8 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/exodus/templates/deleteNode.html
-
Property svn:mergeinfo
set to
r6323 r6325 1 {% extends "exodus-template.html" %}2 3 {% block content %}4 5 <h1>Delete node {{ object.name }}</h1>6 7 1 Interfaces to be deleted: 8 2 <ol> … … 24 18 {% endfor %} 25 19 </ol> 26 27 <form method="post" action=".">28 <h3>Are you sure you want to <b>DELETE</b> this data <b>PERMANENTLY</b>?</h3>29 <input type="submit" name="cancel" value="NO, cancel">30 <input type="submit" name="proceed" value="OK, proceed">31 </form>32 33 {% endblock %} -
Property svn:mergeinfo
set to
-
trunk/exodus/templates/exodus-template.html
r6324 r6325 15 15 <img width="130" height="97" alt="foto" src="{% url static path="foto.jpg" %}"/><br> 16 16 <A class="menu" href="{% url root %}">Exodus</a><br> 17 <A class="menu" href="{% url nodelist %}">Node List</a><br>17 <A class="menu" href="{% url exodus.views.viewNodelist %}">Node List</a><br> 18 18 <A class="menu" href="{% url exodus.views.genericLocation "add" "new" %}">Add Location</a><br> 19 19 <A class="menu" href="{% url exodus.views.genericNode "add" "new" %}">Add Node</a><br> -
trunk/exodus/templates/freebsd-5.0/named.conf
-
Property svn:mergeinfo
set to
-
Property svn:mergeinfo
set to
-
trunk/exodus/templates/viewNode.html
r6324 r6325 2 2 3 3 {% block content %} 4 <a href="{% url nodelist %}">Node List</a>4 <a href="{% url exodus.views.viewNodelist %}">Node List</a> 5 5 6 6 <div style="border:1px solid #000000;"> … … 47 47 <li>Long description: {{ interlink.desc }} </li> 48 48 <li>IP: {{ interlink.ip }}/{{ interlink.netmask }} </li> 49 <li> Link to Node: <a href="{% url node-detailinterlink.node %}">49 <li> Link to Node: <a href="{% url exodus.views.viewNode interlink.node %}"> 50 50 {{ interlink.node }}</a> </li> 51 51 </ul> -
trunk/exodus/templates/viewNodelist.html
-
Property svn:mergeinfo
set to
r6323 r6325 5 5 <P class="blue"> Node List </P> 6 6 7 {% if object_list%}7 {% if nodes %} 8 8 <table border="3" cellpadding="1"> 9 {% for object in object_list%}9 {% for node in nodes %} 10 10 <tr> 11 <td class="list" ><a class="list"href="{% url node-detail object.name %}">{{ object.name }}</a></td> 12 <td><a href="{% url exodus.views.conf_dhcpd_conf object.name %}">dhcpd.conf</a></td> 13 <td><a href="{% url exodus.views.conf_named_conf object.name %}">named.conf</a></td> 14 <td><a href="{% url exodus.views.conf_rc_node_local object.name %}">rc.node.local</a></td> 15 <td><a href="{% url exodus.views.conf_resolv_conf object.name %}">resolv.conf</a></td> 11 <td class="list" ><a class="list"href="{% url exodus.views.viewNode node.name %}">{{ node.name }}</a></td> 12 {% for configFile in configFiles %} 13 <td><a href="{% url exodus.views.configFile "freebsd-5.0" node.name configFile %}">{{ configFile }}</a></td> 14 {% endfor %} 16 15 </tr> 17 16 -
Property svn:mergeinfo
set to
-
trunk/exodus/urls.py
r6324 r6325 5 5 from os import path as os_path 6 6 from django.conf import settings 7 from django.views.generic.simple import direct_to_template 7 8 8 # # experimental databrowse code9 9 # 10 # experimental databrowse code 10 11 from django.contrib import databrowse 11 12 databrowse.site.register(Antenna) … … 18 19 databrowse.site.register(DhcpStatic) 19 20 20 node_dict = {21 'queryset': Node.objects.all(),22 }23 24 21 urlpatterns = patterns('', 25 26 # databse thingy 27 (r'^databrowse/(.*)', databrowse.site.root), 28 29 # views 30 url(r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'index.html'}, "root") , 31 url(r'^nodelist/$', 'django.views.generic.list_detail.object_list', dict(node_dict, template_name='node-list.html'), "nodelist"), 32 url(r'^view/node/(?P<node>.+)/$', 'exodus.views.node', {}, "node-detail"), 22 # generic view 23 url(r'^$', 'exodus.urls.direct_to_template', {'template': 'index.html'}, "root"), 24 (r'^view/nodelist/$', 'exodus.views.viewNodelist'), 25 (r'^view/node/(?P<node>.+)/$', 'exodus.views.viewNode'), 33 26 34 27 # config urls 35 (r'^config/freebsd-5.0/(?P<object_id>.+)/dhcpd.conf$', 'exodus.views.conf_dhcpd_conf'), 36 (r'^config/freebsd-5.0/(?P<object_id>.+)/named.conf$', 'exodus.views.conf_named_conf'), 37 (r'^config/freebsd-5.0/(?P<object_id>.+)/rc.node.local$', 'exodus.views.conf_rc_node_local'), 38 (r'^config/freebsd-5.0/(?P<object_id>.+)/resolv.conf$', 'exodus.views.conf_resolv_conf'), 39 40 41 42 (r'^edit/link/(?P<object_id>.+)/$', 'exodus.views.addLink'), 28 (r'^config/(?P<version>.+)/(?P<node>.+)/(?P<file>.+)$', 'exodus.views.configFile'), 43 29 44 30 # Generic urls … … 48 34 (r'^dhcp/(?P<mode>(add|edit|delete))/(?P<node>.+)/(?P<interface>.+)/(?P<publicAP>.+)/$', 'exodus.views.genericPublicAP'), 49 35 36 # 3th party/embedded databsse thingy 37 (r'^databrowse/(.*)', databrowse.site.root), 50 38 ) 51 39 -
trunk/exodus/views.py
r6324 r6325 15 15 16 16 17 def node(request, node):18 object = Node.objects.get(name=node)19 return render_to_response('node-detail.html', {'node': object})20 21 22 class addLinkForm(forms.Form):23 class Meta:24 model = Node25 exclude = ( 'shortdesc', 'desc' )26 27 def addLink(request):28 if request.POST:29 form = addLinkForm(request.POST)30 if form.is_valid():31 instance = form.save(commit=False)32 # Get this code working and clean it up afterwards33 # check if we have two different ifaces from two different nodes34 # Should add a error message if they are from the same node35 compatibleInterfaces = False36 differentNodes = True37 errorMessage = ""38 39 # check if they have the same mode40 if instance.iface1.node.id == instance.iface2.node.id:41 differentNodes = False42 43 # Interface check44 # XXX: Make sure interfaces type is defined as beeing a certain type instead of hardcoding45 if instance.iface1.type == instance.iface2.type:46 compatibleInterfaces = True47 if str(instance.iface1.type) == '11b' and str(instance.iface2.type) == '11g':48 compatibleInterfaces = True49 if str(instance.iface1.type) == '11g' and str(instance.iface2.type) == '11b':50 compatibleInterfaces = True51 52 if compatibleInterfaces and differentNodes:53 instance.save()54 return HttpResponseRedirect(reverse('nodelist'))55 else:56 form = addLinkForm(instance = instance)57 if compatibleInterfaces == False:58 errorMessage = "Please use compatible interfaces"59 elif differentNodes == False:60 errorMessage = "No interlink possible between interfaces on the same node"61 62 return render_to_response('addinterlink.html',{'form': form, 'error_message' : errorMessage })63 #XXX :if wifi: check master and managed states for existings NICs/Interlinks64 #XXX :check if omni, than Nic must be in master mode65 #Generate SSID66 # add descriptions67 #Generate ips and netmask68 #Save form69 else:70 #XXX: Autofetch new IP numbers71 newForm = Link()72 form = addLinkForm(instance = newForm)73 return render_to_response('addinterlink.html',{'form': form})74 75 76 17 class GenericHandler(): 77 18 """Conventions used: type has to to the same name as the dependency object, delet template is named delete<type>.html""" … … 86 27 87 28 if request.POST.has_key('cancel'): 88 self.response = HttpResponseRedirect(reverse(' node-detail', args=[self.node.name]))29 self.response = HttpResponseRedirect(reverse('exodus.views.viewNode', args=[self.node.name])) 89 30 elif request.POST.has_key('proceed'): 90 31 if mode == 'delete': 91 32 self._deleteete() 92 self.response = HttpResponseRedirect(reverse(' node-detail', args=[self.node.name]))33 self.response = HttpResponseRedirect(reverse('exodus.views.viewNode', args=[self.node.name])) 93 34 else: 94 35 # First checking whether form is valid, then add/edit actions … … 96 37 if self.form.is_valid(): 97 38 # Set response on forehand, to allow override in procedure 98 self.response = HttpResponseRedirect(reverse(' node-detail', args=[self.node.name]))39 self.response = HttpResponseRedirect(reverse('exodus.views.viewNode', args=[self.node.name])) 99 40 if mode == 'add': 100 41 self._add() … … 266 207 self._saveInterface() 267 208 # After adding a location, allow adding a Node with this location 268 self.response = HttpResponseRedirect(reverse('exodus.views.genericNode', args=["add", "new"]) + "?location=%i" % self._instance.pk) 209 self.response = HttpResponseRedirect( 210 reverse('exodus.views.genericNode', args=["add", "new"]) + "?location=%i" % self._instance.pk) 269 211 270 212 def _delete(self): … … 277 219 278 220 279 280 281 def nodename2id(node): 282 """Convert node name to ID if found in the database""" 283 return Node.objects.get(name=node).id 284 285 def conf_generator(node, template): 286 object_id = nodename2id(node) 287 object = Node.objects.get(pk=object_id) 288 289 #Some extra values for statictics info 290 object.name = Node.objects.get(pk=object_id).name 291 object.host = gethostname() 292 # object.nic = object.nic_set.all() 221 # 222 # Views 223 def viewNode(request, node): 224 node = Node.objects.get(name=node) 225 return render_to_response('viewNode.html', {'node': node}) 226 227 def viewNodelist(request): 228 nodes = Node.objects.all() 229 configFiles = ( 230 'rc.local', 231 'rc.node.local', 232 'dhcpd.conf', 233 'named.conf', 234 'resolv.conf' ) 235 return render_to_response('viewNodelist.html', {'nodes' : nodes, 'configFiles' : configFiles}) 236 237 def configFile(request, version, node, file): 238 node = Node.objects.get(name=node) 293 239 294 #Used for named.conf 295 object.domains = Network.objects.all() 296 297 t = loader.get_template(template) 298 c = Context({'object': object}) 299 return HttpResponse(t.render(c), mimetype='text/plain') 300 301 def conf_dhcpd_conf(request, object_id): 302 """isc-dhcpd-3-server conf generator""" 303 return conf_generator(object_id, 'dhcpd.conf') 304 305 def conf_named_conf(request, object_id): 306 """bind conf generator""" 307 return conf_generator(object_id, 'named.conf') 308 309 def conf_rc_local(request, object_id): 310 """5.X legacy rc.local conf generator""" 311 312 object_id = nodename2id(object_id) 313 object = Node.objects.get(pk=object_id) 314 object.name = Node.objects.get(pk=object_id).name 315 object.host = gethostname() 316 317 # check if it is a wireless nic, and add wifimode for wicontrol 318 for nic in object: 319 if nic.ssid: 320 if nic.mode.mode == 'master': 321 nic.wifimode = 6 322 nic.wifidesc = 'master mode' 323 else: 324 nic.wifimode = 1 325 nic.wifidesc = 'managed mode' 326 t = loader.get_template('rc-local.txt') 327 c = Context({'object': object, 328 }) 329 return HttpResponse(t.render(c), mimetype='text/plain') 330 331 def conf_rc_node_local5X(request, object_id): 332 """5.X Legacy rc.node.local conf generator""" 333 334 object_id = nodename2id(object_id) 335 336 object.name = Node.objects.get(pk=object_id).name 337 object.host = gethostname() 338 339 t = loader.get_template('rc-node-local.txt') 340 c = Context({'object': object, 341 }) 342 return HttpResponse(t.render(c), mimetype='text/plain') 343 344 def conf_rc_node_local(request, object_id): 345 """rc.node.local conf generator""" 240 # Extra statictics information for use of generation 241 server = {} 242 server['host'] = gethostname() 346 243 347 object_id = nodename2id(object_id) 348 349 object = Node.objects.get(pk=object_id).interface_set.all() 350 object.name = Node.objects.get(pk=object_id).name 351 object.host = gethostname() 352 353 t = loader.get_template('rc-node-local.txt') 354 c = Context({'object': object, }) 355 356 print c 357 return HttpResponse(t.render(c), mimetype='text/plain') 358 359 360 def conf_resolv_conf(request, object_id): 361 """resolv.conf generator""" 362 return conf_generator(object_id, 'resolv.conf') 363 244 templateFile = version + '/' + file 245 return render_to_response(templateFile, {'node' : node, 'server' : server}, 246 mimetype='text/plain') 247
Note:
See TracChangeset
for help on using the changeset viewer.