Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #92 #93 & #94 #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions ns1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,13 @@ def createScope(
return scope.create(callback=callback, errback=errback, **kwargs)

def loadScope(
self, scopegroup_id, address_id, callback=None, errback=None
):
self,
id,
callback=None,
errback=None):
import ns1.ipam

scope = ns1.ipam.Scope(self.config, scopegroup_id, address_id)
# pass dummy values for scope group and address id, as these are not used here anyways
scope = ns1.ipam.Scope(self.config, None, None, id)

return scope.load(callback=callback, errback=errback)

Expand Down
1 change: 1 addition & 0 deletions ns1/ipam.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ def load(self, callback=None, errback=None, reload=False):

def success(result, *args):
self.data = result
self.scopegroup_id = result["scope_group_id"]
self.address_id = result["address_id"]
self.options = result["options"]

Expand Down
25 changes: 18 additions & 7 deletions ns1/rest/ipam.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ class Addresses(resource.BaseResource):
ROOT = "ipam/address"
INT_FIELDS = [
"network_id",
"address_id",
"root_address_id",
" merged_address_id",
"parent_id",
"scope_group_id",
]
PASSTHRU_FIELDS = ["prefix", "status", "desc", "tags", "reserve"]
PASSTHRU_FIELDS = ["name", "prefix", "status", "desc", "tags", "reserve", "hostname", "forward_zone_handle",
"reverse_zone_handle", ]
BOOL_FIELDS = ["parent"]

def _buildBody(self, **kwargs):
Expand Down Expand Up @@ -137,12 +136,15 @@ def retrieve_dhcp_option(self, address_id, callback=None, errback=None):
# callback=callback,
# errback=errback)

def search(self, network_id, prefix, callback=None, errback=None):
def search(self, callback=None, errback=None, **kwargs):
params = {k: v for k, v in kwargs if
k in ['network_id', 'asc_desc', 'mask', 'max', 'name', 'order_by', 'prefix', 'tag', 'status']}
return self._make_request(
"GET",
"%s/search/%s/%s" % (self.ROOT, network_id, prefix),
"%s/search" % (self.ROOT),
callback=callback,
errback=errback,
params=params,
)


Expand Down Expand Up @@ -218,7 +220,7 @@ def report(self, network_id, callback=None, errback=None):
class Scopegroups(resource.BaseResource):
ROOT = "dhcp/scopegroup"
INT_FIELDS = ["id", "dhcp_service_id", "valid_lifetime_secs"]
PASSTHRU_FIELDS = ["dhcpv4", "dhcpv6", "name", "tags"]
PASSTHRU_FIELDS = ["dhcpv4", "dhcpv6", "name", "tags", "template", "options", ]
BOOL_FIELDS = ["enabled", "echo_client_id"]

def _buildBody(self, **kwargs):
Expand Down Expand Up @@ -269,6 +271,15 @@ def retrieve(self, scope_group_id, callback=None, errback=None):
errback=errback,
)

def expand(self, scope_group_id, callback=None, errback=None):
return self._make_request(
"GET",
"%s/%s" % (self.ROOT, scope_group_id),
callback=callback,
errback=errback,
params={'expand': True}
)


class Scopes(resource.BaseResource):
ROOT = "dhcp/scope"
Expand Down