Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
whitej6 committed Sep 20, 2023
1 parent aa8e4db commit 583d447
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="zone",
name="new_interfaces",
field=models.ManyToManyField(
blank=True, related_name="zones", to="nautobot_firewall_models.UserObject"
),
field=models.ManyToManyField(blank=True, related_name="zones", to="nautobot_firewall_models.UserObject"),
),
migrations.AddField(
model_name="zone",
name="new_vrfs",
field=models.ManyToManyField(
blank=True, related_name="zones", to="nautobot_firewall_models.UserObject"
),
field=models.ManyToManyField(blank=True, related_name="zones", to="nautobot_firewall_models.UserObject"),
),
migrations.AddField(
model_name="serviceobjectgroup",
Expand All @@ -54,7 +50,9 @@ class Migration(migrations.Migration):
model_name="applicationobjectgroup",
name="new_application_objects",
field=models.ManyToManyField(
blank=True, related_name="new_application_object_groups", to="nautobot_firewall_models.ApplicationObject"
blank=True,
related_name="new_application_object_groups",
to="nautobot_firewall_models.ApplicationObject",
),
),
# start policyrule source
Expand Down Expand Up @@ -112,7 +110,9 @@ class Migration(migrations.Migration):
model_name="policyrule",
name="new_destination_address_groups",
field=models.ManyToManyField(
blank=True, related_name="new_destination_policy_rules", to="nautobot_firewall_models.AddressObjectGroup"
blank=True,
related_name="new_destination_policy_rules",
to="nautobot_firewall_models.AddressObjectGroup",
),
),
migrations.AddField(
Expand All @@ -126,7 +126,9 @@ class Migration(migrations.Migration):
model_name="policyrule",
name="new_destination_service_groups",
field=models.ManyToManyField(
blank=True, related_name="new_destination_policy_rules", to="nautobot_firewall_models.ServiceObjectGroup"
blank=True,
related_name="new_destination_policy_rules",
to="nautobot_firewall_models.ServiceObjectGroup",
),
),
migrations.AddField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
"nautobot_firewall_models.PolicyRule": {"old": "source_service_groups", "new": "new_source_service_groups"},
# policy rule dest
"nautobot_firewall_models.PolicyRule": {"old": "destination_addresses", "new": "new_destination_addresses"},
"nautobot_firewall_models.PolicyRule": {"old": "destination_address_groups", "new": "new_destination_addresse_groups"},
"nautobot_firewall_models.PolicyRule": {
"old": "destination_address_groups",
"new": "new_destination_addresse_groups",
},
"nautobot_firewall_models.PolicyRule": {"old": "destination_services", "new": "new_destination_services"},
"nautobot_firewall_models.PolicyRule": {"old": "destination_service_groups", "new": "new_destination_service_groups"},
"nautobot_firewall_models.PolicyRule": {
"old": "destination_service_groups",
"new": "new_destination_service_groups",
},
"nautobot_firewall_models.PolicyRule": {"old": "applications", "new": "new_applications"},
"nautobot_firewall_models.PolicyRule": {"old": "application_groups", "new": "new_application_groups"},
# policy policyrule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ class Migration(migrations.Migration):
new_name="address_objects",
),
migrations.AlterField(
model_name='addressobjectgroup',
name='address_objects',
field=models.ManyToManyField(blank=True, related_name='address_object_groups', to='nautobot_firewall_models.AddressObject'),
model_name="addressobjectgroup",
name="address_objects",
field=models.ManyToManyField(
blank=True, related_name="address_object_groups", to="nautobot_firewall_models.AddressObject"
),
),
# models.address.fqdn
migrations.RemoveField(
Expand All @@ -42,9 +44,9 @@ class Migration(migrations.Migration):
new_name="ip_addresses",
),
migrations.AlterField(
model_name='fqdn',
name='ip_addresses',
field=models.ManyToManyField(blank=True, related_name='fqdns', to='ipam.IPAddress'),
model_name="fqdn",
name="ip_addresses",
field=models.ManyToManyField(blank=True, related_name="fqdns", to="ipam.IPAddress"),
),
# models.user.userobjectgroup
migrations.RemoveField(
Expand All @@ -60,9 +62,11 @@ class Migration(migrations.Migration):
new_name="user_objects",
),
migrations.AlterField(
model_name='userobjectgroup',
name='user_objects',
field=models.ManyToManyField(blank=True, related_name='user_object_groups', to='nautobot_firewall_models.UserObject'),
model_name="userobjectgroup",
name="user_objects",
field=models.ManyToManyField(
blank=True, related_name="user_object_groups", to="nautobot_firewall_models.UserObject"
),
),
# models.zone.zone
migrations.RemoveField(
Expand Down Expand Up @@ -90,14 +94,14 @@ class Migration(migrations.Migration):
new_name="vrfs",
),
migrations.AlterField(
model_name='zone',
name='interfaces',
field=models.ManyToManyField(blank=True, related_name='zones', to='dcim.Interface'),
model_name="zone",
name="interfaces",
field=models.ManyToManyField(blank=True, related_name="zones", to="dcim.Interface"),
),
migrations.AlterField(
model_name='zone',
name='vrfs',
field=models.ManyToManyField(blank=True, related_name='zones', to='ipam.VRF'),
model_name="zone",
name="vrfs",
field=models.ManyToManyField(blank=True, related_name="zones", to="ipam.VRF"),
),
# models.service.serviceobjectgroup
migrations.RemoveField(
Expand All @@ -113,9 +117,11 @@ class Migration(migrations.Migration):
new_name="service_objects",
),
migrations.AlterField(
model_name='serviceobjectgroup',
name='service_objects',
field=models.ManyToManyField(blank=True, related_name='service_object_groups', to='nautobot_firewall_models.ServiceObject'),
model_name="serviceobjectgroup",
name="service_objects",
field=models.ManyToManyField(
blank=True, related_name="service_object_groups", to="nautobot_firewall_models.ServiceObject"
),
),
# models.service.applicationobjectgroup
migrations.RemoveField(
Expand All @@ -131,9 +137,11 @@ class Migration(migrations.Migration):
new_name="application_objects",
),
migrations.AlterField(
model_name='applicationobjectgroup',
name='application_objects',
field=models.ManyToManyField(blank=True, related_name='application_object_groups', to='nautobot_firewall_models.ApplicationObject'),
model_name="applicationobjectgroup",
name="application_objects",
field=models.ManyToManyField(
blank=True, related_name="application_object_groups", to="nautobot_firewall_models.ApplicationObject"
),
),
# models.security_policy.policyrule source
migrations.RemoveField(
Expand Down Expand Up @@ -209,34 +217,46 @@ class Migration(migrations.Migration):
new_name="source_service_groups",
),
migrations.AlterField(
model_name='policyrule',
name='source_address_groups',
field=models.ManyToManyField(blank=True, related_name='source_policy_rules', to='nautobot_firewall_models.AddressObjectGroup'),
model_name="policyrule",
name="source_address_groups",
field=models.ManyToManyField(
blank=True, related_name="source_policy_rules", to="nautobot_firewall_models.AddressObjectGroup"
),
),
migrations.AlterField(
model_name='policyrule',
name='source_addresses',
field=models.ManyToManyField(blank=True, related_name='source_policy_rules', to='nautobot_firewall_models.AddressObject'),
model_name="policyrule",
name="source_addresses",
field=models.ManyToManyField(
blank=True, related_name="source_policy_rules", to="nautobot_firewall_models.AddressObject"
),
),
migrations.AlterField(
model_name='policyrule',
name='source_service_groups',
field=models.ManyToManyField(blank=True, related_name='source_policy_rules', to='nautobot_firewall_models.ServiceObjectGroup'),
model_name="policyrule",
name="source_service_groups",
field=models.ManyToManyField(
blank=True, related_name="source_policy_rules", to="nautobot_firewall_models.ServiceObjectGroup"
),
),
migrations.AlterField(
model_name='policyrule',
name='source_services',
field=models.ManyToManyField(blank=True, related_name='source_policy_rules', to='nautobot_firewall_models.ServiceObject'),
model_name="policyrule",
name="source_services",
field=models.ManyToManyField(
blank=True, related_name="source_policy_rules", to="nautobot_firewall_models.ServiceObject"
),
),
migrations.AlterField(
model_name='policyrule',
name='source_user_groups',
field=models.ManyToManyField(blank=True, related_name='policy_rules', to='nautobot_firewall_models.UserObjectGroup'),
model_name="policyrule",
name="source_user_groups",
field=models.ManyToManyField(
blank=True, related_name="policy_rules", to="nautobot_firewall_models.UserObjectGroup"
),
),
migrations.AlterField(
model_name='policyrule',
name='source_users',
field=models.ManyToManyField(blank=True, related_name='policy_rules', to='nautobot_firewall_models.UserObject'),
model_name="policyrule",
name="source_users",
field=models.ManyToManyField(
blank=True, related_name="policy_rules", to="nautobot_firewall_models.UserObject"
),
),
# models.security_policy.policyrule destination
migrations.RemoveField(
Expand Down Expand Up @@ -312,34 +332,46 @@ class Migration(migrations.Migration):
new_name="application_groups",
),
migrations.AlterField(
model_name='policyrule',
name='application_groups',
field=models.ManyToManyField(blank=True, related_name='policy_rules', to='nautobot_firewall_models.ApplicationObjectGroup'),
model_name="policyrule",
name="application_groups",
field=models.ManyToManyField(
blank=True, related_name="policy_rules", to="nautobot_firewall_models.ApplicationObjectGroup"
),
),
migrations.AlterField(
model_name='policyrule',
name='applications',
field=models.ManyToManyField(blank=True, related_name='policy_rules', to='nautobot_firewall_models.ApplicationObject'),
model_name="policyrule",
name="applications",
field=models.ManyToManyField(
blank=True, related_name="policy_rules", to="nautobot_firewall_models.ApplicationObject"
),
),
migrations.AlterField(
model_name='policyrule',
name='destination_address_groups',
field=models.ManyToManyField(blank=True, related_name='destination_policy_rules', to='nautobot_firewall_models.AddressObjectGroup'),
model_name="policyrule",
name="destination_address_groups",
field=models.ManyToManyField(
blank=True, related_name="destination_policy_rules", to="nautobot_firewall_models.AddressObjectGroup"
),
),
migrations.AlterField(
model_name='policyrule',
name='destination_addresses',
field=models.ManyToManyField(blank=True, related_name='destination_policy_rules', to='nautobot_firewall_models.AddressObject'),
model_name="policyrule",
name="destination_addresses",
field=models.ManyToManyField(
blank=True, related_name="destination_policy_rules", to="nautobot_firewall_models.AddressObject"
),
),
migrations.AlterField(
model_name='policyrule',
name='destination_service_groups',
field=models.ManyToManyField(blank=True, related_name='destination_policy_rules', to='nautobot_firewall_models.ServiceObjectGroup'),
model_name="policyrule",
name="destination_service_groups",
field=models.ManyToManyField(
blank=True, related_name="destination_policy_rules", to="nautobot_firewall_models.ServiceObjectGroup"
),
),
migrations.AlterField(
model_name='policyrule',
name='destination_services',
field=models.ManyToManyField(blank=True, related_name='destination_policy_rules', to='nautobot_firewall_models.ServiceObject'),
model_name="policyrule",
name="destination_services",
field=models.ManyToManyField(
blank=True, related_name="destination_policy_rules", to="nautobot_firewall_models.ServiceObject"
),
),
# models.security_policy.policy
migrations.RemoveField(
Expand All @@ -355,9 +387,8 @@ class Migration(migrations.Migration):
new_name="policy_rules",
),
migrations.AlterField(
model_name='policy',
name='policy_rules',
field=models.ManyToManyField(blank=True, related_name='policies', to='nautobot_firewall_models.PolicyRule'),
model_name="policy",
name="policy_rules",
field=models.ManyToManyField(blank=True, related_name="policies", to="nautobot_firewall_models.PolicyRule"),
),
]

13 changes: 8 additions & 5 deletions nautobot_firewall_models/models/security_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class PolicyRule(PrimaryModel):
blank=True, to="nautobot_firewall_models.AddressObject", related_name="destination_policy_rules"
)
destination_address_groups = models.ManyToManyField(
blank=True, to="nautobot_firewall_models.AddressObjectGroup",
blank=True,
to="nautobot_firewall_models.AddressObjectGroup",
related_name="destination_policy_rules",
)
destination_zone = models.ForeignKey(
Expand All @@ -73,10 +74,11 @@ class PolicyRule(PrimaryModel):
related_name="destination_policy_rules",
)
destination_services = models.ManyToManyField(
blank=True,to="nautobot_firewall_models.ServiceObject", related_name="destination_policy_rules"
blank=True, to="nautobot_firewall_models.ServiceObject", related_name="destination_policy_rules"
)
destination_service_groups = models.ManyToManyField(
blank=True,to="nautobot_firewall_models.ServiceObjectGroup",
blank=True,
to="nautobot_firewall_models.ServiceObjectGroup",
related_name="destination_policy_rules",
)
action = models.CharField(choices=choices.ACTION_CHOICES, max_length=20)
Expand All @@ -87,10 +89,10 @@ class PolicyRule(PrimaryModel):
default=get_default_status,
)
applications = models.ManyToManyField(
blank=True,to="nautobot_firewall_models.ApplicationObject", related_name="policy_rules"
blank=True, to="nautobot_firewall_models.ApplicationObject", related_name="policy_rules"
)
application_groups = models.ManyToManyField(
blank=True,to="nautobot_firewall_models.ApplicationObjectGroup", related_name="policy_rules"
blank=True, to="nautobot_firewall_models.ApplicationObjectGroup", related_name="policy_rules"
)
request_id = models.CharField(max_length=100, null=True, blank=True)
description = models.CharField(max_length=200, null=True, blank=True)
Expand Down Expand Up @@ -227,6 +229,7 @@ def __str__(self):
# Through Models
###########################


class PolicyDeviceM2M(BaseModel):
"""Through model to add weight to the the Policy & Device relationship."""

Expand Down
4 changes: 1 addition & 3 deletions nautobot_firewall_models/models/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class Zone(PrimaryModel):
)
name = models.CharField(max_length=100, unique=True, help_text="Name of the zone (e.g. trust)")
vrfs = models.ManyToManyField(to="ipam.VRF", blank=True, related_name="zones")
interfaces = models.ManyToManyField(
to="dcim.Interface", blank=True, related_name="zones"
)
interfaces = models.ManyToManyField(to="dcim.Interface", blank=True, related_name="zones")
status = StatusField(
on_delete=models.PROTECT,
related_name="%(app_label)s_%(class)s_related", # e.g. dcim_device_related
Expand Down
2 changes: 1 addition & 1 deletion nautobot_firewall_models/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def create_env():
dynamic_group = DynamicGroup.objects.create(
name="North Texas", content_type=ContentType.objects.get_for_model(Device)
)
dynamic_group.filter = {"location": ["dfw"]}
dynamic_group.filter = {"location": ["DFW"]}
dynamic_group.validated_save()
PolicyDeviceM2M.objects.create(policy=pol1, device=dev1, weight=150)
PolicyDeviceM2M.objects.create(policy=pol2, device=dev1, weight=200)
Expand Down

0 comments on commit 583d447

Please sign in to comment.