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.

This commit is contained in:
Jessica Wang 2012-11-26 13:03:27 -08:00
parent 7d89d928d9
commit af79da5d80
1 changed files with 52 additions and 6 deletions

View File

@ -277,11 +277,16 @@
$networkStep.find("#from_vpc_tier").show();
}
else { //from Instance page
step5ContainerType = 'select-network';
$networkStep.find("#from_instance_page_1").show();
$networkStep.find("#from_instance_page_2").show();
$networkStep.find("#from_vpc_tier").text("");
$networkStep.find("#from_vpc_tier").hide();
if(selectedZoneObj.securitygroupsenabled != true) { // Advanced SG-disabled zone
step5ContainerType = 'select-network';
$networkStep.find("#from_instance_page_1").show();
$networkStep.find("#from_instance_page_2").show();
$networkStep.find("#from_vpc_tier").text("");
$networkStep.find("#from_vpc_tier").hide();
}
else { // Advanced SG-enabled zone
step5ContainerType = 'select-security-group';
}
}
}
else { //Basic zone. Show securigy group list or nothing(when no SecurityGroup service in guest network)
@ -320,7 +325,16 @@
var networkData = {
zoneId: args.currentData.zoneid
};
// step5ContainerType of Advanced SG-enabled zone is 'select-security-group', so won't come into this block
/*
if(selectedZoneObj.networktype == 'Advanced' && selectedZoneObj.securitygroupsenabled == true) {
$.extend(networkData, {
type: 'Shared'
});
}
*/
if (!(cloudStack.context.projects && cloudStack.context.projects[0])) {
networkData.domainid = g_domainid;
networkData.account = g_account;
@ -532,6 +546,38 @@
if(checkedSecurityGroupIdArray.length > 0)
array1.push("&securitygroupids=" + checkedSecurityGroupIdArray.join(","));
if(selectedZoneObj.networktype == "Advanced" && selectedZoneObj.securitygroupsenabled == true) { // Advanced SG-enabled zone
var networkData = {
zoneId: selectedZoneObj.id,
type: 'Shared',
supportedServices: 'SecurityGroup'
};
if (!(cloudStack.context.projects && cloudStack.context.projects[0])) {
networkData.domainid = g_domainid;
networkData.account = g_account;
}
var selectedNetworkObj = null;
$.ajax({
url: createURL('listNetworks'),
data: networkData,
async: false,
success: function(json) {
var networks = json.listnetworksresponse.network;
if(networks != null && networks.length > 0) {
selectedNetworkObj = networks[0]; //each Advanced SG-enabled zone has only one guest network that is Shared and has SecurityGroup service
}
}
});
if(selectedNetworkObj != null) {
array1.push("&networkIds=" + selectedNetworkObj.id);
}
else {
alert('unable to find any Shared network with SecurityGroup service. Therefore, unable to deploy VM in this Advanced SecurityGroup-enabled zone.');
return;
}
}
}
else if (step5ContainerType == 'nothing-to-select') {
if(args.context.networks != null) { //from VPC tier