Exemple #1
0
def add_port(bridge):
      
	#check if bridge already exists
	if len(str(sub_sean.bridge_pc(bridge))) == 0:
		abort(404)

	if not request.json:
		abort(400)

	if not 'port' in request.json or type(request.json['port']) != unicode:
		abort(400)
	
	port = request.json['port']

        #check if interface already exists on pc
        if len(str(sub_sean.int_pc(port))) == 0:
                abort(404)

	sub_sean.add_ports(bridge, port)
	return jsonify({'Bridge': bridge,
			'Port': port}), 201
Exemple #2
0
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})