def delete_all(self, folder='Common'): folder = str(folder).replace('/', '') request_url = self.bigip.icr_url + '/net/tunnels/tunnel/' 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): self.delete_all_fdb_entries(item['name'], folder) 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('VXLAN', response.text) raise exceptions.VXLANDeleteException( response.text) elif response.status_code != 404: Log.error('VXLAN', response.text) raise exceptions.VXLANQueryException(response.text) return True
def delete_tunnel(self, name=None, folder='Common'): """ Delete vxlan multipoint tunnel """ folder = str(folder).replace('/', '') # delete arp and fdb records for this tunnel first request_url = self.bigip.icr_url + '/net/fdb/tunnel/' request_url += '~' + folder + '~' + name response = self.bigip.icr_session.get(request_url, timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: response_obj = json.loads(response.text) if const.FDB_POPULATE_STATIC_ARP: if 'records' in response_obj: for record in response_obj['records']: self.bigip.arp.delete_by_mac( mac_address=record['name'], folder=folder) payload = dict() payload['records'] = [] tunnel_link = self.bigip.icr_link(response_obj['selfLink']) response = self.bigip.icr_session.put( tunnel_link, data=json.dumps(payload), timeout=const.CONNECTION_TIMEOUT) response = self.bigip.icr_session.delete( tunnel_link, timeout=const.CONNECTION_TIMEOUT) if response.status_code > 399: Log.error('fdb', response.text) raise exceptions.VXLANDeleteException(response.text) elif response.status_code != 404: Log.error('fdb', response.text) raise exceptions.VXLANQueryException(response.text) request_url = self.bigip.icr_url + '/net/tunnels/tunnel/' 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('VXLAN', response.text) raise exceptions.VXLANDeleteException(response.text)
def delete_profile(self, name=None, folder='Common'): folder = str(folder).replace('/', '') request_url = self.bigip.icr_url + '/net/tunnels/vxlan/' 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('VXLAN', response.text) raise exceptions.VXLANDeleteException(response.text) return False