bug 13553: network page - Display "View IP adresses" option only for (1) Isolated networks with SourceNat (2) Shared networks with ELB/EIP/SecurityGroup.

This commit is contained in:
Jessica Wang 2012-02-09 13:50:14 -08:00
parent 881a46ff54
commit e93af6e1f9

View File

@ -284,9 +284,56 @@
path: 'network.ipAddresses',
label: 'IP addresses',
preFilter: function(args) {
if (args.context.networks[0].state == 'Destroyed') return false;
return true;
if (args.context.networks[0].state == 'Destroyed')
return false;
var services = args.context.networks[0].service;
if(services == null)
return false;
if(args.context.networks[0].type == "Isolated") {
for(var i=0; i < services.length; i++) {
var service = services[i];
if(service.name == "SourceNat") {
return true;
}
}
}
else if(args.context.networks[0].type == "Shared") {
var havingSecurityGroupService = false;
var havingElasticIpCapability = false;
var havingElasticLbCapability = false;
for(var i=0; i < services.length; i++) {
var service = services[i];
if(service.name == "SecurityGroup") {
havingSecurityGroupService = true;
}
else if(service.name == "StaticNat") {
$(service.capability).each(function(){
if(this.name == "ElasticIp" && this.value == "true") {
havingElasticIpCapability = true;
return false; //break $.each() loop
}
});
}
else if(service.name == "Lb") {
$(service.capability).each(function(){
if(this.name == "ElasticLb" && this.value == "true") {
havingElasticLbCapability = true;
return false; //break $.each() loop
}
});
}
}
if(havingSecurityGroupService == true && havingElasticIpCapability == true && havingElasticLbCapability == true)
return true;
else
return false;
}
return false;
}
},
actions: {