diff --git a/gbpui/panels/policytargets/workflows.py b/gbpui/panels/policytargets/workflows.py index 39bc48d..7e7af26 100644 --- a/gbpui/panels/policytargets/workflows.py +++ b/gbpui/panels/policytargets/workflows.py @@ -408,24 +408,10 @@ class SetGroupAction(workflows.Action): super(SetGroupAction, self).__init__(request, *args, **kwargs) policy_targetid = self.request.path.split("/")[-2] ptg = client.policy_target_get(request, policy_targetid) - subnet_dedails = None - for subnet_id in ptg.subnets: - try: - subnet = api.neutron.subnet_get(request, subnet_id) - if subnet_dedails is None: - subnet_dedails = subnet['cidr'] - else: - subnet_dedails = subnet_dedails + ";" + subnet['cidr'] - allocation_pools = subnet['allocation_pools'] - if allocation_pools: - start = allocation_pools[0]['start'] - end = allocation_pools[0]['end'] - subnet_dedails = subnet_dedails + "," + start - subnet_dedails = subnet_dedails + "," + end - except Exception as e: - LOG.error(str(e)) - pass - initial_value = policy_targetid + ":" + subnet_dedails + for choice in self.fields['network'].choices: + if choice[0].startswith(ptg.id): + initial_value = choice[0] + break self.fields['network'].initial = [initial_value] class Meta(object): @@ -443,12 +429,19 @@ class SetGroupAction(workflows.Action): pt_list = [] pts = client.policy_target_list(request, tenant_id=request.user.tenant_id) + proxy_groups = [pt.proxy_group_id for pt in pts + if pt.proxy_group_id] for pt in pts: + if pt.id in proxy_groups or pt.proxied_group_id: + continue pt.set_id_as_name_if_empty() subnet_dedails = None for subnet_id in pt.subnets: try: subnet = api.neutron.subnet_get(request, subnet_id) + subnet_name = subnet.name.split("_") + if subnet_name[-1] in proxy_groups: + continue if subnet_dedails is None: subnet_dedails = subnet['cidr'] else: diff --git a/gbpui/static/dashboard/js/member.js b/gbpui/static/dashboard/js/member.js index 4c490ae..79db4a7 100644 --- a/gbpui/static/dashboard/js/member.js +++ b/gbpui/static/dashboard/js/member.js @@ -44,7 +44,7 @@ member = { var $li = $('
  • '); ip_lable = '' if (selected){ - ip_lable = " [Click to Set IP]" + ip_lable = " (Click to Set IP)" } $li.attr('name', value).html(name + ip_lable + ''); return $li; @@ -75,7 +75,7 @@ member = { active_groups.each(function(index, value){ ip_ele = $("#selected_network li[name^='"+ value +"'] span") if(ip_ele.text() == "" && $("#id_count").val() == 1){ - ip_ele.html(" [Click to Set IP]") + ip_ele.html(" (Click to Set IP)") } groupListId.find("input:checkbox[value^='" + value + "']") .prop('checked', true) @@ -186,6 +186,7 @@ member = { associate_fixed_ip: function(){ if (member.allowed() == false) return + $("#errors").hide().text("") ptg = $("#fixed_ip").attr("data-ptg") subnet = $("#fixed_ip").attr("data-subnet") subnet = subnet.replace(";", ":") @@ -207,7 +208,7 @@ member = { selected_element.val(value) if(fixed_ip){ $("#selected_network li[name^='"+ ptg +"'] span").html( - " ["+fixed_ip + ", Click to Edit IP]") + ", "+fixed_ip + " (Click to Edit IP)") } $("ul#selected_network li[name^='"+ ptg +"']").css("background-color", ""); $("#fixed_ip_div").hide() @@ -230,7 +231,7 @@ member = { value = ptg + ":" + subnet selected_element = $(".multiple-checkbox #id_network li input[value^='"+ ptg +"']"); selected_element.val(value) - $("#selected_network li[name^='"+ ptg +"'] span").html(" [Click to Set IP]") + $("#selected_network li[name^='"+ ptg +"'] span").html(" (Click to Set IP)") $("#fixed_ip_div").hide() $("ul#selected_network li").css("background-color", ""); member.control_max_instances() @@ -261,7 +262,7 @@ member = { $("#selected_network li").find("span").html(""); } else{ - $("#selected_network li").find("span").html(" [Click to Set IP]") + $("#selected_network li").find("span").html(" (Click to Set IP)") $("#errors").hide().text("") } $("#fixed_ip_div").hide()