Skip to content

Commit 7566eae

Browse files
author
Jessica Wang
committed
CLOUDSTACK-2074: cloudstack UI - Affinity - VM Wizard - collect affinity group IDs and pass them to API call.
1 parent b203e6c commit 7566eae

1 file changed

Lines changed: 33 additions & 17 deletions

File tree

‎ui/scripts/instanceWizard.js‎

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
(function($, cloudStack) {
1919
var zoneObjs, hypervisorObjs, featuredTemplateObjs, communityTemplateObjs, myTemplateObjs, featuredIsoObjs, community, networkObjs;
2020
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)
2222

2323
cloudStack.instanceWizard = {
2424
maxDiskOfferingSize: function() {
@@ -339,26 +339,26 @@
339339
var $networkStepContainer = $('.step.network:visible');
340340

341341
if(args.initArgs.pluginForm != null && args.initArgs.pluginForm.name == "vpcTierInstanceWizard") { //from VPC Tier chart
342-
step5ContainerType = 'nothing-to-select';
342+
step6ContainerType = 'nothing-to-select';
343343
$networkStep.find("#from_instance_page_1").hide();
344344
$networkStep.find("#from_instance_page_2").hide();
345345
$networkStep.find("#from_vpc_tier").text("tier " + args.context.networks[0].name);
346346
$networkStep.find("#from_vpc_tier").show();
347347
} else { //from Instance page
348348
if(selectedZoneObj.securitygroupsenabled != true) { // Advanced SG-disabled zone
349-
step5ContainerType = 'select-network';
349+
step6ContainerType = 'select-network';
350350
$networkStep.find("#from_instance_page_1").show();
351351
$networkStep.find("#from_instance_page_2").show();
352352
$networkStep.find("#from_vpc_tier").text("");
353353
$networkStep.find("#from_vpc_tier").hide();
354354
$networkStepContainer.removeClass('next-use-security-groups');
355355
} else { // Advanced SG-enabled zone
356-
step5ContainerType = 'select-advanced-sg';
356+
step6ContainerType = 'select-advanced-sg';
357357
}
358358

359359
if ($networkStepContainer.hasClass('next-use-security-groups')) {
360360
$networkStepContainer.removeClass('repeat next-use-security-groups loaded');
361-
step5ContainerType = 'select-security-group';
361+
step6ContainerType = 'select-security-group';
362362
}
363363
}
364364
}
@@ -385,15 +385,15 @@
385385
});
386386

387387
if(includingSecurityGroupService == false || selectedHypervisor == "VMware") {
388-
step5ContainerType = 'nothing-to-select';
388+
step6ContainerType = 'nothing-to-select';
389389
}
390390
else {
391-
step5ContainerType = 'select-security-group';
391+
step6ContainerType = 'select-security-group';
392392
}
393393
}
394394

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') {
397397
var defaultNetworkArray = [], optionalNetworkArray = [];
398398
var networkData = {
399399
zoneId: args.currentData.zoneid,
@@ -478,7 +478,7 @@
478478

479479
$networkStepContainer.removeClass('repeat next-use-security-groups');
480480

481-
if (step5ContainerType == 'select-advanced-sg') {
481+
if (step6ContainerType == 'select-advanced-sg') {
482482
$networkStepContainer.addClass('repeat next-use-security-groups');
483483

484484
// Add guest network is disabled
@@ -498,7 +498,7 @@
498498
});
499499
}
500500

501-
else if(step5ContainerType == 'select-security-group') {
501+
else if(step6ContainerType == 'select-security-group') {
502502
var securityGroupArray = [];
503503
var data = {
504504
domainid: g_domainid,
@@ -530,7 +530,7 @@
530530
});
531531
}
532532

533-
else if(step5ContainerType == 'nothing-to-select') {
533+
else if(step6ContainerType == 'nothing-to-select') {
534534
args.response.success({
535535
type: 'nothing-to-select',
536536
data: {
@@ -544,7 +544,7 @@
544544

545545
},
546546

547-
// Step 6: Review
547+
// Step 7: Review
548548
function(args) {
549549
return false;
550550
}
@@ -569,9 +569,25 @@
569569
if(selectedDiskOfferingObj.iscustomized == true)
570570
array1.push("&size=" + args.data.size);
571571
}
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+
}
572585

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') {
575591
var array2 = [];
576592
var defaultNetworkId = args.data.defaultNetwork; //args.data.defaultNetwork might be equal to string "new-network" or a network ID
577593

@@ -634,7 +650,7 @@
634650

635651
array1.push("&networkIds=" + array2.join(","));
636652
}
637-
else if (step5ContainerType == 'select-security-group') {
653+
else if (step6ContainerType == 'select-security-group') {
638654
var checkedSecurityGroupIdArray;
639655
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"],
640656
checkedSecurityGroupIdArray = args.data["security-groups"];
@@ -682,7 +698,7 @@
682698
array1.push("&networkIds=" + array2.join(","));
683699
}
684700
}
685-
else if (step5ContainerType == 'nothing-to-select') {
701+
else if (step6ContainerType == 'nothing-to-select') {
686702
if(args.context.networks != null) { //from VPC tier
687703
array1.push("&networkIds=" + args.context.networks[0].id);
688704
array1.push("&domainid=" + args.context.vpc[0].domainid);

0 commit comments

Comments
 (0)