Commit 16213292 by Őry Máté

firewall: don't fail if default_vlangroup is missing

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