def put_remove_router_interface(nb_db, content, parameters):
    nb_db.delete_router_interface(get_entity(content), parameters[ROUTER_ID])
    return Response({"router": {}})
def post_tokens(content, parameters):
    received_auth = get_entity(content, 'auth')
    try:
        if 'passwordCredentials' in received_auth:
            password_credentials = received_auth['passwordCredentials']
            user_at_domain = password_credentials['username']
            user_password = password_credentials['password']
            token = auth.create_token(user_at_domain=user_at_domain,
                                      user_password=user_password)
        else:
            token = received_auth['token']['id']
    except KeyError as e:
        raise BadRequestError(e)

    if not auth.validate_token(token):
        raise auth.Forbidden()

    neutronurl = neutron_url()
    keystoneurl = keystone_url()
    novaurl = nova_url_with_version()
    region = openstack_region()
    neutron_id = openstack_neutron_id()
    keystone_id = openstack_keystone_id()

    # OpenStack Identity API v2.0 specifies HTTP 200 as return code for
    # successful token creation
    http_code = httplib.OK

    return Response(
        {
            'access': {
                'token': {
                    'id': token,
                    'expires': _get_token_expires()
                },
                'user': {
                    'username': '******',
                    'roles_links': [],
                    'id': '',
                    'roles': [{
                        'name': 'admin'
                    }],
                    'name': 'admin'
                },
                'serviceCatalog': [{
                    'endpoints': [{
                        'adminURL': neutronurl,
                        'internalURL': neutronurl,
                        'publicURL': neutronurl,
                        'region': region,
                        'id': neutron_id,
                    }],
                    'endpoints_links': [],
                    'type':
                    'network',
                    'name':
                    'neutron',
                }, {
                    'endpoints': [{
                        'adminURL': keystoneurl,
                        'region': region,
                        'internalURL': keystoneurl,
                        'id': keystone_id,
                        'publicURL': keystoneurl
                    }],
                    'endpoints_links': [],
                    'type':
                    'identity',
                    'name':
                    'keystone'
                }, {
                    'endpoints': [{
                        'adminURL': novaurl,
                        'region': region,
                        'internalURL': novaurl,
                        'id': keystone_id,
                        'publicURL': novaurl
                    }],
                    'endpoints_links': [],
                    'type':
                    'compute',
                    'name':
                    'nova'
                }]
            },
        },
        code=http_code)
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})
def put_add_router_inerface(nb_db, content, parameters):
    result = nb_db.add_router_interface(get_entity(content),
                                        parameters[ROUTER_ID])
    return Response(result)
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})
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})
def post_subnets(nb_db, content, parameters):
    received_subnet = get_entity(content, 'subnet')
    subnet = nb_db.add_subnet(received_subnet)
    return Response({'subnet': subnet})
def post_ports(nb_db, content, parameters):
    received_port = get_entity(content, 'port')
    port = nb_db.add_port(received_port)
    return Response({'port': port})
def post_networks(nb_db, content, parameters):
    received_network = get_entity(content, 'network')
    network = nb_db.add_network(received_network)
    return Response({'network': network})