|
18 | 18 | (function($, cloudStack) { |
19 | 19 | var zoneObjs, hypervisorObjs, featuredTemplateObjs, communityTemplateObjs, myTemplateObjs, featuredIsoObjs, community, networkObjs; |
20 | 20 | var selectedZoneObj, selectedTemplateObj, selectedHypervisor, selectedDiskOfferingObj; |
21 | | - var step5ContainerType = 'nothing-to-select'; //'nothing-to-select', 'select-network', 'select-security-group', 'select-advanced-sg'(advanced sg-enabled zone) |
| 21 | + var step6ContainerType = 'nothing-to-select'; //'nothing-to-select', 'select-network', 'select-security-group', 'select-advanced-sg'(advanced sg-enabled zone) |
22 | 22 |
|
23 | 23 | cloudStack.instanceWizard = { |
24 | 24 | maxDiskOfferingSize: function() { |
|
339 | 339 | var $networkStepContainer = $('.step.network:visible'); |
340 | 340 |
|
341 | 341 | if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart |
342 | | - step5ContainerType = 'nothing-to-select'; |
| 342 | + step6ContainerType = 'nothing-to-select'; |
343 | 343 | $networkStep.find("#from_instance_page_1").hide(); |
344 | 344 | $networkStep.find("#from_instance_page_2").hide(); |
345 | 345 | $networkStep.find("#from_vpc_tier").text("tier " + args.context.networks[0].name); |
346 | 346 | $networkStep.find("#from_vpc_tier").show(); |
347 | 347 | } else { //from Instance page |
348 | 348 | if(selectedZoneObj.securitygroupsenabled != true) { // Advanced SG-disabled zone |
349 | | - step5ContainerType = 'select-network'; |
| 349 | + step6ContainerType = 'select-network'; |
350 | 350 | $networkStep.find("#from_instance_page_1").show(); |
351 | 351 | $networkStep.find("#from_instance_page_2").show(); |
352 | 352 | $networkStep.find("#from_vpc_tier").text(""); |
353 | 353 | $networkStep.find("#from_vpc_tier").hide(); |
354 | 354 | $networkStepContainer.removeClass('next-use-security-groups'); |
355 | 355 | } else { // Advanced SG-enabled zone |
356 | | - step5ContainerType = 'select-advanced-sg'; |
| 356 | + step6ContainerType = 'select-advanced-sg'; |
357 | 357 | } |
358 | 358 |
|
359 | 359 | if ($networkStepContainer.hasClass('next-use-security-groups')) { |
360 | 360 | $networkStepContainer.removeClass('repeat next-use-security-groups loaded'); |
361 | | - step5ContainerType = 'select-security-group'; |
| 361 | + step6ContainerType = 'select-security-group'; |
362 | 362 | } |
363 | 363 | } |
364 | 364 | } |
|
385 | 385 | }); |
386 | 386 |
|
387 | 387 | if(includingSecurityGroupService == false || selectedHypervisor == "VMware") { |
388 | | - step5ContainerType = 'nothing-to-select'; |
| 388 | + step6ContainerType = 'nothing-to-select'; |
389 | 389 | } |
390 | 390 | else { |
391 | | - step5ContainerType = 'select-security-group'; |
| 391 | + step6ContainerType = 'select-security-group'; |
392 | 392 | } |
393 | 393 | } |
394 | 394 |
|
395 | | - //step5ContainerType = 'nothing-to-select'; //for testing only, comment it out before checking in |
396 | | - if(step5ContainerType == 'select-network' || step5ContainerType == 'select-advanced-sg') { |
| 395 | + //step6ContainerType = 'nothing-to-select'; //for testing only, comment it out before checking in |
| 396 | + if(step6ContainerType == 'select-network' || step6ContainerType == 'select-advanced-sg') { |
397 | 397 | var defaultNetworkArray = [], optionalNetworkArray = []; |
398 | 398 | var networkData = { |
399 | 399 | zoneId: args.currentData.zoneid, |
|
478 | 478 |
|
479 | 479 | $networkStepContainer.removeClass('repeat next-use-security-groups'); |
480 | 480 |
|
481 | | - if (step5ContainerType == 'select-advanced-sg') { |
| 481 | + if (step6ContainerType == 'select-advanced-sg') { |
482 | 482 | $networkStepContainer.addClass('repeat next-use-security-groups'); |
483 | 483 |
|
484 | 484 | // Add guest network is disabled |
|
498 | 498 | }); |
499 | 499 | } |
500 | 500 |
|
501 | | - else if(step5ContainerType == 'select-security-group') { |
| 501 | + else if(step6ContainerType == 'select-security-group') { |
502 | 502 | var securityGroupArray = []; |
503 | 503 | var data = { |
504 | 504 | domainid: g_domainid, |
|
530 | 530 | }); |
531 | 531 | } |
532 | 532 |
|
533 | | - else if(step5ContainerType == 'nothing-to-select') { |
| 533 | + else if(step6ContainerType == 'nothing-to-select') { |
534 | 534 | args.response.success({ |
535 | 535 | type: 'nothing-to-select', |
536 | 536 | data: { |
|
544 | 544 |
|
545 | 545 | }, |
546 | 546 |
|
547 | | - // Step 6: Review |
| 547 | + // Step 7: Review |
548 | 548 | function(args) { |
549 | 549 | return false; |
550 | 550 | } |
|
569 | 569 | if(selectedDiskOfferingObj.iscustomized == true) |
570 | 570 | array1.push("&size=" + args.data.size); |
571 | 571 | } |
| 572 | + |
| 573 | + //step 5: select an affinity group |
| 574 | + var checkedAffinityGroupIdArray; |
| 575 | + if(typeof(args.data["affinity-groups"]) == "object" && args.data["affinity-groups"].length != null) { //args.data["affinity-groups"] is an array of string, e.g. ["2375f8cc-8a73-4b8d-9b26-50885a25ffe0", "27c60d2a-de7f-4bb7-96e5-a602cec681df","c6301d77-99b5-4e8a-85e2-3ea2ab31c342"], |
| 576 | + checkedAffinityGroupIdArray = args.data["affinity-groups"]; |
| 577 | + } |
| 578 | + else if(typeof(args.data["affinity-groups"]) == "string" && args.data["affinity-groups"].length > 0) { //args.data["affinity-groups"] is a string, e.g. "2375f8cc-8a73-4b8d-9b26-50885a25ffe0" |
| 579 | + checkedAffinityGroupIdArray = []; |
| 580 | + checkedAffinityGroupIdArray.push(args.data["affinity-groups"]); |
| 581 | + } |
| 582 | + else { // typeof(args.data["affinity-groups"]) == null |
| 583 | + checkedAffinityGroupIdArray = []; |
| 584 | + } |
572 | 585 |
|
573 | | - //step 5: select network |
574 | | - if (step5ContainerType == 'select-network' || step5ContainerType == 'select-advanced-sg') { |
| 586 | + if(checkedAffinityGroupIdArray.length > 0) |
| 587 | + array1.push("&affinitygroupids=" + checkedAffinityGroupIdArray.join(",")); |
| 588 | + |
| 589 | + //step 6: select network |
| 590 | + if (step6ContainerType == 'select-network' || step6ContainerType == 'select-advanced-sg') { |
575 | 591 | var array2 = []; |
576 | 592 | var defaultNetworkId = args.data.defaultNetwork; //args.data.defaultNetwork might be equal to string "new-network" or a network ID |
577 | 593 |
|
|
634 | 650 |
|
635 | 651 | array1.push("&networkIds=" + array2.join(",")); |
636 | 652 | } |
637 | | - else if (step5ContainerType == 'select-security-group') { |
| 653 | + else if (step6ContainerType == 'select-security-group') { |
638 | 654 | var checkedSecurityGroupIdArray; |
639 | 655 | if(typeof(args.data["security-groups"]) == "object" && args.data["security-groups"].length != null) { //args.data["security-groups"] is an array of string, e.g. ["2375f8cc-8a73-4b8d-9b26-50885a25ffe0", "27c60d2a-de7f-4bb7-96e5-a602cec681df","c6301d77-99b5-4e8a-85e2-3ea2ab31c342"], |
640 | 656 | checkedSecurityGroupIdArray = args.data["security-groups"]; |
|
682 | 698 | array1.push("&networkIds=" + array2.join(",")); |
683 | 699 | } |
684 | 700 | } |
685 | | - else if (step5ContainerType == 'nothing-to-select') { |
| 701 | + else if (step6ContainerType == 'nothing-to-select') { |
686 | 702 | if(args.context.networks != null) { //from VPC tier |
687 | 703 | array1.push("&networkIds=" + args.context.networks[0].id); |
688 | 704 | array1.push("&domainid=" + args.context.vpc[0].domainid); |
|
0 commit comments