|
581 | 581 | ], |
582 | 582 | action: function(args) { |
583 | 583 | // Create a new VM!!!! |
584 | | - var array1 = []; |
| 584 | + var deployVmData = {}; |
585 | 585 |
|
586 | | - //step 1 : select zone |
587 | | - array1.push("&zoneId=" + args.data.zoneid); |
| 586 | + //step 1 : select zone |
| 587 | + $.extend(deployVmData, { |
| 588 | + zoneid : args.data.zoneid |
| 589 | + }); |
588 | 590 |
|
589 | | - //step 2: select template |
590 | | - array1.push("&templateId=" + args.data.templateid); |
591 | | - array1.push("&hypervisor=" + selectedHypervisor); |
| 591 | + //step 2: select template |
| 592 | + $.extend(deployVmData, { |
| 593 | + templateid : args.data.templateid |
| 594 | + }); |
| 595 | + |
| 596 | + $.extend(deployVmData, { |
| 597 | + hypervisor : selectedHypervisor |
| 598 | + }); |
592 | 599 |
|
593 | 600 | if (args.$wizard.find('input[name=rootDiskSize]').parent().css('display') != 'none') { |
594 | | - if (args.$wizard.find('input[name=rootDiskSize]').val().length > 0) { |
595 | | - array1.push("&rootdisksize=" + args.$wizard.find('input[name=rootDiskSize]').val()); |
| 601 | + if (args.$wizard.find('input[name=rootDiskSize]').val().length > 0) { |
| 602 | + $.extend(deployVmData, { |
| 603 | + rootdisksize : args.$wizard.find('input[name=rootDiskSize]').val() |
| 604 | + }); |
596 | 605 | } |
597 | 606 | } |
598 | 607 |
|
599 | | - //step 3: select service offering |
600 | | - array1.push("&serviceOfferingId=" + args.data.serviceofferingid); |
| 608 | + //step 3: select service offering |
| 609 | + $.extend(deployVmData, { |
| 610 | + serviceofferingid : args.data.serviceofferingid |
| 611 | + }); |
601 | 612 |
|
602 | 613 | if (args.$wizard.find('input[name=compute-cpu-cores]').parent().parent().css('display') != 'none') { |
603 | | - if (args.$wizard.find('input[name=compute-cpu-cores]').val().length > 0) { |
604 | | - array1.push("&cpunumber=" + args.$wizard.find('input[name=compute-cpu-cores]').val()); |
| 614 | + if (args.$wizard.find('input[name=compute-cpu-cores]').val().length > 0) { |
| 615 | + $.extend(deployVmData, { |
| 616 | + 'customparameters[0].cpuNumber' : args.$wizard.find('input[name=compute-cpu-cores]').val() |
| 617 | + }); |
605 | 618 | } |
606 | | - if (args.$wizard.find('input[name=compute-cpu]').val().length > 0) { |
607 | | - array1.push("&cpuspeed=" + args.$wizard.find('input[name=compute-cpu]').val()); |
| 619 | + if (args.$wizard.find('input[name=compute-cpu]').val().length > 0) { |
| 620 | + $.extend(deployVmData, { |
| 621 | + 'customparameters[0].cpuSpeed' : args.$wizard.find('input[name=compute-cpu]').val() |
| 622 | + }); |
608 | 623 | } |
609 | | - if (args.$wizard.find('input[name=compute-memory]').val().length > 0) { |
610 | | - array1.push("&memory=" + args.$wizard.find('input[name=compute-memory]').val()); |
| 624 | + if (args.$wizard.find('input[name=compute-memory]').val().length > 0) { |
| 625 | + $.extend(deployVmData, { |
| 626 | + 'customparameters[0].memory' : args.$wizard.find('input[name=compute-memory]').val() |
| 627 | + }); |
611 | 628 | } |
612 | 629 | } |
613 | 630 |
|
614 | 631 | //step 4: select disk offering |
615 | | - if (args.data.diskofferingid != null && args.data.diskofferingid != "0") { |
616 | | - array1.push("&diskOfferingId=" + args.data.diskofferingid); |
617 | | - if (selectedDiskOfferingObj.iscustomized == true) |
618 | | - array1.push("&size=" + args.data.size); |
| 632 | + if (args.data.diskofferingid != null && args.data.diskofferingid != "0") { |
| 633 | + $.extend(deployVmData, { |
| 634 | + diskofferingid : args.data.diskofferingid |
| 635 | + }); |
| 636 | + |
| 637 | + if (selectedDiskOfferingObj.iscustomized == true) { |
| 638 | + $.extend(deployVmData, { |
| 639 | + size : args.data.size |
| 640 | + }); |
| 641 | + } |
619 | 642 | } |
620 | 643 |
|
621 | 644 | //step 5: select an affinity group |
|
629 | 652 | checkedAffinityGroupIdArray = []; |
630 | 653 | } |
631 | 654 |
|
632 | | - if (checkedAffinityGroupIdArray.length > 0) |
633 | | - array1.push("&affinitygroupids=" + checkedAffinityGroupIdArray.join(",")); |
| 655 | + if (checkedAffinityGroupIdArray.length > 0) { |
| 656 | + $.extend(deployVmData, { |
| 657 | + affinitygroupids : checkedAffinityGroupIdArray.join(",") |
| 658 | + }); |
| 659 | + } |
634 | 660 |
|
635 | 661 | //step 6: select network |
636 | 662 | if (step6ContainerType == 'select-network' || step6ContainerType == 'select-advanced-sg') { |
|
651 | 677 | if (args.data["new-network"] == "create-new-network") { |
652 | 678 | var isCreateNetworkSuccessful = true; |
653 | 679 |
|
654 | | - var data = { |
| 680 | + var createNetworkData = { |
655 | 681 | networkOfferingId: args.data["new-network-networkofferingid"], |
656 | 682 | name: args.data["new-network-name"], |
657 | 683 | displayText: args.data["new-network-name"], |
|
660 | 686 |
|
661 | 687 | $.ajax({ |
662 | 688 | url: createURL('createNetwork'), |
663 | | - data: data, |
| 689 | + data: createNetworkData, |
664 | 690 | async: false, |
665 | 691 | success: function(json) { |
666 | 692 | newNetwork = json.createnetworkresponse.network; |
|
681 | 707 | //create new network ends here |
682 | 708 |
|
683 | 709 | //add default network first |
684 | | - if (defaultNetworkId != null && defaultNetworkId.length > 0) |
| 710 | + if (defaultNetworkId != null && defaultNetworkId.length > 0) { |
685 | 711 | array2.push(defaultNetworkId); |
| 712 | + } |
686 | 713 |
|
687 | 714 | //then, add other checked networks |
688 | 715 | if (checkedNetworkIdArray.length > 0) { |
|
691 | 718 | array2.push(checkedNetworkIdArray[i]); |
692 | 719 | } |
693 | 720 | } |
694 | | - |
695 | | - array1.push("&networkIds=" + array2.join(",")); |
| 721 | + |
| 722 | + $.extend(deployVmData, { |
| 723 | + networkids : array2.join(",") |
| 724 | + }); |
| 725 | + |
696 | 726 | } else if (step6ContainerType == 'select-security-group') { |
697 | 727 | var checkedSecurityGroupIdArray; |
698 | 728 | 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"], |
|
704 | 734 | checkedSecurityGroupIdArray = []; |
705 | 735 | } |
706 | 736 |
|
707 | | - if (checkedSecurityGroupIdArray.length > 0) |
708 | | - array1.push("&securitygroupids=" + checkedSecurityGroupIdArray.join(",")); |
| 737 | + if (checkedSecurityGroupIdArray.length > 0) { |
| 738 | + $.extend(deployVmData, { |
| 739 | + securitygroupids : checkedSecurityGroupIdArray.join(",") |
| 740 | + }); |
| 741 | + } |
709 | 742 |
|
710 | 743 | if (selectedZoneObj.networktype == "Advanced" && selectedZoneObj.securitygroupsenabled == true) { // Advanced SG-enabled zone |
711 | 744 | var array2 = []; |
|
723 | 756 | } |
724 | 757 |
|
725 | 758 | //add default network first |
726 | | - if (defaultNetworkId != null && defaultNetworkId.length > 0 && defaultNetworkId != 'new-network') |
| 759 | + if (defaultNetworkId != null && defaultNetworkId.length > 0 && defaultNetworkId != 'new-network') { |
727 | 760 | array2.push(defaultNetworkId); |
| 761 | + } |
728 | 762 |
|
729 | 763 | //then, add other checked networks |
730 | 764 | if (checkedNetworkIdArray.length > 0) { |
|
733 | 767 | array2.push(checkedNetworkIdArray[i]); |
734 | 768 | } |
735 | 769 | } |
736 | | - |
737 | | - array1.push("&networkIds=" + array2.join(",")); |
| 770 | + |
| 771 | + $.extend(deployVmData, { |
| 772 | + networkids : array2.join(",") |
| 773 | + }); |
738 | 774 | } |
739 | 775 | } else if (step6ContainerType == 'nothing-to-select') { |
740 | | - if (args.context.networks != null) { //from VPC tier |
741 | | - array1.push("&networkIds=" + args.context.networks[0].id); |
742 | | - array1.push("&domainid=" + args.context.vpc[0].domainid); |
743 | | - |
744 | | - if (args.context.vpc[0].account != null) |
745 | | - array1.push("&account=" + args.context.vpc[0].account); |
746 | | - else if (args.context.vpc[0].projectid != null) |
747 | | - array1.push("&projectid=" + args.context.vpc[0].projectid); |
| 776 | + if (args.context.networks != null) { //from VPC tier |
| 777 | + $.extend(deployVmData, { |
| 778 | + networkids : args.context.networks[0].id |
| 779 | + }); |
| 780 | + $.extend(deployVmData, { |
| 781 | + domainid : args.context.vpc[0].domainid |
| 782 | + }); |
| 783 | + if (args.context.vpc[0].account != null) { |
| 784 | + $.extend(deployVmData, { |
| 785 | + account : args.context.vpc[0].account |
| 786 | + }); |
| 787 | + } else if (args.context.vpc[0].projectid != null) { |
| 788 | + $.extend(deployVmData, { |
| 789 | + projectid : args.context.vpc[0].projectid |
| 790 | + }); |
| 791 | + } |
748 | 792 | } |
749 | 793 | } |
750 | 794 |
|
751 | 795 | var displayname = args.data.displayname; |
752 | | - if (displayname != null && displayname.length > 0) { |
753 | | - array1.push("&displayname=" + todb(displayname)); |
754 | | - array1.push("&name=" + todb(displayname)); |
| 796 | + if (displayname != null && displayname.length > 0) { |
| 797 | + $.extend(deployVmData, { |
| 798 | + displayname : displayname |
| 799 | + }); |
| 800 | + $.extend(deployVmData, { |
| 801 | + name : displayname |
| 802 | + }); |
755 | 803 | } |
756 | 804 |
|
757 | 805 | var group = args.data.groupname; |
758 | | - if (group != null && group.length > 0) |
759 | | - array1.push("&group=" + todb(group)); |
760 | | - |
761 | | - //array1.push("&startVm=false"); //for testing only, comment it out before checking in |
| 806 | + if (group != null && group.length > 0) { |
| 807 | + $.extend(deployVmData, { |
| 808 | + group : group |
| 809 | + }); |
| 810 | + } |
762 | 811 |
|
763 | 812 | $.ajax({ |
764 | | - url: createURL("deployVirtualMachine" + array1.join("")), |
765 | | - dataType: "json", |
| 813 | + url: createURL('deployVirtualMachine'), |
| 814 | + data: deployVmData, |
766 | 815 | success: function(json) { |
767 | 816 | var jid = json.deployvirtualmachineresponse.jobid; |
768 | 817 | var vmid = json.deployvirtualmachineresponse.id; |
|
0 commit comments