mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	bug 8655: VM Wizard - step 4 - If Security Group Network is used AND there is at least one dedicated direct tagged default network for the account, then prompt “Do you wish to launch your VM on a private cloud/network?” If Yes, present network container. If No, present security groups container.
This commit is contained in:
		
							parent
							
								
									ac144e1446
								
							
						
					
					
						commit
						df4fbe796b
					
				@ -19,6 +19,7 @@ label.security.groups.enabled=Security Groups Enabled
 | 
				
			|||||||
label.isolation.mode=Isolation Mode
 | 
					label.isolation.mode=Isolation Mode
 | 
				
			||||||
label.virtual=Virtual
 | 
					label.virtual=Virtual
 | 
				
			||||||
label.security.group=Security Group
 | 
					label.security.group=Security Group
 | 
				
			||||||
 | 
					message.launch.vm.on.private.network=Do you wish to launch your VM on a private cloud/network?
 | 
				
			||||||
message.advanced.virtual=Advanced Zone - Virtual Network
 | 
					message.advanced.virtual=Advanced Zone - Virtual Network
 | 
				
			||||||
message.advanced.security.group=Advanced Zone - Security Group
 | 
					message.advanced.security.group=Advanced Zone - Security Group
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -41,7 +41,8 @@ dictionary = {
 | 
				
			|||||||
	'message.action.instance.reset.password': '<fmt:message key="message.action.instance.reset.password"/>',
 | 
						'message.action.instance.reset.password': '<fmt:message key="message.action.instance.reset.password"/>',
 | 
				
			||||||
	'message.action.take.snapshot': '<fmt:message key="message.action.take.snapshot"/>',
 | 
						'message.action.take.snapshot': '<fmt:message key="message.action.take.snapshot"/>',
 | 
				
			||||||
	'label.data.disk.offering': '<fmt:message key="label.data.disk.offering"/>',
 | 
						'label.data.disk.offering': '<fmt:message key="label.data.disk.offering"/>',
 | 
				
			||||||
	'label.root.disk.offering': '<fmt:message key="label.root.disk.offering"/>'
 | 
						'label.root.disk.offering': '<fmt:message key="label.root.disk.offering"/>',
 | 
				
			||||||
 | 
						'message.launch.vm.on.private.network': '<fmt:message key="message.launch.vm.on.private.network"/>'
 | 
				
			||||||
};	
 | 
					};	
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -767,6 +767,187 @@ function initVMWizard() {
 | 
				
			|||||||
	    return false;
 | 
						    return false;
 | 
				
			||||||
    });  
 | 
					    });  
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
						function vmWizardShowNetworkContainer($thisPopup) {	        
 | 
				
			||||||
 | 
						    $thisPopup.find("#step4").find("#network_container").show();
 | 
				
			||||||
 | 
						    $thisPopup.find("#step4").find("#securitygroup_container").hide();	
 | 
				
			||||||
 | 
							$thisPopup.find("#step4").find("#for_no_network_support").hide();
 | 
				
			||||||
 | 
						    		    
 | 
				
			||||||
 | 
							$.ajax({
 | 
				
			||||||
 | 
								data: createURL("command=listNetworks&domainid="+g_domainid+"&account="+g_account+"&zoneId="+$thisPopup.find("#wizard_zone").val()),
 | 
				
			||||||
 | 
								dataType: "json",
 | 
				
			||||||
 | 
								async: false,
 | 
				
			||||||
 | 
								success: function(json) {
 | 
				
			||||||
 | 
									var networks = json.listnetworksresponse.network;
 | 
				
			||||||
 | 
									var virtualNetwork = null;
 | 
				
			||||||
 | 
									if (networks != null && networks.length > 0) {
 | 
				
			||||||
 | 
										for (var i = 0; i < networks.length; i++) {
 | 
				
			||||||
 | 
											if (networks[i].type == 'Virtual') {
 | 
				
			||||||
 | 
												virtualNetwork = networks[i];
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									var $virtualNetworkElement = $thisPopup.find("#network_virtual_container");
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
									// Setup Virtual Networks
 | 
				
			||||||
 | 
									var requiredVirtual = false;
 | 
				
			||||||
 | 
									var defaultNetworkAdded = false;
 | 
				
			||||||
 | 
									var availableSecondary = false;
 | 
				
			||||||
 | 
									if (virtualNetwork == null) {
 | 
				
			||||||
 | 
										$.ajax({
 | 
				
			||||||
 | 
											data: createURL("command=listNetworkOfferings&guestiptype=Virtual"),
 | 
				
			||||||
 | 
											dataType: "json",
 | 
				
			||||||
 | 
											async: false,
 | 
				
			||||||
 | 
											success: function(json) {
 | 
				
			||||||
 | 
												var networkOfferings = json.listnetworkofferingsresponse.networkoffering;
 | 
				
			||||||
 | 
												if (networkOfferings != null && networkOfferings.length > 0) {
 | 
				
			||||||
 | 
													for (var i = 0; i < networkOfferings.length; i++) {
 | 
				
			||||||
 | 
														if (networkOfferings[i].isdefault == true && networkOfferings[i].availability != "Unavailable") {
 | 
				
			||||||
 | 
															// Create a virtual network
 | 
				
			||||||
 | 
															var networkName = "Virtual Network";
 | 
				
			||||||
 | 
							                                var networkDesc = "A dedicated virtualized network for your account.  The broadcast domain is contained within a VLAN and all public network access is routed out by a virtual router.";				
 | 
				
			||||||
 | 
															$.ajax({
 | 
				
			||||||
 | 
																data: createURL("command=createNetwork&networkOfferingId="+networkOfferings[i].id+"&name="+todb(networkName)+"&displayText="+todb(networkDesc)+"&zoneId="+$thisPopup.find("#wizard_zone").val()),
 | 
				
			||||||
 | 
																dataType: "json",
 | 
				
			||||||
 | 
																async: false,
 | 
				
			||||||
 | 
																success: function(json) {
 | 
				
			||||||
 | 
																	var network = json.createnetworkresponse.network;														
 | 
				
			||||||
 | 
																	$virtualNetworkElement.show();
 | 
				
			||||||
 | 
																	if (network.networkofferingavailability == 'Required') {
 | 
				
			||||||
 | 
																		requiredVirtual = true;
 | 
				
			||||||
 | 
																		$virtualNetworkElement.find("#network_virtual").attr('disabled', true);
 | 
				
			||||||
 | 
																	}
 | 
				
			||||||
 | 
																	defaultNetworkAdded = true;
 | 
				
			||||||
 | 
																	$virtualNetworkElement.find("#network_virtual").data("id", network.id).data("jsonObj", network);														 
 | 
				
			||||||
 | 
																}
 | 
				
			||||||
 | 
															});
 | 
				
			||||||
 | 
														}
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										});
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										if (virtualNetwork.networkofferingavailability != 'Unavailable') {
 | 
				
			||||||
 | 
											$virtualNetworkElement.show();
 | 
				
			||||||
 | 
											if (virtualNetwork.networkofferingavailability == 'Required') {
 | 
				
			||||||
 | 
												requiredVirtual = true;
 | 
				
			||||||
 | 
												$virtualNetworkElement.find("#network_virtual").attr('disabled', true);
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											defaultNetworkAdded = true;
 | 
				
			||||||
 | 
											$virtualNetworkElement.data("id", virtualNetwork.id);
 | 
				
			||||||
 | 
											$virtualNetworkElement.find("#network_virtual").data("id", virtualNetwork.id).data("jsonObj", virtualNetwork);
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											$virtualNetworkElement.hide();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									// Setup Direct Networks
 | 
				
			||||||
 | 
									var $networkDirectTemplate = $("#wizard_network_direct_template");
 | 
				
			||||||
 | 
									var $networkSecondaryDirectTemplate = $("#wizard_network_direct_secondary_template");
 | 
				
			||||||
 | 
									var $networkDirectContainer = $("#network_direct_container").empty();
 | 
				
			||||||
 | 
									var $networkDirectSecondaryContainer = $("#network_direct_secondary_container").empty();
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									if (networks != null && networks.length > 0) {
 | 
				
			||||||
 | 
										for (var i = 0; i < networks.length; i++) {
 | 
				
			||||||
 | 
											if (networks[i].type != 'Direct') {
 | 
				
			||||||
 | 
												continue;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											var $directNetworkElement = null;
 | 
				
			||||||
 | 
											if (networks[i].isdefault) {
 | 
				
			||||||
 | 
												if (requiredVirtual) {
 | 
				
			||||||
 | 
													continue;
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												$directNetworkElement = $networkDirectTemplate.clone().attr("id", "direct"+networks[i].id);
 | 
				
			||||||
 | 
												if (defaultNetworkAdded || i > 0) {
 | 
				
			||||||
 | 
													// Only check the first default network
 | 
				
			||||||
 | 
													$directNetworkElement.find("#network_direct_checkbox").removeAttr("checked");
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
												defaultNetworkAdded = true;
 | 
				
			||||||
 | 
											} else {
 | 
				
			||||||
 | 
												$directNetworkElement = $networkSecondaryDirectTemplate.clone().attr("id", "direct"+networks[i].id);
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											$directNetworkElement.find("#network_direct_checkbox").data("jsonObj", networks[i]);
 | 
				
			||||||
 | 
											$directNetworkElement.find("#network_direct_name").text(networks[i].name);
 | 
				
			||||||
 | 
											$directNetworkElement.find("#network_direct_desc").text(networks[i].displaytext);
 | 
				
			||||||
 | 
											if (networks[i].isdefault) {
 | 
				
			||||||
 | 
												$networkDirectContainer.append($directNetworkElement.show());
 | 
				
			||||||
 | 
											} else {
 | 
				
			||||||
 | 
												availableSecondary = true;
 | 
				
			||||||
 | 
												$networkDirectSecondaryContainer.append($directNetworkElement.show());
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
										
 | 
				
			||||||
 | 
									// Add any additional shared direct networks
 | 
				
			||||||
 | 
									$.ajax({
 | 
				
			||||||
 | 
										data: createURL("command=listNetworks&isshared=true&zoneId="+$thisPopup.find("#wizard_zone").val()),
 | 
				
			||||||
 | 
										dataType: "json",
 | 
				
			||||||
 | 
										async: false,
 | 
				
			||||||
 | 
										success: function(json) {
 | 
				
			||||||
 | 
											var sharedNetworks = json.listnetworksresponse.network;
 | 
				
			||||||
 | 
											if (sharedNetworks != null && sharedNetworks.length > 0) {
 | 
				
			||||||
 | 
												for (var i = 0; i < sharedNetworks.length; i++) {
 | 
				
			||||||
 | 
													if (sharedNetworks[i].type != 'Direct') {
 | 
				
			||||||
 | 
														continue;
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
													if (sharedNetworks[i].isdefault) {
 | 
				
			||||||
 | 
														if (requiredVirtual) {
 | 
				
			||||||
 | 
															continue;
 | 
				
			||||||
 | 
														}
 | 
				
			||||||
 | 
														$directNetworkElement = $networkDirectTemplate.clone().attr("id", "direct"+sharedNetworks[i].id);
 | 
				
			||||||
 | 
														if (defaultNetworkAdded || i > 0) {
 | 
				
			||||||
 | 
															// Only check the first default network
 | 
				
			||||||
 | 
															$directNetworkElement.find("#network_direct_checkbox").removeAttr("checked");
 | 
				
			||||||
 | 
														}
 | 
				
			||||||
 | 
														defaultNetworkAdded = true;
 | 
				
			||||||
 | 
													} else {
 | 
				
			||||||
 | 
														$directNetworkElement = $networkSecondaryDirectTemplate.clone().attr("id", "direct"+sharedNetworks[i].id);
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
													$directNetworkElement.find("#network_direct_checkbox").data("jsonObj", sharedNetworks[i]);
 | 
				
			||||||
 | 
													$directNetworkElement.find("#network_direct_name").text(sharedNetworks[i].name);
 | 
				
			||||||
 | 
													$directNetworkElement.find("#network_direct_desc").text(sharedNetworks[i].displaytext);
 | 
				
			||||||
 | 
													if (sharedNetworks[i].isdefault) {
 | 
				
			||||||
 | 
														$networkDirectContainer.append($directNetworkElement.show());
 | 
				
			||||||
 | 
													} else {
 | 
				
			||||||
 | 
														availableSecondary = true;
 | 
				
			||||||
 | 
														$networkDirectSecondaryContainer.append($directNetworkElement.show());
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									});
 | 
				
			||||||
 | 
									if (availableSecondary) {
 | 
				
			||||||
 | 
										$("#secondary_network_title, #secondary_network_desc").show();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						function vmWizardShowSecurityGroupContainer($thisPopup) {	        
 | 
				
			||||||
 | 
					        $thisPopup.find("#step4").find("#network_container").hide();	
 | 
				
			||||||
 | 
					        if($selectedVmWizardTemplate.data("hypervisor") != "VMware" && getDirectAttachSecurityGroupsEnabled() == "true") {		
 | 
				
			||||||
 | 
							    $thisPopup.find("#step4").find("#securitygroup_container").show();
 | 
				
			||||||
 | 
							    $thisPopup.find("#step4").find("#for_no_network_support").hide();
 | 
				
			||||||
 | 
					            $thisPopup.find("#step4").find("#security_group_section").show();			        
 | 
				
			||||||
 | 
						        $thisPopup.find("#step5").find("#wizard_review_network").text("Basic Network");
 | 
				
			||||||
 | 
						    }
 | 
				
			||||||
 | 
						    else {
 | 
				
			||||||
 | 
							    $thisPopup.find("#step4").find("#securitygroup_container").hide();
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
							    $thisPopup.find("#step4").find("#for_no_network_support").show();	
 | 
				
			||||||
 | 
							    if($selectedVmWizardTemplate.data("hypervisor") == "VMware") {
 | 
				
			||||||
 | 
							        $thisPopup.find("#step4").find("#for_no_network_support").find("#not_available_message_1").show();	
 | 
				
			||||||
 | 
							        $thisPopup.find("#step4").find("#for_no_network_support").find("#not_available_message_2").hide();
 | 
				
			||||||
 | 
							    }		
 | 
				
			||||||
 | 
							    else if(getDirectAttachSecurityGroupsEnabled() != "true") {
 | 
				
			||||||
 | 
							        $thisPopup.find("#step4").find("#for_no_network_support").find("#not_available_message_1").hide();
 | 
				
			||||||
 | 
							        $thisPopup.find("#step4").find("#for_no_network_support").find("#not_available_message_2").show();	
 | 
				
			||||||
 | 
							    }    
 | 
				
			||||||
 | 
								    			
 | 
				
			||||||
 | 
					            $thisPopup.find("#step5").find("#wizard_review_network").text("Basic Network");			   
 | 
				
			||||||
 | 
						    }		   
 | 
				
			||||||
 | 
					    }		    
 | 
				
			||||||
 | 
							
 | 
				
			||||||
    $vmPopup.find("#next_step").bind("click", function(event) {
 | 
					    $vmPopup.find("#next_step").bind("click", function(event) {
 | 
				
			||||||
	    event.preventDefault();
 | 
						    event.preventDefault();
 | 
				
			||||||
	    event.stopPropagation();	
 | 
						    event.stopPropagation();	
 | 
				
			||||||
@ -851,182 +1032,50 @@ function initVMWizard() {
 | 
				
			|||||||
			
 | 
								
 | 
				
			||||||
			var zoneObj = $thisPopup.find("#wizard_zone option:selected").data("zoneObj");
 | 
								var zoneObj = $thisPopup.find("#wizard_zone option:selected").data("zoneObj");
 | 
				
			||||||
						
 | 
											
 | 
				
			||||||
			if (zoneObj.securitygroupsenabled == false) { //Select Network			    
 | 
								if (zoneObj.securitygroupsenabled == false) { //show network container				
 | 
				
			||||||
			    $thisPopup.find("#step4").find("#network_container").show();
 | 
								    vmWizardShowNetworkContainer($thisPopup);	
 | 
				
			||||||
			    $thisPopup.find("#step4").find("#securitygroup_container").hide();	
 | 
								} 
 | 
				
			||||||
				$thisPopup.find("#step4").find("#for_no_network_support").hide();
 | 
								else if (zoneObj.securitygroupsenabled == true) {  // if security group is enabled			    
 | 
				
			||||||
			    		    
 | 
								    var hasDedicatedDirectTaggedDefaultNetwork = false;
 | 
				
			||||||
				var networkName = "Virtual Network";
 | 
								    $.ajax({
 | 
				
			||||||
				var networkDesc = "A dedicated virtualized network for your account.  The broadcast domain is contained within a VLAN and all public network access is routed out by a virtual router.";
 | 
										data: createURL("command=listNetworks&type=Direct&domainid="+g_domainid+"&account="+g_account+"&zoneId="+$thisPopup.find("#wizard_zone").val()),
 | 
				
			||||||
				$.ajax({
 | 
					 | 
				
			||||||
					data: createURL("command=listNetworks&domainid="+g_domainid+"&account="+g_account+"&zoneId="+$thisPopup.find("#wizard_zone").val()),
 | 
					 | 
				
			||||||
					dataType: "json",
 | 
										dataType: "json",
 | 
				
			||||||
					async: false,
 | 
										async: false,
 | 
				
			||||||
					success: function(json) {
 | 
										success: function(json) {
 | 
				
			||||||
						var networks = json.listnetworksresponse.network;
 | 
											var items = json.listnetworksresponse.network;											
 | 
				
			||||||
						var virtualNetwork = null;
 | 
											if (items != null && items.length > 0) {
 | 
				
			||||||
						if (networks != null && networks.length > 0) {
 | 
												for (var i = 0; i < items.length; i++) {								
 | 
				
			||||||
							for (var i = 0; i < networks.length; i++) {
 | 
													if(items[i].isshared ==	false && items[i].isdefault == true) { //dedicated, is default one.
 | 
				
			||||||
								if (networks[i].type == 'Virtual') {
 | 
													    var broadcasturi = items[i].broadcasturi;	//e.g. "vlan://53"
 | 
				
			||||||
									virtualNetwork = networks[i];
 | 
													    if(broadcasturi != null && broadcasturi.length > 0) {
 | 
				
			||||||
 | 
													        var vlanIdString = broadcasturi.substring(7); //e.g. "53"
 | 
				
			||||||
 | 
													        if(isNaN(vlanIdString) == false)
 | 
				
			||||||
 | 
													            hasDedicatedDirectTaggedDefaultNetwork = true;
 | 
				
			||||||
 | 
													    }
 | 
				
			||||||
								}
 | 
													}
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						var $virtualNetworkElement = $("#vm_popup #network_virtual_container");
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
						// Setup Virtual Networks
 | 
					 | 
				
			||||||
						var requiredVirtual = false;
 | 
					 | 
				
			||||||
						var defaultNetworkAdded = false;
 | 
					 | 
				
			||||||
						var availableSecondary = false;
 | 
					 | 
				
			||||||
						if (virtualNetwork == null) {
 | 
					 | 
				
			||||||
							$.ajax({
 | 
					 | 
				
			||||||
								data: createURL("command=listNetworkOfferings&guestiptype=Virtual"),
 | 
					 | 
				
			||||||
								dataType: "json",
 | 
					 | 
				
			||||||
								async: false,
 | 
					 | 
				
			||||||
								success: function(json) {
 | 
					 | 
				
			||||||
									var networkOfferings = json.listnetworkofferingsresponse.networkoffering;
 | 
					 | 
				
			||||||
									if (networkOfferings != null && networkOfferings.length > 0) {
 | 
					 | 
				
			||||||
										for (var i = 0; i < networkOfferings.length; i++) {
 | 
					 | 
				
			||||||
											if (networkOfferings[i].isdefault == true && networkOfferings[i].availability != "Unavailable") {
 | 
					 | 
				
			||||||
												// Create a network from this.
 | 
					 | 
				
			||||||
												$.ajax({
 | 
					 | 
				
			||||||
													data: createURL("command=createNetwork&networkOfferingId="+networkOfferings[i].id+"&name="+todb(networkName)+"&displayText="+todb(networkDesc)+"&zoneId="+$thisPopup.find("#wizard_zone").val()),
 | 
					 | 
				
			||||||
													dataType: "json",
 | 
					 | 
				
			||||||
													async: false,
 | 
					 | 
				
			||||||
													success: function(json) {
 | 
					 | 
				
			||||||
														var network = json.createnetworkresponse.network;														
 | 
					 | 
				
			||||||
														$virtualNetworkElement.show();
 | 
					 | 
				
			||||||
														if (network.networkofferingavailability == 'Required') {
 | 
					 | 
				
			||||||
															requiredVirtual = true;
 | 
					 | 
				
			||||||
															$virtualNetworkElement.find("#network_virtual").attr('disabled', true);
 | 
					 | 
				
			||||||
														}
 | 
					 | 
				
			||||||
														defaultNetworkAdded = true;
 | 
					 | 
				
			||||||
														$virtualNetworkElement.find("#network_virtual").data("id", network.id).data("jsonObj", network);														 
 | 
					 | 
				
			||||||
													}
 | 
					 | 
				
			||||||
												});
 | 
					 | 
				
			||||||
											}
 | 
					 | 
				
			||||||
										}
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							});
 | 
					 | 
				
			||||||
						} else {
 | 
					 | 
				
			||||||
							if (virtualNetwork.networkofferingavailability != 'Unavailable') {
 | 
					 | 
				
			||||||
								$virtualNetworkElement.show();
 | 
					 | 
				
			||||||
								if (virtualNetwork.networkofferingavailability == 'Required') {
 | 
					 | 
				
			||||||
									requiredVirtual = true;
 | 
					 | 
				
			||||||
									$virtualNetworkElement.find("#network_virtual").attr('disabled', true);
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
								defaultNetworkAdded = true;
 | 
					 | 
				
			||||||
								$virtualNetworkElement.data("id", virtualNetwork.id);
 | 
					 | 
				
			||||||
								$virtualNetworkElement.find("#network_virtual").data("id", virtualNetwork.id).data("jsonObj", virtualNetwork);
 | 
					 | 
				
			||||||
							} else {
 | 
					 | 
				
			||||||
								$virtualNetworkElement.hide();
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						
 | 
					 | 
				
			||||||
						// Setup Direct Networks
 | 
					 | 
				
			||||||
						var $networkDirectTemplate = $("#wizard_network_direct_template");
 | 
					 | 
				
			||||||
						var $networkSecondaryDirectTemplate = $("#wizard_network_direct_secondary_template");
 | 
					 | 
				
			||||||
						var $networkDirectContainer = $("#network_direct_container").empty();
 | 
					 | 
				
			||||||
						var $networkDirectSecondaryContainer = $("#network_direct_secondary_container").empty();
 | 
					 | 
				
			||||||
						
 | 
					 | 
				
			||||||
						if (networks != null && networks.length > 0) {
 | 
					 | 
				
			||||||
							for (var i = 0; i < networks.length; i++) {
 | 
					 | 
				
			||||||
								if (networks[i].type != 'Direct') {
 | 
					 | 
				
			||||||
									continue;
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
								var $directNetworkElement = null;
 | 
					 | 
				
			||||||
								if (networks[i].isdefault) {
 | 
					 | 
				
			||||||
									if (requiredVirtual) {
 | 
					 | 
				
			||||||
										continue;
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
									$directNetworkElement = $networkDirectTemplate.clone().attr("id", "direct"+networks[i].id);
 | 
					 | 
				
			||||||
									if (defaultNetworkAdded || i > 0) {
 | 
					 | 
				
			||||||
										// Only check the first default network
 | 
					 | 
				
			||||||
										$directNetworkElement.find("#network_direct_checkbox").removeAttr("checked");
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
									defaultNetworkAdded = true;
 | 
					 | 
				
			||||||
								} else {
 | 
					 | 
				
			||||||
									$directNetworkElement = $networkSecondaryDirectTemplate.clone().attr("id", "direct"+networks[i].id);
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
								$directNetworkElement.find("#network_direct_checkbox").data("jsonObj", networks[i]);
 | 
					 | 
				
			||||||
								$directNetworkElement.find("#network_direct_name").text(networks[i].name);
 | 
					 | 
				
			||||||
								$directNetworkElement.find("#network_direct_desc").text(networks[i].displaytext);
 | 
					 | 
				
			||||||
								if (networks[i].isdefault) {
 | 
					 | 
				
			||||||
									$networkDirectContainer.append($directNetworkElement.show());
 | 
					 | 
				
			||||||
								} else {
 | 
					 | 
				
			||||||
									availableSecondary = true;
 | 
					 | 
				
			||||||
									$networkDirectSecondaryContainer.append($directNetworkElement.show());
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
							
 | 
					 | 
				
			||||||
						// Add any additional shared direct networks
 | 
					 | 
				
			||||||
						$.ajax({
 | 
					 | 
				
			||||||
							data: createURL("command=listNetworks&isshared=true&zoneId="+$thisPopup.find("#wizard_zone").val()),
 | 
					 | 
				
			||||||
							dataType: "json",
 | 
					 | 
				
			||||||
							async: false,
 | 
					 | 
				
			||||||
							success: function(json) {
 | 
					 | 
				
			||||||
								var sharedNetworks = json.listnetworksresponse.network;
 | 
					 | 
				
			||||||
								if (sharedNetworks != null && sharedNetworks.length > 0) {
 | 
					 | 
				
			||||||
									for (var i = 0; i < sharedNetworks.length; i++) {
 | 
					 | 
				
			||||||
										if (sharedNetworks[i].type != 'Direct') {
 | 
					 | 
				
			||||||
											continue;
 | 
					 | 
				
			||||||
										}
 | 
					 | 
				
			||||||
										if (sharedNetworks[i].isdefault) {
 | 
					 | 
				
			||||||
											if (requiredVirtual) {
 | 
					 | 
				
			||||||
												continue;
 | 
					 | 
				
			||||||
											}
 | 
					 | 
				
			||||||
											$directNetworkElement = $networkDirectTemplate.clone().attr("id", "direct"+sharedNetworks[i].id);
 | 
					 | 
				
			||||||
											if (defaultNetworkAdded || i > 0) {
 | 
					 | 
				
			||||||
												// Only check the first default network
 | 
					 | 
				
			||||||
												$directNetworkElement.find("#network_direct_checkbox").removeAttr("checked");
 | 
					 | 
				
			||||||
											}
 | 
					 | 
				
			||||||
											defaultNetworkAdded = true;
 | 
					 | 
				
			||||||
										} else {
 | 
					 | 
				
			||||||
											$directNetworkElement = $networkSecondaryDirectTemplate.clone().attr("id", "direct"+sharedNetworks[i].id);
 | 
					 | 
				
			||||||
										}
 | 
					 | 
				
			||||||
										$directNetworkElement.find("#network_direct_checkbox").data("jsonObj", sharedNetworks[i]);
 | 
					 | 
				
			||||||
										$directNetworkElement.find("#network_direct_name").text(sharedNetworks[i].name);
 | 
					 | 
				
			||||||
										$directNetworkElement.find("#network_direct_desc").text(sharedNetworks[i].displaytext);
 | 
					 | 
				
			||||||
										if (sharedNetworks[i].isdefault) {
 | 
					 | 
				
			||||||
											$networkDirectContainer.append($directNetworkElement.show());
 | 
					 | 
				
			||||||
										} else {
 | 
					 | 
				
			||||||
											availableSecondary = true;
 | 
					 | 
				
			||||||
											$networkDirectSecondaryContainer.append($directNetworkElement.show());
 | 
					 | 
				
			||||||
										}
 | 
					 | 
				
			||||||
									}
 | 
					 | 
				
			||||||
								}
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						});
 | 
					 | 
				
			||||||
						if (availableSecondary) {
 | 
					 | 
				
			||||||
							$("#secondary_network_title, #secondary_network_desc").show();
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				});
 | 
									});		
 | 
				
			||||||
			} 
 | 
									
 | 
				
			||||||
			else if (zoneObj.securitygroupsenabled == true) {  // Select Security Group
 | 
									if(hasDedicatedDirectTaggedDefaultNetwork == true) {
 | 
				
			||||||
			    $thisPopup.find("#step4").find("#network_container").hide();	
 | 
									    $("#dialog_confirmation")
 | 
				
			||||||
			    if($selectedVmWizardTemplate.data("hypervisor") != "VMware" && getDirectAttachSecurityGroupsEnabled() == "true") {		
 | 
					                    .text(dictionary["message.launch.vm.on.private.network"])
 | 
				
			||||||
					$thisPopup.find("#step4").find("#securitygroup_container").show();
 | 
					                    .dialog("option", "buttons", {	                    
 | 
				
			||||||
					$thisPopup.find("#step4").find("#for_no_network_support").hide();
 | 
					                         "Yes": function() {
 | 
				
			||||||
			        $thisPopup.find("#step4").find("#security_group_section").show();			        
 | 
					                             //present the current UI we have today	
 | 
				
			||||||
				    $thisPopup.find("#step5").find("#wizard_review_network").text("Basic Network");
 | 
					                             vmWizardShowNetworkContainer($thisPopup);	
 | 
				
			||||||
				}
 | 
					                             $(this).dialog("close");
 | 
				
			||||||
				else {
 | 
					                         },
 | 
				
			||||||
					$thisPopup.find("#step4").find("#securitygroup_container").hide();
 | 
					                         "No": function() {	                         
 | 
				
			||||||
					
 | 
					                             //present security groups for user to select
 | 
				
			||||||
					$thisPopup.find("#step4").find("#for_no_network_support").show();	
 | 
					                             vmWizardShowSecurityGroupContainer($thisPopup);	
 | 
				
			||||||
					if($selectedVmWizardTemplate.data("hypervisor") == "VMware") {
 | 
					                             $(this).dialog("close");	
 | 
				
			||||||
					    $thisPopup.find("#step4").find("#for_no_network_support").find("#not_available_message_1").show();	
 | 
					                         }
 | 
				
			||||||
					    $thisPopup.find("#step4").find("#for_no_network_support").find("#not_available_message_2").hide();
 | 
					                    }).dialog("open");     
 | 
				
			||||||
					}		
 | 
					                }					    
 | 
				
			||||||
					else if(getDirectAttachSecurityGroupsEnabled() != "true") {
 | 
								    else {
 | 
				
			||||||
					    $thisPopup.find("#step4").find("#for_no_network_support").find("#not_available_message_1").hide();
 | 
								        vmWizardShowSecurityGroupContainer($thisPopup);				        
 | 
				
			||||||
					    $thisPopup.find("#step4").find("#for_no_network_support").find("#not_available_message_2").show();	
 | 
					 | 
				
			||||||
					}    
 | 
					 | 
				
			||||||
					    			
 | 
					 | 
				
			||||||
			        $thisPopup.find("#step5").find("#wizard_review_network").text("Basic Network");			   
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
	    }	
 | 
						    }	
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user