コード例 #1
0
 def get_form_data(self, context, request):
     if context["subnet_type"] == "vsd_manual":
         return {"id_cidr": "", "id_gateway_ip": "", "id_subnet_name": "", "id_nuage_id": "", "id_net_partition": ""}
     elif context["subnet_type"] == "os":
         return {
             "id_cidr": "",
             "id_gateway_ip": "",
             "id_subnet_name": "",
             "id_nuage_id": ".",
             "id_net_partition": ".",
         }
     else:
         if not context["sub_id"]:
             return {}
         vsd_subnet = neutron.vsd_subnet_get(request, context["sub_id"])
         vsd_organisation = neutron.vsd_organisation_list(request, id=context["org_id"])[0]
         request.session["vsd_subnet"] = vsd_subnet
         request.session["vsd_organisation"] = vsd_organisation
         return {
             "id_nuage_id": vsd_subnet["id"],
             "id_net_partition": vsd_organisation["name"],
             "id_cidr": vsd_subnet["cidr"],
             "id_gateway_ip": vsd_subnet["gateway"],
             "id_ip_version": vsd_subnet["ip_version"][-1],
             "id_subnet_name": vsd_subnet["name"],
         }
コード例 #2
0
    def __init__(self, request, context, *args, **kwargs):
        super(CreateSubnetDetailAction, self).__init__(request, context, *args, **kwargs)
        if context.get("nuage_id") and context["nuage_id"] != ".":
            vsd_subnet = neutron.vsd_subnet_get(request, context["nuage_id"])
            request.session["vsd_subnet"] = vsd_subnet
            if vsd_subnet.get("cidr"):
                del self.fields["dummy_cidr"]

        if not request.user.is_superuser or not context.get("network_id"):
            del self.fields["underlay"]
        else:
            network = neutron.network_get(request, context["network_id"])
            if not network or not network.get("router:external", False):
                del self.fields["underlay"]