mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	fix bug 6160 - "No disk offering" option is missing when creating VM from templates tab.
This commit is contained in:
		
							parent
							
								
									0f2f356874
								
							
						
					
					
						commit
						7b8218af7b
					
				@ -614,9 +614,9 @@ long milliseconds = new Date().getTime();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<!-- Create VM from template/ISO (begin) -->
 | 
			
		||||
<div id="dialog_create_vm_from_template" title="Create VM" style="display:none">
 | 
			
		||||
	<p>Create VM from <b id="template">xxx</b></p>
 | 
			
		||||
<!-- Create VM from template (begin) -->
 | 
			
		||||
<div id="dialog_create_vm_from_template" title="Create VM from template" style="display:none">
 | 
			
		||||
	<p>Create VM from <b id="source_name">xxx</b></p>
 | 
			
		||||
	<div class="dialog_formcontent">
 | 
			
		||||
		<form action="#" method="post" id="form5">
 | 
			
		||||
			<ol>			   
 | 
			
		||||
@ -644,4 +644,36 @@ long milliseconds = new Date().getTime();
 | 
			
		||||
		</form>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
<!-- Create VM from template/ISO (end) -->
 | 
			
		||||
<!-- Create VM from template (end) -->
 | 
			
		||||
 | 
			
		||||
<!-- Create VM from ISO (begin) -->
 | 
			
		||||
<div id="dialog_create_vm_from_iso" title="Create VM from ISO" style="display:none">
 | 
			
		||||
	<p>Create VM from <b id="source_name">xxx</b></p>
 | 
			
		||||
	<div class="dialog_formcontent">
 | 
			
		||||
		<form action="#" method="post" id="form5">
 | 
			
		||||
			<ol>			   
 | 
			
		||||
				<li>
 | 
			
		||||
					<label>Name:</label>
 | 
			
		||||
					<input class="text" type="text" id="name"/>
 | 
			
		||||
					<div id="name_errormsg" class="dialog_formcontent_errormsg" style="display:none;"></div>
 | 
			
		||||
				</li>
 | 
			
		||||
				<li>
 | 
			
		||||
					<label>Group:</label>
 | 
			
		||||
					<input class="text" type="text" id="group"/>
 | 
			
		||||
					<div id="group_errormsg" class="dialog_formcontent_errormsg" style="display:none;"></div>
 | 
			
		||||
				</li>				
 | 
			
		||||
				<li>
 | 
			
		||||
                    <label>Service Offering:</label>
 | 
			
		||||
                    <select class="select" id="service_offering">
 | 
			
		||||
                    </select>
 | 
			
		||||
                </li>					
 | 
			
		||||
				<li>
 | 
			
		||||
                    <label>Disk Offering:</label>
 | 
			
		||||
                    <select class="select" id="disk_offering">
 | 
			
		||||
                    </select>
 | 
			
		||||
                </li>					
 | 
			
		||||
			</ol>
 | 
			
		||||
		</form>
 | 
			
		||||
	</div>
 | 
			
		||||
</div>
 | 
			
		||||
<!-- Create VM from ISO (end) -->
 | 
			
		||||
@ -51,6 +51,12 @@ function showTemplatesTab() {
 | 
			
		||||
		zIndex: 2000
 | 
			
		||||
	}));
 | 
			
		||||
	
 | 
			
		||||
	activateDialog($("#dialog_create_vm_from_iso").dialog({ 
 | 
			
		||||
		width:300,
 | 
			
		||||
		autoOpen: false,
 | 
			
		||||
		modal: true,
 | 
			
		||||
		zIndex: 2000
 | 
			
		||||
	}));
 | 
			
		||||
	
 | 
			
		||||
	var g_zoneIds = [], g_zoneNames = [];				
 | 
			
		||||
	var addTemplateZoneField = $("#dialog_add_template #add_template_zone");	
 | 
			
		||||
@ -109,9 +115,12 @@ function showTemplatesTab() {
 | 
			
		||||
	    success: function(json) {
 | 
			
		||||
	        var items = json.listserviceofferingsresponse.serviceoffering;
 | 
			
		||||
	        if(items != null && items.length > 0 ) {
 | 
			
		||||
	            var serviceOfferingField = $("#dialog_create_vm_from_template #service_offering").empty();
 | 
			
		||||
	            for(var i = 0; i < items.length; i++)		        
 | 
			
		||||
	                serviceOfferingField.append("<option value='" + items[i].id + "'>" + sanitizeXSS(items[i].name) + "</option>");
 | 
			
		||||
	            var templateServiceOfferingField = $("#dialog_create_vm_from_template #service_offering").empty();
 | 
			
		||||
	            var isoServiceOfferingField = $("#dialog_create_vm_from_iso #service_offering").empty();
 | 
			
		||||
	            for(var i = 0; i < items.length; i++) {		        
 | 
			
		||||
	                templateServiceOfferingField.append("<option value='" + items[i].id + "'>" + sanitizeXSS(items[i].name) + "</option>");
 | 
			
		||||
	                isoServiceOfferingField.append("<option value='" + items[i].id + "'>" + sanitizeXSS(items[i].name) + "</option>");
 | 
			
		||||
	            }
 | 
			
		||||
	        }		        
 | 
			
		||||
	    }
 | 
			
		||||
	});		
 | 
			
		||||
@ -122,9 +131,15 @@ function showTemplatesTab() {
 | 
			
		||||
	    success: function(json) {
 | 
			
		||||
	        var items = json.listdiskofferingsresponse.diskoffering;
 | 
			
		||||
	        if(items != null && items.length > 0 ) {
 | 
			
		||||
	            var diskOfferingField = $("#dialog_create_vm_from_template #disk_offering").empty();
 | 
			
		||||
	            for(var i = 0; i < items.length; i++)		        
 | 
			
		||||
	                diskOfferingField.append("<option value='" + items[i].id + "'>" + sanitizeXSS(items[i].name) + "</option>");
 | 
			
		||||
	            var templateDiskOfferingField = $("#dialog_create_vm_from_template #disk_offering").empty();
 | 
			
		||||
	            templateDiskOfferingField.append("<option value=''>No disk offering</option>");
 | 
			
		||||
	            
 | 
			
		||||
	            var isoDiskOfferingField = $("#dialog_create_vm_from_iso #disk_offering").empty();
 | 
			
		||||
	            
 | 
			
		||||
	            for(var i = 0; i < items.length; i++) {		        
 | 
			
		||||
	                templateDiskOfferingField.append("<option value='" + items[i].id + "'>" + sanitizeXSS(items[i].name) + "</option>");
 | 
			
		||||
	                isoDiskOfferingField.append("<option value='" + items[i].id + "'>" + sanitizeXSS(items[i].name) + "</option>");
 | 
			
		||||
	            }
 | 
			
		||||
	        }		  
 | 
			
		||||
	        
 | 
			
		||||
	    }
 | 
			
		||||
@ -523,12 +538,20 @@ function showTemplatesTab() {
 | 
			
		||||
	function createVMFromTemplateOrISO(actionLink, sourceType) {					
 | 
			
		||||
		var parentElementId = actionLink.data("parentElementId");
 | 
			
		||||
		var thisTemplate = $("#"+parentElementId);			
 | 
			
		||||
		var id = (sourceType == "template")? thisTemplate.data("templateId"): thisTemplate.data("isoId");					
 | 
			
		||||
		var name = thisTemplate.data("name");						
 | 
			
		||||
		var zoneId = thisTemplate.data("zoneId");
 | 
			
		||||
		
 | 
			
		||||
		var createVmDialog = $("#dialog_create_vm_from_template");				
 | 
			
		||||
		createVmDialog.find("#template").text(name);
 | 
			
		||||
		var id;
 | 
			
		||||
		var createVmDialog;
 | 
			
		||||
		if(sourceType == "template") {
 | 
			
		||||
		    id = thisTemplate.data("templateId");
 | 
			
		||||
		    createVmDialog = $("#dialog_create_vm_from_template");		
 | 
			
		||||
		}
 | 
			
		||||
		else { //sourceType == "iso"
 | 
			
		||||
		    id = thisTemplate.data("isoId");
 | 
			
		||||
		    createVmDialog = $("#dialog_create_vm_from_iso");		
 | 
			
		||||
		}
 | 
			
		||||
		createVmDialog.find("#source_name").text(name);
 | 
			
		||||
			
 | 
			
		||||
		createVmDialog
 | 
			
		||||
		.dialog('option', 'buttons', {			    
 | 
			
		||||
@ -541,12 +564,22 @@ function showTemplatesTab() {
 | 
			
		||||
			    isValid &= validateString("Group", thisDialog.find("#group"), thisDialog.find("#group_errormsg"), true);				
 | 
			
		||||
			    if (!isValid) return;	       
 | 
			
		||||
		          
 | 
			
		||||
		        var name = trim(thisDialog.find("#name").val());		
 | 
			
		||||
		        var group = trim(thisDialog.find("#group").val());		
 | 
			
		||||
		        var serviceOfferingId = thisDialog.find("#service_offering").val();				        
 | 
			
		||||
		        var diskOfferingId = thisDialog.find("#disk_offering").val();
 | 
			
		||||
		        thisDialog.dialog("close");  
 | 
			
		||||
		          
 | 
			
		||||
		        var array1 = [];      
 | 
			
		||||
		        var name = trim(thisDialog.find("#name").val());	
 | 
			
		||||
		        array1.push("&displayname="+encodeURIComponent(name));
 | 
			
		||||
		        	
 | 
			
		||||
		        var group = trim(thisDialog.find("#group").val());	
 | 
			
		||||
		        array1.push("&group="+encodeURIComponent(group));
 | 
			
		||||
		        	
 | 
			
		||||
		        var serviceOfferingId = thisDialog.find("#service_offering").val();		
 | 
			
		||||
		        array1.push("&serviceOfferingId="+serviceOfferingId);
 | 
			
		||||
		        		               
 | 
			
		||||
		        var diskOfferingId = thisDialog.find("#disk_offering").val();
 | 
			
		||||
		        if(diskOfferingId != null && diskOfferingId.length > 0)
 | 
			
		||||
		            array1.push("&diskOfferingId="+diskOfferingId);	 
 | 
			
		||||
		        		        
 | 
			
		||||
		        var loadingImg = thisTemplate.find(".adding_loading");		
 | 
			
		||||
                var rowContainer = thisTemplate.find("#row_container");                                         	                               
 | 
			
		||||
                loadingImg.find(".adding_text").text("Creating VM....");	
 | 
			
		||||
@ -554,7 +587,7 @@ function showTemplatesTab() {
 | 
			
		||||
                rowContainer.hide();      
 | 
			
		||||
		        			        		        
 | 
			
		||||
                $.ajax({
 | 
			
		||||
		                data: createURL("command=deployVirtualMachine&zoneId="+zoneId+"&serviceOfferingId="+serviceOfferingId+"&diskOfferingId="+diskOfferingId+"&templateId="+id+"&group="+encodeURIComponent(group)+"&displayname="+encodeURIComponent(name)+"&response=json"),
 | 
			
		||||
		                data: createURL("command=deployVirtualMachine&zoneId="+zoneId+"&templateId="+id+array1.join("")+"&response=json"),
 | 
			
		||||
			        dataType: "json",
 | 
			
		||||
			        success: function(json) {					            
 | 
			
		||||
				        var jobId = json.deployvirtualmachineresponse.jobid;						        
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user