Skip to content

Commit

Permalink
Merge pull request #642 from nautobot/bootstrap_fix_imports
Browse files Browse the repository at this point in the history
Bootstrap: fix imports for ipam models
  • Loading branch information
bile0026 authored Jan 7, 2025
2 parents 436b504 + 58f2f84 commit 668308c
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 92 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.4"
- name: "Linting: ruff format"
run: "poetry run invoke ruff --action format"
ruff-lint:
Expand All @@ -36,6 +38,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.4"
- name: "Linting: ruff"
run: "poetry run invoke ruff --action lint"
check-docs-build:
Expand All @@ -47,6 +51,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.4"
- name: "Check Docs Build"
run: "poetry run invoke build-and-check-docs"
poetry:
Expand All @@ -58,6 +64,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.4"
- name: "Checking: poetry lock file"
run: "poetry run invoke lock --check"
yamllint:
Expand All @@ -69,6 +77,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.4"
- name: "Linting: yamllint"
run: "poetry run invoke yamllint"
check-in-docker:
Expand All @@ -91,6 +101,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.4"
- name: "Constrain Nautobot version and regenerate lock file"
env:
INVOKE_NAUTOBOT_SSOT_LOCAL: "true"
Expand Down Expand Up @@ -146,6 +158,8 @@ jobs:
uses: "actions/checkout@v4"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.4"
- name: "Constrain Nautobot version and regenerate lock file"
env:
INVOKE_NAUTOBOT_SSOT_LOCAL: "true"
Expand Down Expand Up @@ -187,6 +201,8 @@ jobs:
fetch-depth: "0"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v6"
with:
poetry-version: "1.8.4"
- name: "Check for changelog entry"
run: |
git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
Expand Down
1 change: 1 addition & 0 deletions changes/641.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed incorrectly nested imports within if block used for Device Lifecycle Models.
182 changes: 94 additions & 88 deletions nautobot_ssot/integrations/bootstrap/diffsync/models/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,148 +402,154 @@ def delete(self):
return self


if LIFECYCLE_MGMT:
class BootstrapNamespace(Namespace):
"""Bootstrap implementation of Bootstrap Namespace model."""

class BootstrapSoftware(Software):
"""Bootstrap implementation of Bootstrap Software model."""
@classmethod
def create(cls, diffsync, ids, attrs):
"""Create Namespace in Bootstrap from BootstrapNamespace object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create Software in Bootstrap from BootstrapSoftware object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)
def update(self, attrs):
"""Update Namespace in Bootstrap from BootstrapNamespace object."""
return super().update(attrs)

def update(self, attrs):
"""Update Software in Bootstrap from BootstrapSoftware object."""
return super().update(attrs)
def delete(self):
"""Delete Namespace in Bootstrap from BootstrapNamespace object."""
return self

def delete(self):
"""Delete Software in Bootstrap from BootstrapSoftware object."""
return self

class BootstrapSoftwareImage(SoftwareImage):
"""Bootstrap implementation of Bootstrap SoftwareImage model."""
class BootstrapRiR(RiR):
"""Bootstrap implementation of Bootstrap RiR model."""

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create SoftwareImage in Bootstrap from BootstrapSoftwareImage object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)
@classmethod
def create(cls, diffsync, ids, attrs):
"""Create RiR in Bootstrap from BootstrapRiR object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

def update(self, attrs):
"""Update SoftwareImage in Bootstrap from BootstrapSoftwareImage object."""
return super().update(attrs)
def update(self, attrs):
"""Update RiR in Bootstrap from BootstrapRiR object."""
return super().update(attrs)

def delete(self):
"""Delete SoftwareImage in Bootstrap from BootstrapSoftwareImage object."""
return self
def delete(self):
"""Delete RiR in Bootstrap from BootstrapRiR object."""
return self

class BootstrapValidatedSoftware(ValidatedSoftware):
"""Bootstrap implementation of Bootstrap ValidatedSoftware model."""

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create ValidatedSoftware in Bootstrap from BootstrapValidatedSoftware object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)
class BootstrapVLANGroup(VLANGroup):
"""Bootstrap implementation of Bootstrap VLANGroup model."""

def update(self, attrs):
"""Update ValidatedSoftware in Bootstrap from BootstrapValidatedSoftware object."""
return super().update(attrs)
@classmethod
def create(cls, diffsync, ids, attrs):
"""Create VLANGroup in Bootstrap from BootstrapVLANGroup object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

def delete(self):
"""Delete ValidatedSoftware in Bootstrap from BootstrapValidatedSoftware object."""
return self
def update(self, attrs):
"""Update VLANGroup in Bootstrap from BootstrapVLANGroup object."""
return super().update(attrs)

class BootstrapNamespace(Namespace):
"""Bootstrap implementation of Bootstrap Namespace model."""
def delete(self):
"""Delete VLANGroup in Bootstrap from BootstrapVLANGroup object."""
return self

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create Namespace in Bootstrap from BootstrapNamespace object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

def update(self, attrs):
"""Update Namespace in Bootstrap from BootstrapNamespace object."""
return super().update(attrs)
class BootstrapVLAN(VLAN):
"""Bootstrap implementation of Bootstrap VLAN model."""

def delete(self):
"""Delete Namespace in Bootstrap from BootstrapNamespace object."""
return self
@classmethod
def create(cls, diffsync, ids, attrs):
"""Create VLAN in Bootstrap from BootstrapVLAN object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

class BootstrapRiR(RiR):
"""Bootstrap implementation of Bootstrap RiR model."""
def update(self, attrs):
"""Update VLAN in Bootstrap from BootstrapVLAN object."""
return super().update(attrs)

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create RiR in Bootstrap from BootstrapRiR object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)
def delete(self):
"""Delete VLAN in Bootstrap from BootstrapVLAN object."""
return self

def update(self, attrs):
"""Update RiR in Bootstrap from BootstrapRiR object."""
return super().update(attrs)

def delete(self):
"""Delete RiR in Bootstrap from BootstrapRiR object."""
return self
class BootstrapVRF(VRF):
"""Bootstrap implementation of Bootstrap VRF model."""

class BootstrapVLANGroup(VLANGroup):
"""Bootstrap implementation of Bootstrap VLANGroup model."""
@classmethod
def create(cls, diffsync, ids, attrs):
"""Create VRF in Bootstrap from BootstrapVRF object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create VLANGroup in Bootstrap from BootstrapVLANGroup object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)
def update(self, attrs):
"""Update VRF in Bootstrap from BootstrapVRF object."""
return super().update(attrs)

def update(self, attrs):
"""Update VLANGroup in Bootstrap from BootstrapVLANGroup object."""
return super().update(attrs)
def delete(self):
"""Delete VRF in Bootstrap from BootstrapVRF object."""
return self

def delete(self):
"""Delete VLANGroup in Bootstrap from BootstrapVLANGroup object."""
return self

class BootstrapVLAN(VLAN):
"""Bootstrap implementation of Bootstrap VLAN model."""
class BootstrapPrefix(Prefix):
"""Bootstrap implementation of Bootstrap Prefix model."""

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create Prefix in Bootstrap from BootstrapPrefix object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

def update(self, attrs):
"""Update Prefix in Bootstrap from BootstrapPrefix object."""
return super().update(attrs)

def delete(self):
"""Delete Prefix in Bootstrap from BootstrapPrefix object."""
return self


if LIFECYCLE_MGMT:

class BootstrapSoftware(Software):
"""Bootstrap implementation of Bootstrap Software model."""

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create VLAN in Bootstrap from BootstrapVLAN object."""
"""Create Software in Bootstrap from BootstrapSoftware object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

def update(self, attrs):
"""Update VLAN in Bootstrap from BootstrapVLAN object."""
"""Update Software in Bootstrap from BootstrapSoftware object."""
return super().update(attrs)

def delete(self):
"""Delete VLAN in Bootstrap from BootstrapVLAN object."""
"""Delete Software in Bootstrap from BootstrapSoftware object."""
return self

class BootstrapVRF(VRF):
"""Bootstrap implementation of Bootstrap VRF model."""
class BootstrapSoftwareImage(SoftwareImage):
"""Bootstrap implementation of Bootstrap SoftwareImage model."""

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create VRF in Bootstrap from BootstrapVRF object."""
"""Create SoftwareImage in Bootstrap from BootstrapSoftwareImage object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

def update(self, attrs):
"""Update VRF in Bootstrap from BootstrapVRF object."""
"""Update SoftwareImage in Bootstrap from BootstrapSoftwareImage object."""
return super().update(attrs)

def delete(self):
"""Delete VRF in Bootstrap from BootstrapVRF object."""
"""Delete SoftwareImage in Bootstrap from BootstrapSoftwareImage object."""
return self

class BootstrapPrefix(Prefix):
"""Bootstrap implementation of Bootstrap Prefix model."""
class BootstrapValidatedSoftware(ValidatedSoftware):
"""Bootstrap implementation of Bootstrap ValidatedSoftware model."""

@classmethod
def create(cls, diffsync, ids, attrs):
"""Create Prefix in Bootstrap from BootstrapPrefix object."""
"""Create ValidatedSoftware in Bootstrap from BootstrapValidatedSoftware object."""
return super().create(diffsync=diffsync, ids=ids, attrs=attrs)

def update(self, attrs):
"""Update Prefix in Bootstrap from BootstrapPrefix object."""
"""Update ValidatedSoftware in Bootstrap from BootstrapValidatedSoftware object."""
return super().update(attrs)

def delete(self):
"""Delete Prefix in Bootstrap from BootstrapPrefix object."""
"""Delete ValidatedSoftware in Bootstrap from BootstrapValidatedSoftware object."""
return self
6 changes: 2 additions & 4 deletions nautobot_ssot/tests/infoblox/test_tags_and_cfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ def test_objects_synced_to_infoblox_are_tagged(self):
"""Ensure objects synced to Infoblox have 'SSoT Synced to Infoblox' tag applied."""
create_prefix_relationship()
nb_prefix = Prefix(
network="10.0.0.0",
prefix_length=8,
prefix="10.0.0.0/8",
description="Test Network",
type="network",
status=Status.objects.get_for_model(Prefix).first(),
Expand Down Expand Up @@ -204,8 +203,7 @@ def test_cfs_have_correct_content_types_set(self):
def test_cf_updated_for_objects_synced_to_infoblox(self):
"""Ensure objects synced to Infoblox have cf 'ssot_synced_to_infoblox' correctly updated."""
nb_prefix = Prefix(
network="10.0.0.0",
prefix_length=8,
prefix="10.0.0.0/8",
description="Test Network",
type="network",
status=Status.objects.get_for_model(Prefix).first(),
Expand Down

0 comments on commit 668308c

Please sign in to comment.