Skip to content

Commit ee8f471

Browse files
committed
Merge branch 'develop'
2 parents 81163b1 + a5af25a commit ee8f471

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v1.2.1 (2021-04-20)
4+
5+
### Fixed
6+
7+
- #37 - Custom fields are now handled correctly on the second pass of the importer as well
8+
39
## v1.2.0 (2021-04-14)
410

511
### Added

nautobot_netbox_importer/diffsync/adapters/nautobot.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,11 @@ def load(self):
121121
def restore_required_custom_fields(self, source: DiffSync):
122122
"""Post-synchronization cleanup function to restore any 'required=True' custom field records."""
123123
self.logger.debug("Restoring the 'required=True' flag on any such custom fields")
124-
for customfield in source.get_all(source.customfield):
125-
if customfield.actual_required:
126-
# We don't want to change the DiffSync record's `required` flag, only the Nautobot record
127-
customfield.update_nautobot_record(
128-
customfield.nautobot_model(),
129-
ids=customfield.get_identifiers(),
130-
attrs={"required": True},
131-
multivalue_attrs={},
132-
)
124+
for source_customfield in source.get_all(source.customfield):
125+
if source_customfield.actual_required:
126+
# Update both the local DiffSync record (so that on the second-pass resync we again reset required=False)
127+
# and the Nautobot record (so that the end state is correct)
128+
self.get(self.customfield, source_customfield.get_unique_id()).update({"required": True})
133129

134130
def sync_complete(self, source: DiffSync, *args, **kwargs):
135131
"""Callback invoked after completing a sync operation in which changes occurred."""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "nautobot-netbox-importer"
3-
version = "1.2.0"
3+
version = "1.2.1"
44
description = "Data importer from NetBox 2.10.x to Nautobot"
55
authors = ["Network to Code, LLC <opensource@networktocode.com>"]
66

0 commit comments

Comments
 (0)