|
1272 | 1272 | actions: { |
1273 | 1273 | add: { |
1274 | 1274 | 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 |
1279 | 1327 | return true; |
| 1328 | + } |
| 1329 | + else { //Guest Network section > VPC network, hide Acquire IP button |
| 1330 | + return false; |
1280 | 1331 | } |
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: { |
1289 | 1339 | confirm: function(args) { |
1290 | 1340 | 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'; |
1292 | 1342 | else |
1293 | | - return 'message.acquire.new.ip'; |
1294 | | - }, |
| 1343 | + return 'message.acquire.new.ip'; |
| 1344 | + }, |
1295 | 1345 | notification: function(args) { |
1296 | 1346 | return 'label.acquire.new.ip'; |
1297 | 1347 | } |
|
2743 | 2793 | }, |
2744 | 2794 | async: false, |
2745 | 2795 | success: function(json) { |
2746 | | - //debugger; |
2747 | 2796 | if(json.listautoscalevmgroupsresponse.autoscalevmgroup != null && json.listautoscalevmgroupsresponse.autoscalevmgroup.length > 0) { //from 'autoScale' button |
2748 | 2797 | item._hideFields = ['add-vm']; |
2749 | 2798 | } |
|
0 commit comments