|
119 | 119 | lbruleid: args.context.multiRules[0].id |
120 | 120 | }, |
121 | 121 | success: function(json) { |
122 | | - var autoscaleVmGroup = json.listautoscalevmgroupsresponse.autoscalevmgroup[0]; |
| 122 | + var response = json.listautoscalevmgroupsresponse.autoscalevmgroup; |
| 123 | + if (!response || !response[0]) { |
| 124 | + // Existing LB, but no configured VM Group yet |
| 125 | + args.response.success({ |
| 126 | + data: null |
| 127 | + }); |
| 128 | + return; |
| 129 | + } |
| 130 | + |
| 131 | + var autoscaleVmGroup = response[0]; |
123 | 132 |
|
124 | 133 | $.ajax({ |
125 | 134 | url: createURL('listAutoScaleVmProfiles'), |
|
329 | 338 |
|
330 | 339 | minInstance: { |
331 | 340 | label: 'label.min.instances', |
332 | | - defaultValue: '3', |
| 341 | + defaultValue: '1', |
333 | 342 | validation: { |
334 | 343 | required: true, |
335 | 344 | number: true |
|
338 | 347 |
|
339 | 348 | maxInstance: { |
340 | 349 | label: 'label.max.instances', |
341 | | - defaultValue: '10', |
| 350 | + defaultValue: '5', |
342 | 351 | validation: { |
343 | 352 | required: true, |
344 | 353 | number: true |
|
742 | 751 | actions: { |
743 | 752 | apply: function(args) { |
744 | 753 | //validation (begin) ***** |
745 | | - if (!('multiRules' in args.context)) { //from a new LB |
| 754 | + if (!('multiRules' in args.context) || !args.context.originalAutoscaleData) { //from a new LB or from existing LB without AutoscaleVmGroup |
746 | 755 | if (args.formData.name == '' || args.formData.publicport == '' || args.formData.privateport == '') { |
747 | 756 | args.response.error('Name, Public Port, Private Port of Load Balancing are required. Please close this dialog box and fill Name, Public Port, Private Port first.'); |
748 | 757 | return; |
|
872 | 881 | var item = json.queryasyncjobresultresponse.jobresult.condition; |
873 | 882 | scaleUpConditionIds.push(item.id); |
874 | 883 | if (scaleUpConditionIds.length == scaleUpData.length) { |
875 | | - if (!('multiRules' in args.context)) { //from a new LB |
| 884 | + if (!('multiRules' in args.context) || !args.context.originalAutoscaleData) { //from a new LB or from existing LB without AutoscaleVmGroup |
876 | 885 | var data = { |
877 | 886 | action: 'scaleup', |
878 | 887 | conditionids: scaleUpConditionIds.join(","), |
|
1004 | 1013 | var item = json.queryasyncjobresultresponse.jobresult.condition; |
1005 | 1014 | scaleDownConditionIds.push(item.id); |
1006 | 1015 | if (scaleDownConditionIds.length == scaleDownData.length) { |
1007 | | - if (!('multiRules' in args.context)) { //from a new LB |
| 1016 | + if (!('multiRules' in args.context) || !args.context.originalAutoscaleData) { //from a new LB or from existing LB without AutoscaleVmGroup |
1008 | 1017 | var data = { |
1009 | 1018 | action: 'scaledown', |
1010 | 1019 | conditionids: scaleDownConditionIds.join(","), |
|
1114 | 1123 | var createOrUpdateVmProfile = function(args) { |
1115 | 1124 | var array1 = []; |
1116 | 1125 | var apiCmd, apiCmdRes; |
1117 | | - if (!('multiRules' in args.context)) { //from a new LB |
| 1126 | + if (!('multiRules' in args.context) || !args.context.originalAutoscaleData) { //from a new LB or from existing LB without AutoscaleVmGroup) { //from a new LB |
1118 | 1127 | var data = { |
1119 | 1128 | zoneid: args.context.networks[0].zoneid, //get zoneid from args.context.networks[0] instead of args.context.ipAddresses[0] because args.context.ipAddresses is null when adding AutoScale rule from Add Load Balancer tab in Network page |
1120 | 1129 | serviceofferingid: args.data.serviceOfferingId, |
|
1266 | 1275 | }; |
1267 | 1276 |
|
1268 | 1277 | var loadBalancer = function(args) { |
| 1278 | + // In case load balancer was already created, but no autoscale options yet |
| 1279 | + if ('loadbalancer' in args.context) { |
| 1280 | + loadBalancerResponse = args.context.loadbalancer; |
| 1281 | + autoScaleVmGroup(args); |
| 1282 | + return; |
| 1283 | + } |
| 1284 | + |
1269 | 1285 | var networkid; |
1270 | 1286 | if ('vpc' in args.context) { //from VPC section |
1271 | 1287 | if (args.data.tier == null) { |
|
1332 | 1348 | }; |
1333 | 1349 |
|
1334 | 1350 | var autoScaleVmGroup = function(args) { |
1335 | | - if (!('multiRules' in args.context)) { //from a new LB |
| 1351 | + if (!('multiRules' in args.context) || !args.context.originalAutoscaleData) { //from a new LB or from existing LB without AutoscaleVmGroup) { //from a new LB |
1336 | 1352 | var array1 = []; |
1337 | 1353 | array1.push("&lbruleid=" + loadBalancerResponse.id); |
1338 | 1354 | array1.push("&minMembers=" + args.data.minInstance); |
|
0 commit comments