def del_port(bridge): #check if bridge exists if len(str(sub_sean.bridge_pc(bridge))) == 0: abort(404) if not request.json or not 'port' in request.json: abort(400) port = request.json['port'] #check if port exists on bridge if len(str(sub_sean.port_bridge(bridge, port))) == 0: abort(404) sub_sean.del_ports(bridge, port) #check if delete was successful if len(str(sub_sean.port_bridge(bridge, port))) != 0: abort(404) return jsonify({'Result': True})
def update_port(bridge, port): #check if bridge exist if len(str(sub_sean.bridge_pc(bridge))) == 0: abort(404) #check if port exist on bridge if len(str(sub_sean.port_bridge(bridge, port))) == 0: abort(404) if not request.json or not 'action' in request.json: abort(400) action = request.json['action'] sub_sean.update_ports(bridge, port, action) return jsonify({'Bridge': bridge, 'Port': port, 'Action': action})
def update_mirror(bridge): #check if bridge already exists if len(str(sub_sean.bridge_pc(bridge))) == 0: abort(404) if not request.json or not 'port1' in request.json: abort(400) if not request.json or not 'port2' in request.json: abort(400) if not request.json or not 'port3' in request.json: abort(400) if not request.json or not 'port4' in request.json: abort(400) if not request.json or not 'name' in request.json: abort(400) if not request.json or not 'dest' in request.json: abort(400) if not request.json or not 'source' in request.json: abort(400) if not request.json or not 'output' in request.json: abort(400) port1 = request.json['port1'] port2 = request.json['port2'] port3 = request.json['port3'] port4 = request.json['port4'] name = request.json['name'] dest = request.json['dest'] source = request.json['source'] output = request.json['output'] #check if port already exists if len(str(sub_sean.int_pc(port2))) == 0: abort(404) if len(str(sub_sean.int_pc(port4))) == 0: abort(404) #check if port exist on bridge if len(str(sub_sean.port_bridge(bridge, port2))) == 0: abort(404) if len(str(sub_sean.port_bridge(bridge, port4))) == 0: abort(404) if port2 == port4: abort(400) sub_sean.add_mirror(bridge, port1, port2, port3, port4, name, dest, source, output) return jsonify({'Bridge': bridge, 'Name': name, 'Destination': dest, 'Source': source, 'Output': output})