Statistics
| Branch: | Tag: | Revision:

root / ui / views.py @ de9bbf4e

History | View | Annotate | Download (2.9 kB)

1
from django.template import Context, loader
2
from django.http import HttpResponse
3
import os
4

    
5
DEFAULT_IMAGES = [
6
              {'id': 'ubuntu-10.10-x86_64-server', 'type':'standard', 'title': 'Ubuntu 10.10 server 64bit', 'description': 'Apache, MySQL, php5 preinstalled', 'size': '834', 'logo':'ubuntu.png'}, 
7
              {'id': 'fedora-14-desktop', 'type':'standard', 'title': 'Fedora 14 desktop 32bit', 'description': 'Apache, MySQL, php5 preinstalled', 'size': '912', 'logo':'fedora.png'}, 
8
              {'id': 'windows7-pro', 'type':'standard', 'title': 'Windows 7 professional', 'description': 'MS Office 7 preinstalled', 'size': '8142', 'logo':'windows.png'}, 
9
              {'id': 'windows-xp', 'type':'standard', 'title': 'Windows XP', 'description': 'MS Office XP preinstalled', 'size': '6192', 'logo':'windows.png'},
10
              {'id': 'netbsd-server', 'type':'custom', 'title': 'NetBSD server', 'description': 'my secure torrent server', 'size': '898', 'logo':'netbsd.png'}, 
11
              {'id': 'gentoo-playroom', 'type':'custom', 'title': 'Centoo', 'description': 'online pinaball olympiad server', 'size': '912', 'logo':'gentoo.png'},  
12
             ]
13

    
14
DEFAULT_NODES = [
15
                 {'id':1, 'name':'My mail server', 'state':'3','public_ip':'147.102.1.62', 'thumb' : 'ubuntu.png'},
16
                 {'id':2, 'name':'My name server', 'state':'3','public_ip':'147.102.1.64', 'thumb' : 'debian.png'},
17
                 {'id':3, 'name':'My file server', 'state':'3','public_ip':'147.102.1.65', 'thumb' : 'slackware.png'},
18
                 {'id':4, 'name':'My torrent server', 'state':'3','public_ip':'147.102.1.66', 'thumb' : 'gentoo.png'},
19
                 {'id':5, 'name':'My firewall', 'state':'3','public_ip':'147.102.1.67', 'thumb' : 'netbsd.png'},
20
                 {'id':6, 'name':'My windows workstation', 'state':'0','public_ip':'147.102.1.69', 'thumb' : 'windows-off.png'},
21
                ]
22

    
23
def template(name, context):
24
    template_path = os.path.join(os.path.dirname(__file__), "templates/")  
25
    current_template = template_path + name + '.html'
26
    t = loader.get_template(current_template)
27
    return HttpResponse(t.render(Context(context)))
28

    
29
def home(request):
30
    context = { 'project' : '+nefo', 'request': request }
31
    return template('home', context)
32

    
33
def instances(request):
34
    context = {'nodes': DEFAULT_NODES, 'images': DEFAULT_IMAGES}
35
    return template('instances', context)
36

    
37
def alt_instances(request):
38
    context = {'nodes': DEFAULT_NODES, 'images': DEFAULT_IMAGES}
39
    return template('alt_instances', context)
40
   
41
def instances_list(request):
42
    context = {'nodes': DEFAULT_NODES, 'images': DEFAULT_IMAGES}
43
    return template('list', context)
44

    
45
def images(request): 
46
    context = {'images': DEFAULT_IMAGES}
47
    return template('images', context)
48

    
49
def disks(request):
50
    context = { 'project' : '+nefo' }
51
    return template('disks', context)
52

    
53
def networks(request):
54
    context = { 'project' : '+nefo' }
55
    return template('networks', context)