Skip to content

Commit

Permalink
Merge pull request #819 from NethServer/issue818
Browse files Browse the repository at this point in the history
ns-api: redirects, expand object support
  • Loading branch information
gsanchietti authored Oct 4, 2024
2 parents 39fc078 + 9bded6e commit 224edf9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/ns-api/files/ns.redirects
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,17 @@ def list_zones():
ret['zones'].append(name)
return ret

def filter_ranges(obj):
# remove host sets with IP ranges
if 'subtype' in obj and obj['subtype'] == 'host_set':
for ip in obj.get('ipaddr', []):
if '-' in ip:
return False
return True

def list_object_suggestions(u):
return {
"ns_src": objects.list_domain_sets(u),
"ns_src": list(filter(filter_ranges, objects.list_objects(u, include_domain_sets=True, include_host_sets=True, expand=True))),
"ns_dst": objects.list_objects(u, singleton_only=True, include_domain_sets=False)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ns-objects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ Objects can be used inside the following fields:

Supported object types depends on the field:

- `ns_src` can be any type of object
- `ns_src` can be any type of object, except for host sets containing an IP range
- `ns_dst` can be an object with only one IP address, like:
- a static lease, a record of type `host` from `dhcp` db
- a dns record, a record of type `domain` from `dhcp` db
Expand Down

0 comments on commit 224edf9

Please sign in to comment.