def subnet_data(request): tenant_id = request.GET.get('tenant_id', request.user.tenant_id) subnet_list = neutron.subnet_list(request, tenant_id=tenant_id) net_list = neutron.network_list(request) id_net = dict([(net.id, net) for net in net_list]) subnet_list = [subnet.to_dict() for subnet in subnet_list if valid_gw_subnet(subnet, id_net)] response = http.HttpResponse(json.dumps(subnet_list, ensure_ascii=False)) return response
def get_subnets_data(self): try: network = self._get_data() fields = ["name", "id", "cidr", "ip_version", "gateway_ip", "vsd_managed"] subnets = neutron.subnet_list(self.request, network_id=network.id, fields=fields) except Exception: subnets = [] msg = _("Subnet list can not be retrieved.") exceptions.handle(self.request, msg) return subnets