Skip to content

Commit

Permalink
api v2: pool actions
Browse files Browse the repository at this point in the history
  • Loading branch information
edersonbrilhante committed Nov 26, 2015
1 parent f95620f commit e69a926
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 30 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
- Mauricio Leoncio dos Santos
- Mateus Constanzo
- [Silvano Buback](https://github.com/snbuback)
- [Ederson Brilhante](https://github.com/edersonbrilhante)
3 changes: 2 additions & 1 deletion networkapiclient/ApiGenericClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def put(self, uri, data=None):
error = self._parse(request.text)
raise NetworkAPIClientError(error.get('detail', ''))

def delete(self, uri):
def delete(self, uri, data=None):
"""
Sends a DELETE request.
Expand All @@ -132,6 +132,7 @@ def delete(self, uri):

request = requests.delete(
self._url(uri),
data=json.dumps(data),
auth=self._auth_basic(),
headers=self._header()
)
Expand Down
68 changes: 41 additions & 27 deletions networkapiclient/Pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__(self, networkapi_url, user, password, user_ldap=None):
user_ldap
)


def poolmember_state(self, pools):
"""
Enable/Disable pool member by list
Expand All @@ -51,20 +50,19 @@ def poolmember_state(self, pools):
"""

data = dict()

uri = "api/pools/poolmember_state/"

data["pools"] = pools

return self.post(uri, data=data)

return self.post(uri, data=data)

def list_all_members(self, id_pools, checkstatus=False):
"""
Return pool member list by POST request method
param: {"id_pools":[<id_pool>], "checkstatus":"<1 or 0>"}
return: Following dictionary: {
"pools": [
{
Expand All @@ -77,15 +75,14 @@ def list_all_members(self, id_pools, checkstatus=False):
}
"""
data = dict()

uri = "api/pools/get_all_members/"

data["id_pools"] = id_pools
data["checkstatus"] = checkstatus

return self.post(uri, data=data)


def list_all(self, environment_id, pagination):
"""
List All Pools To Populate Datatable
Expand Down Expand Up @@ -117,7 +114,6 @@ def list_all(self, environment_id, pagination):

return self.post(uri, data=data)


def list_all_by_reqvip(self, id_vip, pagination):
"""
List All Pools To Populate Datatable
Expand Down Expand Up @@ -179,9 +175,31 @@ def inserir(self, identifier, default_port, environment, balancing, healthcheck_

return self.post(uri, data=data)

def save_pool(self, pools):
"""
Save pool
param: Following dictionary: {
"pools": [
{
"server_pool": {
},
"server_pool_members": [
]
}
]
}
"""

data = dict()
data["pools"] = pools

uri = "api/pools/v2/"

return self.post(uri, data)

def save(self, id, identifier, default_port, environment, balancing, healthcheck_type, healthcheck_expect,
healthcheck_request, maxcom, ip_list_full, nome_equips, id_equips, priorities,
weight, ports_reals, id_pool_member, servicedownaction=None):
healthcheck_request, maxcom, ip_list_full, nome_equips, id_equips, priorities,
weight, ports_reals, id_pool_member, servicedownaction=None):

uri = "api/pools/save/"

Expand Down Expand Up @@ -257,7 +275,7 @@ def update(self, id_server_pool, default_port, balancing, healthcheck_type, heal
def list_all_members_by_pool(self, id_server_pool, checkstatus=False, pagination=None):

data = dict()

uri = "api/pools/get_all_members/%s/?checkstatus=%s" % (id_server_pool, checkstatus)

if pagination:
Expand All @@ -271,7 +289,6 @@ def list_all_members_by_pool(self, id_server_pool, checkstatus=False, pagination
return self.get(uri)

def get_equip_by_ip(self, id_ip):

"""
Get equipment by IP id
Expand Down Expand Up @@ -319,7 +336,7 @@ def list_healthchecks(self):

return self.get(uri)

def delete(self, ids):
def delete_pool(self, ids):
"""
Delete Pools
Expand All @@ -345,7 +362,7 @@ def get_by_pk(self, pk):

return self.get(uri)

def remove(self, ids):
def remove(self, pools):
"""
Remove Pools Running Script And Update to Not Created
Expand All @@ -359,17 +376,17 @@ def remove(self, ids):
"""

data = dict()
data["ids"] = ids
data["pools"] = pools

uri = "api/pools/remove/"
uri = "api/pools/v2/"

return self.post(uri, data)
return self.delete(uri, data)

def create(self, ids):
def create(self, pools):
"""
Create Pools Running Script And Update to Created
:param ids: List of ids
:param pools: List of pools
:return: None on success
Expand All @@ -380,11 +397,11 @@ def create(self, ids):
"""

data = dict()
data["ids"] = ids
data["pools"] = pools

uri = "api/pools/create/"
uri = "api/pools/v2/"

return self.post(uri, data)
return self.put(uri, data)

def enable(self, ids):
"""
Expand Down Expand Up @@ -499,7 +516,6 @@ def list_by_environmet_vip(self, environment_vip_id):

return self.get(uri)


def list_environments_with_pools(self):
"""
"""
Expand All @@ -508,7 +524,6 @@ def list_environments_with_pools(self):

return self.get(uri)


def list_all_environment_related_environment_vip(self):
"""
"""
Expand All @@ -517,9 +532,8 @@ def list_all_environment_related_environment_vip(self):
return self.get(uri)

def get_available_ips_to_add_server_pool(self, equip_name, id_ambiente):

"""
"""
uri = "api/pools/getipsbyambiente/{}/{}/".format(equip_name, id_ambiente)

return self.get(uri)
return self.get(uri)
2 changes: 1 addition & 1 deletion networkapiclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

MAJOR_VERSION = '0'
MINOR_VERSION = '6'
PATCH_VERSION = '10'
PATCH_VERSION = '15'
VERSION = '.'.join((MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION,))

2 changes: 1 addition & 1 deletion networkapiclient/version_control.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CLIENT_VERSION = '0.6.10'
CLIENT_VERSION = '0.6.15'

0 comments on commit e69a926

Please sign in to comment.