Commit d3cded80 by Guba Sándor

Merge branch 'master' of giccero.cloud.ik.bme.hu:cloud

parents 0c6bca57 915ec04b
......@@ -37,3 +37,5 @@ nosetests.xml
# Other
*.swp
*~
local_settings.py
# Django settings for cloud project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('Ory, Mate', 'maat@iit.bme.hu'),
('IK', 'cloud@iit.bme.hu'),
)
MANAGERS = ADMINS
......@@ -113,12 +114,9 @@ INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'one',
'school',
......@@ -128,7 +126,6 @@ INSTALLED_APPS = (
'south',
'djcelery',
'kombu.transport.django',
#'django_bfm',
)
# A sample logging configuration. The only tangible logging
......@@ -178,5 +175,9 @@ import djcelery
djcelery.setup_loader()
BROKER_URL = 'django://'
try:
from cloud.local_settings import *
except:
pass
# vim: et sw=4 ai fenc=utf8 smarttab :
from django.contrib import admin
from firewall.models import *
from django import contrib
class AliasInline(contrib.admin.TabularInline):
model = Alias
class HostAdmin(admin.ModelAdmin):
list_display = ('hostname', 'vlan', 'ipv4', 'ipv6', 'pub_ipv4', 'mac', 'shared_ip', 'owner', 'groups_l', 'rules_l', 'description')
ordering = ('hostname',)
list_display = ('hostname', 'vlan', 'ipv4', 'ipv6', 'pub_ipv4', 'mac', 'shared_ip', 'owner', 'groups_l', 'rules_l', 'description', 'reverse')
ordering = ('hostname', )
list_filter = ('owner', 'vlan', 'groups')
search_fields = ('hostname', 'description', 'ipv4', 'ipv6', 'mac')
filter_horizontal = ('groups', 'rules',)
filter_horizontal = ('groups', 'rules', )
inlines = (AliasInline, )
class HostInline(contrib.admin.TabularInline):
model = Host
fields = ('hostname', 'ipv4', 'ipv6', 'pub_ipv4', 'mac', 'shared_ip', 'owner', 'reverse')
class VlanAdmin(admin.ModelAdmin):
list_display = ('vid', 'name', 'rules_l', 'ipv4', 'net_ipv4', 'ipv6', 'net_ipv6', 'description', 'domain', 'snat_ip', 'snat_to_l')
ordering = ('vid',)
ordering = ('vid', )
inlines = (HostInline, )
class RuleAdmin(admin.ModelAdmin):
list_display = ('r_type', 'color_desc', 'description', 'vlan_l', 'owner', 'extra', 'direction', 'accept', 'proto', 'sport', 'dport', 'nat', 'nat_dport')
list_filter = ('r_type', 'vlan', 'owner', 'direction', 'accept', 'proto', 'nat')
class AliasAdmin(admin.ModelAdmin):
list_display = ('alias', 'host')
class SettingAdmin(admin.ModelAdmin):
list_display = ('key', 'value')
admin.site.register(Host, HostAdmin)
admin.site.register(Vlan, VlanAdmin)
admin.site.register(Rule, RuleAdmin)
admin.site.register(Alias, AliasAdmin)
admin.site.register(Setting, SettingAdmin)
admin.site.register(Group)
admin.site.register(Firewall)
......@@ -7,6 +7,13 @@ from django.utils.translation import ugettext_lazy as _
from firewall.fields import *
from south.modelsinspector import add_introspection_rules
from django.core.validators import MinValueValidator, MaxValueValidator
from modeldict import ModelDict
class Setting(models.Model):
key = models.CharField(max_length=32)
value = models.CharField(max_length=200)
settings = ModelDict(Setting, key='key', value='value', instances=False)
class Rule(models.Model):
CHOICES_type = (('host', 'host'), ('firewall', 'firewall'), ('vlan', 'vlan'))
......@@ -97,12 +104,19 @@ class Group(models.Model):
def __unicode__(self):
return self.name
class Alias(models.Model):
host = models.ForeignKey('Host')
alias = models.CharField(max_length=40, unique=True, validators=[val_domain])
class Meta:
verbose_name_plural = 'aliases'
class Host(models.Model):
hostname = models.CharField(max_length=40, unique=True, validators=[val_alfanum])
reverse = models.CharField(max_length=40, validators=[val_domain], blank=True, null=True)
mac = MACAddressField(unique=True)
ipv4 = models.GenericIPAddressField(protocol='ipv4', unique=True)
pub_ipv4 = models.GenericIPAddressField(protocol='ipv4', blank=True, null=True)
ipv6 = models.GenericIPAddressField(protocol='ipv6', unique=True, blank=True)
ipv6 = models.GenericIPAddressField(protocol='ipv6', unique=True, blank=True, null=True)
shared_ip = models.BooleanField(default=False)
description = models.TextField(blank=True)
comment = models.TextField(blank=True)
......@@ -115,7 +129,7 @@ class Host(models.Model):
def __unicode__(self):
return self.hostname
def save(self, *args, **kwargs):
if not self.id and not self.ipv6:
if not self.id and self.ipv6 == "auto":
self.ipv6 = ipv4_2_ipv6(self.ipv4)
if not self.shared_ip and self.pub_ipv4 and Host.objects.exclude(id=self.id).filter(pub_ipv4=self.pub_ipv4):
raise ValidationError("Ha a shared_ip be van pipalva, akkor egyedinek kell lennie a pub_ipv4-nek!")
......
......@@ -3,7 +3,7 @@ from django.core.cache import cache
import os
import time
from firewall.fw import *
from firewall.models import settings
def reload_firewall_lock():
acquire_lock = lambda: cache.add("reload_lock1", "true", 9)
......@@ -25,7 +25,11 @@ class ReloadTask(Task):
return
print "indul"
time.sleep(10)
try:
sleep = float(settings['reload_sleep'])
except:
sleep = 10
time.sleep(sleep)
try:
print "ipv4"
......
#!/usr/bin/python
import base64
import xmltodict
import urllib2
import sys
xml = base64.b64decode(sys.argv[1])
data = xmltodict.parse(xml)
try:
booturl = data["VM"]["TEMPLATE"]["CONTEXT"]["BOOTURL"]
except:
print 'Error'
req=urllib2.Request(booturl)
response = urllib2.urlopen(req)
#!/bin/bash
if [ "$1" != -f ]
then
echo 'Clear ALL PRIVATE DATA ON THE VM. This is used for praparing VM template.'
echo -- '-f switch is required.'
exit 1
fi
rm -rf /opt/webadmin/cloud*
rm .bash_history
rm -f ~/.gitconfig
mysql <<A
DROP USER webadmin@localhost;
A
mysql <<A
DROP DATABASE webadmin;
A
sudo chpasswd <<<'cloud:ezmiez'
#!/bin/bash
if [ -z "$SSH_AUTH_SOCK" ]
then
cat <<A
Use SSH authentication agent forwarding ("ssh -A cloud@host").
On the client side you can use "ssh-add [filename]" to let the agent know more keys.
In .ssh/config you can also use "ForwardAgent yes" setting.
A
exit 1
fi
if ! git config user.name
then
echo -n "Your name: "
read NAME
git config --global user.name "$NAME"
fi
mysql <<A
DROP USER webadmin@localhost;
A
mysql <<A
DROP DATABASE webadmin;
A
set -e
mysql <<A
CREATE USER webadmin@localhost IDENTIFIED BY 'asjklddfjklqjf';
CREATE DATABASE webadmin CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON webadmin.* TO webadmin@localhost;
A
cd /opt/webadmin/
mv cloud cloud.$(date +%s) || true
git clone 'ssh://git@giccero.cloud.ik.bme.hu/cloud'
cd cloud
./manage.py syncdb --noinput
./manage.py migrate
./manage.py createsuperuser --email=cloud@ik.bme.hu
./manage.py loaddata /home/cloud/user.yaml 2>/dev/null || true
./manage.py loaddata /home/cloud/fw.yaml
./manage.py loaddata /home/cloud/one.yaml
./manage.py update
- fields: {name: wifi, nat: true, public: false}
model: one.network
pk: 1
- fields: {CPU: 1, RAM: 102, name: small}
model: one.instancetype
pk: 1
- fields: {access_type: ssh, created_at: !!timestamp '2013-01-24 23:06:00+00:00', disk: 1, instance_type: 1, name: tty, network: 1, owner: 1}
model: one.template
pk: 1
- fields: {name: Copy of ttylinux - kvm}
model: one.disk
pk: 1
- fields:
comment: ''
description: ''
dhcp_pool: manual
domain: wifi.ik.bme.hu
interface: fake
ipv4: 192.168.255.254
ipv6: 2001:738:2001:4031:168:255:254:0
name: 'wifi'
net4: 192.168.0.0
net6: '2001:738:2001:4031:168::'
prefix4: 16
prefix6: 80
snat_ip: 152.66.243.160
snat_to: [4, 7]
vid: 168
model: firewall.vlan
pk: 168
- fields:
date_joined: 2012-11-27 10:33:20+00:00
email: ''
first_name: ''
groups: []
is_active: true
is_staff: true
is_superuser: false
last_login: 2013-01-14 21:41:28+00:00
last_name: ''
password: pbkdf2_sha256$10000$nKZoYcdY1hCp$EUltsuHxLC4hYDMjh0P/3JCqZshnrvYTZpQDcotqjns=
user_permissions: []
username: bd
model: auth.user
pk: 2
- fields:
date_joined: 2012-11-27 10:40:57+00:00
email: ''
first_name: ''
groups: []
is_active: true
is_staff: false
is_superuser: false
last_login: 2012-11-27 10:40:57+00:00
last_name: ''
password: pbkdf2_sha256$10000$yQSOV0aqQyKoM$YryBbUnvH8pc3+OcpU6CoxPfxA+H/+s5LIRgKKbtrA=
user_permissions: []
username: mate
model: auth.user
pk: 3
- fields:
date_joined: 2012-11-27 10:41:08+00:00
email: ''
first_name: ''
groups: []
is_active: true
is_staff: false
is_superuser: false
last_login: 2012-11-27 10:41:08+00:00
last_name: ''
password: pbkdf2_sha256$10000$aDfLP2f50s9$/J3We6Rbgx5karvbK/xRcGJVPpQHKlPnGSxHMYl7/AgU=
user_permissions: []
username: tarokkk
model: auth.user
pk: 4
- fields:
date_joined: 2012-12-23 18:57:31+00:00
email: ''
first_name: ''
groups: []
is_active: true
is_staff: false
is_superuser: false
last_login: 2012-12-23 18:57:31+00:00
last_name: ''
password: pbkdf2_sha256$10000$fJrZiQ78vfDi$obQ8lqeEbWu1gJkUohGaL2VXDB+zHuc7qzrWwmDKye4=
user_permissions: []
username: opennebula
model: auth.user
pk: 5
- fields:
date_joined: 2013-01-14 15:01:51+00:00
email: ''
first_name: ''
groups: []
is_active: true
is_staff: true
is_superuser: true
last_login: 2013-01-14 15:07:27+00:00
last_name: ''
password: pbkdf2_sha256$10000$PxbeA5QOMTNr$hxUBeBD9yU7Gmu75+drJoqgpHFeYtop0w5ovx978Ec8=
user_permissions: []
username: lennon
model: auth.user
pk: 6
- fields:
date_joined: 2013-01-16 12:36:01+00:00
email: ''
first_name: ''
groups: []
is_active: true
is_staff: true
is_superuser: true
last_login: 2013-01-22 15:21:22+00:00
last_name: ''
password: pbkdf2_sha256$10000$gx04X6OpW8kW$iCU3cuhqQcvq7I8tRVkrnES03ty/3vqN8ou4xZgfPBQ=
user_permissions: []
username: test
model: auth.user
pk: 7
- fields:
date_joined: 2013-01-21 18:07:32+00:00
email: ''
first_name: ''
groups: []
is_active: true
is_staff: true
is_superuser: true
last_login: 2013-01-21 18:08:27+00:00
last_name: ''
password: pbkdf2_sha256$10000$1ckVZD48XFt8$7vj20S4x33KDRP/y02PKm8is9zf1FoLHJQ+xf1zhKzw=
user_permissions: []
username: test23
model: auth.user
pk: 9
- fields:
date_joined: 2013-01-21 18:11:21+00:00
email: ''
first_name: ''
groups: []
is_active: true
is_staff: true
is_superuser: true
last_login: 2013-01-22 00:09:01+00:00
last_name: ''
password: pbkdf2_sha256$10000$9gr7ctlRFCS8$A3Ex+7gs0OVU+SzZNvijisjvCQjBT6l0Tl3dGCQ5UEs=
user_permissions: []
username: test77
model: auth.user
pk: 10
- fields:
date_joined: 2013-01-22 23:03:18+00:00
email: orymate@gmail.com
first_name: "M\xE1t\xE9"
groups: []
is_active: true
is_staff: false
is_superuser: false
last_login: 2013-01-23 22:12:20+00:00
last_name: "\u0150ry"
password: '!'
user_permissions: []
username: K2JL24
model: auth.user
pk: 11
- fields:
date_joined: 2013-01-23 08:49:10+00:00
email: bd@doszgep.hu
first_name: "D\xE1niel"
groups: []
is_active: true
is_staff: false
is_superuser: false
last_login: 2013-01-23 11:30:27+00:00
last_name: Bach
password: '!'
user_permissions: []
username: JI1M92
model: auth.user
pk: 12
- fields:
date_joined: 2013-01-23 13:37:22+00:00
email: gubasanyi@gmail.com
first_name: "S\xE1ndor"
groups: []
is_active: true
is_staff: false
is_superuser: false
last_login: 2013-01-24 21:40:05+00:00
last_name: Guba
password: '!'
user_permissions: []
username: TFDAZ6
model: auth.user
pk: 13
- fields:
date_joined: 2013-01-23 15:04:46+00:00
email: madbence@gmail.com
first_name: Bence
groups: []
is_active: true
is_staff: false
is_superuser: false
last_login: 2013-01-23 15:04:46+00:00
last_name: "D\xE1nyi"
password: '!'
user_permissions: []
username: K7YLW5
model: auth.user
pk: 14
......@@ -6,6 +6,30 @@
<title>{% block title %}IK Cloud{% endblock %}</title>
<link rel="stylesheet" href="/static/style.css" />
<link rel="icon" type="image/png" href="/static/favicon.png" />
<link rel="icon" type="image/png" href="one/static/favicon.png">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('.wm').click(function(){
if($(this).children('.details').is(':hidden')){
$(this).children('.details')
.css('height',0)
.css('padding','0px 5px')
.show()
.animate({height:160,paddingTop:15,paddingBottom:15},700);
} else {
var that=this;
$(this).children('.details')
.css('height',130)
.css('padding','15px 5px')
.animate({height:0,paddingTop:0,paddingBottom:0},700,function(){
$(that).children('.details').hide();
});
}
})
})
</script>
{{ form.media }}
{% block js %}{% endblock %}
......
......@@ -26,27 +26,91 @@
{% endfor %}
</div>
<div class="boxes">
<div class="contentblock">
<h2>Adattár</h2>
<h2>
Adattár
</h2>
<div class="content">
<ul class="file-list">
<li class="wm">
<div class="summary">
<div class="name filetype-c">hello.c</div>
<div class="actions">
<a href="#"><img src="/static/icons/pencil.png" alt="rename" /></a>
<a href="#"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
<a href="#"><img src="/static/icons/download-cloud.png" alt="download" /></a>
</div>
<div class="info">1 Kb</div>
<div class="clear"></div>
</div>
<div class="details">
<h3>Részletek</h3>
<ul>
<li>a.out <span class="file-size">4K</span> <span class="file-age">(5 perce)</span> <a href="" class="file-download">Letöltés</a></li>
<li>a.out <span class="file-size">4K</span> <span class="file-age">(5 perce)</span> <a href="" class="file-download">Letöltés</a></li>
<li class="file-details">Tovább</li>
<li class="file-upload">Fájl feltöltése</li>
<li>Létrehozva: <span class="value">2012.12.29. 23:12</span></li>
<li>Módosítva: <span class="value">2012.12.29. 23:12</span></li>
<li>Hozzáférés: <span class="value">2012.12.29. 23:12</span></li>
<li>Típus: <span class="value">text/plain</span></li>
</ul>
</div>
</li>
<li class="wm">
<div class="summary">
<div class="name filetype-image">suna.jpg</div>
<div class="actions">
<a href="#"><img src="/static/icons/pencil.png" alt="rename" /></a>
<a href="#"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
<a href="#"><img src="/static/icons/download-cloud.png" alt="download" /></a>
</div>
<div class="contentblock" id="state">
<h2>A cluster állapota</h2>
<div class="content">
<p>
<a href="http://cloud.ik.bme.hu/">
<img src="/stat/cpu.png" alt="aktuális terhelés" />
<img src="/stat/ram.png" alt="aktuális memóriafoglaltság" />
</a>
</p>
<div class="info">1 Kb</div>
<div class="clear"></div>
</div>
<div class="details">
<h3>Részletek</h3>
<ul>
<li>Létrehozva: <span class="value">2012.12.29. 23:12</span></li>
<li>Módosítva: <span class="value">2012.12.29. 23:12</span></li>
<li>Hozzáférés: <span class="value">2012.12.29. 23:12</span></li>
<li>Típus: <span class="value">image/jpg</span></li>
</ul>
</div>
</li>
<li class="wm">
<div class="summary">
<div class="name filetype-folder">poresz</div>
<div class="actions">
<a href="#"><img src="/static/icons/pencil.png" alt="rename" /></a>
<a href="#"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
</div>
<div class="info">katalógus</div>
<div class="clear"></div>
</div>
<div class="details">
<h3>Részletek</h3>
<ul>
<li>Létrehozva: <span class="value">2012.12.29. 23:12</span></li>
<li>Módosítva: <span class="value">2012.12.29. 23:12</span></li>
<li>Hozzáférés: <span class="value">2012.12.29. 23:12</span></li>
<li>Fájlok: <span class="value">666 db</span></li>
</ul>
</div>
</li>
<li class="file-details wm">
<div class="summary">
<div class="name filetype-more">Mutasd a régebbi fájlokat!</div>
<div class="clear"></div>
</div>
</li>
<li class="file-upload wm">
<div class="summary">
<div class="name filetype-up">Fájlfeltöltés</div>
<div class="clear"></div>
</div>
</li>
</ul>
</div>
</div>
</div>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment