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

RE-211 - Update IPAM #18

Merged
merged 3 commits into from
Jun 10, 2019
Merged

RE-211 - Update IPAM #18

merged 3 commits into from
Jun 10, 2019

Conversation

lawnmowerlatte
Copy link
Contributor

@lawnmowerlatte lawnmowerlatte commented Jun 8, 2019

Add Scopes, Scope, tests and top level helpers
Add Reservations, Reservation, tests and top level helpers
Add DHCP Option manipulators to Addresses (and tests)
Added create_scope, scopes, reserve and reservations to Scopegroups
Added reserve to Address
Use new API routes and update tests
Allow 204 responses for all transport options

    - Extend basic to accept params (to match interface with requests and twisted)
    - Extend all three transports to accept 2xx
    - Extend all three transports to accept empty responses
    - Update Scopegroups object with updted API
    - Add Scopes and Reservations
    - Add high level helpers for Scopes and Reservations
    - Remove loadScopeGroupbyName
    - Rename loadScopeGroupbyID to loadScopeGroup
    - Add Address.reserve and Scopegroup.reserve
    - Add Scopegroup.reservations
    - Add Scope and Reservation
    - Add tests for Scopes and Reservations
    - Update tests for Scopegroups
    - Updated dhcp_option functions
    - Add tests for options and scopes
    - Remove hardcoded test value
    - Remove loadScopeGroupbyName
    - Add createReservation, loadReservation, createScope and loadScope
    - Add Scopes.retrieve
    - Add test for Scopes.retrieve
    - Make Scopes.create actually return data
    - Add Scopegroup.scope and Scopegroups.create_scope
    - Add Scope object
    - Use scopegroup instead of scope_group
@@ -299,27 +299,16 @@ def createAddress(self, prefix, type, network_id, callback=None, errback=None, *
address = ns1.ipam.Address(self.config, prefix=prefix, type=type, network=network)
return address.create(callback=callback, errback=errback, **kwargs)

def loadScopeGroupbyID(self, id, callback=None, errback=None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to loadScopeGroup


:param int id: id of an existing ScopeGroup
"""
import ns1.ipam
scope_group = ns1.ipam.Scopegroup(self.config, id=id)
return scope_group.load(callback=callback, errback=errback)

def loadScopeGroupbyName(self, name, service_group_id, callback=None, errback=None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, this is no longer consistent since name is not globally unique and service group ID is not returned.

@@ -347,14 +365,7 @@ def success(result, *args):
return self

if self.id is None:
if self.dhcp4 is None or self.dhcp6 is None or self.name is None or self.service_group_id is None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed possibility of searching by name, ID is the only viable search criteria.

resp,
body)
# TODO make sure json is valid if there is a body
if body:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to allow 204 status code

@@ -26,7 +26,7 @@ def __init__(self, config):
TransportBase.__init__(self, config, self.__module__)
self._timeout = self._config.get('timeout', socket._GLOBAL_DEFAULT_TIMEOUT)

def send(self, method, url, headers=None, data=None, files=None,
def send(self, method, url, headers=None, data=None, files=None, params=None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to make basic match requests and twisted interfaces

@@ -37,7 +37,8 @@ def send(self, method, url, headers=None, data=None, params=None, files=None,
self._logHeaders(headers)
resp = self.REQ_MAP[method](url, headers=headers, verify=self._verify,
data=data, files=files, params=params, timeout=self._timeout)
if resp.status_code != 200:

if resp.status_code < 200 or resp.status_code >= 300:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow 2xx

resp.text)

# TODO make sure json is valid if a body is returned
if resp.text:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to allow 204

@@ -110,7 +110,7 @@ def _onBody(self, body, response, user_callback, data, headers):
response.request.absoluteURI,
response.code,
data))
if response.code != 200:
if response.code < 200 or response.code >= 300:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow 2xx

response,
body)

if body:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to allow 204

Copy link
Contributor

@saxmfone1 saxmfone1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@mburtless mburtless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 🔥, loving the test coverage. LGTM

@lawnmowerlatte lawnmowerlatte merged commit fd7c088 into master Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants