def delete_all(self, folder='Common'): """ Delete Route Entries """ folder = str(folder).replace('/', '') request_url = self.bigip.icr_url + '/net/route/' request_url += '?$select=name,selfLink' request_filter = 'partition eq ' + folder request_url += '&$filter=' + request_filter response = self.bigip.icr_session.get(request_url, timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: response_obj = json.loads(response.text) if 'items' in response_obj: for item in response_obj['items']: if item['name'].startswith(self.OBJ_PREFIX): response = self.bigip.icr_session.delete( self.bigip.icr_link(item['selfLink']), timeout=const.CONNECTION_TIMEOUT) if response.status_code > 400 and \ response.status_code != 404: Log.error('route', response.text) raise exceptions.RouteDeleteException( response.text) return True else: Log.error('route', response.text) raise exceptions.RouteQueryException(response.text) return False
def delete_domain(self, folder='Common'): folder = str(folder).replace('/', '') if not folder == 'Common': request_url = self.bigip.icr_url + '/net/route-domain/' request_url += '~' + folder + '~' + folder response = self.bigip.icr_session.delete( request_url, timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: return True elif response.status_code != 404: Log.error('route-domain', response.text) raise exceptions.RouteDeleteException(response.text) return True
def delete(self, name=None, folder='Common'): if name: folder = str(folder).replace('/', '') request_url = self.bigip.icr_url + '/ltm/rule/' request_url += '~' + folder + '~' + name response = self.bigip.icr_session.delete(request_url, timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: return True elif response.status_code == 404: return True else: Log.error('rule', response.text) raise exceptions.RouteDeleteException(response.text) return False