Browse Source

Hide stitching PTGs & subnets while member lauch

User should not be able to associate ip address
from either stitching PTGs or subnets, hence
hiding the same during member launch.

Also moving out fixed ip address from square
brackets and changing square brackets to
function brackets around 'Click to Set IP'
and 'Click to Edit IP'

Change-Id: Ib64604801530c244cc469d75dd5fb2065316ac11
Closes-Bug: #1626903
ank 2 years ago
parent
commit
3bd464bf51
2 changed files with 17 additions and 23 deletions
  1. 11
    18
      gbpui/panels/policytargets/workflows.py
  2. 6
    5
      gbpui/static/dashboard/js/member.js

+ 11
- 18
gbpui/panels/policytargets/workflows.py View File

@@ -408,24 +408,10 @@ class SetGroupAction(workflows.Action):
408 408
         super(SetGroupAction, self).__init__(request, *args, **kwargs)
409 409
         policy_targetid = self.request.path.split("/")[-2]
410 410
         ptg = client.policy_target_get(request, policy_targetid)
411
-        subnet_dedails = None
412
-        for subnet_id in ptg.subnets:
413
-            try:
414
-                subnet = api.neutron.subnet_get(request, subnet_id)
415
-                if subnet_dedails is None:
416
-                    subnet_dedails = subnet['cidr']
417
-                else:
418
-                    subnet_dedails = subnet_dedails + ";" + subnet['cidr']
419
-                allocation_pools = subnet['allocation_pools']
420
-                if allocation_pools:
421
-                    start = allocation_pools[0]['start']
422
-                    end = allocation_pools[0]['end']
423
-                    subnet_dedails = subnet_dedails + "," + start
424
-                    subnet_dedails = subnet_dedails + "," + end
425
-            except Exception as e:
426
-                LOG.error(str(e))
427
-                pass
428
-        initial_value = policy_targetid + ":" + subnet_dedails
411
+        for choice in self.fields['network'].choices:
412
+            if choice[0].startswith(ptg.id):
413
+                initial_value = choice[0]
414
+                break
429 415
         self.fields['network'].initial = [initial_value]
430 416
 
431 417
     class Meta(object):
@@ -443,12 +429,19 @@ class SetGroupAction(workflows.Action):
443 429
             pt_list = []
444 430
             pts = client.policy_target_list(request,
445 431
                 tenant_id=request.user.tenant_id)
432
+            proxy_groups = [pt.proxy_group_id for pt in pts
433
+                            if pt.proxy_group_id]
446 434
             for pt in pts:
435
+                if pt.id in proxy_groups or pt.proxied_group_id:
436
+                    continue
447 437
                 pt.set_id_as_name_if_empty()
448 438
                 subnet_dedails = None
449 439
                 for subnet_id in pt.subnets:
450 440
                     try:
451 441
                         subnet = api.neutron.subnet_get(request, subnet_id)
442
+                        subnet_name = subnet.name.split("_")
443
+                        if subnet_name[-1] in proxy_groups:
444
+                            continue
452 445
                         if subnet_dedails is None:
453 446
                             subnet_dedails = subnet['cidr']
454 447
                         else:

+ 6
- 5
gbpui/static/dashboard/js/member.js View File

@@ -44,7 +44,7 @@ member = {
44 44
     var $li = $('<li>');
45 45
     ip_lable = '<span></span>'
46 46
     if (selected){
47
-      ip_lable = "<span> [<a style='font-size:80%;'>Click to Set IP</a>]</span>"
47
+      ip_lable = "<span> (<a style='font-size:80%;'>Click to Set IP</a>)</span>"
48 48
     }
49 49
     $li.attr('name', value).html(name + ip_lable + '<a href="#" class="btn btn-primary"></a>');
50 50
     return $li;
@@ -75,7 +75,7 @@ member = {
75 75
       active_groups.each(function(index, value){
76 76
         ip_ele = $("#selected_network li[name^='"+ value +"'] span")
77 77
         if(ip_ele.text() == "" && $("#id_count").val() == 1){
78
-          ip_ele.html(" [<a style='font-size:80%;'>Click to Set IP</a>]")
78
+          ip_ele.html(" (<a style='font-size:80%;'>Click to Set IP</a>)")
79 79
         }
80 80
         groupListId.find("input:checkbox[value^='" + value + "']")
81 81
           .prop('checked', true)
@@ -186,6 +186,7 @@ member = {
186 186
   associate_fixed_ip: function(){
187 187
       if (member.allowed() == false)
188 188
         return
189
+      $("#errors").hide().text("")
189 190
       ptg = $("#fixed_ip").attr("data-ptg")
190 191
       subnet = $("#fixed_ip").attr("data-subnet")
191 192
       subnet = subnet.replace(";", ":")
@@ -207,7 +208,7 @@ member = {
207 208
             selected_element.val(value)
208 209
             if(fixed_ip){
209 210
               $("#selected_network li[name^='"+ ptg +"'] span").html(
210
-                " ["+fixed_ip + ", <a style='font-size:80%;'>Click to Edit IP</a>]")
211
+                ", "+fixed_ip + " (<a style='font-size:80%;'>Click to Edit IP</a>)")
211 212
             }
212 213
             $("ul#selected_network li[name^='"+ ptg +"']").css("background-color", "");
213 214
             $("#fixed_ip_div").hide()
@@ -230,7 +231,7 @@ member = {
230 231
     value = ptg + ":" + subnet
231 232
     selected_element = $(".multiple-checkbox #id_network li input[value^='"+ ptg +"']");
232 233
     selected_element.val(value)
233
-    $("#selected_network li[name^='"+ ptg +"'] span").html(" [<a style='font-size:80%;'>Click to Set IP</a>]")
234
+    $("#selected_network li[name^='"+ ptg +"'] span").html(" (<a style='font-size:80%;'>Click to Set IP</a>)")
234 235
     $("#fixed_ip_div").hide()
235 236
     $("ul#selected_network li").css("background-color", "");
236 237
     member.control_max_instances()
@@ -261,7 +262,7 @@ member = {
261 262
         $("#selected_network li").find("span").html("");
262 263
       }
263 264
       else{
264
-        $("#selected_network li").find("span").html(" [<a style='font-size:80%;'>Click to Set IP</a>]")
265
+        $("#selected_network li").find("span").html(" (<a style='font-size:80%;'>Click to Set IP</a>)")
265 266
         $("#errors").hide().text("")
266 267
       }
267 268
       $("#fixed_ip_div").hide()

Loading…
Cancel
Save