Пример #1
0
def put_network(nb_db, content, parameters):
    received_network = get_entity(content, 'network')
    network = nb_db.update_network(received_network, parameters[NETWORK_ID])
    return Response({'network': network})
Пример #2
0
def put_ports(nb_db, content, parameters):
    received_port = get_entity(content, 'port')
    port = nb_db.update_port(received_port, parameters[PORT_ID])
    return Response({'port': port})
Пример #3
0
def post_ports(nb_db, content, parameters):
    received_port = get_entity(content, 'port')
    port = nb_db.add_port(received_port)
    return Response({'port': port})
Пример #4
0
def post_subnets(nb_db, content, parameters):
    received_subnet = get_entity(content, 'subnet')
    subnet = nb_db.add_subnet(received_subnet)
    return Response({'subnet': subnet})
Пример #5
0
def show_handler(nb_db, content, path_parts):
    return Response({'method:': REST_RESPONSE_SHOW})
Пример #6
0
def post_networks(nb_db, content, parameters):
    received_network = get_entity(content, 'network')
    network = nb_db.add_network(received_network)
    return Response({'network': network})
Пример #7
0
def delete_network(nb_db, content, parameters):
    nb_db.delete_network(parameters[NETWORK_ID])
    return Response()
Пример #8
0
def post_routers(nb_db, content, parameters):
    content_json = json.loads(content)
    received_router = content_json['router']
    router = nb_db.add_router(received_router)
    return Response({'router': router})
Пример #9
0
def tokens_handler(content, id):
    return Response({'value': REST_RESPONSE_POST + json.loads(content)['key']})
Пример #10
0
def empty_handler(content, id):
    return Response({'value': EMPTY})
Пример #11
0
def response_code_201(nb_db, content, path_parts):
    return Response({
        'method:': REST_RESPONSE_POST,
        'value:': content
    },
                    code=httplib.CREATED)
Пример #12
0
def post_handler(nb_db, content, path_parts):
    return Response({'method:': REST_RESPONSE_POST, 'value:': content})
Пример #13
0
def delete_handler(nb_db, content, path_parts):
    return Response()
Пример #14
0
def put_subnets(nb_db, content, parameters):
    received_subnet = get_entity(content, 'subnet')
    subnet = nb_db.update_subnet(received_subnet, parameters[SUBNET_ID])
    return Response({'subnet': subnet})
Пример #15
0
def delete_port(nb_db, content, parameters):
    nb_db.delete_port(parameters[PORT_ID])
    return Response()
Пример #16
0
def get_routers(nb_db, content, parameters):
    return Response({'routers': nb_db.list_routers()})
Пример #17
0
def delete_subnet(nb_db, content, parameters):
    nb_db.delete_subnet(parameters[SUBNET_ID])
    return Response()
Пример #18
0
def get_router(nb_db, content, parameters):
    return Response({'router': nb_db.get_router(parameters[ROUTER_ID])})
Пример #19
0
def get_handler(nb_db, content, path_parts):
    return Response({'method:': REST_RESPONSE_GET})