def arp_byip_delete_api(): """ Implementation Notes Deletes ARP record for given IP address. Response Class (Status 200) Parameters { networkType (string): Network type. Valid values are 'VLAN' and 'VXLAN'. , segmentationId (string): VLAN id or VXLAN vni. , ipAddress (string): IP address. } """ try: req = models.ArpRequest(request.json) req.validate() except Exception as e: result = { "NeutronError": { "message": "Request check failed: %s" % e, "type": "BadRequest", "detail": "" } } log.error(result) return Response(json.dumps(result)), 500 if req.ip_address is None: result = { "NeutronError": { "message": "Request check failed, ipAddress not given", "type": "BadRequest", "detail": "" } } log.error(result) return Response(json.dumps(result)), 500 resp, code = get_arp_byip(req, True) if code != 200: return resp, code resp['macAddress'] = resp['mac'] del resp['mac'] del resp['ip'] req = models.ArpRequest(resp) return delete_arp_bymac(req)
def arp_bymac_get_api(): """ Implementation Notes Returns IP address for given MAC address. Response Class (Status 200) ArpRecord { ip (string, optional): IP addresss. , mac (string, optional): MAC address. , networkType (string, optional): Network type. Valid values are 'VLAN' and 'VXLAN'. , segmentationId (integer, optional): VLAN id or VXLAN vni } Parameters { networkType (string): Network type. Valid values are 'VLAN' and 'VXLAN'. , segmentationId (string): VLAN id or VXLAN vni. , macAddress (string): MAC address. } """ try: req = models.ArpRequest(request.json) req.validate() except Exception as e: result = { "NeutronError": { "message": "Request check failed: %s" % e, "type": "BadRequest", "detail": "" } } log.error(result) return Response(json.dumps(result)), 500 if req.mac_address is None: result = { "NeutronError": { "message": "Request check failed, macAddress not given", "type": "BadRequest", "detail": "" } } log.error(result) return Response(json.dumps(result)), 500 return get_arp_bymac(req)
def arp_put_api(): """ Implementation Notes Adds/Update global static ARP records. Each logical L2 network (networkType, segmentationId pair) has an independent ARP table. Response Class (Status 200) ArpRecord { ip (string, optional): IP addresss. , mac (string, optional): MAC address. , networkType (string, optional): Network type. Valid values are 'VLAN' and 'VXLAN'. , segmentationId (integer, optional): VLAN id or VXLAN vni } Parameters [ { networkType (string): Network type. Valid values are 'VLAN' and 'VXLAN'. , segmentationId (string): VLAN id or VXLAN vni. , macAddress (string): MAC address. , ipAddress (string): IP address. } ] """ code = 200 reqs = [] if not isinstance(request.json, list): result = { "NeutronError": { "message": "Request check failed", "type": "BadRequest", "detail": "" } } log.error(result) return Response(json.dumps(result)), 500 for json_data in request.json: try: req = models.ArpRequest(json_data) req.validate() reqs.append(req) except Exception as e: result = { "NeutronError": { "message": "Request check failed: %s" % e, "type": "BadRequest", "detail": "" } } log.error(result) return Response(json.dumps(result)), 500 if req.mac_address is None or req.ip_address is None: result = { "NeutronError": { "message": "Request check failed, " + "macAddress or ipAddress not given", "type": "BadRequest", "detail": "" } } log.error(result) return Response(json.dumps(result)), 500 result = [] for req in reqs: resp, code = get_arp_byip(req, True) if code != 200: return resp, code result.append(resp) return Response(json.dumps(result)), code