Skip to content

Commit 7f40eef

Browse files
author
Jessica Wang
committed
CLOUDSTACK-538: cloudstack UI - IP Addresses page - Acquire New IP button - If it's under a Basic zone, check whether its network offering is EIP ELB. If yes, show the button. If no, hide the button.
1 parent 17b11d7 commit 7f40eef

1 file changed

Lines changed: 65 additions & 16 deletions

File tree

‎ui/scripts/network.js‎

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,26 +1272,76 @@
12721272
actions: {
12731273
add: {
12741274
label: 'label.acquire.new.ip',
1275-
addRow: 'true',
1276-
preFilter: function(args) {
1277-
if('networks' in args.context) { //from Guest Network section
1278-
if(args.context.networks[0].vpcid == null) { //if it's a non-VPC network, show Acquire IP button
1275+
addRow: 'true',
1276+
preFilter: function(args) {
1277+
var zoneObj;
1278+
$.ajax({
1279+
url: createURL('listZones'),
1280+
data: {
1281+
id: args.context.networks[0].zoneid
1282+
},
1283+
async: false,
1284+
success: function(json) {
1285+
zoneObj = json.listzonesresponse.zone[0];
1286+
}
1287+
});
1288+
1289+
if(zoneObj.networktype == 'Basic') {
1290+
var havingEIP = false, havingELB = false;
1291+
$.ajax({
1292+
url: createURL('listNetworkOfferings'),
1293+
data: {
1294+
id: args.context.networks[0].networkofferingid
1295+
},
1296+
async: false,
1297+
success: function(json) {
1298+
$(json.listnetworkofferingsresponse.networkoffering[0].service).each(function(){
1299+
var thisService = this;
1300+
if(thisService.name == "StaticNat") {
1301+
$(thisService.capability).each(function(){
1302+
if(this.name == "ElasticIp" && this.value == "true") {
1303+
havingEIP = true;
1304+
return false; //break $.each() loop
1305+
}
1306+
});
1307+
}
1308+
else if(thisService.name == "Lb") {
1309+
$(thisService.capability).each(function(){
1310+
if(this.name == "ElasticLb" && this.value == "true") {
1311+
havingELB = true;
1312+
return false; //break $.each() loop
1313+
}
1314+
});
1315+
}
1316+
});
1317+
}
1318+
});
1319+
if(havingEIP != true || havingELB != true) { //not EIP-ELB
1320+
return false; //acquire new IP is not allowed in non-EIP-ELB basic zone
1321+
}
1322+
}
1323+
1324+
//*** from Guest Network section ***
1325+
if('networks' in args.context) {
1326+
if(args.context.networks[0].vpcid == null){ //Guest Network section > non-VPC network, show Acquire IP button
12791327
return true;
1328+
}
1329+
else { //Guest Network section > VPC network, hide Acquire IP button
1330+
return false;
12801331
}
1281-
else //if it's a VPC network, hide Acquire IP button
1282-
return false;
1283-
}
1284-
else { //from VPC section
1285-
return true; //show Acquire IP button
1286-
}
1287-
},
1288-
messages: {
1332+
}
1333+
//*** from VPC section ***
1334+
else { //'vpc' in args.context
1335+
return true; //VPC section, show Acquire IP button
1336+
}
1337+
},
1338+
messages: {
12891339
confirm: function(args) {
12901340
if(args.context.vpc)
1291-
return 'Please confirm that you would like to acquire a new IP for this VPC';
1341+
return 'message.acquire.new.ip.vpc';
12921342
else
1293-
return 'message.acquire.new.ip';
1294-
},
1343+
return 'message.acquire.new.ip';
1344+
},
12951345
notification: function(args) {
12961346
return 'label.acquire.new.ip';
12971347
}
@@ -2743,7 +2793,6 @@
27432793
},
27442794
async: false,
27452795
success: function(json) {
2746-
//debugger;
27472796
if(json.listautoscalevmgroupsresponse.autoscalevmgroup != null && json.listautoscalevmgroupsresponse.autoscalevmgroup.length > 0) { //from 'autoScale' button
27482797
item._hideFields = ['add-vm'];
27492798
}

0 commit comments

Comments
 (0)