Commit 16213292 by Őry Máté

firewall: don't fail if default_vlangroup is missing

parent 9fee2104
...@@ -536,20 +536,26 @@ class Host(models.Model): ...@@ -536,20 +536,26 @@ class Host(models.Model):
else: else:
public = self._get_random_port(proto) public = self._get_random_port(proto)
vg = VlanGroup.objects.get(name=settings["default_vlangroup"]) try:
if self.shared_ip: vgname = settings["default_vlangroup"]
if public < 1024: vg = VlanGroup.objects.get(name=vgname)
raise ValidationError(_("Only ports above 1024 can be used.")) except VlanGroup.DoesNotExist as e:
rule = Rule(direction='1', owner=self.owner, dport=public, logger.error('Host.add_port: default_vlangroup %s missing. %s',
proto=proto, nat=True, accept=True, vgname, unicode(e))
nat_dport=private, host=self, foreign_network=vg)
else: else:
rule = Rule(direction='1', owner=self.owner, dport=private, if self.shared_ip:
proto=proto, nat=False, accept=True, if public < 1024:
host=self, foreign_network=vg) raise ValidationError(
_("Only ports above 1024 can be used."))
rule.full_clean() rule = Rule(direction='1', owner=self.owner, dport=public,
rule.save() proto=proto, nat=True, accept=True,
nat_dport=private, host=self, foreign_network=vg)
else:
rule = Rule(direction='1', owner=self.owner, dport=private,
proto=proto, nat=False, accept=True,
host=self, foreign_network=vg)
rule.full_clean()
rule.save()
def del_port(self, proto, private): def del_port(self, proto, private):
""" """
......
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