Commit 0689cfbd by Dudás Ádám

Merge branch 'master' into dev-siliconbrain

Conflicts:
	cloud/urls.py
	firewall/admin.py
parents 458553dc 05d4ad46
...@@ -33,4 +33,6 @@ urlpatterns = patterns('', ...@@ -33,4 +33,6 @@ urlpatterns = patterns('',
url(r'^fwapi/$', 'firewall.views.firewall_api', name='firewall_api'), url(r'^fwapi/$', 'firewall.views.firewall_api', name='firewall_api'),
url(r'^store/$', 'store.views.index', name='store_index'), url(r'^store/$', 'store.views.index', name='store_index'),
url(r'^store/top/$', 'store.views.toplist', name='store_top'), url(r'^store/top/$', 'store.views.toplist', name='store_top'),
url(r'^ajax/templateWizard$', 'one.views.ajax_template_wizard',
name='ajax_template_wizard'),
) )
# -*- coding: utf8 -*-
from django.contrib import admin from django.contrib import admin
from firewall.models import * from firewall.models import *
from django import contrib from django import contrib
...@@ -6,15 +8,23 @@ from django import contrib ...@@ -6,15 +8,23 @@ from django import contrib
class AliasInline(contrib.admin.TabularInline): class AliasInline(contrib.admin.TabularInline):
model = Alias model = Alias
class RuleInline(contrib.admin.TabularInline):
model = Rule
class HostAdmin(admin.ModelAdmin): class HostAdmin(admin.ModelAdmin):
list_display = ('hostname', 'vlan', 'ipv4', 'ipv6', 'pub_ipv4', 'mac', list_display = ('hostname', 'vlan', 'ipv4', 'ipv6', 'pub_ipv4', 'mac',
'shared_ip', 'owner', 'groups_l', 'rules_l', 'description', 'shared_ip', 'owner', 'description', 'reverse', 'groups_l')
'reverse')
ordering = ('hostname', ) ordering = ('hostname', )
list_filter = ('owner', 'vlan', 'groups') list_filter = ('owner', 'vlan', 'groups')
search_fields = ('hostname', 'description', 'ipv4', 'ipv6', 'mac') search_fields = ('hostname', 'description', 'ipv4', 'ipv6', 'mac')
filter_horizontal = ('groups', 'rules', ) filter_horizontal = ('groups', )
inlines = (AliasInline, ) inlines = (AliasInline, RuleInline)
def groups_l(self, instance):
retval = []
for i in instance.groups.all():
retval.append(i.name)
return u', '.join(retval)
class HostInline(contrib.admin.TabularInline): class HostInline(contrib.admin.TabularInline):
model = Host model = Host
...@@ -22,29 +32,59 @@ class HostInline(contrib.admin.TabularInline): ...@@ -22,29 +32,59 @@ class HostInline(contrib.admin.TabularInline):
'owner', 'reverse') 'owner', 'reverse')
class VlanAdmin(admin.ModelAdmin): class VlanAdmin(admin.ModelAdmin):
list_display = ('vid', 'name', 'rules_l', 'ipv4', 'net_ipv4', 'ipv6', list_display = ('vid', 'name', 'ipv4', 'net_ipv4', 'ipv6', 'net_ipv6',
'net_ipv6', 'description', 'domain', 'snat_ip', 'snat_to_l') 'description', 'domain', 'snat_ip', )
ordering = ('vid', ) ordering = ('vid', )
inlines = (HostInline, ) inlines = (RuleInline, )
class RuleAdmin(admin.ModelAdmin): class RuleAdmin(admin.ModelAdmin):
list_display = ('r_type', 'color_desc', 'description', 'vlan_l', list_display = ('r_type', 'color_desc', 'owner', 'extra', 'direction',
'owner', 'extra', 'direction', 'accept', 'proto', 'sport', 'dport', 'accept', 'proto', 'sport', 'dport', 'nat', 'nat_dport', 'used_in')
'nat', 'nat_dport')
list_filter = ('r_type', 'vlan', 'owner', 'direction', 'accept', list_filter = ('r_type', 'vlan', 'owner', 'direction', 'accept',
'proto', 'nat') 'proto', 'nat')
def color_desc(self, instance):
para = '</span>'
if(instance.dport):
para = "dport=%s %s" % (instance.dport, para)
if(instance.sport):
para = "sport=%s %s" % (instance.sport, para)
if(instance.proto):
para = "proto=%s %s" % (instance.proto, para)
para= u'<span style="color: #00FF00;">' + para
return u'<span style="color: #FF0000;">[' + instance.r_type + u']</span> ' + (instance.foreign_network.name + u'<span style="color: #0000FF;"> ▸ </span>' + instance.r_type if instance.direction=='1' else instance.r_type + u'<span style="color: #0000FF;"> ▸ </span>' + instance.foreign_network.name) + ' ' + para + ' ' + instance.description
color_desc.allow_tags = True
def vlan_l(self, instance):
retval = []
for vl in instance.foreign_network.vlans.all():
retval.append(vl.name)
return u', '.join(retval)
def used_in(self, instance):
for field in [instance.vlan, instance.vlangroup, instance.host, instance.hostgroup, instance.firewall]:
if field is not None:
return unicode(field) + ' ' + field._meta.object_name
class AliasAdmin(admin.ModelAdmin): class AliasAdmin(admin.ModelAdmin):
list_display = ('alias', 'host') list_display = ('alias', 'host')
class SettingAdmin(admin.ModelAdmin): class SettingAdmin(admin.ModelAdmin):
list_display = ('key', 'value') list_display = ('key', 'value', 'description')
class GroupAdmin(admin.ModelAdmin):
list_display = ('name', 'owner', 'description')
inlines = (RuleInline, )
class FirewallAdmin(admin.ModelAdmin):
inlines = (RuleInline, )
admin.site.register(Host, HostAdmin) admin.site.register(Host, HostAdmin)
admin.site.register(Vlan, VlanAdmin) admin.site.register(Vlan, VlanAdmin)
admin.site.register(Rule, RuleAdmin) admin.site.register(Rule, RuleAdmin)
admin.site.register(Alias, AliasAdmin) admin.site.register(Alias, AliasAdmin)
admin.site.register(Setting, SettingAdmin) admin.site.register(Setting, SettingAdmin)
admin.site.register(Group) admin.site.register(Group, GroupAdmin)
admin.site.register(Firewall) admin.site.register(VlanGroup)
admin.site.register(Firewall, FirewallAdmin)
...@@ -38,6 +38,9 @@ class firewall: ...@@ -38,6 +38,9 @@ class firewall:
self.SZABALYOK_NAT.append(s) self.SZABALYOK_NAT.append(s)
def host2vlan(self, host, rule): def host2vlan(self, host, rule):
if rule.foreign_network is None:
return
if(self.IPV6 and host.ipv6): if(self.IPV6 and host.ipv6):
ipaddr = host.ipv6 + "/112" ipaddr = host.ipv6 + "/112"
else: else:
...@@ -45,7 +48,7 @@ class firewall: ...@@ -45,7 +48,7 @@ class firewall:
dport_sport = self.dportsport(rule) dport_sport = self.dportsport(rule)
for vlan in rule.vlan.all(): for vlan in rule.foreign_network.vlans.all():
if(rule.accept): if(rule.accept):
if(rule.direction == '0' and vlan.name == "PUB"): if(rule.direction == '0' and vlan.name == "PUB"):
if(rule.dport == 25): if(rule.dport == 25):
...@@ -64,18 +67,24 @@ class firewall: ...@@ -64,18 +67,24 @@ class firewall:
def fw2vlan(self, rule): def fw2vlan(self, rule):
if rule.foreign_network is None:
return
dport_sport = self.dportsport(rule) dport_sport = self.dportsport(rule)
for vlan in rule.vlan.all(): for vlan in rule.foreign_network.vlans.all():
if(rule.direction == '1'): # HOSTHOZ megy if(rule.direction == '1'): # HOSTHOZ megy
self.iptables("-A INPUT -i %s %s %s -g %s" % (vlan.interface, dport_sport, rule.extra, "LOG_ACC" if rule.accept else "LOG_DROP")) self.iptables("-A INPUT -i %s %s %s -g %s" % (vlan.interface, dport_sport, rule.extra, "LOG_ACC" if rule.accept else "LOG_DROP"))
else: else:
self.iptables("-A OUTPUT -o %s %s %s -g %s" % (vlan.interface, dport_sport, rule.extra, "LOG_ACC" if rule.accept else "LOG_DROP")) self.iptables("-A OUTPUT -o %s %s %s -g %s" % (vlan.interface, dport_sport, rule.extra, "LOG_ACC" if rule.accept else "LOG_DROP"))
def vlan2vlan(self, l_vlan, rule): def vlan2vlan(self, l_vlan, rule):
if rule.foreign_network is None:
return
dport_sport = self.dportsport(rule) dport_sport = self.dportsport(rule)
for vlan in rule.vlan.all(): for vlan in rule.foreign_network.vlans.all():
if(rule.accept): if(rule.accept):
if((rule.direction == '0') and vlan.name == "PUB"): if((rule.direction == '0') and vlan.name == "PUB"):
action = "PUB_OUT" action = "PUB_OUT"
......
...@@ -12,6 +12,7 @@ from modeldict import ModelDict ...@@ -12,6 +12,7 @@ from modeldict import ModelDict
class Setting(models.Model): class Setting(models.Model):
key = models.CharField(max_length=32) key = models.CharField(max_length=32)
value = models.CharField(max_length=200) value = models.CharField(max_length=200)
description = models.TextField(blank=True)
settings = ModelDict(Setting, key='key', value='value', instances=False) settings = ModelDict(Setting, key='key', value='value', instances=False)
...@@ -19,9 +20,10 @@ class Rule(models.Model): ...@@ -19,9 +20,10 @@ class Rule(models.Model):
CHOICES_type = (('host', 'host'), ('firewall', 'firewall'), ('vlan', 'vlan')) CHOICES_type = (('host', 'host'), ('firewall', 'firewall'), ('vlan', 'vlan'))
CHOICES_proto = (('tcp', 'tcp'), ('udp', 'udp'), ('icmp', 'icmp')) CHOICES_proto = (('tcp', 'tcp'), ('udp', 'udp'), ('icmp', 'icmp'))
CHOICES_dir = (('0', 'out'), ('1', 'in')) CHOICES_dir = (('0', 'out'), ('1', 'in'))
direction = models.CharField(max_length=1, choices=CHOICES_dir, blank=False) direction = models.CharField(max_length=1, choices=CHOICES_dir, blank=False)
description = models.TextField(blank=True) description = models.TextField(blank=True)
vlan = models.ManyToManyField('Vlan', symmetrical=False, blank=True, null=True) foreign_network = models.ForeignKey('VlanGroup', related_name="ForeignRules")
dport = models.IntegerField(blank=True, null=True, validators=[MinValueValidator(1), MaxValueValidator(65535)]) dport = models.IntegerField(blank=True, null=True, validators=[MinValueValidator(1), MaxValueValidator(65535)])
sport = models.IntegerField(blank=True, null=True, validators=[MinValueValidator(1), MaxValueValidator(65535)]) sport = models.IntegerField(blank=True, null=True, validators=[MinValueValidator(1), MaxValueValidator(65535)])
proto = models.CharField(max_length=10, choices=CHOICES_proto, blank=True, null=True) proto = models.CharField(max_length=10, choices=CHOICES_proto, blank=True, null=True)
...@@ -34,20 +36,22 @@ class Rule(models.Model): ...@@ -34,20 +36,22 @@ class Rule(models.Model):
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
vlan = models.ForeignKey('Vlan', related_name="rules", blank=True, null=True)
vlangroup = models.ForeignKey('VlanGroup', related_name="rules", blank=True, null=True)
host = models.ForeignKey('Host', related_name="rules", blank=True, null=True)
hostgroup = models.ForeignKey('Group', related_name="rules", blank=True, null=True)
firewall = models.ForeignKey('Firewall', related_name="rules", blank=True, null=True)
def __unicode__(self): def __unicode__(self):
return self.desc() return self.desc()
def color_desc(self): def clean(self):
para = '</span>' count = 0
if(self.dport): for field in [self.vlan, self.vlangroup, self.host, self.hostgroup, self.firewall]:
para = "dport=%s %s" % (self.dport, para) if field is None:
if(self.sport): count = count + 1
para = "sport=%s %s" % (self.sport, para) if count != 4:
if(self.proto): raise ValidationError('jaj')
para = "proto=%s %s" % (self.proto, para)
para= u'<span style="color: #00FF00;">' + para
return u'<span style="color: #FF0000;">[' + self.r_type + u']</span> ' + (self.vlan_l() + u'<span style="color: #0000FF;"> ▸ </span>' + self.r_type if self.direction=='1' else self.r_type + u'<span style="color: #0000FF;"> ▸ </span>' + self.vlan_l()) + ' ' + para + ' ' +self.description
color_desc.allow_tags = True
def desc(self): def desc(self):
para = u"" para = u""
...@@ -57,12 +61,7 @@ class Rule(models.Model): ...@@ -57,12 +61,7 @@ class Rule(models.Model):
para = "sport=%s %s" % (self.sport, para) para = "sport=%s %s" % (self.sport, para)
if(self.proto): if(self.proto):
para = "proto=%s %s" % (self.proto, para) para = "proto=%s %s" % (self.proto, para)
return u'[' + self.r_type + u'] ' + (self.vlan_l() + u' ▸ ' + self.r_type if self.direction=='1' else self.r_type + u' ▸ ' + self.vlan_l()) + u' ' + para + u' ' +self.description return u'[' + self.r_type + u'] ' + (unicode(self.foreign_network) + u' ▸ ' + self.r_type if self.direction=='1' else self.r_type + u' ▸ ' + unicode(self.foreign_network)) + u' ' + para + u' ' +self.description
def vlan_l(self):
retval = []
for vl in self.vlan.all():
retval.append(vl.name)
return u', '.join(retval)
class Vlan(models.Model): class Vlan(models.Model):
vid = models.IntegerField(unique=True) vid = models.IntegerField(unique=True)
...@@ -76,34 +75,38 @@ class Vlan(models.Model): ...@@ -76,34 +75,38 @@ class Vlan(models.Model):
ipv6 = models.GenericIPAddressField(protocol='ipv6', unique=True) ipv6 = models.GenericIPAddressField(protocol='ipv6', unique=True)
snat_ip = models.GenericIPAddressField(protocol='ipv4', blank=True, null=True) snat_ip = models.GenericIPAddressField(protocol='ipv4', blank=True, null=True)
snat_to = models.ManyToManyField('self', symmetrical=False, blank=True, null=True) snat_to = models.ManyToManyField('self', symmetrical=False, blank=True, null=True)
rules = models.ManyToManyField('Rule', related_name="%(app_label)s_%(class)s_related", symmetrical=False, blank=True, null=True)
description = models.TextField(blank=True) description = models.TextField(blank=True)
comment = models.TextField(blank=True) comment = models.TextField(blank=True)
domain = models.TextField(blank=True, validators=[val_domain]) domain = models.TextField(blank=True, validators=[val_domain])
dhcp_pool = models.TextField(blank=True) dhcp_pool = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
owner = models.ForeignKey(User, blank=True, null=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
def __unicode__(self): def __unicode__(self):
return self.name return self.name
def net_ipv6(self): def net_ipv6(self):
return self.net6 + "/" + unicode(self.prefix6) return self.net6 + "/" + unicode(self.prefix6)
def net_ipv4(self): def net_ipv4(self):
return self.net4 + "/" + unicode(self.prefix4) return self.net4 + "/" + unicode(self.prefix4)
def rules_l(self):
retval = [] class VlanGroup(models.Model):
for rl in self.rules.all(): name = models.CharField(max_length=20, unique=True)
retval.append(unicode(rl)) vlans = models.ManyToManyField('Vlan', symmetrical=False, blank=True, null=True)
return ', '.join(retval) description = models.TextField(blank=True)
def snat_to_l(self): owner = models.ForeignKey(User, blank=True, null=True)
retval = [] created_at = models.DateTimeField(auto_now_add=True)
for rl in self.snat_to.all(): modified_at = models.DateTimeField(auto_now=True)
retval.append(unicode(rl))
return ', '.join(retval) def __unicode__(self):
return self.name
class Group(models.Model): class Group(models.Model):
name = models.CharField(max_length=20, unique=True) name = models.CharField(max_length=20, unique=True)
rules = models.ManyToManyField('Rule', symmetrical=False, blank=True, null=True) description = models.TextField(blank=True)
owner = models.ForeignKey(User, blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
...@@ -116,6 +119,7 @@ class Alias(models.Model): ...@@ -116,6 +119,7 @@ class Alias(models.Model):
owner = models.ForeignKey(User, null=True, blank=True) owner = models.ForeignKey(User, null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
class Meta: class Meta:
verbose_name_plural = 'aliases' verbose_name_plural = 'aliases'
...@@ -133,12 +137,12 @@ class Host(models.Model): ...@@ -133,12 +137,12 @@ class Host(models.Model):
vlan = models.ForeignKey('Vlan') vlan = models.ForeignKey('Vlan')
owner = models.ForeignKey(User) owner = models.ForeignKey(User)
groups = models.ManyToManyField('Group', symmetrical=False, blank=True, null=True) groups = models.ManyToManyField('Group', symmetrical=False, blank=True, null=True)
rules = models.ManyToManyField('Rule', symmetrical=False, blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
def __unicode__(self): def __unicode__(self):
return self.hostname return self.hostname
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.id and self.ipv6 == "auto": if not self.id and self.ipv6 == "auto":
self.ipv6 = ipv4_2_ipv6(self.ipv4) self.ipv6 = ipv4_2_ipv6(self.ipv4)
...@@ -146,18 +150,9 @@ class Host(models.Model): ...@@ -146,18 +150,9 @@ class Host(models.Model):
raise ValidationError("Ha a shared_ip be van pipalva, akkor egyedinek kell lennie a pub_ipv4-nek!") raise ValidationError("Ha a shared_ip be van pipalva, akkor egyedinek kell lennie a pub_ipv4-nek!")
if Host.objects.exclude(id=self.id).filter(pub_ipv4=self.ipv4): if Host.objects.exclude(id=self.id).filter(pub_ipv4=self.ipv4):
raise ValidationError("Egy masik host natolt cimet nem hasznalhatod sajat ipv4-nek") raise ValidationError("Egy masik host natolt cimet nem hasznalhatod sajat ipv4-nek")
self.full_clean()
super(Host, self).save(*args, **kwargs) super(Host, self).save(*args, **kwargs)
def groups_l(self):
retval = []
for grp in self.groups.all():
retval.append(grp.name)
return ', '.join(retval)
def rules_l(self):
retval = []
for rl in self.rules.all():
retval.append(unicode(rl.color_desc()))
return '<br>'.join(retval)
rules_l.allow_tags = True
def enable_net(self): def enable_net(self):
self.groups.add(Group.objects.get(name="netezhet")) self.groups.add(Group.objects.get(name="netezhet"))
...@@ -168,17 +163,9 @@ class Host(models.Model): ...@@ -168,17 +163,9 @@ class Host(models.Model):
for host in Host.objects.filter(pub_ipv4=self.pub_ipv4): for host in Host.objects.filter(pub_ipv4=self.pub_ipv4):
if host.rules.filter(nat=True, proto=proto, dport=public): if host.rules.filter(nat=True, proto=proto, dport=public):
raise ValidationError("A %s %s port mar hasznalva" % (proto, public)) raise ValidationError("A %s %s port mar hasznalva" % (proto, public))
rule = Rule(direction='1', owner=self.owner, description=u"%s %s %s ▸ %s" % (self.hostname, proto, public, private), dport=public, proto=proto, nat=True, accept=True, r_type="host", nat_dport=private) rule = Rule(direction='1', owner=self.owner, dport=public, proto=proto, nat=True, accept=True, r_type="host", nat_dport=private, host=self, foreign_network=VlanGroup.objects.get(name=settings["default_vlangroup"]))
rule.full_clean() rule.full_clean()
rule.save() rule.save()
rule.vlan.add(Vlan.objects.get(name="PUB"))
rule.vlan.add(Vlan.objects.get(name="HOT"))
rule.vlan.add(Vlan.objects.get(name="LAB"))
rule.vlan.add(Vlan.objects.get(name="DMZ"))
rule.vlan.add(Vlan.objects.get(name="VM-NET"))
rule.vlan.add(Vlan.objects.get(name="WAR"))
rule.vlan.add(Vlan.objects.get(name="OFF2"))
self.rules.add(rule)
def del_port(self, proto, public): def del_port(self, proto, public):
self.rules.filter(owner=self.owner, proto=proto, nat=True, dport=public).delete() self.rules.filter(owner=self.owner, proto=proto, nat=True, dport=public).delete()
...@@ -194,7 +181,6 @@ class Host(models.Model): ...@@ -194,7 +181,6 @@ class Host(models.Model):
class Firewall(models.Model): class Firewall(models.Model):
name = models.CharField(max_length=20, unique=True) name = models.CharField(max_length=20, unique=True)
rules = models.ManyToManyField('Rule', symmetrical=False, blank=True, null=True)
def __unicode__(self): def __unicode__(self):
return self.name return self.name
......
...@@ -2,14 +2,13 @@ ...@@ -2,14 +2,13 @@
cd /opt/webadmin/ cd /opt/webadmin/
if [ -d cloud ] if [ -d cloud ]
then then
: :
else else
echo Run init.sh? [N/y] echo Run init.sh? [N/y]
read read
if [ "$REPLY" = y ] if [ "$REPLY" = y ]
then then
passwd source /home/cloud/init.sh
/home/cloud/init.sh fi
fi
fi fi
cd cloud cd /opt/webadmin/cloud
...@@ -8,7 +8,7 @@ then ...@@ -8,7 +8,7 @@ then
exit 1 exit 1
fi fi
cp /opt/webadmin/cloud/miscellaneous/devenv/{.bash_login,init.sh,clean.sh} ~/
rm -rf /opt/webadmin/cloud* rm -rf /opt/webadmin/cloud*
rm .bash_history rm .bash_history
rm -f ~/.gitconfig rm -f ~/.gitconfig
...@@ -20,3 +20,5 @@ DROP DATABASE webadmin; ...@@ -20,3 +20,5 @@ DROP DATABASE webadmin;
A A
sudo chpasswd <<<'cloud:ezmiez' sudo chpasswd <<<'cloud:ezmiez'
sudo passwd -e cloud
rm ~/.ssh/authorized_keys
description "IK Cloud Store REST Daemon"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /opt/webadmin/cloud/miscellaneous/store-server/CloudStore.py
[
{
"pk": 7,
"model": "auth.user",
"fields": {
"username": "test",
"first_name": "",
"last_name": "",
"is_active": true,
"is_superuser": true,
"is_staff": true,
"last_login": "2013-01-30T23:33:32Z",
"groups": [],
"user_permissions": [],
"password": "pbkdf2_sha256$10000$LbTrj1qFLbLq$9F2K+3WXE/cb+/EjxwTf+1bmhKxm37MuTPZ/l7vyzn0=",
"email": "",
"date_joined": "2013-01-16T12:36:01Z"
}
},
{
"pk": 9,
"model": "one.template",
"fields": {
"name": "Ubuntu 12.04 desktop",
"created_at": "2013-01-31T10:11:08Z",
"access_type": "nx",
"instance_type": 3,
"owner": 1,
"disk": 1,
"network": 2
}
},
{
"pk": 10,
"model": "one.template",
"fields": {
"name": "Windows 7",
"created_at": "2013-01-31T10:11:21Z",
"access_type": "rdp",
"instance_type": 2,
"owner": 1,
"disk": 1,
"network": 2
}
},
{
"pk": 1,
"model": "store.setting",
"fields": {
"value": "True",
"key": "basic_auth"
}
},
{
"pk": 2,
"model": "store.setting",
"fields": {
"value": "False",
"key": "verify_ssl"
}
},
{
"pk": 3,
"model": "store.setting",
"fields": {
"value": "False",
"key": "ssl_auth"
}
},
{
"pk": 4,
"model": "store.setting",
"fields": {
"value": "IQu8Eice",
"key": "store_client_pass"
}
},
{
"pk": 5,
"model": "store.setting",
"fields": {
"value": "admin",
"key": "store_client_user"
}
},
{
"pk": 6,
"model": "store.setting",
"fields": {
"value": "/opt/webadmin/cloud/client.key",
"key": "store_client_key"
}
},
{
"pk": 7,
"model": "store.setting",
"fields": {
"value": "/opt/webadmin/cloud/client.crt",
"key": "store_client_cert"
}
},
{
"pk": 8,
"model": "store.setting",
"fields": {
"value": "http://localhost:9000",
"key": "store_url"
}
},
{
"pk": 2,
"model": "one.network",
"fields": {
"name": "VM-NET",
"nat": true,
"public": false
}
}
]
description "IK Cloud Django Development Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /opt/webadmin/cloud/manage.py runserver 0.0.0.0:8080
...@@ -16,6 +16,9 @@ then ...@@ -16,6 +16,9 @@ then
echo -n "Your name: " echo -n "Your name: "
read NAME read NAME
git config --global user.name "$NAME" git config --global user.name "$NAME"
echo -n "Your e-mail address: "
read MAIL
git config --global user.email "$MAIL"
fi fi
...@@ -43,35 +46,5 @@ mv cloud cloud.$(date +%s) || true ...@@ -43,35 +46,5 @@ mv cloud cloud.$(date +%s) || true
git clone 'ssh://git@giccero.cloud.ik.bme.hu/cloud' git clone 'ssh://git@giccero.cloud.ik.bme.hu/cloud'
cd cloud cd cloud
./manage.py syncdb --noinput source miscellaneous/devenv/nextinit.sh
./manage.py migrate set +e
./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 loaddata /home/cloud/store.yaml
./manage.py update
#Set up store server
rm -rf /var/www/*
mkdir -p /var/www
cd /opt/webadmin/cloud/miscellaneous/store-server/
LOCAL_IP=$(ip addr show dev eth0|grep inet|head -1|awk '{print $2}'|cut -d '/' -f 1)
cat <<EOF > store.config
[store]
#Default root folder (for download and upload)
root_www_folder = /var/www
#Deafult binary folder (for executables)
root_bin_folder = /opt/webadmin/cloud/miscellaneous/store-server/
#Site host (for standalone server)
site_host = 0.0.0.0
#Site port (for standalone server)
site_port = 9000
#Site url (for download and upload links) %(variable)formatter ex: %(port)s
site_url = http://${LOCAL_IP}:%(site_port)s
#User manager script (add, del, set, update)
user_manager = FAKEUserManager.sh
#Temporary directory
temp_dir = /tmp/dl
EOF
sudo /opt/webadmin/cloud/miscellaneous/store-server/CloudStore.py >/dev/null 2>&1 &
#!/bin/bash
for i in cloudstore toplist django
do
sudo stop $i
done
set -x
cd /opt/webadmin/cloud
./manage.py syncdb --noinput
./manage.py migrate
./manage.py loaddata miscellaneous/dump.json
./manage.py loaddata miscellaneous/devenv/dev.json
./manage.py update
./manage.py loaddata miscellaneous/devenv/dev.json
set +x
#Set up store server
rm -rf /var/www/*
mkdir -p /var/www
cd /opt/webadmin/cloud/miscellaneous/store-server/
LOCAL_IP=$(ip addr show dev eth0|grep inet|head -1|awk '{print $2}'|cut -d '/' -f 1)
cat <<EOF > store.config
[store]
#Default root folder (for download and upload)
root_www_folder = /var/www
#Deafult binary folder (for executables)
root_bin_folder = /opt/webadmin/cloud/miscellaneous/store-server/
#Site host (for standalone server)
site_host = 0.0.0.0
#Site port (for standalone server)
site_port = 9000
#Site url (for download and upload links) %(variable)formatter ex: %(port)s
site_url = http://${LOCAL_IP}:%(site_port)s
#User manager script (add, del, set, update)
user_manager = FAKEUserManager.sh
#Temporary directory
temp_dir = /tmp/dl
EOF
for i in cloudstore toplist django
do
sudo cp /opt/webadmin/cloud/miscellaneous/devenv/$i.conf /etc/init/
sudo start $i
done
cd /opt/webadmin/cloud/miscellaneous/devenv
sudo cp vimrc.local /etc/vim/vimrc.local
cd /opt/webadmin/cloud
./manage.py changepassword test
true
- 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
description "IK Cloud Store Toplist Daemon"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /opt/webadmin/cloud/miscellaneous/store-server/TopList.py
- 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$tHbyy0OTBCBQ$YVdhrXZVK6wi7Px/zX5zmpOGkQUnddXXdrwNFnJskx0=
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
highlight ExtraWhitespace ctermfg=white ctermbg=red guibg=red guifg=white
match ExtraWhitespace /\(\s\+$\|^\s*\t\|,[^ ]\|[;]$\|#[^ ].\|def [A-Z]\|class [a-z]\)/
autocmd BufWinEnter * match ExtraWhitespace /\(\s\+$\|^\s*\t\|,[^ ]\|[;]$\|#[^ ].\|def [A-Z]\|class [a-z]\)/
autocmd BufWinLeave * call clearmatches()
set et
set sw=4
set ai
set smarttab
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/bin/bash
/opt/webadmin/cloud/manage.py dumpdata -e admin -e one.userclouddetails -e school -e auth.permission -e contenttypes -e sessions -e djcelery --format=json --indent=2|grep -v '"password":'|sed -e 's/^.*"smb_password":.*$/"smb_password": "kamu",/' -e 's/BEGIN RSA PRIVATE.*END RSA/xxx/' >/opt/webadmin/cloud/miscellaneous/dump.json
...@@ -183,7 +183,7 @@ class Network(models.Model): ...@@ -183,7 +183,7 @@ class Network(models.Model):
cls.objects.exclude(id__in=l).delete() cls.objects.exclude(id__in=l).delete()
def __unicode__(self): def __unicode__(self):
return u"%s (vlan%03d)" % (self.name, self.id) return self.name
class Meta: class Meta:
ordering = ['name'] ordering = ['name']
...@@ -392,8 +392,7 @@ class Instance(models.Model): ...@@ -392,8 +392,7 @@ class Instance(models.Model):
host.hostname = u"id-%d_user-%s" % (inst.id, owner.username) host.hostname = u"id-%d_user-%s" % (inst.id, owner.username)
host.mac = x.getElementsByTagName("MAC")[0].childNodes[0].nodeValue host.mac = x.getElementsByTagName("MAC")[0].childNodes[0].nodeValue
host.ipv4 = inst.ip host.ipv4 = inst.ip
host.pub_ipv4 = "152.66.243.62" host.pub_ipv4 = Vlan.objects.get(name=template.network.name).snat_ip
host.full_clean()
host.save() host.save()
host.enable_net() host.enable_net()
host.add_port("tcp", inst.get_port(), {"rdp": 3389, "nx": 22, "ssh": 22}[inst.template.access_type]) host.add_port("tcp", inst.get_port(), {"rdp": 3389, "nx": 22, "ssh": 22}[inst.template.access_type])
...@@ -409,7 +408,6 @@ class Instance(models.Model): ...@@ -409,7 +408,6 @@ class Instance(models.Model):
proc = subprocess.Popen(["/opt/occi.sh", "compute", proc = subprocess.Popen(["/opt/occi.sh", "compute",
"delete", "%d"%self.one_id], stdout=subprocess.PIPE) "delete", "%d"%self.one_id], stdout=subprocess.PIPE)
(out, err) = proc.communicate() (out, err) = proc.communicate()
self.firewall_host.del_rules()
self.firewall_host.delete() self.firewall_host.delete()
reload_firewall_lock() reload_firewall_lock()
......
...@@ -61,11 +61,35 @@ ...@@ -61,11 +61,35 @@
&.opened .actions{ &.opened .actions{
display: block !important; display: block !important;
} }
&.small .summary{
padding: 5px;
cursor: default;
&:hover{
background-color: #c1c1c1;
}
.name{
background: none !important;
text-align: center;
float: none;
}
}
.quota{
left: 0;
top: 0;
z-index: 0;
position: absolute;
width: 100%;
height: 100%;
.used{
height: 100%;
}
}
.summary{ .summary{
padding: 15px 5px; padding: 15px 5px;
border-top: 1px solid #888; border-top: 1px solid #888;
cursor: pointer; cursor: pointer;
background-color: #c1c1c1; background-color: #c1c1c1;
position: relative;
&.unfinished{ &.unfinished{
background-color: #FFFF66; background-color: #FFFF66;
} }
...@@ -75,6 +99,7 @@ ...@@ -75,6 +99,7 @@
display: block; display: block;
} }
} }
.id{ .id{
float: right; float: right;
width: 30px; width: 30px;
...@@ -84,16 +109,22 @@ ...@@ -84,16 +109,22 @@
padding-left: 25px; padding-left: 25px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: 0 0; background-position: 0 0;
z-index: 2;
position: relative;
} }
.status{ .status{
text-align: right; text-align: right;
float: right; float: right;
width: 60px; width: 60px;
z-index: 2;
position: relative;
} }
.actions{ .actions{
float: right; float: right;
margin-left: 5px; margin-left: 5px;
display: none; display: none;
z-index: 2;
position: relative;
a{ a{
height: 16px; height: 16px;
width: 16px; width: 16px;
...@@ -110,21 +141,26 @@ ...@@ -110,21 +141,26 @@
.details{ .details{
border-top: 1px solid #888; border-top: 1px solid #888;
background-color: #d1d1d1; background-color: #d1d1d1;
padding: 15px 5px;
display: none; display: none;
.container{
padding: 5px 5px;
}
h3{ h3{
font-weight: normal; font-weight: normal;
} }
ul{ ul{
list-style: none; list-style: none;
margin: 10px 3px; margin: 0px 5px;
} }
li{ li{
margin: 12px 0px; margin: 8px 0px 4px 0px;
padding: 3px 0px 3px 20px; padding: 3px 0px 3px 20px;
border-bottom: 1px dotted #aaa; border-bottom: 1px dotted #aaa;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: 0px 4px; background-position: 0px 4px;
&:last-child{
border-bottom: none;
};
} }
a{ a{
text-decoration: underline; text-decoration: underline;
...@@ -164,6 +200,8 @@ ...@@ -164,6 +200,8 @@
background-image: url(icons/document-snippet.png); background-image: url(icons/document-snippet.png);
.value{ .value{
font-size: 0.8em; font-size: 0.8em;
word-spacing: 3px;
width: 350px;
} }
} }
} }
...@@ -230,3 +268,35 @@ ...@@ -230,3 +268,35 @@
.wm-list.modal .wm:nth-child(1) .summary{ .wm-list.modal .wm:nth-child(1) .summary{
border-top: none; border-top: none;
} }
#template{
.wm {
.template-details{
margin: 0;
padding: 0;
border-top: 1px solid #888;
display: none;
ul{
list-style-type: none;
}
li{
padding-left: 10px;
border-top: 1px solid #aaa;
position: relative;
&:first-child{
border-top: none;
};
.status{
float: right;
padding: 0 5px;
}
.group-name{
float: left;
line-height: 1.5em;
z-index: 2;
position: relative;
}
}
}
}
}
#modal{ #modal{
top: 0;
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 999;
} }
#shadow{ #shadow{
position: absolute; position: fixed;
height: 100%; height: 100%;
width: 100%; width: 100%;
background-color: rgba(0,0,0,0.6); background-color: rgba(0,0,0,0.6);
......
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>404 - A manóba</title>
</head>
<body>
<h1>404 - A manóba!</h1>
</body>
</html>
...@@ -12,11 +12,12 @@ ...@@ -12,11 +12,12 @@
<script src="/static/jquery.min.js"></script> <script src="/static/jquery.min.js"></script>
<script src="/static/less.min.js"></script> <script src="/static/less.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var toggleDetails;
$(function(){ $(function(){
$('.wm .summary').each(function(){ $('.wm .summary').each(function(){
this.originalHeight=parseInt($(this).next('.details').css('height')); this.originalHeight=parseInt($(this).next('.details').css('height'));
}) })
var toggleDetails=function(){ toggleDetails=function(){
if($(this).next('.details').is(':hidden')){ if($(this).next('.details').is(':hidden')){
$(this).next('.details') $(this).next('.details')
.show() .show()
...@@ -47,20 +48,26 @@ $(function(){ ...@@ -47,20 +48,26 @@ $(function(){
},2000); },2000);
}) })
$('#new-wm-button').click(function(){ $('#new-wm-button').click(function(){
$('#modal').show(); $('#modal').show();
$('#modal-container').html($('#new-wm').html()); $('#modal-container').html($('#new-wm').html());
$('#modal-container .wm .summary').each(function(){ $('#modal-container .wm .summary').each(function(){
this.originalHeight=parseInt($(this).next('.details').css('height')); this.originalHeight=parseInt($(this).next('.details').css('height'));
}) })
$('#modal-container .wm .summary').click(toggleDetails); $('#modal-container .wm .summary').click(toggleDetails);
}); });
$('#new-template-button').click(function(){ $('#new-template-button').click(function(){
$('#modal').show(); $('#modal').show();
$('#modal-container').html($('#new-template').html()); $('#modal-container').html($('#new-template').html());
}); });
$('#shadow').click(function(){ $('#shadow').click(function(){
$('#modal').hide(); $('#modal').hide();
}) })
$('#new-template-button').click(function(){
$.get('/ajax/templateWizard', function(data){
$('#modal-container').html(data);
})
$('#modal').show();
});
}) })
</script> </script>
...@@ -94,7 +101,7 @@ $(function(){ ...@@ -94,7 +101,7 @@ $(function(){
{% endblock %} {% endblock %}
{% block header %} {% block header %}
{% block header_title %} {% block header_title %}
<h1><a href="/">IK Cloud</a></h1> <h1><a href="/">IK Cloud <span style="font-size: 21px">&beta;</span></a></h1>
{% endblock %} {% endblock %}
{% endblock %} {% endblock %}
</div> </div>
...@@ -109,10 +116,12 @@ $(function(){ ...@@ -109,10 +116,12 @@ $(function(){
<div id="content"> <div id="content">
{% block content %}{% endblock %} {% block content %}{% endblock %}
<div class="clear"></div>
</div> </div>
<div id="modal" style="display: none"> <div id="modal" style="display: none">
<div id="shadow"></div> <div id="shadow"></div>
<div id="modal-container"> <div id="modal-container">
</div> </div>
</div> </div>
</body> </body>
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
</li> </li>
<li id="new-wm" style="display: none"> <li id="new-wm" style="display: none">
<h2>Rendelkezésre álló sablonok</h2> <h2>Rendelkezésre álló sablonok</h2>
<p>
Mese, hogy mit is lehet csinálni.
</p>
<div class="container"> <div class="container">
<ul class="wm-list modal"> <ul class="wm-list modal">
{% for m in templates %} {% for m in templates %}
...@@ -23,7 +26,7 @@ ...@@ -23,7 +26,7 @@
<div class="summary"> <div class="summary">
<div class="name wm-on">{{m.name}}</div> <div class="name wm-on">{{m.name}}</div>
<div class="status"> <div class="status">
<input type="submit" value="Indítás"/> 3/10
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
...@@ -36,6 +39,7 @@ ...@@ -36,6 +39,7 @@
<li class="type">Instance típus: <span class="value">{{m.instance_type.name}}</span></li> <li class="type">Instance típus: <span class="value">{{m.instance_type.name}}</span></li>
<li class="memory">Memória: <span class="value">{{m.instance_type.RAM}} MiB</span></li> <li class="memory">Memória: <span class="value">{{m.instance_type.RAM}} MiB</span></li>
<li class="cpu">CPU magok: <span class="value">{{m.instance_type.CPU}}</span></li> <li class="cpu">CPU magok: <span class="value">{{m.instance_type.CPU}}</span></li>
<li>&nbsp;<span class="value"><input type="submit" value="Indítás"/></span></li>
</ul> </ul>
</div> </div>
</form> </form>
...@@ -51,7 +55,61 @@ ...@@ -51,7 +55,61 @@
<ul class="wm-list"> <ul class="wm-list">
<li class="wm"> <li class="wm">
<div class="summary"> <div class="summary">
<div class="quota">
<div class="used" style="background-color: rgba(0,255,0,0.5); width: 20%"></div>
</div>
<div class="name">Win7 Matlab</div>
<div class="status">2/10</div>
<div class="actions">
<a href="#" title="Átnevezés"><img src="/static/icons/pencil.png" alt="rename" /></a>
<a href="#" title="Törlés"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
<a href="#" title="Megosztás"><img src="static/icons/user-share.png" alt="share" /></a>
</div>
<div class="clear"></div>
</div>
<div class="details">
<h3>Részletek</h3>
<ul>
<li class="name">Rendszer: <span class="value">Windows 7 Desktop</span></li>
<li class="description">Leírás: <span class="value">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh arcu, cursus et sodales eu, iaculis id metus. Suspendisse et mauris nisi, luctus feugiat nisi. Nullam elementum tincidunt urna a luctus.</span><div class="clear"></div></li>
<li class="date">Létrehozva: <span class="value">2013.01.10. 13:40:22</span></li>
<li class="date">Módosítva: <span class="value">2013.01.10. 13:40:22</span></li>
<li class="count">Futó példányok: <span class="value">1 db</span></li>
</ul>
</div>
</li>
<li class="wm">
<div class="summary">
<div class="quota">
<div class="used" style="background-color: rgba(255,128,0,0.5); width: 70%"></div>
</div>
<div class="name">Win7 Matlab</div>
<div class="status">7/10</div>
<div class="actions">
<a href="#" title="Átnevezés"><img src="/static/icons/pencil.png" alt="rename" /></a>
<a href="#" title="Törlés"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
<a href="#" title="Megosztás"><img src="static/icons/user-share.png" alt="share" /></a>
</div>
<div class="clear"></div>
</div>
<div class="details">
<h3>Részletek</h3>
<ul>
<li class="name">Rendszer: <span class="value">Windows 7 Desktop</span></li>
<li class="description">Leírás: <span class="value">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh arcu, cursus et sodales eu, iaculis id metus. Suspendisse et mauris nisi, luctus feugiat nisi. Nullam elementum tincidunt urna a luctus.</span><div class="clear"></div></li>
<li class="date">Létrehozva: <span class="value">2013.01.10. 13:40:22</span></li>
<li class="date">Módosítva: <span class="value">2013.01.10. 13:40:22</span></li>
<li class="count">Futó példányok: <span class="value">5 db</span></li>
</ul>
</div>
</li>
<li class="wm">
<div class="summary">
<div class="quota">
<div class="used" style="background-color: rgba(255,0,0,0.5); width: 100%"></div>
</div>
<div class="name">Win7 Matlab</div> <div class="name">Win7 Matlab</div>
<div class="status">10/10</div>
<div class="actions"> <div class="actions">
<a href="#" title="Átnevezés"><img src="/static/icons/pencil.png" alt="rename" /></a> <a href="#" title="Átnevezés"><img src="/static/icons/pencil.png" alt="rename" /></a>
<a href="#" title="Törlés"><img src="/static/icons/minus-circle.png" alt="delete" /></a> <a href="#" title="Törlés"><img src="/static/icons/minus-circle.png" alt="delete" /></a>
...@@ -66,7 +124,7 @@ ...@@ -66,7 +124,7 @@
<li class="description">Leírás: <span class="value">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh arcu, cursus et sodales eu, iaculis id metus. Suspendisse et mauris nisi, luctus feugiat nisi. Nullam elementum tincidunt urna a luctus.</span><div class="clear"></div></li> <li class="description">Leírás: <span class="value">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh arcu, cursus et sodales eu, iaculis id metus. Suspendisse et mauris nisi, luctus feugiat nisi. Nullam elementum tincidunt urna a luctus.</span><div class="clear"></div></li>
<li class="date">Létrehozva: <span class="value">2013.01.10. 13:40:22</span></li> <li class="date">Létrehozva: <span class="value">2013.01.10. 13:40:22</span></li>
<li class="date">Módosítva: <span class="value">2013.01.10. 13:40:22</span></li> <li class="date">Módosítva: <span class="value">2013.01.10. 13:40:22</span></li>
<li class="count">Aktív példányok: <span class="value">8 db</span></li> <li class="count">Futó példányok: <span class="value">10 db</span></li>
</ul> </ul>
</div> </div>
</li> </li>
...@@ -87,7 +145,7 @@ ...@@ -87,7 +145,7 @@
<li class="description">Leírás: <span class="value">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh arcu, cursus et sodales eu, iaculis id metus. Suspendisse et mauris nisi, luctus feugiat nisi. Nullam elementum tincidunt urna a luctus.</span><div class="clear"></div></li> <li class="description">Leírás: <span class="value">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin nibh arcu, cursus et sodales eu, iaculis id metus. Suspendisse et mauris nisi, luctus feugiat nisi. Nullam elementum tincidunt urna a luctus.</span><div class="clear"></div></li>
<li class="date">Létrehozva: <span class="value">2013.01.10. 13:40:22</span></li> <li class="date">Létrehozva: <span class="value">2013.01.10. 13:40:22</span></li>
<li class="date">Módosítva: <span class="value">2013.01.10. 13:40:22</span></li> <li class="date">Módosítva: <span class="value">2013.01.10. 13:40:22</span></li>
<li class="count">Aktív példányok: <span class="value">8 db</span></li> <li class="count">Futó példányok: <span class="value">8 db</span></li>
</ul> </ul>
</div> </div>
</li> </li>
...@@ -97,9 +155,15 @@ ...@@ -97,9 +155,15 @@
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</li> </li>
<script type="text/html" id="new-template" style="display: none"> <li class="wm small">
{% include "new-template-flow.html" %} <div class="summary">
</script> <div class="quota">
<div class="used" style="background-color: rgba(0,255,0,0.5); width: 19%"></div>
</div>
<div class="name">Kvóta: 19/100</div>
<div class="clear"></div>
</div>
</li>
</ul> </ul>
</div> </div>
{% for box in boxes %} {% for box in boxes %}
......
<form action="/" method="post"> <form action="/" method="post" id="template-wizard">
<div id="new-template-step-1" class="wizard"> <div id="new-template-step-1" class="wizard">
<div class="progress"> <div class="progress">
<div class="bar-container"> <div class="bar-container">
...@@ -57,11 +57,100 @@ ...@@ -57,11 +57,100 @@
<a href="#" class="next">Tovább &raquo;</a> <a href="#" class="next">Tovább &raquo;</a>
<div class="clear"></div> <div class="clear"></div>
</nav> </nav>
<script type="text/javascript">
$(function(){
$('#new-template-step-1 nav .next').click(function(){
$('#new-template-step-1').hide();
$('#new-template-step-2').show();
})
$('#new-template-step-1 nav .prev').click(function(){
$('#modal').hide();
})
})
</script>
</div> </div>
<div id="new-template-step-2" style="display: none"> <div id="new-template-step-2" class="wizard" style="display: none">
<div class="progress">
<div class="bar-container">
<div class="bar" style="width: 66%"></div>
</div>
<h3>2/3</h3>
</div>
<h2>2. lépés</h2>
<p>Leírás, mit is kéne itt ezen az ablakon csinálni, és miért jó, ha azt csinálja, amit.</p>
<div class="container">
<ul class="wm-list modal">
{% for m in templates %}
<li class="wm">
<form method="POST" action="/vm/new/{{m.pk}}/">{% csrf_token %}
<div class="summary">
<div class="name wm-on">{{m.name}}</div>
<div class="status">
<input type="submit" value="Indítás"/>
</div>
<div class="clear"></div>
</div>
<div class="details">
<h3>
Részletek
</h3>
<ul>
<li class="name">Rendszer: <span class="value">{{m.disk.name}}</span></li>
<li class="type">Instance típus: <span class="value">{{m.instance_type.name}}</span></li>
<li class="memory">Memória: <span class="value">{{m.instance_type.RAM}} MiB</span></li>
<li class="cpu">CPU magok: <span class="value">{{m.instance_type.CPU}}</span></li>
</ul>
</div>
</form>
</li>
{% endfor %}
</ul>
</div>
<nav>
<a href="#" class="prev">&laquo; Mégse</a>
<a href="#" class="next">Tovább &raquo;</a>
<div class="clear"></div>
</nav>
<script type="text/javascript">
$(function(){
console.log('foo');
$('#modal .wm .summary').each(function(){
$(this).next('.details').show();
console.log($(this).next('.details').css('display'), $(this).next('.details').css('height'));
//this.originalHeight=parseInt($(this).next('.details').css('height'));
})
$('#modal .wm .summary').click(function(){
if($(this).next('.details').is(':hidden')){
$(this).next('.details')
.slideDown(700);
$(this).parent('.wm').addClass('opened');
} else {
var that=this;
$(this).next('.details')
.removeClass('opened')
.slideUp(700);
}
});
$('#new-template-step-2 nav .prev').click(function(){
$('#new-template-step-2').hide();
$('#new-template-step-1').show();
})
$('#new-template-step-2 nav .next').click(function(){
$('#new-template-step-2').hide();
$('#new-template-step-3').show();
$.ajax({
'type': 'POST',
'url': '/ajax/templateWizard',
'data': $('#template-wizard').serialize()
})
.done(function(){ console.log('ok')});
})
})
</script>
</div> </div>
<div id="new-template-step-3" style="display: none"> <div id="new-template-step-3" class="wizard" style="display: none">
</div> </div>
</form> </form>
...@@ -73,6 +73,13 @@ def home(request): ...@@ -73,6 +73,13 @@ def home(request):
'instances': _list_instances(request), 'instances': _list_instances(request),
})) }))
@require_GET
@login_required
def ajax_template_wizard(request):
return render_to_response('new-template-flow.html', RequestContext(request,{
'templates': Template.objects.all(),
}))
@require_POST @require_POST
@login_required @login_required
def vm_new(request, template): def vm_new(request, template):
...@@ -116,7 +123,7 @@ class VmPortAddView(View): ...@@ -116,7 +123,7 @@ class VmPortAddView(View):
def post(self, request, iid, *args, **kwargs): def post(self, request, iid, *args, **kwargs):
try: try:
public = int(request.POST['public']) public = int(request.POST['public'])
if public >= 22000 and public < 24000: if public >= 22000 and public < 24000:
raise ValidationError("a port nem lehet 22000 es 24000 kozott") raise ValidationError("a port nem lehet 22000 es 24000 kozott")
inst = get_object_or_404(Instance, id=iid, owner=request.user) inst = get_object_or_404(Instance, id=iid, owner=request.user)
......
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