Skip to content

Commit af79da5

Browse files
author
Jessica Wang
committed
CLOUDSTACK-537: cloudstack UI - Advanced SG-Enabled zone - VM wizard - (1) step 5 - Show Security Groups instead of networks. (2) When Launch button is hit, Programmatically find a Shared network with Security Group in the selected zone, then pass it to deployVirtualMachine API.
1 parent 7d89d92 commit af79da5

1 file changed

Lines changed: 52 additions & 6 deletions

File tree

ui/scripts/instanceWizard.js

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,16 @@
277277
$networkStep.find("#from_vpc_tier").show();
278278
}
279279
else { //from Instance page
280-
step5ContainerType = 'select-network';
281-
$networkStep.find("#from_instance_page_1").show();
282-
$networkStep.find("#from_instance_page_2").show();
283-
$networkStep.find("#from_vpc_tier").text("");
284-
$networkStep.find("#from_vpc_tier").hide();
280+
if(selectedZoneObj.securitygroupsenabled != true) { // Advanced SG-disabled zone
281+
step5ContainerType = 'select-network';
282+
$networkStep.find("#from_instance_page_1").show();
283+
$networkStep.find("#from_instance_page_2").show();
284+
$networkStep.find("#from_vpc_tier").text("");
285+
$networkStep.find("#from_vpc_tier").hide();
286+
}
287+
else { // Advanced SG-enabled zone
288+
step5ContainerType = 'select-security-group';
289+
}
285290
}
286291
}
287292
else { //Basic zone. Show securigy group list or nothing(when no SecurityGroup service in guest network)
@@ -320,7 +325,16 @@
320325
var networkData = {
321326
zoneId: args.currentData.zoneid
322327
};
323-
328+
329+
// step5ContainerType of Advanced SG-enabled zone is 'select-security-group', so won't come into this block
330+
/*
331+
if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) {
332+
$.extend(networkData, {
333+
type: 'Shared'
334+
});
335+
}
336+
*/
337+
324338
if (!(cloudStack.context.projects && cloudStack.context.projects[0])) {
325339
networkData.domainid = g_domainid;
326340
networkData.account = g_account;
@@ -532,6 +546,38 @@
532546

533547
if(checkedSecurityGroupIdArray.length > 0)
534548
array1.push("&securitygroupids=" + checkedSecurityGroupIdArray.join(","));
549+
550+
if(selectedZoneObj.networktype == "Advanced" && selectedZoneObj.securitygroupsenabled == true) { // Advanced SG-enabled zone
551+
var networkData = {
552+
zoneId: selectedZoneObj.id,
553+
type: 'Shared',
554+
supportedServices: 'SecurityGroup'
555+
};
556+
if (!(cloudStack.context.projects && cloudStack.context.projects[0])) {
557+
networkData.domainid = g_domainid;
558+
networkData.account = g_account;
559+
}
560+
561+
var selectedNetworkObj = null;
562+
$.ajax({
563+
url: createURL('listNetworks'),
564+
data: networkData,
565+
async: false,
566+
success: function(json) {
567+
var networks = json.listnetworksresponse.network;
568+
if(networks != null && networks.length > 0) {
569+
selectedNetworkObj = networks[0]; //each Advanced SG-enabled zone has only one guest network that is Shared and has SecurityGroup service
570+
}
571+
}
572+
});
573+
if(selectedNetworkObj != null) {
574+
array1.push("&networkIds=" + selectedNetworkObj.id);
575+
}
576+
else {
577+
alert('unable to find any Shared network with SecurityGroup service. Therefore, unable to deploy VM in this Advanced SecurityGroup-enabled zone.');
578+
return;
579+
}
580+
}
535581
}
536582
else if (step5ContainerType == 'nothing-to-select') {
537583
if(args.context.networks != null) { //from VPC tier

0 commit comments

Comments
 (0)