Commit 2dee91d5 by Bach Dániel

firewall: random fixes

parent a14c9ce4
...@@ -263,7 +263,7 @@ FIREWALL_SETTINGS = { ...@@ -263,7 +263,7 @@ FIREWALL_SETTINGS = {
} }
SITE_NAME = "IK Cloud" SITE_NAME = "IK Cloud"
DEFAULT_FROM_EMAIL = "noreply@cloud.ik.bme.hu" DEFAULT_FROM_EMAIL = "noreply@cloud.ik.bme.hu"
DELETE_VM = False DELETE_VM = True
EMAIL_HOST = '152.66.243.92' # giccero ipv4 EMAIL_HOST = '152.66.243.92' # giccero ipv4
CLOUD_URL = 'https://cloud.ik.bme.hu/' CLOUD_URL = 'https://cloud.ik.bme.hu/'
try: try:
......
...@@ -212,10 +212,10 @@ class Firewall: ...@@ -212,10 +212,10 @@ class Firewall:
# hard-wired rules # hard-wired rules
self.iptablesnat('-A POSTROUTING -s 10.5.0.0/16 -o vlan0003 -j SNAT ' self.iptablesnat('-A POSTROUTING -s 10.5.0.0/16 -o vlan0003 -j SNAT '
'--to-source 10.3.255.254') # man elerheto legyen '--to-source 10.3.255.254') # man elerheto legyen
self.iptablesnat('-A POSTROUTING -s 10.5.0.0/16 -o vlan0008 -j SNAT ' self.iptablesnat('-A POSTROUTING -o vlan0008 -j SNAT '
'--to-source 10.0.0.247') # wolf network for printing '--to-source 10.0.0.247') # wolf network for printing
self.iptablesnat('-A POSTROUTING -s 10.3.0.0/16 -o vlan0002 -j SNAT ' self.iptablesnat('-A POSTROUTING -s 10.3.0.0/16 -p udp --dport 53 -o vlan0002 -j SNAT '
'--to-source %s' % self.pub.ipv4) # kulonben nemmegy a du '--to-source %s' % self.pub.ipv4) # kulonben nem megy a dns man-ban
self.iptablesnat('COMMIT') self.iptablesnat('COMMIT')
......
...@@ -49,7 +49,7 @@ def firewall_api(request): ...@@ -49,7 +49,7 @@ def firewall_api(request):
obj.snort_message=data["snort_message"] obj.snort_message=data["snort_message"]
if created: if created:
try: try:
obj.host = models.Host.objects.get(ipv4=data["ip"]) obj.host = Host.objects.get(ipv4=data["ip"])
user = obj.host.owner user = obj.host.owner
lang = user.person_set.all()[0].language lang = user.person_set.all()[0].language
translation.activate(lang) translation.activate(lang)
...@@ -61,8 +61,6 @@ def firewall_api(request): ...@@ -61,8 +61,6 @@ def firewall_api(request):
SendMailTask.delay(to=obj.host.owner.email, subject='[IK Cloud] %s' % obj.host.instance_set.get().name, msg=msg, sender=u'cloud@ik.bme.hu') SendMailTask.delay(to=obj.host.owner.email, subject='[IK Cloud] %s' % obj.host.instance_set.get().name, msg=msg, sender=u'cloud@ik.bme.hu')
except (Host.DoesNotExist, ValidationError, IntegrityError, AttributeError): except (Host.DoesNotExist, ValidationError, IntegrityError, AttributeError):
pass pass
print obj.modified_at + datetime.timedelta(minutes=5)
print datetime.datetime.utcnow().replace(tzinfo=utc)
if obj.type == 'tempwhite' and obj.modified_at + datetime.timedelta(minutes=1) < datetime.datetime.utcnow().replace(tzinfo=utc): if obj.type == 'tempwhite' and obj.modified_at + datetime.timedelta(minutes=1) < datetime.datetime.utcnow().replace(tzinfo=utc):
obj.type = 'tempban' obj.type = 'tempban'
obj.save() obj.save()
...@@ -76,10 +74,10 @@ def firewall_api(request): ...@@ -76,10 +74,10 @@ def firewall_api(request):
if command == "create": if command == "create":
data["owner"] = "opennebula" data["owner"] = "opennebula"
owner = auth.models.User.objects.get(username=data["owner"]) owner = auth.models.User.objects.get(username=data["owner"])
host = models.Host(hostname=data["hostname"], host = Host(hostname=data["hostname"],
vlan=models.Vlan.objects.get(name=data["vlan"]), vlan=Vlan.objects.get(name=data["vlan"]),
mac=data["mac"], ipv4=data["ip"], owner=owner, mac=data["mac"], ipv4=data["ip"], owner=owner,
description=data["description"], pub_ipv4=models. description=data["description"], pub_ipv4=
Vlan.objects.get(name=data["vlan"]).snat_ip, Vlan.objects.get(name=data["vlan"]).snat_ip,
shared_ip=True) shared_ip=True)
host.full_clean() host.full_clean()
...@@ -96,7 +94,7 @@ def firewall_api(request): ...@@ -96,7 +94,7 @@ def firewall_api(request):
data["owner"] = "opennebula" data["owner"] = "opennebula"
print data["hostname"] print data["hostname"]
owner = auth.models.User.objects.get(username=data["owner"]) owner = auth.models.User.objects.get(username=data["owner"])
host = models.Host.objects.get(hostname=data["hostname"], host = Host.objects.get(hostname=data["hostname"],
owner=owner) owner=owner)
host.delete() host.delete()
......
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