コード例 #1
0
def delete_route(context, id):
    #TODO(mdietz): This is probably where we check to see that someone is
    #              admin and only filter on tenant if they aren't. Correct
    #              for all the above later
    LOG.info("delete_route %s for tenant %s" % (id, context.tenant_id))
    route = db_api.route_find(context, id, scope=db_api.ONE)
    if not route:
        raise quark_exceptions.RouteNotFound(route_id=id)
    db_api.route_delete(context, route)
コード例 #2
0
ファイル: routes.py プロジェクト: kilogram/quark
def delete_route(context, id):
    #TODO(mdietz): This is probably where we check to see that someone is
    #              admin and only filter on tenant if they aren't. Correct
    #              for all the above later
    LOG.info("delete_route %s for tenant %s" % (id, context.tenant_id))
    route = db_api.route_find(context, id, scope=db_api.ONE)
    if not route:
        raise quark_exceptions.RouteNotFound(route_id=id)
    db_api.route_delete(context, route)
コード例 #3
0
ファイル: plugin.py プロジェクト: ugoring/quark
    def update_subnet(self, context, id, subnet):
        """Update values of a subnet.

        : param context: quantum api request context
        : param id: UUID representing the subnet to update.
        : param subnet: dictionary with keys indicating fields to update.
            valid keys are those that have a value of True for 'allow_put'
            as listed in the RESOURCE_ATTRIBUTE_MAP object in
            quantum/api/v2/attributes.py.
        """
        LOG.info("update_subnet %s for tenant %s" %
                 (id, context.tenant_id))

        subnet_db = db_api.subnet_find(context, id=id, scope=db_api.ONE)
        if not subnet_db:
            raise exceptions.SubnetNotFound(id=id)

        s = subnet["subnet"]

        dns_ips = s.pop("dns_nameservers", [])
        routes = s.pop("host_routes", [])
        gateway_ip = s.pop("gateway_ip", None)

        if gateway_ip:
            default_route = None
            for route in routes:
                if netaddr.IPNetwork(route["destination"]) == DEFAULT_ROUTE:
                    default_route = route
                    break
            if default_route is None:
                route_model = db_api.route_find(
                    context,
                    cidr=str(DEFAULT_ROUTE),
                    subnet_id=id,
                    scope=db_api.ONE)
                if route_model:
                    db_api.route_update(context,
                                        route_model,
                                        gateway=gateway_ip)
                else:
                    db_api.route_create(context,
                                        cidr=str(DEFAULT_ROUTE),
                                        gateway=gateway_ip,
                                        subnet_id=id)

        subnet = db_api.subnet_update(context, subnet_db, **s)
        subnet_dict = self._make_subnet_dict(subnet)

        if dns_ips:
            dns_models = subnet_db["dns_nameservers"]
            for dns_model in dns_models:
                db_api.dns_delete(context, dns_model)
            subnet_dict["dns_nameservers"] = []
        for dns_ip in dns_ips:
            db_api.dns_create(context,
                              ip=netaddr.IPAddress(dns_ip),
                              subnet_id=subnet["id"])
            subnet_dict["dns_nameservers"].append(dns_ip)

        if routes:
            route_models = subnet_db["routes"]
            for route_model in route_models:
                db_api.route_delete(context, route_model)
            subnet_dict["host_routes"] = []
            subnet_dict["gateway_ip"] = None
        for route in routes:
            db_api.route_create(context,
                                cidr=route["destination"],
                                gateway=route["nexthop"],
                                subnet_id=subnet["id"])
            if netaddr.IPNetwork(route["destination"]) == DEFAULT_ROUTE:
                subnet_dict["gateway_ip"] = route["nexthop"]
            subnet_dict["host_routes"].append(route)

        return subnet_dict