Skip to content

Commit

Permalink
Merge pull request #10 from sukiyaki/sourcery/main
Browse files Browse the repository at this point in the history
Sourcery refactored main branch
  • Loading branch information
mochipon authored Oct 18, 2022
2 parents 9de4865 + 0e675d6 commit 0259f12
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion octodns_netbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _populate_PTR(self, zone: Zone, family: Literal[4, 6]) -> typing.List[Rr]:
# take the first fqdn
fqdns = self._get_fqdns_list(
ipam_record[self.field_name],
len_limit=1 if not self.multivalue_ptr else None,
len_limit=None if self.multivalue_ptr else 1,
)

for fqdn in fqdns:
Expand Down
8 changes: 4 additions & 4 deletions octodns_netbox/reversename.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def to_network_v4(zone: Zone) -> ipaddress.IPv4Network:
if not last_label_parsed:
raise ValueError("Faild to parse the zone name")

if last_label_parsed.group(2):
if last_label_parsed[2]:
# non-octet boundary delegation detected
# remove netmask and save it to the result
last_octect = last_label_parsed.group(1)
last_octect = last_label_parsed[1]
labels[0] = last_octect
netmask = int(last_label_parsed.group(2)[1:])
netmask = int(last_label_parsed[2][1:])

labels = ["0"] * offset + labels
prefix_str = ".".join(reversed(labels))
Expand Down Expand Up @@ -76,6 +76,6 @@ def from_address(

zone_labels = zone.name.split(".")
standard_labels = fqdn.split(".")
for i in range(0, len(zone_labels) - len(standard_labels) + 1):
for i in range(len(zone_labels) - len(standard_labels) + 1):
zone_labels.insert(0, standard_labels[i])
return ".".join(zone_labels)
2 changes: 1 addition & 1 deletion tests/test_octodns_netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def test_populate_A_and_AAAA_field_is_dns_name_populate_subdomains_is_False(self
def test_populate_A_and_AAAA_field_is_dns_name_populate_and_defined_sub_zones(
self, caplog
):
zone = Zone("example.com.", set(["subdomain1"]))
zone = Zone("example.com.", {"subdomain1"})
source = NetboxSource(
"test",
url="http://netbox.example.com/",
Expand Down

0 comments on commit 0259f12

Please sign in to comment.