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
This commit is contained in:
ank 2016-09-23 14:18:35 +05:30
parent ebd860e5ec
commit 3bd464bf51
2 changed files with 17 additions and 23 deletions

View File

@ -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:

View File

@ -44,7 +44,7 @@ member = {
var $li = $('<li>');
ip_lable = '<span></span>'
if (selected){
ip_lable = "<span> [<a style='font-size:80%;'>Click to Set IP</a>]</span>"
ip_lable = "<span> (<a style='font-size:80%;'>Click to Set IP</a>)</span>"
}
$li.attr('name', value).html(name + ip_lable + '<a href="#" class="btn btn-primary"></a>');
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(" [<a style='font-size:80%;'>Click to Set IP</a>]")
ip_ele.html(" (<a style='font-size:80%;'>Click to Set IP</a>)")
}
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 + ", <a style='font-size:80%;'>Click to Edit IP</a>]")
", "+fixed_ip + " (<a style='font-size:80%;'>Click to Edit IP</a>)")
}
$("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(" [<a style='font-size:80%;'>Click to Set IP</a>]")
$("#selected_network li[name^='"+ ptg +"'] span").html(" (<a style='font-size:80%;'>Click to Set IP</a>)")
$("#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(" [<a style='font-size:80%;'>Click to Set IP</a>]")
$("#selected_network li").find("span").html(" (<a style='font-size:80%;'>Click to Set IP</a>)")
$("#errors").hide().text("")
}
$("#fixed_ip_div").hide()