Esempio n. 1
0
def get_mirror(mirror):
	
	#check if mirror exists
	if len(str(sub_sean.check_mirror(mirror))) == 0:
		abort(404)

        return jsonify({'Mirror': sub_sean.get_mirror(mirror).splitlines()})
Esempio n. 2
0
def del_mirror(bridge, mirror):

        #check if bridge exists
        if len(str(sub_sean.bridge_pc(bridge))) == 0:
                abort(404)

        #check if mirror exists
        if len(str(sub_sean.check_mirror(mirror))) == 0:
                abort(404)

        sub_sean.del_mirror(bridge, mirror)

        #check if mirror gets deleted successfully
        if len(str(sub_sean.check_mirror(mirror))) != 0:
                abort(400)

        return jsonify({'Result': True})
Esempio n. 3
0
def add_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)

        #check if mirror with same name already exists
        if len(str(sub_sean.check_mirror(name))) != 0:
                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}), 201