diff --git a/.github/workflows/main_ci.yml b/.github/workflows/main_ci.yml index 9545db7..e86a39d 100644 --- a/.github/workflows/main_ci.yml +++ b/.github/workflows/main_ci.yml @@ -11,8 +11,8 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ["3.11"] - netbox-version: ["v4.0.3"] + python-version: ["3.12"] + netbox-version: ["v4.3.5"] services: redis: image: redis diff --git a/.github/workflows/pr_ci.yml b/.github/workflows/pr_ci.yml index d05d6d2..174ca47 100644 --- a/.github/workflows/pr_ci.yml +++ b/.github/workflows/pr_ci.yml @@ -14,8 +14,8 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: ["3.11"] - netbox-version: ["v4.0.3"] + python-version: ["3.12"] + netbox-version: ["v4.3.5"] services: redis: image: redis diff --git a/netbox_cloudflare_plugin/__init__.py b/netbox_cloudflare_plugin/__init__.py index 342d167..05b49a5 100644 --- a/netbox_cloudflare_plugin/__init__.py +++ b/netbox_cloudflare_plugin/__init__.py @@ -8,9 +8,9 @@ class NetBoxCloudflareConfig(PluginConfig): name = "netbox_cloudflare_plugin" verbose_name = " NetBox Cloudflare Plugin" description = "Manage Cloudflare" - version = "0.3.0" + version = "0.4.0" base_url = "cloudflare" - min_version = "4.0.0" + min_version = "4.3.0" author= "Vincent Simonin " author_email= "vincent@saashup.com" default_settings = { diff --git a/netbox_cloudflare_plugin/models.py b/netbox_cloudflare_plugin/models.py index 1ac46fa..ee27e98 100644 --- a/netbox_cloudflare_plugin/models.py +++ b/netbox_cloudflare_plugin/models.py @@ -60,6 +60,8 @@ def get_absolute_url(self): class DnsRecord(NetBoxModel): """DNS entry definition class""" + is_deleted_manually = False + CNAME = "CNAME" A = "A" @@ -142,3 +144,9 @@ def __str__(self): def get_absolute_url(self): """override""" return reverse("plugins:netbox_cloudflare_plugin:dnsrecord", args=[self.pk]) + + def delete(self, using=None, keep_parents=False): + """override""" + self.is_deleted_manually = True + + return super().delete(using, keep_parents) diff --git a/netbox_cloudflare_plugin/signals.py b/netbox_cloudflare_plugin/signals.py index e0c4f17..6fd0aec 100644 --- a/netbox_cloudflare_plugin/signals.py +++ b/netbox_cloudflare_plugin/signals.py @@ -59,9 +59,9 @@ def create_dnsrecord(instance, **_kwargs): @receiver(pre_delete, sender=DnsRecord) def delete_dnsrecord(instance, **_kwargs): - """Delte a DNS Record on Cloudflare""" + """Delete a DNS Record on Cloudflare""" - if isinstance(_kwargs["origin"], DnsRecord): + if instance.is_deleted_manually is True: client = CloudflareDnsClient( instance.zone, settings.PLUGINS_CONFIG["netbox_cloudflare_plugin"]["cloudflare_base_url"], diff --git a/pyproject.toml b/pyproject.toml index 4dc19f3..f552231 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-cloudflare-plugin" -version = "0.3.0" +version = "0.4.0" authors = [ { name="Vincent Simonin", email="vincent@saashup.com" } ] description = "Manage Cloudflare with Netbox & style." readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.12" classifiers = [ "Programming Language :: Python :: 3", ]