xcpweb

changeset 14:c4237fb33e88 tip

Create New VM module and some bugfixes
author Nikola Nikov <nikolanikov@webconnect.bg>
date Sat Aug 14 19:33:00 2010 +0300 (2010-08-14)
parents 3f3d1227676b
children
files index.html interface/img/active-gradient.jpg interface/img/border.png interface/img/button_bg.png interface/img/button_hover.png interface/img/centos.png interface/img/checked.png interface/img/debian.png interface/img/fedora.png interface/img/ico-close.jpg interface/img/linux.png interface/img/next_step_button.png interface/img/next_step_button_active.png interface/img/oracle.png interface/img/redhat.png interface/img/suse.png interface/img/template_16.png interface/img/ubuntu.png interface/img/unactive-gradient-hover.jpg interface/img/unactive-gradient.jpg interface/img/user_template_16.png interface/img/windows.png interface/index.html interface/js/interface_init.js interface/templates/cloud_pool.js interface/templates/create_new.css interface/templates/create_new.html interface/templates/create_new.js interface/templates/create_new_step1.html interface/templates/create_new_step2.html interface/templates/create_new_step3.html interface/templates/create_new_step4.html interface/templates/create_new_step5.html interface/templates/main.js interface/xcp.css libxen/core.js libxen/db_callbacks.js libxen/libxen_host.js libxen/libxen_init.js libxen/libxen_other.js libxen/libxen_vm.js
line diff
     1.1 --- a/index.html	Thu Aug 05 00:15:19 2010 +0300
     1.2 +++ b/index.html	Sat Aug 14 19:33:00 2010 +0300
     1.3 @@ -1,11 +1,8 @@
     1.4  <html>
     1.5 -  <title>XenCloudPlatform 0.1.1</title>
     1.6 +  <title>XenCloudPlatform </title>
     1.7  <head>
     1.8  </head>
     1.9  <body>
    1.10 -  <p/>Citrix Systems, Inc. XenCloudPlatform 0.1.1
    1.11 -  <p/><a href="XenCenter.iso">XenCenter CD image</a>
    1.12 -  <p/><a href="XenCenter.msi">XenCenter installer</a>
    1.13    <p/><a href="interface/">xcpweb</a>
    1.14  </body>
    1.15  </html>
     2.1 Binary file interface/img/active-gradient.jpg has changed
     3.1 Binary file interface/img/border.png has changed
     4.1 Binary file interface/img/button_bg.png has changed
     5.1 Binary file interface/img/button_hover.png has changed
     6.1 Binary file interface/img/centos.png has changed
     7.1 Binary file interface/img/checked.png has changed
     8.1 Binary file interface/img/debian.png has changed
     9.1 Binary file interface/img/fedora.png has changed
    10.1 Binary file interface/img/ico-close.jpg has changed
    11.1 Binary file interface/img/linux.png has changed
    12.1 Binary file interface/img/next_step_button.png has changed
    13.1 Binary file interface/img/next_step_button_active.png has changed
    14.1 Binary file interface/img/oracle.png has changed
    15.1 Binary file interface/img/redhat.png has changed
    16.1 Binary file interface/img/suse.png has changed
    17.1 Binary file interface/img/template_16.png has changed
    18.1 Binary file interface/img/ubuntu.png has changed
    19.1 Binary file interface/img/unactive-gradient-hover.jpg has changed
    20.1 Binary file interface/img/unactive-gradient.jpg has changed
    21.1 Binary file interface/img/user_template_16.png has changed
    22.1 Binary file interface/img/windows.png has changed
    23.1 --- a/interface/index.html	Thu Aug 05 00:15:19 2010 +0300
    23.2 +++ b/interface/index.html	Sat Aug 14 19:33:00 2010 +0300
    23.3 @@ -27,5 +27,6 @@ var libxen_path='/libxen';
    23.4  
    23.5  <div id="otherPages"></div>
    23.6  <div id="submenus"></div>
    23.7 +<input type="text" id="control_focus" style="display:none" />
    23.8  </body>
    23.9  </html>
   23.10 \ No newline at end of file
    24.1 --- a/interface/js/interface_init.js	Thu Aug 05 00:15:19 2010 +0300
    24.2 +++ b/interface/js/interface_init.js	Sat Aug 14 19:33:00 2010 +0300
    24.3 @@ -1,3 +1,13 @@
    24.4 +function isINT(param)
    24.5 +{
    24.6 +   var ValidChars="0123456789";
    24.7 +   var isINT=1;
    24.8 +
    24.9 +   for (i=0;i<param.length && isINT==1; i++)if(ValidChars.indexOf(param.charAt(i))==-1)isINT=0;
   24.10 +      
   24.11 +return isINT;
   24.12 +}
   24.13 +
   24.14  function templates_req() {
   24.15  	var self = this;
   24.16  	var xmldoc;
   24.17 @@ -68,7 +78,41 @@ function templates_req() {
   24.18  		head.appendChild(style);
   24.19  	}
   24.20  	// other functions
   24.21 +	this.select = function(fobj,varToSet)
   24.22 +	{
   24.23 +		var table;
   24.24 +		if(typeof(fobj)=='undefined') return false;
   24.25 +		if(typeof(fobj)=='string')fobj=document.getElementById(fobj);
   24.26 +		/*
   24.27 +		while(fobj.tagName!='TR' || fobj.tagName!='BODY')fobj=fobj.parentNode;
   24.28 +		if(fobj.tagName=='BODY') return false;
   24.29 +		*/
   24.30 +		table=fobj.parentNode;
   24.31 +		
   24.32 +		if(fobj.getAttribute('selectval') && typeof(varToSet)=='string')eval(varToSet+'="'+fobj.getAttribute('selectval')+'";');
   24.33 +				
   24.34 +		for(var i in table.rows)
   24.35 +			{
   24.36 +				if(isINT(i))
   24.37 +				{
   24.38 +				if(table.rows[i].getAttribute('selectval'))
   24.39 +				{
   24.40 +					table.rows[i].className='';
   24.41 +				}
   24.42 +				}
   24.43 +			}
   24.44 +			
   24.45 +
   24.46 +	fobj.className='table_select';
   24.47 +		
   24.48 +		return fobj.getAttribute('selectval');
   24.49 +	}
   24.50  	
   24.51 +	this.control_focus=function()
   24.52 +	{
   24.53 +		document.getElementById('control_focus').focus();
   24.54 +	}
   24.55 +	 
   24.56  	this.findPos = function(fobj) {
   24.57  		if (typeof(fobj) != 'object') { return [0,0]; }
   24.58  		var curleft = curtop = 0;
   24.59 @@ -491,16 +535,21 @@ function PopupWindow() {
   24.60  	this.mouseX = function(e) { return e ? Number(e.clientX) : Number(event.clientX); }
   24.61  	this.mouseY = function(e) { return e ? Number(e.clientY) : Number(event.clientY); }
   24.62  	
   24.63 -	this.create = function(id,titlebar,content) {
   24.64 +	this.create = function(id,titlebar,content,width,height) {
   24.65 +	var temp;
   24.66 +	var mainobj;
   24.67 +		
   24.68  		if(created_windows[id])return false;
   24.69  		created_windows[id]=1;
   24.70 +		
   24.71  		var tpl = '<div id="window'+id+'" class="window" win="'+id+'" onmouseout="popup.backCursor(this,event)" onmouseover="popup.changeCursor(this,event);">';
   24.72  		tpl += '<div class="win-titlebar" dragwin="window'+id+'">';
   24.73  		tpl += '<div class="title" dragwin="window'+id+'">'+titlebar+'</div>';
   24.74  		tpl += '<div class="close"><img onclick="popup.destroy(\''+id+'\');" src="'+path+'img/close.png" alt="" /></div>';
   24.75  		tpl += '<div class="clear"></div>';
   24.76  		tpl += '</div>';
   24.77 -		tpl += '<div class="win-content" id="resize-'+id+'">';
   24.78 +		if(typeof(width)!='undefined' && typeof(height)!='undefined')tpl += '<div class="win-content" style="width:'+width+'px;height:'+height+'px;" id="resize-'+id+'">';
   24.79 +		else tpl += '<div class="win-content" id="resize-'+id+'">';
   24.80  		tpl += '<div class="cnt" id="wincnt'+id+'"></div>';
   24.81  		tpl += '<img class="corner" src="'+path+'img/corner.png" />';
   24.82  		tpl += '</div>';
   24.83 @@ -510,6 +559,12 @@ function PopupWindow() {
   24.84  			if(typeof(content)=='undefined')return id;
   24.85  			else if(typeof(content)=='object')document.getElementById('wincnt'+id).appendChild(content);
   24.86  			else document.getElementById('wincnt'+id).innerHTML=content;
   24.87 +			
   24.88 +			temp=document.getElementById('window'+id);
   24.89 +			mainobj=document.getElementById('content');
   24.90 +			temp.style.left=templates.findPosX(mainobj)+'px';
   24.91 +			temp.style.top=templates.findPosY(mainobj)+'px';
   24.92 +			
   24.93  			return id;
   24.94  		}
   24.95  		catch(e) { return false; }
   24.96 @@ -519,6 +574,8 @@ function PopupWindow() {
   24.97  	}
   24.98  	
   24.99  	this.create_error = function(titlebar,content) {
  24.100 +	var temp;
  24.101 +	var mainobj;
  24.102  		self.error_windows++;
  24.103  		id='error_'+self.error_windows;
  24.104  		if(created_windows[id])return false;
  24.105 @@ -539,6 +596,11 @@ function PopupWindow() {
  24.106  			if(typeof(content)=='undefined')return id;
  24.107  			else if(typeof(content)=='object')document.getElementById('wincnt'+id).appendChild(content);
  24.108  			else document.getElementById('wincnt'+id).innerHTML=content;
  24.109 +
  24.110 +			temp=document.getElementById('window'+id);
  24.111 +			mainobj=document.getElementById('content');
  24.112 +			temp.style.left=templates.findPosX(mainobj)+'px';
  24.113 +			temp.style.top=templates.findPosY(mainobj)+'px';
  24.114  			return id;
  24.115  		}
  24.116  		catch(e) { return false; }
  24.117 @@ -644,6 +706,64 @@ function PopupWindow() {
  24.118  }
  24.119  var popup = new PopupWindow();
  24.120  
  24.121 +//Tabs
  24.122 +
  24.123 +function Tabs() {
  24.124 +	var self = this;
  24.125 +	var tempTab = false;
  24.126 +	this.clear = function() { tempTab = true; }
  24.127 +	this.construct = function(tabId) {
  24.128 +		var tbl = document.createElement('TABLE');
  24.129 +		tbl.className = 'tabs';
  24.130 +		tbl.setAttribute('tabList','yes');
  24.131 +		tbl.setAttribute('id',tabId);
  24.132 +		tbl.setAttribute('cellpadding',0);
  24.133 +		tbl.setAttribute('cellspacing',0);
  24.134 +		tbl.insertRow(0);
  24.135 +		tempTab = tbl;
  24.136 +		return tempTab;
  24.137 +	}
  24.138 +	this.getTr = function(param) { return param ? param.rows[0] : false; }
  24.139 +	this.getDom = function() { return tempTab; }
  24.140 +	this.append = function(tabAlias,tabName,onclickEvent,temp) {
  24.141 +		if (!temp) { temp = tempTab; }
  24.142 +		var tr = self.getTr(temp);
  24.143 +		var cl = tr.insertCell(tr.cells.length);
  24.144 +		var div = document.createElement('DIV');
  24.145 +		div.className = 'tabBg';
  24.146 +		cl.appendChild(div);
  24.147 +		cl.setAttribute('nowrap','nowrap');
  24.148 +		cl.setAttribute('tabAlias',tabAlias);
  24.149 +		var a = document.createElement('A');
  24.150 +		a.onclick = function() {
  24.151 +			tabs.activate(this.parentNode.parentNode);
  24.152 +			onclickEvent();
  24.153 +		}
  24.154 +		a.appendChild(document.createTextNode(tabName));
  24.155 +		div.appendChild(a);
  24.156 +		tempTab = temp;
  24.157 +		return tempTab;
  24.158 +	}
  24.159 +	this.activate = function(param) {
  24.160 +		var tr = param;
  24.161 +		while (tr = tr.parentNode) {
  24.162 +			if (tr.tagName == 'TR') { break; }
  24.163 +		}
  24.164 +		for (var i=0,len=tr.cells.length;i<len;i++) { tr.cells[i].className = 'singleTab'; }
  24.165 +		param.className = 'activeTab';
  24.166 +	}
  24.167 +	this.activateByAlias = function(alias,temp) {
  24.168 +		if (!temp) { return false; }
  24.169 +		var tr = self.getTr(temp);
  24.170 +		for (var i=0,len=tr.cells.length;i<len;i++) {
  24.171 +			if (tr.cells[i].getAttribute('tabAlias') == alias) {
  24.172 +				tr.cells[i].className = 'activeTab';
  24.173 +			}
  24.174 +			else { tr.cells[i].className = 'singleTab'; }
  24.175 +		}
  24.176 +	}
  24.177 +}
  24.178 +var tabs = new Tabs();
  24.179  
  24.180  //Events
  24.181  
  24.182 @@ -662,15 +782,6 @@ document.onmouseup = popup.mouseup;
  24.183  
  24.184  //The Error Default handling
  24.185  
  24.186 -function isINT(param)
  24.187 -{
  24.188 -   var ValidChars="0123456789";
  24.189 -   var isINT=1;
  24.190 -
  24.191 -   for (i=0;i<param.length && isINT==1; i++)if(ValidChars.indexOf(param.charAt(i))==-1)isINT=0;
  24.192 -      
  24.193 -return isINT;
  24.194 -}
  24.195  
  24.196  
  24.197  function error_callback_default(raw,xmldoc,param_pass)
    25.1 --- a/interface/templates/cloud_pool.js	Thu Aug 05 00:15:19 2010 +0300
    25.2 +++ b/interface/templates/cloud_pool.js	Sat Aug 14 19:33:00 2010 +0300
    25.3 @@ -156,6 +156,7 @@ var is_hidden = 0;
    25.4  	
    25.5  	this.initBox = function()
    25.6  	{
    25.7 +	if(main_buttons.active!='cloud_pool_button')return true;
    25.8  	self.clearBox();
    25.9  	//non resident
   25.10  	var non_resident=xen_get_vm_list_non_resident();
   25.11 @@ -197,7 +198,7 @@ var is_hidden = 0;
   25.12  }
   25.13  
   25.14  var cp_vm_box = new Cloud_Pool_VM_box();
   25.15 -
   25.16 +xen_register_db_event('vm',cp_vm_box.initBox);
   25.17  
   25.18  function Cloud_Pool_submenus()
   25.19  {
   25.20 @@ -266,6 +267,7 @@ this.vm = function(param,e)
   25.21  			if(allowed_operations[op_id]=='resume')xcp_menu.appendInMenu(subcurrent,'resume','Resume',"xen_vm_resume('"+param+"');",'/interface/img/menu_resume.png');
   25.22  			if(allowed_operations[op_id]=='suspend')xcp_menu.appendInMenu(subcurrent,'suspend','Suspend',"xen_vm_suspend('"+param+"');",'/interface/img/menu_shutdown.png');
   25.23  			if(allowed_operations[op_id]=='start')xcp_menu.appendInMenu(subcurrent,'start','Start',"xen_vm_start('"+param+"');",'/interface/img/menu_start.png');
   25.24 +			if(allowed_operations[op_id]=='destroy')xcp_menu.appendInMenu(subcurrent,'destroy','Destroy',"xen_vm_destroy('"+param+"');",'/interface/img/close.png');
   25.25  			}
   25.26  		}
   25.27  		xcp_menu.appendInMenu(currentMenu,'graphics','Statistics',"",'/interface/img/menu_stats.png');
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/interface/templates/create_new.css	Sat Aug 14 19:33:00 2010 +0300
    26.3 @@ -0,0 +1,565 @@
    26.4 +.install_vm_content
    26.5 +{
    26.6 +margin-left: 30px;
    26.7 +clear:both;
    26.8 +width: 940px;
    26.9 +/*border: 1px solid #89b1c1;*/
   26.10 +padding: 5px;
   26.11 +/*
   26.12 +behavior: url("/interface/border-radius.htc");
   26.13 +-moz-border-radius: 4px;
   26.14 +-webkit-border-radius: 4px;
   26.15 +border-radius: 4px;
   26.16 +*/
   26.17 +}
   26.18 +
   26.19 +.install_vm_content .tr
   26.20 +{
   26.21 +min-height: 300px;
   26.22 +vertical-align: top;
   26.23 +}
   26.24 +
   26.25 +
   26.26 +.install_vm_content .steps_td
   26.27 +{
   26.28 +width: 160px;
   26.29 +border: 3px solid #bde0fc;
   26.30 +background-color: #f8fcfd;
   26.31 +-moz-border-radius: 4px;
   26.32 +-webkit-border-radius: 4px;
   26.33 +}
   26.34 +
   26.35 +.install_vm_content .content_td
   26.36 +{
   26.37 +width: 600px;
   26.38 +border: 3px solid #bde0fc;
   26.39 +background-color: #f8fcfd;
   26.40 +-moz-border-radius: 4px;
   26.41 +-webkit-border-radius: 4px;
   26.42 +}
   26.43 +
   26.44 +.install_vm_content .menu_tr_selected
   26.45 +{
   26.46 +background-color: #a5e3fc;
   26.47 +}
   26.48 +
   26.49 +.install_vm_content .menu_tr
   26.50 +{
   26.51 +	cursor:pointer;
   26.52 +}
   26.53 +
   26.54 +.install_vm_content .menu_tr:hover
   26.55 +{
   26.56 +background-color: #f0fbfe;
   26.57 +}
   26.58 +
   26.59 +.install_vm_content .step_inst_steps
   26.60 +{
   26.61 +	font-family: Arial,Helvetica,sans-serif;
   26.62 +	font-size: 13pt;
   26.63 +	font-weight: bold;
   26.64 +	color: #384764;
   26.65 +	padding-top: 8px;
   26.66 +	padding-bottom: 20px;
   26.67 +	text-shadow: 0 1px 2px #d1cafa;
   26.68 +}
   26.69 +
   26.70 +.install_vm_content .step_name
   26.71 +{
   26.72 +	font-family: Arial,Helvetica,sans-serif;
   26.73 +	font-size: 13pt;
   26.74 +	font-weight: bold;
   26.75 +	color: #384764;
   26.76 +	height: 40px;
   26.77 +}
   26.78 +
   26.79 +.install_vm_content .step1_tr
   26.80 +{
   26.81 +	height: 30px;
   26.82 +}
   26.83 +
   26.84 +.install_vm_content .step1_td_label
   26.85 +{
   26.86 +	text-align: left;
   26.87 +	padding-left: 10px;
   26.88 +	font-family: Arial,Helvetica,sans-serif;
   26.89 +	font-size: 10pt;
   26.90 +	font-weight: bold;
   26.91 +}
   26.92 +
   26.93 +.install_vm_content .step1_td_input
   26.94 +{
   26.95 +	border: 1px solid #bde0fc;
   26.96 +}
   26.97 +
   26.98 +.install_vm_content .step1_td_input:focus
   26.99 +{
  26.100 +	border: 2px solid #bde0fc;
  26.101 +}
  26.102 +
  26.103 +.install_vm_content .host_status_box
  26.104 +{
  26.105 +	float:left;
  26.106 +	clear:none;
  26.107 +	width:180px;
  26.108 +	height:110px;
  26.109 +	margin: 9px 0px 0px 40px;
  26.110 +	background-color: #f0fbfe;
  26.111 +	border: 1px solid #a5e3fc;
  26.112 +	-moz-border-radius: 4px;
  26.113 +	-webkit-border-radius: 4px;
  26.114 +}
  26.115 +
  26.116 +.install_vm_content .host_status_box .title
  26.117 +{
  26.118 +	color: #384764;
  26.119 +	size:10pt;
  26.120 +	font-weight:bold;
  26.121 +	padding:4px;
  26.122 +	clear:both;
  26.123 +	width:100%;
  26.124 +	text-align:center;
  26.125 +}
  26.126 +
  26.127 +.install_vm_content .host_status_box .description_row
  26.128 +{
  26.129 +	color: #384764;
  26.130 +	size:10pt;
  26.131 +	padding-left:20px;
  26.132 +	padding-top:5px;
  26.133 +	clear:both;
  26.134 +	width:100%;
  26.135 +	text-align:left;
  26.136 +}
  26.137 +
  26.138 +.install_vm_content .host_status_box .description_row span
  26.139 +{
  26.140 +	color: #384764;
  26.141 +	size:10pt;	
  26.142 +}
  26.143 +
  26.144 +.install_vm_content .select_os_label
  26.145 +{
  26.146 +	text-align: left;
  26.147 +	padding-left: 10px;
  26.148 +	font-family: Arial,Helvetica,sans-serif;
  26.149 +	font-size: 10pt;
  26.150 +	font-weight: bold;
  26.151 +	float:left;
  26.152 +	clear:both;
  26.153 +	width:100%;
  26.154 +	padding-top:10px;
  26.155 +}
  26.156 +
  26.157 +.install_vm_content .select_os
  26.158 +{
  26.159 +	overflow: auto;
  26.160 +	width: 580px;
  26.161 +	margin-left: 10px;
  26.162 +	float:left;
  26.163 +	clear:both;
  26.164 +	margin-top:10px;
  26.165 +	border: 1px solid #bde0fc;
  26.166 +	background-color: #ffffff;
  26.167 +	height: 100px;
  26.168 +}
  26.169 +
  26.170 +.install_vm_content .select_os tr
  26.171 +{
  26.172 +	height:20px;
  26.173 +	cursor:pointer;
  26.174 +	background-color: #ffffff;
  26.175 +}
  26.176 +
  26.177 +.install_vm_content .select_os tr:hover
  26.178 +{
  26.179 +	height:20px;
  26.180 +	cursor:pointer;
  26.181 +	background-color: #f0fbfe;
  26.182 +}
  26.183 +
  26.184 +.install_vm_content .select_os .icon
  26.185 +{
  26.186 +	width:24px;
  26.187 +	text-align:left;
  26.188 +	padding-left: 4px;	
  26.189 +}
  26.190 +
  26.191 +.install_vm_content .select_os .title
  26.192 +{
  26.193 +	text-align:left;
  26.194 +	padding-left: 2px;
  26.195 +	color: #384764;
  26.196 +	size:10pt;
  26.197 +	font-weight:bold;	
  26.198 +}
  26.199 +
  26.200 +.install_vm_content .select_os .type
  26.201 +{
  26.202 +	width:90px;
  26.203 +	text-align:center;	
  26.204 +	color: #384764;
  26.205 +	size:10pt;
  26.206 +	font-weight:bold;
  26.207 +}
  26.208 +
  26.209 +.install_vm_content .next_step_button
  26.210 +{
  26.211 +float:right;
  26.212 +clear:both;
  26.213 +width: 210px;
  26.214 +height: 50px;
  26.215 +background-image: url(/interface/img/next_step_button.png);
  26.216 +display: block;
  26.217 +cursor: pointer;
  26.218 +margin: 10px;
  26.219 +}
  26.220 +
  26.221 +
  26.222 +.install_vm_content .next_step_button:hover
  26.223 +{
  26.224 +background-image: url(/interface/img/next_step_button_active.png) !important;
  26.225 +}
  26.226 +
  26.227 +/* step 2 */
  26.228 +
  26.229 +.install_vm_content .step2_vm_label
  26.230 +{
  26.231 +	text-align: left;
  26.232 +	padding-top: 10px;
  26.233 +	padding-left: 10px;
  26.234 +	font-family: Arial,Helvetica,sans-serif;
  26.235 +	font-size: 10pt;
  26.236 +	font-weight: bold;
  26.237 +}
  26.238 +
  26.239 +.install_vm_content .step2_vm_label .icon
  26.240 +{
  26.241 +	padding-left:4px;
  26.242 +	padding-right:4px;
  26.243 +	position:relative;
  26.244 +	top:3px;
  26.245 +}
  26.246 +
  26.247 +.install_vm_content .step2_vm_label .title
  26.248 +{
  26.249 +	color: #384764;
  26.250 +}
  26.251 +
  26.252 +.install_vm_content .step2_vm_description
  26.253 +{
  26.254 +float:left;
  26.255 +clear:none;
  26.256 +width:570px;
  26.257 +margin-left: 10px;
  26.258 +margin-top: 10px;
  26.259 +background-color: #f0fbfe;
  26.260 +border: 1px solid #a5e3fc;
  26.261 +padding: 4px;
  26.262 +font-family: Arial,Helvetica,sans-serif;
  26.263 +font-size: 10pt;
  26.264 +-moz-border-radius: 5px;
  26.265 +-webkit-border-radius: 5px;
  26.266 +}
  26.267 +
  26.268 +.install_vm_content .step2_location_title
  26.269 +{
  26.270 +float:left;
  26.271 +clear:none;
  26.272 +width:100%;
  26.273 +font-family: Arial,Helvetica,sans-serif;
  26.274 +font-size: 10pt;
  26.275 +font-weight: bold;
  26.276 +padding-top: 20px;
  26.277 +padding-left: 10px;
  26.278 +}
  26.279 +
  26.280 +.install_vm_content .step2_location
  26.281 +{
  26.282 +float:left;
  26.283 +clear:none;
  26.284 +width:100%;
  26.285 +
  26.286 +padding-top: 14px;
  26.287 +padding-left: 10px;
  26.288 +}
  26.289 +
  26.290 +.install_vm_content .step2_location .tr
  26.291 +{
  26.292 +	height:30px;
  26.293 +}
  26.294 +
  26.295 +.install_vm_content .step2_location .td_radio
  26.296 +{
  26.297 +	vertical-align: middle;
  26.298 +	padding-right: 10px;
  26.299 +}
  26.300 +
  26.301 +.install_vm_content .step2_location .td_title
  26.302 +{
  26.303 +	font-family: Arial,Helvetica,sans-serif;
  26.304 +	vertical-align: middle;
  26.305 +	font-size: 10pt;
  26.306 +	font-weight: bold;
  26.307 +	width:120px;
  26.308 +	text-align: left;
  26.309 +}
  26.310 +
  26.311 +.install_vm_content .step2_location .td_input
  26.312 +{
  26.313 +	vertical-align: middle;
  26.314 +}
  26.315 +
  26.316 +.install_vm_content .step2_location .input
  26.317 +{
  26.318 +	width: 250px;
  26.319 +	vertical-align: middle;
  26.320 +	border: 1px solid #bde0fc;
  26.321 +	height: 20px;
  26.322 +}
  26.323 +
  26.324 +.install_vm_content .step2_location .input:focus
  26.325 +{
  26.326 +	border: 2px solid #bde0fc;
  26.327 +}
  26.328 +
  26.329 +/* step 3 and 4*/
  26.330 +
  26.331 +.install_vm_content button {
  26.332 +	background-image: url(/interface/img/button_bg.png);
  26.333 +	background-repeat: repeat-x;
  26.334 +	background-position: left top;
  26.335 +	border: 1px solid #89bbd2;
  26.336 +	color: #333333;
  26.337 +	font-family: Arial, Helvetica, sans-serif;
  26.338 +	cursor: pointer;
  26.339 +	padding-top: 2px;
  26.340 +	padding-bottom: 2px;
  26.341 +	font-weight: bold;
  26.342 +	padding-right: 8px;
  26.343 +	padding-left: 8px;
  26.344 +	*padding:0!important;
  26.345 +	background-color: #dddddd;
  26.346 +	font-size: 12px;
  26.347 +	margin-right:4px;
  26.348 +}
  26.349 +.install_vm_content button:hover {
  26.350 +	background-image: url(/interface/img/button_hover.png);
  26.351 +	background-repeat: repeat-x;
  26.352 +	background-position: left top;
  26.353 +	color:#000000;
  26.354 +	padding-top: 2px;
  26.355 +	padding-bottom: 2px;
  26.356 +	font-weight: bold;
  26.357 +	padding-right: 8px;
  26.358 +	padding-left: 8px;
  26.359 +	background-color: #f0efef;
  26.360 +	font-size: 12px;
  26.361 +	border:1px solid #abacac;
  26.362 +}
  26.363 +
  26.364 +.install_vm_content .step3_description
  26.365 +{
  26.366 +float:left;
  26.367 +clear:none;
  26.368 +width:566px;
  26.369 +margin-left: 10px;
  26.370 +margin-top: 10px;
  26.371 +background-color: #f0fbfe;
  26.372 +border: 1px solid #a5e3fc;
  26.373 +padding: 4px;
  26.374 +font-family: Arial,Helvetica,sans-serif;
  26.375 +font-size: 10pt;
  26.376 +-moz-border-radius: 5px;
  26.377 +-webkit-border-radius: 5px;
  26.378 +}
  26.379 +
  26.380 +.install_vm_content .disks_settings
  26.381 +{
  26.382 +	overflow: auto;
  26.383 +	width: 576px;
  26.384 +	margin-left: 10px;
  26.385 +	float:left;
  26.386 +	clear:both;
  26.387 +	margin-top:10px;
  26.388 +	border: 1px solid #bde0fc;
  26.389 +	background-color: #ffffff;
  26.390 +	height: 100px;
  26.391 +}
  26.392 +
  26.393 +.install_vm_content .disks_settings tr
  26.394 +{
  26.395 +	height:20px;
  26.396 +	cursor:pointer;
  26.397 +	background-color: #ffffff;
  26.398 +}
  26.399 +
  26.400 +.install_vm_content .disks_settings tr:hover
  26.401 +{
  26.402 +	height:20px;
  26.403 +	cursor:pointer;
  26.404 +	background-color: #f0fbfe;
  26.405 +}
  26.406 +
  26.407 +.install_vm_content .disks_settings th
  26.408 +{
  26.409 +	text-align:left;
  26.410 +	size:10pt;
  26.411 +	font-weight:bold;
  26.412 +	background-color: #dfdddb;
  26.413 +	padding-left: 3px;
  26.414 +}
  26.415 +
  26.416 +.install_vm_content .disks_settings th:hover
  26.417 +{
  26.418 +	background-color: #bfbbbb;
  26.419 +}
  26.420 +
  26.421 +.install_vm_content .disks_settings td
  26.422 +{
  26.423 +	text-align:left;
  26.424 +	color: #384764;
  26.425 +	size:10pt;
  26.426 +	font-weight:bold;
  26.427 +	padding-left: 3px;
  26.428 +}
  26.429 +
  26.430 +.install_vm_content .disks_settings .size
  26.431 +{
  26.432 +	width: 60px;
  26.433 +}
  26.434 +
  26.435 +.install_vm_content .disks_settings .shared
  26.436 +{
  26.437 +	width: 100px;
  26.438 +}
  26.439 +
  26.440 +.install_vm_content .network_settings
  26.441 +{
  26.442 +	overflow: auto;
  26.443 +	width: 576px;
  26.444 +	margin-left: 10px;
  26.445 +	float:left;
  26.446 +	clear:both;
  26.447 +	margin-top:10px;
  26.448 +	border: 1px solid #bde0fc;
  26.449 +	background-color: #ffffff;
  26.450 +	height: 60px;
  26.451 +}
  26.452 +
  26.453 +.install_vm_content .network_settings tr
  26.454 +{
  26.455 +	height:20px;
  26.456 +	cursor:pointer;
  26.457 +	background-color: #ffffff;
  26.458 +}
  26.459 +
  26.460 +.install_vm_content .network_settings tr:hover
  26.461 +{
  26.462 +	height:20px;
  26.463 +	cursor:pointer;
  26.464 +	background-color: #f0fbfe;
  26.465 +}
  26.466 +
  26.467 +.install_vm_content .network_settings th
  26.468 +{
  26.469 +	text-align:left;
  26.470 +	size:10pt;
  26.471 +	font-weight:bold;
  26.472 +	background-color: #dfdddb;
  26.473 +	padding-left: 3px;
  26.474 +}
  26.475 +
  26.476 +.install_vm_content .network_settings th:hover
  26.477 +{
  26.478 +	background-color: #bfbbbb;
  26.479 +}
  26.480 +
  26.481 +.install_vm_content .network_settings td
  26.482 +{
  26.483 +	text-align:left;
  26.484 +	color: #384764;
  26.485 +	size:10pt;
  26.486 +	font-weight:bold;
  26.487 +	padding-left: 3px;
  26.488 +}
  26.489 +
  26.490 +.install_vm_content .disks_settings .size
  26.491 +{
  26.492 +	width: 120px;
  26.493 +}
  26.494 +
  26.495 +
  26.496 +.install_vm_content .buttons
  26.497 +{
  26.498 +	margin-top: 5px;
  26.499 +	margin-right: 8px;
  26.500 +	margin-bottom: 10px;
  26.501 +	float:right;
  26.502 +	clear:both;
  26.503 +}
  26.504 +
  26.505 +/* step 5 */
  26.506 +
  26.507 +.install_vm_content .configuration_done
  26.508 +{
  26.509 +float:left;
  26.510 +clear:none;
  26.511 +width:100%;
  26.512 +font-family: Arial,Helvetica,sans-serif;
  26.513 +font-size: 20pt;
  26.514 +font-weight: bold;
  26.515 +padding-left: 10px;
  26.516 +padding-top: 10px;
  26.517 +color: #384764;
  26.518 +}
  26.519 +
  26.520 +.install_vm_content .configuration_description
  26.521 +{
  26.522 +float:left;
  26.523 +clear:none;
  26.524 +width:566px;
  26.525 +margin-left: 10px;
  26.526 +margin-top: 10px;
  26.527 +background-color: #f0fbfe;
  26.528 +border: 1px solid #a5e3fc;
  26.529 +padding: 4px;
  26.530 +font-family: Arial,Helvetica,sans-serif;
  26.531 +font-size: 10pt;
  26.532 +-moz-border-radius: 5px;
  26.533 +-webkit-border-radius: 5px;
  26.534 +}
  26.535 +
  26.536 +.install_vm_content .configuration_option
  26.537 +{
  26.538 +	text-align: left;
  26.539 +	padding-top: 10px;
  26.540 +	padding-left: 10px;
  26.541 +	font-family: Arial,Helvetica,sans-serif;
  26.542 +	font-size: 10pt;
  26.543 +	font-weight: bold;
  26.544 +}
  26.545 +
  26.546 +.install_vm_content .passed_steps
  26.547 +{
  26.548 +	padding: 10px;
  26.549 +	
  26.550 +}
  26.551 +
  26.552 +.install_vm_content .passed_steps tr
  26.553 +{
  26.554 +	height: 20px;
  26.555 +	
  26.556 +}
  26.557 +
  26.558 +.install_vm_content .passed_steps .status
  26.559 +{
  26.560 +	padding-right: 5px;
  26.561 +}
  26.562 +
  26.563 +.install_vm_content .passed_steps .title
  26.564 +{
  26.565 +	font-size: 11pt;
  26.566 +	font-weight: bold;
  26.567 +}
  26.568 +
    27.1 --- a/interface/templates/create_new.html	Thu Aug 05 00:15:19 2010 +0300
    27.2 +++ b/interface/templates/create_new.html	Sat Aug 14 19:33:00 2010 +0300
    27.3 @@ -0,0 +1,22 @@
    27.4 +<div class="install_vm_content">
    27.5 +
    27.6 +<table style="empty-cells: show;" cellpadding="0" cellspacing="0"><tr class="tr">
    27.7 +<!--installation steps -->
    27.8 +<td class="steps_td">
    27.9 +<table cellpadding="0" cellspacing="0" width="100%" id="installation_menu">
   27.10 +<tr class="menu_tr"><td align="center" colspan="2"><div class="step_inst_steps">Installation Steps</div></td></tr>
   27.11 +<tr class="menu_tr" onClick="install_vm.activate(1);"><td width="20" align="center"></td><td class="step_name">1. VM Details</td></tr>
   27.12 +<tr class="menu_tr" onClick="install_vm.activate(2);"><td width="20" align="center"></td><td class="step_name">2. OS Location</td></tr>
   27.13 +<tr class="menu_tr" onClick="install_vm.activate(3);"><td width="20" align="center"></td><td class="step_name">3. VM Disks</td></tr>
   27.14 +<tr class="menu_tr" onClick="install_vm.activate(4);"><td width="20" align="center"></td><td class="step_name">4. Interfaces</td></tr>
   27.15 +<tr class="menu_tr" onClick="install_vm.activate(5);"><td width="20" align="center"></td><td class="step_name">5. Finish</td></tr>
   27.16 +</table>
   27.17 +
   27.18 +</td>
   27.19 +
   27.20 +
   27.21 +<td style="width:8px;"><!--some margin --></td>
   27.22 +<td class="content_td"><div id="vm_content_td"><!--step content --></div></td>
   27.23 +</tr></table>
   27.24 +
   27.25 +</div>
   27.26 \ No newline at end of file
    28.1 --- a/interface/templates/create_new.js	Thu Aug 05 00:15:19 2010 +0300
    28.2 +++ b/interface/templates/create_new.js	Sat Aug 14 19:33:00 2010 +0300
    28.3 @@ -0,0 +1,845 @@
    28.4 +function VM_Installation()
    28.5 +{
    28.6 +var self = this;
    28.7 +var done_steps=new Array(0,0,0,0,0);
    28.8 +var install_menu_table='installation_menu';
    28.9 +this.options=new Array();
   28.10 +
   28.11 +this.make_active_step=function(step)
   28.12 +{
   28.13 +	var table=document.getElementById(install_menu_table);
   28.14 +	for(var i in table.rows)table.rows[i].className='menu_tr';
   28.15 +	table.rows[step].className='menu_tr_selected';
   28.16 +} 
   28.17 +
   28.18 +this.fix_left_menu=function()
   28.19 +{	
   28.20 +	var menu=document.getElementById(install_menu_table);
   28.21 +	var last_unchecked=0;
   28.22 +	//make checked icons
   28.23 +	for(var i=0;i<done_steps.length && done_steps[i]!=0;i++)menu.rows[i+1].cells[0].innerHTML='<img src="/interface/img/checked.png" />';
   28.24 +	last_unchecked=i;
   28.25 +	for(;i<done_steps.length;i++)menu.rows[i+1].cells[0].innerHTML='';
   28.26 +	return last_unchecked;
   28.27 +}
   28.28 +
   28.29 +this.init=function()
   28.30 +	{
   28.31 +	var last_unchecked;
   28.32 +	last_unchecked=self.fix_left_menu();	
   28.33 +	return;
   28.34 +	}
   28.35 +
   28.36 +this.activate=function(step)
   28.37 +	{
   28.38 +		if(step==1)eval("install_vm.step_1()");
   28.39 +		else if(done_steps[step-1] || done_steps[step])eval('install_vm.step_'+step+'()');
   28.40 +		return true;
   28.41 +	}
   28.42 +//TODO: Steps memory
   28.43 +this.step_1=function()
   28.44 +	{
   28.45 +		//check for the required vars
   28.46 +		//some errors
   28.47 +		//if everything is ok invoke the step
   28.48 +		templates.LoadTemplate(interface_path+'/templates/create_new_step1.html','vm_content_td',install_vm.step_1_init);
   28.49 +		return true;
   28.50 +	}
   28.51 +
   28.52 +this.step_1_init=function()
   28.53 +	{
   28.54 +		var template_types=new Object();
   28.55 +		var temp='';
   28.56 +		var template_type='';
   28.57 +		var template_name;
   28.58 +		var tempcell;
   28.59 +		var sorted_dists=new Array();
   28.60 +		var sorted_dists_types=new Array();
   28.61 +		self.options['memory']='';
   28.62 +		self.options['name_label']='';
   28.63 +		self.options['name_description']='';
   28.64 +		self.options['template_id']='';
   28.65 +		self.options['host']='';
   28.66 +		done_steps[0]=0;done_steps[1]=0;done_steps[2]=0;done_steps[3]=0;done_steps[4]=0;
   28.67 +		
   28.68 +		
   28.69 +		template_types['windows']='/interface/img/windows.png';
   28.70 +		template_types['centos']='/interface/img/centos.png';
   28.71 +		template_types['Red Hat']='/interface/img/redhat.png';
   28.72 +		template_types['suse']='/interface/img/suse.png';
   28.73 +		template_types['debian']='/interface/img/debian.png';
   28.74 +		template_types['oracle']='/interface/img/oracle.png';
   28.75 +		template_types['ubuntu']='/interface/img/ubuntu.png';
   28.76 +		template_types['fedora']='/interface/img/fedora.png';
   28.77 +		template_types['redhat']='/interface/img/redhat.png';
   28.78 +		template_types['rhel']='/interface/img/redhat.png';
   28.79 +		template_types['linux']='/interface/img/linux.png';
   28.80 +		template_types['template']='/interface/img/template_16.png';
   28.81 +
   28.82 +		self.init();
   28.83 +		self.make_active_step(1);
   28.84 +	
   28.85 +	 //adding hosts
   28.86 +	 var pool=xen_get_vm_list_hosts();
   28.87 +	 for ( var server_id in pool )
   28.88 +	 {
   28.89 +		temp+='<option id="'+server_id+'" onClick="install_vm.options[\'host\']=\''+server_id+'\';install_vm.step_1_update_host_box(\''+server_id+'\');">'+pool[server_id]['name_label']+'</option>'
   28.90 +	 }
   28.91 +	 var host_servers=document.getElementById('host_servers');
   28.92 +	 host_servers.innerHTML=temp;
   28.93 +	 self.options['host']=host_servers.options[host_servers.selectedIndex].id;
   28.94 +	 self.step_1_update_host_box(host_servers.options[host_servers.selectedIndex].id);
   28.95 +	 
   28.96 +	 
   28.97 +	 var dist_list=xen_vm_get_templates();
   28.98 +	 for(var curtmpl in template_types)
   28.99 +		{
  28.100 +			for(var i in dist_list)
  28.101 +			{
  28.102 +			template_name=xen_vm_get_name_label(dist_list[i]);
  28.103 +			if(eval("template_name.search(/"+curtmpl+"/i);")>=0)
  28.104 +				{
  28.105 +				sorted_dists.push(dist_list[i]);
  28.106 +				sorted_dists_types.push(curtmpl);
  28.107 +				delete dist_list[i];
  28.108 +				}
  28.109 +			}
  28.110 +		}
  28.111 +	for(var i in dist_list)
  28.112 +			{
  28.113 +				sorted_dists.push(dist_list[i]);
  28.114 +				sorted_dists_types.push('template');
  28.115 +				delete dist_list[i];	
  28.116 +			}
  28.117 +
  28.118 +	 
  28.119 +	 var dist_list_table=document.getElementById('dist_list');
  28.120 +	 for(var i in sorted_dists)
  28.121 +	 {
  28.122 +	 var x=dist_list_table.insertRow(-1);
  28.123 +	 x.id='dist_list_'+sorted_dists[i];
  28.124 +	 x.setAttribute('selectval',sorted_dists[i]);
  28.125 +	 x.onclick=function(e){
  28.126 +		var bw=document.getElementById&&!document.all;
  28.127 +		var fobj = bw ? e.target : event.srcElement;
  28.128 +			
  28.129 +			if(fobj!=null)
  28.130 +			{
  28.131 +			while(fobj!=null && fobj.tagName!='TR' && fobj.tagName!='BODY')fobj=fobj.parentNode;
  28.132 +			}
  28.133 +			
  28.134 +			self.options['template_id']=templates.select(fobj);
  28.135 +			
  28.136 +			}
  28.137 +			
  28.138 +	 template_name=xen_vm_get_name_label(sorted_dists[i]);
  28.139 +	 
  28.140 +	 
  28.141 +	 tempcell=x.insertCell(0);
  28.142 +	 tempcell.className='icon';
  28.143 +	 tempcell.innerHTML='<img src="'+template_types[sorted_dists_types[i]]+'" />';
  28.144 +	 
  28.145 +	 tempcell=x.insertCell(1);
  28.146 +	 tempcell.className='title';
  28.147 +	 tempcell.innerHTML=template_name;
  28.148 +	 
  28.149 +	 tempcell=x.insertCell(2);
  28.150 +	 tempcell.className='type';
  28.151 +	 tempcell.innerHTML=sorted_dists_types[i];
  28.152 +	 }
  28.153 +	 self.options['template_id']=templates.select(dist_list_table.rows[0]);
  28.154 +	
  28.155 +	 
  28.156 +	 return true;
  28.157 +	}
  28.158 +
  28.159 +this.step_1_update_host_box=function(server_id)
  28.160 +	{
  28.161 +		var temp='';
  28.162 +		var host_details=xen_host_get_details(server_id);
  28.163 +		document.getElementById('host_box_title').innerHTML=host_details['name_label'];
  28.164 +		document.getElementById('host_box_vcpus').innerHTML=host_details['vCPUs'];
  28.165 +		document.getElementById('host_box_memory_total').innerHTML=host_details['memory_total'];
  28.166 +		document.getElementById('host_box_memory_free').innerHTML=host_details['memory_free'];
  28.167 +		document.getElementById('host_box_resident_vms').innerHTML=host_details['resident_VMs_num'];
  28.168 +		for(var i=0;i<host_details['vCPUs'];i++)temp+='<option>'+(i+1)+'</option>';
  28.169 +		document.getElementById('host_vcpus').innerHTML=temp;
  28.170 +		if(i>0)self.options['vCPUs']=1;
  28.171 +		else self.options['vCPUs']=0;
  28.172 +	}
  28.173 +	
  28.174 +this.step_2=function()
  28.175 +	{
  28.176 +		var error=0;
  28.177 +		var error_txt='';
  28.178 +		//check for the required vars
  28.179 +		//some errors
  28.180 +		//if everything is ok invoke the step
  28.181 +		if(self.options['name_label'].length==0)
  28.182 +			{
  28.183 +			error=1;
  28.184 +			error_txt+='<b>VM Name is not set.</b><br><br>';
  28.185 +			}
  28.186 +		if(self.options['memory'].length==0)
  28.187 +			{
  28.188 +			error=1;
  28.189 +			error_txt+='<b>The Memory field is not set.</b><br><br>';
  28.190 +			}
  28.191 +		if(!isINT(self.options['memory']))
  28.192 +			{
  28.193 +			error=1;
  28.194 +			error_txt+='<b>The Memory field must contain numbers only.</b><br><br>';
  28.195 +			}
  28.196 +		if(self.options['template_id'].length==0)
  28.197 +			{
  28.198 +			error=1;
  28.199 +			error_txt+='<b>VM Template is not set.</b><br><br>';
  28.200 +			}
  28.201 +		if(error)popup.create_error("Errors in Step 1",error_txt);
  28.202 +		else templates.LoadTemplate(interface_path+'/templates/create_new_step2.html','vm_content_td',install_vm.step_2_init);
  28.203 +		return true;
  28.204 +	}
  28.205 +
  28.206 +this.step_2_init=function()
  28.207 +	{
  28.208 +	var other_config;
  28.209 +	var temp;
  28.210 +	done_steps[0]=1;done_steps[1]=0;done_steps[2]=0;done_steps[3]=0;done_steps[4]=0;
  28.211 +	self.options['allowed_devices']='';
  28.212 +	self.options['allowed_devices_id']='';
  28.213 +	self.options['allowed_devices_type']='';
  28.214 +	self.options['allowed_devices_url']='';
  28.215 +	
  28.216 +	self.init();
  28.217 +	self.make_active_step(2);
  28.218 +	
  28.219 +	document.getElementById('step2_template_title').innerHTML=xen_vm_get_name_label(self.options['template_id']);
  28.220 +	document.getElementById('step2_template_description').innerHTML=xen_vm_get_name_description(self.options['template_id']);
  28.221 +	
  28.222 +	other_config=xen_vm_get_other_config(self.options['template_id']);
  28.223 +	if(typeof(other_config['install-methods'])!='undefined')
  28.224 +	{
  28.225 +		if(other_config['install-methods'].search(/http/i)==-1 && other_config['install-methods'].search(/ftp/i)==-1 && other_config['install-methods'].search(/nfs/i)==-1)document.getElementById('step2_url').style.display='none';
  28.226 +		if(other_config['install-methods'].search(/cdrom/i)==-1)
  28.227 +		{
  28.228 +		document.getElementById('step2_phys_drive').style.display='none';
  28.229 +		document.getElementById('step2_cdrom').style.display='none';
  28.230 +		}
  28.231 +	}
  28.232 +	
  28.233 +	self.options['allowed_devices']=self.step_2_get_allowed_devices(self.options['host']);
  28.234 +	
  28.235 +	for ( var id in self.options['allowed_devices']['phys'] )
  28.236 +	 {
  28.237 +		temp+='<option id="'+id+'" onClick="install_vm.options[\'allowed_devices_id\']=\''+id+'\';">'+self.options['allowed_devices']['phys'][id]['name_label']+'</option>'
  28.238 +	 }
  28.239 +	 document.getElementById('step2_phys_select').innerHTML=temp;
  28.240 +	 temp='';
  28.241 +	 for ( var id in self.options['allowed_devices']['iso'] )
  28.242 +	 {
  28.243 +		temp+='<option id="'+id+'" onClick="install_vm.options[\'allowed_devices_id\']=\''+id+'\';">'+self.options['allowed_devices']['iso'][id]['name_label']+'</option>'
  28.244 +	 }
  28.245 +	 document.getElementById('step2_iso_select').innerHTML=temp;
  28.246 +	
  28.247 +	  self.step_2_disable_enable();
  28.248 +	
  28.249 +	}
  28.250 +
  28.251 +this.step_2_disable_enable=function(enable_id)
  28.252 +	{
  28.253 +		document.getElementById('step2_iso_select').disabled=true;
  28.254 +		document.getElementById('step2_phys_select').disabled=true;
  28.255 +		document.getElementById('step2_url_select').disabled=true;
  28.256 +		if(typeof(enable_id)!='undefined')
  28.257 +		{
  28.258 +		document.getElementById(enable_id).disabled=false;
  28.259 +			if(enable_id=='step2_iso_select')
  28.260 +			{
  28.261 +			self.options['allowed_devices_type']='iso';
  28.262 +			self.options['allowed_devices_id']=document.getElementById(enable_id).options[document.getElementById(enable_id).selectedIndex].id;
  28.263 +			}
  28.264 +			if(enable_id=='step2_phys_select')
  28.265 +			{
  28.266 +			self.options['allowed_devices_type']='phys';
  28.267 +			self.options['allowed_devices_id']=document.getElementById(enable_id).options[document.getElementById(enable_id).selectedIndex].id;
  28.268 +			}
  28.269 +			if(enable_id=='step2_url_select')self.options['allowed_devices_type']='url';
  28.270 +		}
  28.271 +
  28.272 +	}
  28.273 +	
  28.274 +this.step_2_get_allowed_devices=function(host_id)
  28.275 +	{
  28.276 +		var ret_array=new Object();
  28.277 +		ret_array['phys']=new Array();
  28.278 +		ret_array['iso']=new Array();
  28.279 +		var temp;
  28.280 +		var SR;
  28.281 +		
  28.282 +		var pbds=xen_host_get_pbd_list(host_id);
  28.283 +		for(var pbd_id in pbds)
  28.284 +		{
  28.285 +		SR=xen_pbd_get_sr(pbds[pbd_id]); 
  28.286 +		var sr_details=xen_sr_get_details(SR);
  28.287 +			//first check for iso images
  28.288 +			if(sr_details['type']=='iso')
  28.289 +				{
  28.290 +					for(var vdi in sr_details['VDIs'])
  28.291 +					{
  28.292 +					ret_array['iso'][ret_array['iso'].length] = {
  28.293 +						PBD: pbds[pbd_id],
  28.294 +						SR: SR,
  28.295 +						VDI: sr_details['VDIs'][vdi],
  28.296 +					    name_label: sr_details['name_label']+'( '+xen_vdi_get_name_label(sr_details['VDIs'][vdi])+' )'
  28.297 +						}
  28.298 +					}
  28.299 +				}
  28.300 +			//checking the physical devices
  28.301 +			if(sr_details['type']=='udev')
  28.302 +				{
  28.303 +					for(var vdi in sr_details['VDIs'])
  28.304 +					{
  28.305 +					ret_array['phys'][ret_array['phys'].length] = {
  28.306 +						PBD: pbds[pbd_id],
  28.307 +						SR: SR,
  28.308 +						VDI: sr_details['VDIs'][vdi],
  28.309 +						name_label: sr_details['name_label']+'( '+xen_vdi_get_name_label(sr_details['VDIs'][vdi])+' )'
  28.310 +						}
  28.311 +					}
  28.312 +				}
  28.313 +		}
  28.314 +		
  28.315 +		return ret_array;
  28.316 +	}
  28.317 +	
  28.318 +this.step_3=function()
  28.319 +	{
  28.320 +	
  28.321 +	var error=0;
  28.322 +		var error_txt='';
  28.323 +		//check for the required vars
  28.324 +		//some errors
  28.325 +		//if everything is ok invoke the step
  28.326 +		if(self.options['allowed_devices_type']=='')
  28.327 +			{
  28.328 +			error=1;
  28.329 +			error_txt+='<b>Please specify install source location.</b><br><br>';
  28.330 +			}
  28.331 +		if(self.options['allowed_devices_type']=='url' && self.options['allowed_devices_url'].length<6)
  28.332 +			{
  28.333 +			error=1;
  28.334 +			error_txt+='<b>The url location field is too small.</b><br><br>';
  28.335 +			}
  28.336 +		if(error)popup.create_error("Errors in Step 2",error_txt);
  28.337 +		else templates.LoadTemplate(interface_path+'/templates/create_new_step3.html','vm_content_td',install_vm.step_3_init);
  28.338 +		return true;
  28.339 +	
  28.340 +	}
  28.341 +
  28.342 +this.step_3_init=function()
  28.343 +	{
  28.344 +	var other_config;
  28.345 +	var temp;
  28.346 +	done_steps[0]=1;done_steps[1]=1;done_steps[2]=0;done_steps[3]=0;done_steps[4]=0;
  28.347 +	self.options['disks']=new Array();
  28.348 +	self.options['allowed_disk_devices']=new Array();
  28.349 +	
  28.350 +	self.init();
  28.351 +	self.make_active_step(3);
  28.352 +	
  28.353 +	
  28.354 +	other_config=xen_vm_get_other_config(self.options['template_id']);
  28.355 +	
  28.356 +	if(typeof(other_config['disks'])!='undefined')
  28.357 +	{
  28.358 +	self.options['disks']=xen_vm_get_provision(other_config['disks']);
  28.359 +	}
  28.360 +	
  28.361 +	self.options['allowed_disk_devices']=self.step_3_get_allowed_disk_devices(self.options['host']);
  28.362 +	
  28.363 +	if(self.options['allowed_disk_devices'].length>0 && self.options['disks'].length>0)
  28.364 +		{
  28.365 +			for(var i in self.options['disks'])
  28.366 +			{
  28.367 +			
  28.368 +			if(self.options['disks'][i]['sr']=='')
  28.369 +				{
  28.370 +				self.options['disks'][i]['location_name']=self.options['allowed_disk_devices'][0]['name_label'];
  28.371 +				self.options['disks'][i]['allowed_disk_devices_id']=0;
  28.372 +				self.options['disks'][i]['sr']=self.options['allowed_disk_devices'][0]['SR'];
  28.373 +				self.options['disks'][i]['sr_uuid']=self.options['allowed_disk_devices'][0]['SR_uuid'];
  28.374 +				if(self.options['allowed_disk_devices'][0]['shared'])self.options['disks'][i]['is_shared']='True';
  28.375 +				else self.options['disks'][i]['is_shared']='False';
  28.376 +				self.step_3_add_disk_row(self.options['disks'][i],i);
  28.377 +				}
  28.378 +			else
  28.379 +				{
  28.380 +					self.options['disks'][i]['location_name']='Other SR';
  28.381 +					self.step_3_add_disk_row(self.options['disks'][i],i);
  28.382 +				}
  28.383 +			}
  28.384 +		}
  28.385 +	
  28.386 +	/*
  28.387 +	var temp=new Object();
  28.388 +	temp['size']=500;
  28.389 +	temp['location_name']='Local Storage on xcpweb';
  28.390 +	temp['is_shared']='false';
  28.391 +	self.step_3_add_disk_row(temp,2);
  28.392 +	*/
  28.393 +	
  28.394 +		return true;
  28.395 +	}	
  28.396 +
  28.397 +this.step_3_get_allowed_disk_devices=function(host_id)
  28.398 +	{
  28.399 +		var ret_array=new Array();
  28.400 +		
  28.401 +		var pbds=xen_host_get_pbd_list(host_id);
  28.402 +		for(var pbd_id in pbds)
  28.403 +		{
  28.404 +		SR=xen_pbd_get_sr(pbds[pbd_id]);
  28.405 +		var sr_details=xen_sr_get_details(SR);
  28.406 +			for(var operation in sr_details['allowed_operations'])
  28.407 +			{
  28.408 +				if(sr_details['allowed_operations'][operation]=='vdi_create')
  28.409 +				{
  28.410 +					ret_array[ret_array.length] = {
  28.411 +								PBD: pbds[pbd_id],
  28.412 +								SR: SR,
  28.413 +								SR_uuid: sr_details['uuid'],
  28.414 +								all_space: Math.round((parseInt(sr_details['physical_size'])/(1024*1024*1024))*100)/100,
  28.415 +								free_space: Math.round(((Math.round((parseInt(sr_details['physical_size'])/(1024*1024*1024))*100)/100)-(Math.round((parseInt(sr_details['physical_utilisation'])/(1024*1024*1024))*100)/100))*100)/100,
  28.416 +								is_shared: sr_details['shared'],
  28.417 +								name_label: sr_details['name_label']+' on '+xen_host_get_name_label(xen_pbd_get_host(pbds[pbd_id]))
  28.418 +						}
  28.419 +				}
  28.420 +			}
  28.421 +		
  28.422 +		}
  28.423 +		
  28.424 +		return ret_array;
  28.425 +	}
  28.426 +	
  28.427 +this.step_3_add_disk_row=function(params,id)
  28.428 +	{
  28.429 +	var x=document.getElementById('disks_settings_table').insertRow(-1);
  28.430 +	var tempcell;
  28.431 +	
  28.432 +	
  28.433 +	 x.id='step3_disk_'+id;
  28.434 +	 x.setAttribute('selectval',id);
  28.435 +	 x.onclick=function(e){
  28.436 +		var bw=document.getElementById&&!document.all;
  28.437 +		var fobj = bw ? e.target : event.srcElement;
  28.438 +			
  28.439 +			if(fobj!=null)
  28.440 +			{
  28.441 +			while(fobj!=null && fobj.tagName!='TR' && fobj.tagName!='BODY')fobj=fobj.parentNode;
  28.442 +			}
  28.443 +			
  28.444 +			self.options['temp_step_3_selected_disk']=templates.select(fobj);
  28.445 +			
  28.446 +			}
  28.447 +
  28.448 +	 tempcell=x.insertCell(0);
  28.449 +	 tempcell.className='size';
  28.450 +	 tempcell.innerHTML=params['size'];
  28.451 +	 
  28.452 +	 tempcell=x.insertCell(1);
  28.453 +	 tempcell.className='location';
  28.454 +	 tempcell.innerHTML=params['location_name'];
  28.455 +	 
  28.456 +	 tempcell=x.insertCell(2);
  28.457 +	 tempcell.className='shared';
  28.458 +	 tempcell.innerHTML=params['is_shared'];
  28.459 +	
  28.460 +	}
  28.461 +	
  28.462 +this.step_3_reinit_disk_rows=function()
  28.463 +	{
  28.464 +		var x=document.getElementById('disks_settings_table');
  28.465 +		for(var i=x.rows.length-1;i>=1;i--)x.deleteRow(i);
  28.466 +		
  28.467 +		for(var i in self.options['disks'])self.step_3_add_disk_row(self.options['disks'][i],i);
  28.468 +	}
  28.469 +
  28.470 +this.step_3_insert_disk=function(do_edit_id)
  28.471 +	{
  28.472 +		var insert_id;
  28.473 +		if(typeof(do_edit_id)!='undefined')insert_id=do_edit_id;
  28.474 +		else insert_id=self.options['disks'].length;
  28.475 +		if(self.options['temp_step_3_disk_window']=='' || self.options['temp_step_3_disk_window_size']=='')return;
  28.476 +		//the storage
  28.477 +		self.options['disks'][insert_id]=new Object();
  28.478 +		self.options['disks'][insert_id]['location_name']=self.options['allowed_disk_devices'][parseInt(self.options['temp_step_3_disk_window'])]['name_label'];
  28.479 +		self.options['disks'][insert_id]['sr']=self.options['allowed_disk_devices'][parseInt(self.options['temp_step_3_disk_window'])]['SR'];
  28.480 +		self.options['disks'][insert_id]['sr_uuid']=self.options['allowed_disk_devices'][parseInt(self.options['temp_step_3_disk_window'])]['SR_uuid'];
  28.481 +		if(self.options['allowed_disk_devices'][parseInt(self.options['temp_step_3_disk_window'])]['shared'])self.options['disks'][insert_id]['is_shared']='True';
  28.482 +		else self.options['disks'][insert_id]['is_shared']='False';
  28.483 +		self.options['disks'][insert_id]['allowed_disk_devices_id']=parseInt(self.options['temp_step_3_disk_window']);
  28.484 +				self.options['disks'][insert_id]['size']=parseInt(self.options['temp_step_3_disk_window_size']);
  28.485 +				self.options['disks'][insert_id]['bootable']='false';
  28.486 +				self.options['disks'][insert_id]['type']='system';
  28.487 +		
  28.488 +		self.step_3_reinit_disk_rows();
  28.489 +	}
  28.490 +
  28.491 +this.step_3_delete_disk=function()
  28.492 +	{
  28.493 +		self.options['disks'].splice(parseInt(self.options['temp_step_3_selected_disk']),1);
  28.494 +		self.step_3_reinit_disk_rows();
  28.495 +	}
  28.496 +
  28.497 +this.step_3_new_disk_window=function(do_edit)
  28.498 +	{
  28.499 +	var cur_disk;
  28.500 +	var onclick='';
  28.501 +	var disk_size='';
  28.502 +	var do_edit_id='';
  28.503 +	self.options['temp_step_3_disk_window']='';
  28.504 +	self.options['temp_step_3_disk_window_size']='';
  28.505 +	var tmphtml='<div class="install_vm_content" style="width: 450px; margin-left: 0px;">';
  28.506 +	if(do_edit)
  28.507 +	{
  28.508 +	cur_disk=self.options['disks'][parseInt(self.options['temp_step_3_selected_disk'])];
  28.509 +	do_edit_id=self.options['temp_step_3_selected_disk'];
  28.510 +	disk_size=cur_disk['size'];
  28.511 +	}
  28.512 +	else
  28.513 +	{
  28.514 +	do_edit_id='';
  28.515 +	}
  28.516 +	
  28.517 +	tmphtml+='<div style="padding:5px;clear:both;width:100%;font-size:10pt;font-weight: bold;">Disk Size: <input type="text" id="disk_size_input" value="'+disk_size+'" style="width:80px;border: 1px solid #bde0fc;"> MB</div>';
  28.518 +	tmphtml+='<div style="padding:5px;clear:both;width:100%;font-size:10pt;font-weight: bold;">Location: </div>';
  28.519 +	tmphtml+='<div class="disks_settings" style="width: 426px; margin-top: 0px;">';
  28.520 +	tmphtml+='<table style="width:100%;border-collapse:collapse;clear:both;" id="disk_list_table">';
  28.521 +	tmphtml+='<tr><th style="border-right: 1px solid #717171;">Storage Name</th><th style="border-right: 1px solid #717171;">All Size(GB)</th><th>Free Size(GB)</th></tr>';
  28.522 +	
  28.523 +	for(var i in self.options['allowed_disk_devices'])
  28.524 +	{
  28.525 +	tmphtml+='<tr selectval="'+i+'" id="step3_cur_disk_'+i+'" onclick="install_vm.options[\'temp_step_3_disk_window\']=templates.select(this);"><td style="width:220px;padding-left:3px;">'+self.options['allowed_disk_devices'][i]['name_label']+'</td><td style="width:100px;padding-left:3px;">'+self.options['allowed_disk_devices'][i]['all_space']+' GB</td><td style="width:100px;padding-left:3px;">'+self.options['allowed_disk_devices'][i]['free_space']+' GB</td></tr>';
  28.526 +	}
  28.527 +	
  28.528 +	onclick="install_vm.options['temp_step_3_disk_window_size']=document.getElementById('disk_size_input').value;install_vm.step_3_insert_disk("+do_edit_id+");popup.destroy(\'disk_options\');";
  28.529 +	
  28.530 +	tmphtml+='</table></div>';
  28.531 +	tmphtml+='<div class="buttons"><button onclick="'+onclick+'">OK</button><button onclick="popup.destroy(\'disk_options\');">Close</button></div>';
  28.532 +	
  28.533 +	popup.create('disk_options','Disk Options',tmphtml,480,250);
  28.534 +	
  28.535 +	
  28.536 +	if(do_edit)self.options['temp_step_3_disk_window']=templates.select('step3_cur_disk_'+self.options['disks'][parseInt(self.options['temp_step_3_selected_disk'])]['allowed_disk_devices_id']);
  28.537 +	else if(self.options['allowed_disk_devices'].length)self.options['temp_step_3_disk_window']=templates.select('step3_cur_disk_0');
  28.538 +	
  28.539 +	}
  28.540 +
  28.541 +	
  28.542 +this.step_4=function()
  28.543 +	{
  28.544 +		var error=0;
  28.545 +		var error_txt='';
  28.546 +		//check for the required vars
  28.547 +		//some errors
  28.548 +		//if everything is ok invoke the step
  28.549 +		if(self.options['disks'].length==0)
  28.550 +			{
  28.551 +			error_txt+='<b>There are not any attached storage devices.</b><br><br>Are you sure, that you don\'t need any devices?';
  28.552 +			popup.create_error("Errors in Step 3",error_txt);
  28.553 +			}
  28.554 +		
  28.555 +		templates.LoadTemplate(interface_path+'/templates/create_new_step4.html','vm_content_td',install_vm.step_4_init);
  28.556 +		return true;
  28.557 +	}
  28.558 +
  28.559 +this.step_4_init=function()
  28.560 +	{// TODO to guess the installer network, but for test just put the uuid
  28.561 +	var other_config;
  28.562 +	var temp;
  28.563 +	var install_index=0;
  28.564 +	done_steps[0]=1;done_steps[1]=1;done_steps[2]=1;done_steps[3]=0;done_steps[4]=0;
  28.565 +	self.options['vifs']=new Array();
  28.566 +	
  28.567 +	
  28.568 +	self.init();
  28.569 +	self.make_active_step(4);
  28.570 +	
  28.571 +	self.options['allowed_network_devices']=self.step_4_get_allowed_network_devices(self.options['host']);
  28.572 +	
  28.573 +	
  28.574 +	if(self.options['allowed_network_devices'].length>0)
  28.575 +		{
  28.576 +		
  28.577 +		for(var i in self.options['allowed_network_devices'])
  28.578 +			{
  28.579 +				if(eval("self.options['allowed_network_devices']["+i+"]['bridge'].search(/xapi/i);")>=0)
  28.580 +				{
  28.581 +				install_index=i;
  28.582 +				break;
  28.583 +				}
  28.584 +			}
  28.585 +		
  28.586 +			self.options['vifs'][self.options['vifs'].length] = {
  28.587 +				network_id: self.options['allowed_network_devices'][install_index]['network_id'],
  28.588 +				name_label: self.options['allowed_network_devices'][install_index]['name_label'],
  28.589 +				bridge: self.options['allowed_network_devices'][install_index]['bridge'],
  28.590 +			}
  28.591 +			self.step_4_add_vif_row(self.options['vifs'][self.options['vifs'].length-1],self.options['vifs'].length-1);
  28.592 +		}
  28.593 +	
  28.594 +	return true;
  28.595 +	}
  28.596 +
  28.597 +this.step_4_get_allowed_network_devices=function(host_id)
  28.598 +	{
  28.599 +		var ret_array=new Array();
  28.600 +		
  28.601 +		var networks=xen_host_get_network_list(host_id);
  28.602 +		for(var net_id in networks)
  28.603 +		{
  28.604 +		var network_details=xen_network_get_details(networks[net_id]);
  28.605 +		ret_array[ret_array.length] = {
  28.606 +			network_id: networks[net_id],
  28.607 +			name_label: network_details['name_label'],
  28.608 +			name_description: network_details['name_description'],
  28.609 +			bridge: network_details['bridge']
  28.610 +			}
  28.611 +		
  28.612 +		}
  28.613 +		
  28.614 +		return ret_array;
  28.615 +	}
  28.616 +
  28.617 +this.step_4_add_vif_row=function(params,id)
  28.618 +	{
  28.619 +	var x=document.getElementById('network_settings_table').insertRow(-1);
  28.620 +	var tempcell;
  28.621 +			//<tr><td class="interface">Interface 1</td><td>Auto generated.</td><td>Guest installer network</td></tr>
  28.622 +	
  28.623 +	 x.id='step4_vif_'+id;
  28.624 +	 x.setAttribute('selectval',id);
  28.625 +	 x.onclick=function(e){
  28.626 +		var bw=document.getElementById&&!document.all;
  28.627 +		var fobj = bw ? e.target : event.srcElement;
  28.628 +			
  28.629 +			if(fobj!=null)
  28.630 +			{
  28.631 +			while(fobj!=null && fobj.tagName!='TR' && fobj.tagName!='BODY')fobj=fobj.parentNode;
  28.632 +			}
  28.633 +			
  28.634 +			self.options['temp_step_4_selected_vif']=templates.select(fobj);
  28.635 +			
  28.636 +			}
  28.637 +
  28.638 +	 tempcell=x.insertCell(0);
  28.639 +	 tempcell.className='interface';
  28.640 +	 tempcell.innerHTML='Interface '+id;
  28.641 +	 
  28.642 +	 tempcell=x.insertCell(1);
  28.643 +	 tempcell.className='mac';
  28.644 +	 tempcell.innerHTML='Auto generated.';
  28.645 +	 
  28.646 +	 tempcell=x.insertCell(2);
  28.647 +	 tempcell.className='network';
  28.648 +	 tempcell.innerHTML=params['name_label'];
  28.649 +	
  28.650 +	}
  28.651 +
  28.652 +	this.step_4_new_vif_window=function(do_edit)
  28.653 +	{
  28.654 +	var cur_disk;
  28.655 +	var onclick='';
  28.656 +	var disk_size='';
  28.657 +	var do_edit_id='';
  28.658 +	self.options['temp_step_4_selected_vif']='';
  28.659 +	var tmphtml='<div class="install_vm_content" style="width: 450px; margin-left: 0px;">';
  28.660 +	
  28.661 +	tmphtml+='<div class="disks_settings" style="width: 426px; margin-top: 0px;">';
  28.662 +	tmphtml+='<table style="width:100%;border-collapse:collapse;clear:both;" id="disk_list_table">';
  28.663 +	tmphtml+='<tr><th style="border-right: 1px solid #717171;">Network Name</th><th style="border-right: 1px solid #717171;">Bridge</th></tr>';
  28.664 +	
  28.665 +	for(var i in self.options['allowed_network_devices'])
  28.666 +	{
  28.667 +	tmphtml+='<tr selectval="'+i+'" id="step4_cur_net_'+i+'" onclick="install_vm.options[\'temp_step_4_net_window\']=templates.select(this);"><td style="width:250px;padding-left:3px;">'+self.options['allowed_network_devices'][i]['name_label']+'</td><td style="width:100px;padding-left:3px;">'+self.options['allowed_network_devices'][i]['bridge']+'</td></tr>';
  28.668 +	}
  28.669 +	
  28.670 +	onclick="install_vm.step_4_insert_vif();popup.destroy(\'network_options\');";
  28.671 +	
  28.672 +	tmphtml+='</table></div>';
  28.673 +	tmphtml+='<div class="buttons"><button onclick="'+onclick+'">OK</button><button onclick="popup.destroy(\'network_options\');">Close</button></div>';
  28.674 +	
  28.675 +	popup.create('network_options','Network Options',tmphtml,480,250);
  28.676 +	
  28.677 +	
  28.678 +	}
  28.679 +	
  28.680 +	this.step_4_reinit_network_rows=function()
  28.681 +	{
  28.682 +		var x=document.getElementById('network_settings_table');
  28.683 +		for(var i=x.rows.length-1;i>0;i--)x.deleteRow(i);
  28.684 +		
  28.685 +		for(var i in self.options['vifs'])self.step_4_add_vif_row(self.options['vifs'][i],i);
  28.686 +	}
  28.687 +
  28.688 +this.step_4_insert_vif=function()
  28.689 +	{
  28.690 +		var insert_id=self.options['vifs'].length;
  28.691 +
  28.692 +		if(self.options['temp_step_4_net_window']=='')return;
  28.693 +		//the vif
  28.694 +		self.options['vifs'][insert_id]= {
  28.695 +			network_id: self.options['allowed_network_devices'][parseInt(self.options['temp_step_4_net_window'])]['network_id'],
  28.696 +			name_label: self.options['allowed_network_devices'][parseInt(self.options['temp_step_4_net_window'])]['name_label'],
  28.697 +			bridge: self.options['allowed_network_devices'][parseInt(self.options['temp_step_4_net_window'])]['bridge']
  28.698 +			}
  28.699 +		
  28.700 +		
  28.701 +		self.step_4_reinit_network_rows();
  28.702 +	}
  28.703 +
  28.704 +this.step_4_delete_vif=function()
  28.705 +	{
  28.706 +		self.options['vifs'].splice(parseInt(self.options['temp_step_4_selected_vif']),1);
  28.707 +		self.step_4_reinit_network_rows();
  28.708 +	}
  28.709 +	
  28.710 +this.step_5=function()
  28.711 +	{
  28.712 +
  28.713 +	//here is the installation step
  28.714 +	templates.LoadTemplate(interface_path+'/templates/create_new_step5.html','vm_content_td',install_vm.step_5_init);
  28.715 +	}
  28.716 +
  28.717 +this.step_5_init=function()
  28.718 +	{
  28.719 +	var new_vm_uuid='';
  28.720 +	var cd_ref='';
  28.721 +	var other_config;
  28.722 +	done_steps[0]=1;done_steps[1]=1;done_steps[2]=1;done_steps[3]=1;done_steps[4]=0;
  28.723 +	
  28.724 +	self.init();
  28.725 +	self.make_active_step(5);
  28.726 +		
  28.727 +		
  28.728 +	new_vm_uuid=xen_vm_clone_sync(self.options['template_id'],self.options['name_label']);
  28.729 +	if(new_vm_uuid!='')self.step_5_add_step(1,'Cloning the template.');
  28.730 +	else self.step_5_add_step(0,'Cloning the template.');
  28.731 +	
  28.732 +	self.step_5_add_step(1,'Making some settings to the new vm.');
  28.733 +	xen_vm_set_name_description(new_vm_uuid, self.options['name_description']);
  28.734 +	
  28.735 +	xen_vm_fix_record(new_vm_uuid);
  28.736 +	
  28.737 +	other_config = xen_vm_get_other_config(new_vm_uuid);
  28.738 +    other_config['default_template'] = "false";
  28.739 +	other_config['disks'] = xen_vm_make_provision(self.options['disks']);
  28.740 +	
  28.741 +	xen_set_affinity(new_vm_uuid,self.options['host']);
  28.742 +	
  28.743 +	if(self.options['allowed_devices_type']=='url')other_config["install-repository"]=self.options['allowed_devices_url'];
  28.744 +	else other_config["install-repository"] = "cdrom";
  28.745 +	
  28.746 +	//todo: to set mac_seed 
  28.747 +	self.step_5_add_step(1,'Setting the other_config.');
  28.748 +	xen_vm_set_other_config(new_vm_uuid, other_config);
  28.749 +	
  28.750 +	self.step_5_add_step(1,'Invoking vm_provision to create the block devices.');
  28.751 +	xen_vm_provision(new_vm_uuid);
  28.752 +	
  28.753 +	var vif_temp = {
  28.754 +            uuid: '',
  28.755 +            allowed_operations: [],
  28.756 +            current_operations: {},
  28.757 +            device: '0',
  28.758 +            network: '',
  28.759 +            VM: '',
  28.760 +            MAC: '',
  28.761 +            MTU: '0',
  28.762 +            other_config: {},
  28.763 +            currently_attached: false,
  28.764 +            status_code: '0',
  28.765 +            status_detail: '',
  28.766 +            runtime_properties: {},
  28.767 +            qos_algorithm_type:   '',
  28.768 +            qos_algorithm_params: {},
  28.769 +            metrics: '',
  28.770 +            MAC_autogenerated: false 
  28.771 +        }
  28.772 +
  28.773 +			if(self.options['allowed_devices_type']!='url')
  28.774 +			{
  28.775 +
  28.776 +    var vbd_temp = {
  28.777 +            VM: new_vm_uuid,
  28.778 +            VDI: self.options['allowed_devices'][self.options['allowed_devices_type']][self.options['allowed_devices_id']]['VDI'],
  28.779 +            userdevice: toString(self.options['disks'].length),
  28.780 +            bootable: True,
  28.781 +            mode: "RO",
  28.782 +            type: "CD",
  28.783 +            unplugabble: "0",
  28.784 +            storage_lock: "0",
  28.785 +            empty: false,
  28.786 +            currently_attached: "0",
  28.787 +            status_code: "0",
  28.788 +            other_config: {},
  28.789 +            qos_algorithm_type: "",
  28.790 +            qos_algorithm_params: {},
  28.791 +        }
  28.792 +	
  28.793 +
  28.794 +			
  28.795 +			cd_ref=xen_vbd_create(vbd_temp);
  28.796 +			if(cd_ref!='')self.step_5_add_step(1,'Inserting install media device.');
  28.797 +			else self.step_5_add_step(0,'Inserting install media device.');
  28.798 +			xen_vbd_insert(cd_ref,self.options['allowed_devices'][self.options['allowed_devices_type']][self.options['allowed_devices_id']]['VDI']);
  28.799 +			}
  28.800 +	
  28.801 +	self.step_5_add_step(1,'Setting the memory and VCPUs.');
  28.802 +	
  28.803 +	xen_vm_set_memory_static_min(new_vm_uuid,(parseInt(self.options['memory']))*1024*1024);
  28.804 +	xen_vm_set_memory_dynamic_min(new_vm_uuid,(parseInt(self.options['memory']))*1024*1024);
  28.805 +	xen_vm_set_memory_static_max(new_vm_uuid,(parseInt(self.options['memory']))*1024*1024);
  28.806 +	xen_vm_set_memory_dynamic_max(new_vm_uuid,(parseInt(self.options['memory']))*1024*1024);
  28.807 +	xen_vm_set_VCPUs_max(new_vm_uuid,self.options['vCPUs']);
  28.808 +	xen_vm_set_VCPUs_at_startup(new_vm_uuid,self.options['vCPUs']);
  28.809 +
  28.810 +	self.step_5_add_step(1,'Network Settings.');
  28.811 +	
  28.812 +	for(var i in self.options['vifs'])
  28.813 +		{
  28.814 +            vif_temp['device'] = i.toString();
  28.815 +            vif_temp['network'] = self.options['vifs'][i]['network_id'];
  28.816 +            vif_temp['VM'] = new_vm_uuid;
  28.817 +            xen_vif_create(vif_temp);
  28.818 +		} 
  28.819 +	
  28.820 +	//the end
  28.821 +	done_steps[0]=1;done_steps[1]=1;done_steps[2]=1;done_steps[3]=1;done_steps[4]=1;
  28.822 +	self.init();
  28.823 +	return true;
  28.824 +	}
  28.825 +
  28.826 +this.step_5_add_step=function(is_ok,step_name)
  28.827 +	{
  28.828 +		var x=document.getElementById('passed_steps').insertRow(-1);
  28.829 +	var tempcell;
  28.830 +	var temp;
  28.831 +	if(is_ok)temp='<img src="/interface/img/checked.png">';
  28.832 +	else temp='<img src="/interface/img/close.png">';
  28.833 +	 tempcell=x.insertCell(0);
  28.834 +	 tempcell.className='status';
  28.835 +	 tempcell.innerHTML=temp;
  28.836 +	 
  28.837 +	 tempcell=x.insertCell(1);
  28.838 +	 tempcell.className='title';
  28.839 +	 tempcell.innerHTML=step_name;
  28.840 +	 
  28.841 +	}
  28.842 +
  28.843 +}
  28.844 +
  28.845 +var install_vm=new VM_Installation();
  28.846 +
  28.847 +
  28.848 +templates.LoadTemplate(interface_path+'/templates/create_new.html','main_content',install_vm.step_1);
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/interface/templates/create_new_step1.html	Sat Aug 14 19:33:00 2010 +0300
    29.3 @@ -0,0 +1,38 @@
    29.4 +<div style="float:left;clear:none;">
    29.5 +<table>
    29.6 +<tr class="step1_tr"><td class="step1_td_label" width="124">Host Server :</td><td  align="left" width="200"><select class="step1_td_input" style="width: 100%;" id="host_servers"></select></td></tr>
    29.7 +<tr class="step1_tr"><td class="step1_td_label" width="124">VM Name :</td><td><input type="text" class="step1_td_input" style="width:100%;" onChange="install_vm.options['name_label']=this.value;"/></td></tr>
    29.8 +<tr class="step1_tr"><td class="step1_td_label" width="124">VM Description :</td><td><input type="text" class="step1_td_input"  style="width:100%;" id="description_input" onChange="install_vm.options['name_description']=this.value;"/></td></tr>
    29.9 +<tr class="step1_tr">
   29.10 +	<td colspan="2">
   29.11 +	 <table width="100%" cellpadding="1" cellspacing="1">
   29.12 +	  <tr>
   29.13 +	  <td class="step1_td_label" width="124">Memory :</td>
   29.14 +	  <td><input type="text" class="step1_td_input" style="width:50px;" onChange="install_vm.options['memory']=this.value;"/></td>
   29.15 +	  <td class="step1_td_label" style="padding-left:0px;text-align:right;">vCPUs :</td>
   29.16 +	  <td><select class="step1_td_input" style="width:100%;" id="host_vcpus" onChange="install_vm.options['vCPUs']=this.options[this.selectedIndex].value"></select></td>
   29.17 +	  </tr>
   29.18 +	 </table>
   29.19 +	</td>
   29.20 +</tr>
   29.21 +
   29.22 +</table>
   29.23 +</div>
   29.24 +
   29.25 +<div class="host_status_box">
   29.26 +	
   29.27 +	<div class="title" id="host_box_title"></div>
   29.28 +	<div class="description_row">vCPUs number: <span id="host_box_vcpus"></span></div>
   29.29 +	<div class="description_row">Total memory: <span id="host_box_memory_total"></span>M</div>
   29.30 +	<div class="description_row">Free memory: <span id="host_box_memory_free"></span>M</div>
   29.31 +	<div class="description_row">Resident VMs: <span id="host_box_resident_vms"></span></div>
   29.32 +</div>
   29.33 +
   29.34 +<div class="select_os_label">Select VM Template :</div>
   29.35 +<div class="select_os">
   29.36 +	<table style="width:100%;border-collapse:collapse;" id="dist_list">
   29.37 +	</table>
   29.38 +</div>
   29.39 +
   29.40 +<div class="next_step_button" onclick="document.getElementById('description_input').focus();templates.control_focus();install_vm.step_2();"></div>
   29.41 +<!-- pri zarejdane 1. onload zarejda default host server 2. zarejda templates -->
   29.42 \ No newline at end of file
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/interface/templates/create_new_step2.html	Sat Aug 14 19:33:00 2010 +0300
    30.3 @@ -0,0 +1,1 @@
    30.4 +<div style="float:left;clear:none;width:100%;">
	<div class="step2_vm_label">VM Template : <span class="icon"><img src="img/windows.png"/></span><span class="title" id="step2_template_title"></span></div>
</div>

<div class="step2_vm_description" id="step2_template_description">
</div>

<div class="step2_location_title">
Select a URL, ISO image or physical device for the current template :
</div>

<div class="step2_location">
	<table style="margin-left:40px;float:left;clear:none;">
	<tr class="tr" id="step2_url"><td class="td_radio"><input type="radio" name="install_type" onclick="install_vm.step_2_disable_enable('step2_url_select');"></td><td class="td_title">Install URL:</td><td class="td_input"><input type="text" class="input" id="step2_url_select"/></td></tr>
	<tr class="tr" id="step2_phys_drive"><td class="td_radio"><input type="radio" name="install_type" onclick="install_vm.step_2_disable_enable('step2_phys_select');"></td><td class="td_title">Physical Device:</td><td class="td_input"><select class="input" id="step2_phys_select"></select></td></tr>
	<tr class="tr" id="step2_cdrom"><td class="td_radio"><input type="radio" name="install_type" onclick="install_vm.step_2_disable_enable('step2_iso_select');"></td><td class="td_title">ISO Image:</td><td class="td_input"><select class="input" id="step2_iso_select"></select></td></tr>
	</table>
	
	<div style="float:left;clear:none;font-weight: regular;padding-top:5px; padding-left: 15px;">Examples:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://server/path<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ftp://server/path<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nfs://server/path</div>

</div>

<div class="next_step_button" onclick="install_vm.options['allowed_devices_url']=document.getElementById('step2_url_select').value;install_vm.step_3();"></div>
    30.5 \ No newline at end of file
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/interface/templates/create_new_step3.html	Sat Aug 14 19:33:00 2010 +0300
    31.3 @@ -0,0 +1,28 @@
    31.4 +<div class="step3_description">
    31.5 +The default disks for the template you have selected are listed below.
    31.6 +You can add, modify or delete virtual disks interfaces.
    31.7 +When you have finished, click "Next Step" to continue.
    31.8 +</div>
    31.9 +
   31.10 +<div style="float:left;clear:none;width:100%;">
   31.11 +	<div class="step2_vm_label">Virtual disks installed on the new machine:</div>
   31.12 +</div>
   31.13 +
   31.14 +<div class="disks_settings">
   31.15 +	<table style="width:100%;border-collapse:collapse;clear:both;" id="disks_settings_table">
   31.16 +		<tr>
   31.17 +			<th style="border-right: 1px solid #717171;">Size (MB)</th>
   31.18 +			<th style="border-right: 1px solid #717171;">Location</th>
   31.19 +			<th>Shared</th>
   31.20 +		</tr>
   31.21 +	</table>
   31.22 +</div>
   31.23 +
   31.24 +<div class="buttons">
   31.25 +		<button onclick="install_vm.step_3_new_disk_window(0);">Add...</button>
   31.26 +		<button onclick="install_vm.step_3_new_disk_window(1);">Edit...</button>
   31.27 +		<button onclick="install_vm.step_3_delete_disk();">Delete</button>
   31.28 +</div>
   31.29 +
   31.30 +
   31.31 +<div class="next_step_button" onclick="install_vm.step_4();"></div>
   31.32 \ No newline at end of file
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/interface/templates/create_new_step4.html	Sat Aug 14 19:33:00 2010 +0300
    32.3 @@ -0,0 +1,26 @@
    32.4 +<div class="step3_description">
    32.5 +The default network interfaces for the template you have selected are listed below.
    32.6 +You can add or delete virtual interfaces interfaces.
    32.7 +When you have finished, click "Next Step" to continue.
    32.8 +</div>
    32.9 +
   32.10 +<div style="float:left;clear:none;width:100%;">
   32.11 +	<div class="step2_vm_label">Virtual network interfaces installed on the new machine:</div>
   32.12 +</div>
   32.13 +
   32.14 +<div class="network_settings" >
   32.15 +	<table style="width:100%;border-collapse:collapse;clear:both;" id="network_settings_table">
   32.16 +		<tr>
   32.17 +			<th style="border-right: 1px solid #717171;">Interface name</th>
   32.18 +			<th>MAC Address</th>
   32.19 +			<th>Network</th>
   32.20 +		</tr>
   32.21 +	</table>
   32.22 +</div>
   32.23 +
   32.24 +<div class="buttons">
   32.25 +		<button onclick="install_vm.step_4_new_vif_window();">Add...</button>
   32.26 +		<button onclick="install_vm.step_4_delete_vif();">Delete</button>
   32.27 +</div>
   32.28 +
   32.29 +<div class="next_step_button" onclick="install_vm.step_5();"></div>
   32.30 \ No newline at end of file
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/interface/templates/create_new_step5.html	Sat Aug 14 19:33:00 2010 +0300
    33.3 @@ -0,0 +1,16 @@
    33.4 +<div class="configuration_done">
    33.5 +	Final Step
    33.6 +</div>
    33.7 +
    33.8 +<div class="configuration_description">
    33.9 +	The basic configuration is done. Here you can see the creation process. After the creation process you can start your VM from the Cloud Pool. The process may take several minutes.
   33.10 +</div>
   33.11 +
   33.12 +<div class="configuration_description">
   33.13 +	<!--<div class="configuration_option"><input type="checkbox" style="position:relative;top:2px;" checked />&nbsp;Start VM automatically</div>-->
   33.14 +	<table class="passed_steps" id="passed_steps">
   33.15 +		
   33.16 +	</table>
   33.17 +</div>
   33.18 +
   33.19 +<div style="width:100%;clear:both;padding:5px;height:10px;"> 
   33.20 \ No newline at end of file
    34.1 --- a/interface/templates/main.js	Thu Aug 05 00:15:19 2010 +0300
    34.2 +++ b/interface/templates/main.js	Sat Aug 14 19:33:00 2010 +0300
    34.3 @@ -86,8 +86,10 @@ xen_register_db_event('task',task_manage
    34.4  
    34.5  function main_buttons_req()
    34.6  {
    34.7 +var self = this;
    34.8  var img_path ='/interface/img/'
    34.9  var buttons = new Array('cloud_pool_button','create_new_button','settings_button');
   34.10 +this.active=0;
   34.11  
   34.12  var make_active = function(button_id)
   34.13  	{
   34.14 @@ -98,6 +100,7 @@ var make_active = function(button_id)
   34.15  		document.getElementById(buttons[i]).style.backgroundImage = "url("+img_path+buttons[i]+".png)";
   34.16  		}
   34.17  	document.getElementById(button_id).style.backgroundImage = "url("+img_path+button_id+"_active.png)";
   34.18 +	self.active=button_id;
   34.19  	}
   34.20  
   34.21  this.cloud_pool = function()
   34.22 @@ -111,8 +114,8 @@ this.cloud_pool = function()
   34.23  this.create_new = function()
   34.24  	{
   34.25  	make_active('create_new_button');
   34.26 +	templates.LoadCSS(interface_path+'/templates/create_new.css');
   34.27  	templates.LoadJS(interface_path+'/templates/create_new.js');
   34.28 -	templates.LoadTemplate(interface_path+'/templates/create_new.html','main_content');
   34.29  	return ;
   34.30  	}
   34.31  
   34.32 @@ -128,4 +131,4 @@ this.settings = function()
   34.33  var main_buttons = new main_buttons_req();
   34.34  
   34.35  templates.LoadCSS(interface_path+'/templates/main.css');
   34.36 -templates.LoadTemplate(interface_path+'/templates/main.html','content',main_buttons.cloud_pool);
   34.37 +templates.LoadTemplate(interface_path+'/templates/main.html','content',main_buttons.create_new);
    35.1 --- a/interface/xcp.css	Thu Aug 05 00:15:19 2010 +0300
    35.2 +++ b/interface/xcp.css	Sat Aug 14 19:33:00 2010 +0300
    35.3 @@ -50,7 +50,16 @@ width:100%;
    35.4  float:left;
    35.5  clear:both;
    35.6  }
    35.7 +/* select */
    35.8 +.table_select
    35.9 +{
   35.10 +   background-color: #89b1c1 !important;
   35.11 +}
   35.12  
   35.13 +.table_unselect
   35.14 +{
   35.15 +   background-color: #ffffff !important;
   35.16 +}
   35.17  
   35.18  /* the submenus */
   35.19  
   35.20 @@ -200,8 +209,8 @@ clear:both;
   35.21  	position: fixed;
   35.22  	z-index:20;
   35.23  	padding-bottom:2px;
   35.24 -	min-width:250px;
   35.25 -	min-height:250px;
   35.26 +	min-width:150px;
   35.27 +	min-height:150px;
   35.28  	background-color: white;
   35.29  }
   35.30  .window .win-titlebar 
   35.31 @@ -230,11 +239,11 @@ clear:both;
   35.32  {
   35.33  	width: 650px;
   35.34  	height: 450px;
   35.35 -	min-width:250px;
   35.36 -	min-height:250px;
   35.37 +	min-width:150px;
   35.38 +	min-height:150px;
   35.39  	position: relative;
   35.40  	overflow: auto;
   35.41 -	background-color:#FFFFFF;
   35.42 +	background-color:#F8FCFD;
   35.43  }
   35.44  .window .win-content .cnt 
   35.45  {
   35.46 @@ -243,7 +252,7 @@ clear:both;
   35.47  	padding-bottom: 12px;
   35.48  	padding-left: 8px;
   35.49  	word-wrap: break-word;
   35.50 -	background-color:#ffffff;
   35.51 +	background-color:#F8FCFD;
   35.52  	z-index:1;
   35.53  }
   35.54  .window .win-content .corner 
   35.55 @@ -330,3 +339,109 @@ clear:both;
   35.56  {
   35.57  	clear: both;
   35.58  }
   35.59 +
   35.60 +table.tabs {
   35.61 +	height:24px;
   35.62 +	padding:0;
   35.63 +	border:0;
   35.64 +}
   35.65 +table.tabs td {
   35.66 +	min-width:30px;
   35.67 +	border:0;
   35.68 +	padding:0;
   35.69 +	padding-top:0px;
   35.70 +	width:auto;
   35.71 +}
   35.72 +table.tabs td .tabBg {
   35.73 +	float:left;
   35.74 +	margin-top:5px;
   35.75 +	border:1px solid #867878;
   35.76 + 	min-width:30px;
   35.77 +	font-size:12px;
   35.78 +	border-right:0;
   35.79 +	height:15px;
   35.80 +	padding:0;
   35.81 +	padding-top:3px;
   35.82 +	padding-left:5px;
   35.83 +	padding-right:5px;
   35.84 +	background-color:#EEEAEB;
   35.85 +	background-image:url('/interface/img/unactive-gradient.jpg');
   35.86 +	background-repeat:repeat-x;
   35.87 +	background-position:left top;
   35.88 +	color:#8B7F7F;
   35.89 +	border-left:1px solid #000000;
   35.90 +	overflow:hidden;
   35.91 +	position:relative;
   35.92 +}
   35.93 +table.tabs td .tabBg span.tabClose {
   35.94 +	position:absolute;
   35.95 +	top:0px;
   35.96 +	right:0px;
   35.97 +	display:none;
   35.98 +}
   35.99 +table.tabs td .tabBg:hover  span.tabClose {
  35.100 +	display:block;
  35.101 +	position:absolute;
  35.102 +	top:0px;
  35.103 +	right:0px;
  35.104 +}
  35.105 +table.tabs td .tabBg a {
  35.106 +	height:100%;
  35.107 +	text-decoration:none;
  35.108 +	cursor:pointer;
  35.109 +}
  35.110 +table.tabs td.activeTab {
  35.111 +	background-image:url('/interface/img/border.png');
  35.112 +	background-repeat:no-repeat;
  35.113 +	background-position:bottom right;
  35.114 +	padding-right:4px;
  35.115 +}
  35.116 +table.tabs td.activeTab .tabBg {
  35.117 +	border:1px solid #867878;
  35.118 + 	min-width:30px;
  35.119 +	font-size:12px;
  35.120 +	height:16px;
  35.121 +	padding:0;
  35.122 +	padding-top:7px;
  35.123 +	padding-left:12px;
  35.124 +	padding-right:12px;
  35.125 +	font-weight:bold;
  35.126 +	background-color:#f3f3f3;
  35.127 +	background-image:url('/interface/img/active-gradient.jpg');
  35.128 +	background-repeat:repeat-x;
  35.129 +	background-position:left top;
  35.130 +	border-bottom:1px solid #f3f3f3;
  35.131 +	margin-top:0px;
  35.132 +	text-align:center;
  35.133 +	color:#4E4747;
  35.134 +	border-left:1px solid #000000;
  35.135 +}
  35.136 +table.tabs td.singleTab .active {
  35.137 +	padding-right:13px;
  35.138 +}
  35.139 +table.tabs td.singleTab:hover .tabBg {
  35.140 +	color: #5c5e5d;
  35.141 +	background-color:#EEEAEB;
  35.142 +	background-image:url('/interface/img/unactive-gradient-hover.jpg');
  35.143 +	background-repeat:repeat-x;
  35.144 +	background-position:left top;
  35.145 +}
  35.146 +.tabs .singleTab:last-child .tabBg {
  35.147 +	border-right:1px solid #867878;
  35.148 +}
  35.149 +.tabs .activeTab:first-child .tabBg {
  35.150 +	border-left:1px solid #867878;
  35.151 +}
  35.152 +.tabs .singleTab:first-child .tabBg {
  35.153 +	border-left:1px solid #867878;
  35.154 +}
  35.155 +.tabs div { cursor:pointer; }
  35.156 +.tabContent {
  35.157 +	border:1px solid #867878;
  35.158 +	background-color:#f3f3f3;
  35.159 +	min-width:400px;
  35.160 +	min-height:100px;
  35.161 +	height:auto;
  35.162 +	float:left;
  35.163 +	margin-top:-1px;
  35.164 +}
    36.1 --- a/libxen/core.js	Thu Aug 05 00:15:19 2010 +0300
    36.2 +++ b/libxen/core.js	Sat Aug 14 19:33:00 2010 +0300
    36.3 @@ -72,10 +72,10 @@ url+='&'+rand;
    36.4  				if(xmldoc)
    36.5  				{
    36.6  				
    36.7 -				//debug
    36.8 -				//document.write('<br><textarea style="width:1200px;height:100px">==DATA FROM SERVER== '+httpRequest.responseText+'</textarea>');
    36.9 -				//first looking for Status
   36.10 -				//todo: to make it better
   36.11 +				 //debug
   36.12 +				 //document.write('<br><textarea style="width:1200px;height:100px">==DATA FROM SERVER== '+httpRequest.responseText+'</textarea>');
   36.13 +				 //first looking for Status
   36.14 +				 //todo: to make it better
   36.15  					cur=xmldoc.getElementsByTagName('member');
   36.16  						if(cur[0].childNodes[0].childNodes[0].nodeValue=='Status')
   36.17  							{
   36.18 @@ -169,19 +169,19 @@ serializeToXml = function(data) {
   36.19  				if(data instanceof Date) {
   36.20  					return '<dateTime.iso8601>'+ data.getFullYear() + pad2(data.getMonth()) + pad2(data.getDate()) +'T'+ pad2(data.getHours()) +':'+ pad2(data.getMinutes()) +':'+ pad2(data.getSeconds()) +'</dateTime.iso8601>';
   36.21  				} else if(data instanceof Array) {
   36.22 -					var ret = '<array><data>'+"\n";
   36.23 +					var ret = '<array><data>';
   36.24  					for (var i=0; i < data.length; i++) {
   36.25 -						ret += '  <value>'+ serializeToXml(data[i]) +"</value>\n";
   36.26 +						ret += '<value>'+ serializeToXml(data[i]) +"</value>";
   36.27  					}
   36.28  					ret += '</data></array>';
   36.29  					return ret;
   36.30  				} else {
   36.31 -					var ret = '<struct>'+"\n";
   36.32 +					var ret = '<struct>';
   36.33  					for (key in data)
   36.34  					{
   36.35  					var value = data[key];
   36.36 -					ret += "  <member><name>"+ key +"</name><value>";
   36.37 -					ret += serializeToXml(value) +"</value></member>\n";
   36.38 +					ret += "<member><name>"+ key +"</name><value>";
   36.39 +					ret += serializeToXml(value) +"</value></member>";
   36.40  					}
   36.41  					ret += '</struct>';
   36.42  					return ret;
    37.1 --- a/libxen/db_callbacks.js	Thu Aug 05 00:15:19 2010 +0300
    37.2 +++ b/libxen/db_callbacks.js	Sat Aug 14 19:33:00 2010 +0300
    37.3 @@ -1,1 +1,1 @@
    37.4 -function invoke_event(array_name){if(typeof(xen_db_events[array_name])!='undefined'){xen_db_events[array_name]();}if(typeof(xen_db_events['*'])!='undefined'){xen_db_events['*']();}}
var db_callbacks=new Array();

db_callbacks['session.login_with_password']=function(result)
{
xen_db['session_id']=result;
xen_db['is_logged']=1;
xen_db['logged']=1;
return ;
}

db_callbacks['VM.get_all_records']=function(result){xen_db['VM']=result;invoke_event('VM');return;} 
db_callbacks['task.get_all_records']=function(result){xen_db['task']=result;invoke_event('task');return;} 
db_callbacks['VBD.get_all_records']=function(result){xen_db['VBD']=result;invoke_event('VBD');return;} 
db_callbacks['VBD_metrics.get_all_records']=function(result){xen_db['VBD_metrics']=result;invoke_event('VBD_metrics');return;} 
db_callbacks['VDI.get_all_records']=function(result){xen_db['VDI']=result;invoke_event('VDI');return;} 
db_callbacks['network.get_all_records']=function(result){xen_db['network']=result;invoke_event('network');return;} 
db_callbacks['PIF.get_all_records']=function(result){xen_db['PIF']=result;invoke_event('PIF');return;} 
db_callbacks['PIF_metrics.get_all_records']=function(result){xen_db['PIF_metrics']=result;invoke_event('PIF_metrics');return;} 
db_callbacks['PBD.get_all_records']=function(result){xen_db['PBD']=result;invoke_event('PBD');return;} 
db_callbacks['VIF.get_all_records']=function(result){xen_db['VIF']=result;invoke_event('VIF');return;} 
db_callbacks['VIF_metrics.get_all_records']=function(result){xen_db['VIF_metrics']=result;invoke_event('VIF_metrics');return;} 
db_callbacks['VM_guest_metrics.get_all_records']=function(result){xen_db['VM_guest_metrics']=result;invoke_event('VM_guest_metrics');return;} 
db_callbacks['VM_metrics.get_all_records']=function(result){xen_db['VM_metrics']=result;invoke_event('VM_metrics');return;} 
db_callbacks['host_metrics.get_all_records']=function(result){xen_db['host_metrics']=result;invoke_event('host_metrics');return;} 
db_callbacks['host_cpu.get_all_records']=function(result){xen_db['host_cpu']=result;invoke_event('host_cpu');return;} 
db_callbacks['Bond.get_all_records']=function(result){xen_db['Bond']=result;invoke_event('Bond');return;} 
db_callbacks['pool_patch.get_all_records']=function(result){xen_db['pool_patch']=result;invoke_event('pool_patch');return;} 
db_callbacks['host_patch.get_all_records']=function(result){xen_db['host_patch']=result;invoke_event('host_patch');return;} 
db_callbacks['console.get_all_records']=function(result){xen_db['console']=result;invoke_event('console');return;} 
db_callbacks['host.get_all_records']=function(result){xen_db['host']=result;invoke_event('host');return;} 
db_callbacks['pool.get_all_records']=function(result){xen_db['pool']=result;invoke_event('pool');return;} 
db_callbacks['SR.get_all_records']=function(result){xen_db['SR']=result;invoke_event('SR');return;} 
db_callbacks['message.get_all_records']=function(result){xen_db['message']=result;invoke_event('message');return;}

db_callbacks['event.next']=function(result)
{
	for ( var i in result )
	{
		if(result[i].operation=='mod' || result[i].operation=='add')
		{

		if(typeof(xen_db[result[i].class])!='undefined') 
			{
			xen_db[result[i].class][result[i].ref]=result[i].snapshot;
			}
		else
			{
			xen_db[result[i].class]=new Object();
			xen_db[result[i].class][result[i].ref]=result[i].snapshot;
			}
			invoke_event(result[i].class);
			
		
		}
		if(result[i].operation=='del')
		{ 
		delete xen_db[result[i].class][result[i].ref];
		invoke_event(result[i].class);
		}
	}
	
	return;
}
    37.5 \ No newline at end of file
    37.6 +function invoke_event(array_name){if(typeof(xen_db_events[array_name])!='undefined'){xen_db_events[array_name]();}if(typeof(xen_db_events['*'])!='undefined'){xen_db_events['*']();}}
var db_callbacks=new Array();

db_callbacks['session.login_with_password']=function(result)
{
xen_db['session_id']=result;
xen_db['is_logged']=1;
xen_db['logged']=1;
return ;
}

db_callbacks['VM.get_all_records']=function(result){xen_db['vm']=result;invoke_event('vm');return;} 
db_callbacks['task.get_all_records']=function(result){xen_db['task']=result;invoke_event('task');return;} 
db_callbacks['VBD.get_all_records']=function(result){xen_db['vbd']=result;invoke_event('vbd');return;} 
db_callbacks['VBD_metrics.get_all_records']=function(result){xen_db['vbd_metrics']=result;invoke_event('vbd_metrics');return;} 
db_callbacks['VDI.get_all_records']=function(result){xen_db['vdi']=result;invoke_event('vdi');return;} 
db_callbacks['network.get_all_records']=function(result){xen_db['network']=result;invoke_event('network');return;} 
db_callbacks['PIF.get_all_records']=function(result){xen_db['pif']=result;invoke_event('pif');return;} 
db_callbacks['PIF_metrics.get_all_records']=function(result){xen_db['pif_metrics']=result;invoke_event('pif_metrics');return;} 
db_callbacks['PBD.get_all_records']=function(result){xen_db['pbd']=result;invoke_event('pbd');return;} 
db_callbacks['VIF.get_all_records']=function(result){xen_db['vif']=result;invoke_event('pbd');return;} 
db_callbacks['VIF_metrics.get_all_records']=function(result){xen_db['vif_metrics']=result;invoke_event('vif_metrics');return;} 
db_callbacks['VM_guest_metrics.get_all_records']=function(result){xen_db['vm_guest_metrics']=result;invoke_event('vm_guest_metrics');return;} 
db_callbacks['VM_metrics.get_all_records']=function(result){xen_db['vm_metrics']=result;invoke_event('vm_metrics');return;} 
db_callbacks['host_metrics.get_all_records']=function(result){xen_db['host_metrics']=result;invoke_event('host_metrics');return;} 
db_callbacks['host_cpu.get_all_records']=function(result){xen_db['host_cpu']=result;invoke_event('host_cpu');return;} 
db_callbacks['Bond.get_all_records']=function(result){xen_db['bond']=result;invoke_event('bond');return;} 
db_callbacks['pool_patch.get_all_records']=function(result){xen_db['pool_patch']=result;invoke_event('pool_patch');return;} 
db_callbacks['host_patch.get_all_records']=function(result){xen_db['host_patch']=result;invoke_event('host_patch');return;} 
db_callbacks['console.get_all_records']=function(result){xen_db['console']=result;invoke_event('console');return;} 
db_callbacks['host.get_all_records']=function(result){xen_db['host']=result;invoke_event('host');return;} 
db_callbacks['pool.get_all_records']=function(result){xen_db['pool']=result;invoke_event('pool');return;} 
db_callbacks['SR.get_all_records']=function(result){xen_db['sr']=result;invoke_event('sr');return;} 
db_callbacks['message.get_all_records']=function(result){xen_db['message']=result;invoke_event('message');return;}

db_callbacks['event.next']=function(result)
{
	for ( var i in result )
	{
		if(result[i].operation=='mod' || result[i].operation=='add')
		{

		if(typeof(xen_db[result[i].class])!='undefined') 
			{
			try{xen_db[result[i].class][result[i].ref]=result[i].snapshot;}catch(err){}
			}
		else
			{
			try{
			xen_db[result[i].class]=new Object();
			xen_db[result[i].class][result[i].ref]=result[i].snapshot;
			}catch(err){}
			}
			invoke_event(result[i].class);
			
		
		}
		if(result[i].operation=='del')
		{ 
		
		try{delete xen_db[result[i].class][result[i].ref];}catch(err){}
		invoke_event(result[i].class);
		}
	}
	
	return;
}
    37.7 \ No newline at end of file
    38.1 --- a/libxen/libxen_host.js	Thu Aug 05 00:15:19 2010 +0300
    38.2 +++ b/libxen/libxen_host.js	Sat Aug 14 19:33:00 2010 +0300
    38.3 @@ -1,5 +1,38 @@
    38.4  // functions to deal with Host part of the xen_db
    38.5  
    38.6 +function xen_host_get_pbd_list(host_id)
    38.7 +{
    38.8 +	return xen_db['host'][host_id]['PBDs'];
    38.9 +}
   38.10 +
   38.11 +function xen_host_get_network_list(host_id)
   38.12 +{
   38.13 +var networks=new Array();
   38.14 +
   38.15 +	var pifs=xen_db['host'][host_id]['PIFs'];
   38.16 +	
   38.17 +	for(var pif in pifs)
   38.18 +		{
   38.19 +			for(var network in xen_db['network'])
   38.20 +				{
   38.21 +				if(eval("xen_db['network']['"+network+"']['bridge'].search(/xapi/i);")>=0)networks[networks.length]=network;
   38.22 +				else
   38.23 +					{
   38.24 +						for(var pif in xen_db['network'][network]['PIFs'])
   38.25 +							{
   38.26 +							if(xen_db['network'][network]['PIFs'][pif]==pifs[pif])
   38.27 +								{
   38.28 +								networks[networks.length]=network;
   38.29 +								break;
   38.30 +								}
   38.31 +							}
   38.32 +					}
   38.33 +				}
   38.34 +		}
   38.35 +	
   38.36 +	return networks;
   38.37 +}
   38.38 +
   38.39  function xen_get_vm_list_hosts()
   38.40  {
   38.41  
   38.42 @@ -29,17 +62,22 @@ function xen_host_get_details(host_id)
   38.43  			cpus++;
   38.44  			}
   38.45  		cpu_usage=cpu_usage/cpus;
   38.46 -	
   38.47 +	vm_pool['vCPUs']=cpus;
   38.48  	vm_pool['cpu_usage']=cpu_usage;
   38.49  
   38.50  	vm_pool['memory_free']=Math.floor(parseInt(xen_db['host_metrics'][xen_db['host'][host_id]['metrics']]['memory_free']) / (1024*1024));
   38.51  	vm_pool['memory_total']=Math.floor(parseInt(xen_db['host_metrics'][xen_db['host'][host_id]['metrics']]['memory_total']) / (1024*1024));
   38.52  	
   38.53  	vm_pool['resident_VMs']=new Array();
   38.54 +	vm_pool['resident_VMs_num']=0;
   38.55  	for(var id in xen_db['host'][host_id]['resident_VMs'])
   38.56  	{
   38.57  	var vm_id=xen_db['host'][host_id]['resident_VMs'][id];
   38.58 -	if(!xen_db['VM'][vm_id]['is_a_template'] && !xen_db['VM'][vm_id]['is_control_domain'])vm_pool['resident_VMs'].push(vm_id);
   38.59 +	if(!xen_db['vm'][vm_id]['is_a_template'] && !xen_db['vm'][vm_id]['is_control_domain'])
   38.60 +		{
   38.61 +		vm_pool['resident_VMs'].push(vm_id);
   38.62 +		vm_pool['resident_VMs_num']++;
   38.63 +		}
   38.64  	}
   38.65  	
   38.66  	return vm_pool;
   38.67 @@ -53,7 +91,7 @@ var dom0 = 0;
   38.68   for(var id in xen_db['host'][host_id]['resident_VMs'])
   38.69  	{
   38.70  	var vm_id=xen_db['host'][host_id]['resident_VMs'][id];
   38.71 -	if(xen_db['VM'][vm_id]['is_control_domain'])dom0=vm_id;
   38.72 +	if(xen_db['vm'][vm_id]['is_control_domain'])dom0=vm_id;
   38.73  	}
   38.74  
   38.75   if(dom0)
    39.1 --- a/libxen/libxen_init.js	Thu Aug 05 00:15:19 2010 +0300
    39.2 +++ b/libxen/libxen_init.js	Sat Aug 14 19:33:00 2010 +0300
    39.3 @@ -13,3 +13,4 @@ loadjs(libxen_path+'/libxen.js');
    39.4  loadjs(libxen_path+'/libxen_host.js');
    39.5  loadjs(libxen_path+'/libxen_vm.js');
    39.6  loadjs(libxen_path+'/libxen_task.js');
    39.7 +loadjs(libxen_path+'/libxen_other.js');
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/libxen/libxen_other.js	Sat Aug 14 19:33:00 2010 +0300
    40.3 @@ -0,0 +1,68 @@
    40.4 +
    40.5 +function xen_network_get_details(net_ref)
    40.6 +{
    40.7 +vm_pool = new Array();
    40.8 +	vm_pool['name_label']=xen_db['network'][net_ref]['name_label'];
    40.9 +	vm_pool['name_description']=xen_db['network'][net_ref]['name_description'];
   40.10 +	vm_pool['bridge']=xen_db['network'][net_ref]['bridge'];
   40.11 +return vm_pool;
   40.12 +}
   40.13 +
   40.14 +function xen_vbd_create(vbd_obj)
   40.15 +{
   40.16 +var params=new Array();
   40.17 +params[0]=xen_db['session_id'];
   40.18 +params[1]=vbd_obj;
   40.19 +return ApiCall('VBD.create',params,false,0,0,0,0);
   40.20 +}
   40.21 +
   40.22 +function xen_vif_create(vif_obj)
   40.23 +{
   40.24 +var params=new Array();
   40.25 +params[0]=xen_db['session_id'];
   40.26 +params[1]=vif_obj;
   40.27 +ApiCall('VIF.create',params,true,0,0,0,0);
   40.28 +return ;
   40.29 +}
   40.30 +
   40.31 +function xen_vbd_insert(vbd_ref,vdi_ref)
   40.32 +{
   40.33 +var params=new Array();
   40.34 +params[0]=xen_db['session_id'];
   40.35 +params[1]=vbd_ref;
   40.36 +params[2]=vdi_ref;
   40.37 +ApiCall('VBD.insert',params,true,0,0,0,0);
   40.38 +return ;
   40.39 +}
   40.40 +			
   40.41 +function xen_pbd_get_sr(pbd_id) 
   40.42 +{
   40.43 +	return xen_db['pbd'][pbd_id]['SR'];
   40.44 +}
   40.45 +function xen_pbd_get_host(pbd_id)
   40.46 +{
   40.47 +	return xen_db['pbd'][pbd_id]['host'];
   40.48 +}
   40.49 +
   40.50 +function xen_vdi_get_name_label(vdi_id)
   40.51 +{
   40.52 +	return xen_db['vdi'][vdi_id]['name_label'];
   40.53 +}
   40.54 +
   40.55 +function xen_sr_get_details(sr_id)
   40.56 +{ 
   40.57 +	vm_pool = new Array();
   40.58 +	vm_pool['name_label']=xen_db['sr'][sr_id]['name_label'];
   40.59 +	vm_pool['name_description']=xen_db['sr'][sr_id]['name_description'];
   40.60 +	vm_pool['VDIs']=xen_db['sr'][sr_id]['VDIs'];
   40.61 +	vm_pool['type']=xen_db['sr'][sr_id]['type'];
   40.62 +	vm_pool['uuid']=xen_db['sr'][sr_id]['uuid'];
   40.63 +	vm_pool['content_type']=xen_db['sr'][sr_id]['content_type'];
   40.64 +	vm_pool['other_config']=xen_db['sr'][sr_id]['other_config'];
   40.65 +	vm_pool['allowed_operations']=xen_db['sr'][sr_id]['allowed_operations'];
   40.66 +	vm_pool['shared']=xen_db['sr'][sr_id]['shared'];
   40.67 +	vm_pool['physical_size']=xen_db['sr'][sr_id]['physical_size'];
   40.68 +	vm_pool['physical_utilisation']=xen_db['sr'][sr_id]['physical_utilisation'];
   40.69 +	
   40.70 +	return vm_pool;
   40.71 +}
   40.72 \ No newline at end of file
    41.1 --- a/libxen/libxen_vm.js	Thu Aug 05 00:15:19 2010 +0300
    41.2 +++ b/libxen/libxen_vm.js	Sat Aug 14 19:33:00 2010 +0300
    41.3 @@ -1,5 +1,108 @@
    41.4  // functions to deal with VM part of the xen_db
    41.5  
    41.6 +function xen_vm_fix_record(vm_ref)
    41.7 +{
    41.8 +if(typeof(xen_db['vm'][vm_ref])=='undefined')
    41.9 +	{
   41.10 +	return xen_vm_get_record(vm_ref);
   41.11 +	}
   41.12 +}
   41.13 +
   41.14 +function xen_vm_get_record(vm_ref)
   41.15 +{
   41.16 +var result;
   41.17 +var params=new Array();
   41.18 +params[0]=xen_db['session_id'];
   41.19 +params[1]=vm_ref;
   41.20 +result=ApiCall('VM.get_record',params,false,0,0,0,0);
   41.21 +xen_db['vm'][vm_ref]=result;
   41.22 +invoke_event('vm');
   41.23 +return result;
   41.24 +}
   41.25 +
   41.26 +function xen_vm_get_provision(provxml)
   41.27 +{
   41.28 +var xmlDoc;
   41.29 +	if (window.DOMParser)
   41.30 +  {
   41.31 +  parser=new DOMParser();
   41.32 +  xmlDoc=parser.parseFromString(provxml,"text/xml");
   41.33 +  }
   41.34 +else // Internet Explorer
   41.35 +  {
   41.36 +  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
   41.37 +  xmlDoc.async="false";
   41.38 +  xmlDoc.loadXML(provxml);
   41.39 +  } 
   41.40 +  
   41.41 + var cur;
   41.42 +var retarray=new Array();
   41.43 +if(xmlDoc.childNodes[0].nodeName=='provision')
   41.44 +	{
   41.45 +		for(var i in xmlDoc.childNodes[0].childNodes)
   41.46 +		{
   41.47 +			if(isINT(i))
   41.48 +			{
   41.49 +				retarray[retarray.length]=new Object();
   41.50 +				retarray[retarray.length-1]['device']=xmlDoc.childNodes[0].childNodes[i].getAttribute('device');
   41.51 +				retarray[retarray.length-1]['size']=parseInt(xmlDoc.childNodes[0].childNodes[i].getAttribute('size'));
   41.52 +				retarray[retarray.length-1]['size']=retarray[retarray.length-1]['size']/1048576;
   41.53 +				retarray[retarray.length-1]['sr']=xmlDoc.childNodes[0].childNodes[i].getAttribute('sr');
   41.54 +				retarray[retarray.length-1]['bootable']=xmlDoc.childNodes[0].childNodes[i].getAttribute('bootable');
   41.55 +				retarray[retarray.length-1]['type']=xmlDoc.childNodes[0].childNodes[i].getAttribute('type');
   41.56 +			}
   41.57 +		}
   41.58 +	}
   41.59 +  
   41.60 +  return retarray;
   41.61 +}
   41.62 +
   41.63 +function xen_vm_make_provision(diskarray)
   41.64 +{
   41.65 +var retprov='&lt;provision&gt;';
   41.66 +
   41.67 +//check for bootable
   41.68 +for(var u=0;u<diskarray.length && diskarray[u]['bootable']!='true';u++)
   41.69 +if(u==diskarray.length)diskarray[0]['bootable']='true';
   41.70 +
   41.71 +for(var i in diskarray)
   41.72 +	{
   41.73 +	retprov+='&lt;disk device="'+i+'" size="'+diskarray[i]['size']*1048576+'" sr="'+diskarray[i]['sr_uuid']+'" bootable="'+diskarray[i]['bootable']+'" type="system" ionice="0" readonly="False" /&gt;'
   41.74 +	}
   41.75 +
   41.76 +retprov+='&lt;/provision&gt;';
   41.77 +return retprov;
   41.78 +} 
   41.79 +
   41.80 +function xen_vm_get_templates()
   41.81 +{
   41.82 +	var vm_pool=new Array();
   41.83 +	
   41.84 +	for ( var vm_id in xen_db['vm'] )
   41.85 +		{
   41.86 +			if(xen_db['vm'][vm_id]['is_a_template'])vm_pool.push(vm_id);
   41.87 +		}
   41.88 +		
   41.89 +	return vm_pool;
   41.90 +}
   41.91 +
   41.92 +
   41.93 +
   41.94 +function xen_vm_get_name_label(vm_id)
   41.95 +{
   41.96 +	return	xen_db['vm'][vm_id]['name_label'];
   41.97 +}
   41.98 +
   41.99 +function xen_vm_get_name_description(vm_id)
  41.100 +{
  41.101 +	return	xen_db['vm'][vm_id]['name_description'];
  41.102 +}
  41.103 +
  41.104 +function xen_vm_get_other_config(vm_id)
  41.105 +{
  41.106 +	return	xen_db['vm'][vm_id]['other_config'];
  41.107 +}
  41.108 +
  41.109  function xen_get_vm_list_hosts()
  41.110  {
  41.111  
  41.112 @@ -17,11 +120,11 @@ function xen_get_vm_list_non_resident()
  41.113  {
  41.114  var vm_pool = new Array();
  41.115  
  41.116 -	for ( var vm_id in xen_db['VM'] )
  41.117 +	for ( var vm_id in xen_db['vm'] )
  41.118  		{
  41.119 -		   if(typeof(xen_db['VM'][vm_id]['resident_on'])!='undefined')
  41.120 +		   if(typeof(xen_db['vm'][vm_id]['resident_on'])!='undefined')
  41.121  		   {
  41.122 -		   if((xen_db['VM'][vm_id]['resident_on']=="OpaqueRef:NULL" || xen_db['VM'][vm_id]['resident_on']=='') && !xen_db['VM'][vm_id]['is_a_template'])vm_pool.push(vm_id);
  41.123 +		   if((xen_db['vm'][vm_id]['resident_on']=="OpaqueRef:NULL" || xen_db['vm'][vm_id]['resident_on']=='') && !xen_db['vm'][vm_id]['is_a_template'])vm_pool.push(vm_id);
  41.124  		   }
  41.125  		}
  41.126  
  41.127 @@ -32,13 +135,13 @@ function xen_vm_get_details(vm_id)
  41.128  {
  41.129  var vm_pool = new Array();
  41.130  	
  41.131 -	vm_pool['name_label']=xen_db['VM'][vm_id]['name_label'];
  41.132 -	vm_pool['name_description']=xen_db['VM'][vm_id]['name_description'];
  41.133 -	try {if(vm_pool['name_description']=='')vm_pool['name_description']=xen_db['VM_guest_metrics'][xen_db['VM'][vm_id]['guest_metrics']]['os_version']['name'];}catch(err){}
  41.134 +	vm_pool['name_label']=xen_db['vm'][vm_id]['name_label'];
  41.135 +	vm_pool['name_description']=xen_db['vm'][vm_id]['name_description'];
  41.136 +	try {if(vm_pool['name_description']=='')vm_pool['name_description']=xen_db['vm_guest_metrics'][xen_db['vm'][vm_id]['guest_metrics']]['os_version']['name'];}catch(err){}
  41.137  	
  41.138 -	vm_pool['memory_total']=Math.floor(parseInt(xen_db['VM'][vm_id]['memory_target']) / (1024*1024));
  41.139 -	vm_pool['power_state']=xen_db['VM'][vm_id]['power_state'];
  41.140 -	vm_pool['vm_cpus_count']=xen_db['VM'][vm_id]['VCPUs_max'];
  41.141 +	vm_pool['memory_total']=Math.floor(parseInt(xen_db['vm'][vm_id]['memory_target']) / (1024*1024));
  41.142 +	vm_pool['power_state']=xen_db['vm'][vm_id]['power_state'];
  41.143 +	vm_pool['vm_cpus_count']=xen_db['vm'][vm_id]['VCPUs_max'];
  41.144  	vm_pool['vm_cpus_weight']='';// TODO 
  41.145  	vm_pool['vm_cpus_cap']='';// TODO
  41.146  return vm_pool;
  41.147 @@ -47,9 +150,9 @@ return vm_pool;
  41.148  function xen_vm_get_console(vm_id)
  41.149  {
  41.150  var console_stuff = new Array(); 
  41.151 -if(typeof(xen_db['VM'][vm_id]['consoles']) != 'undefined' && typeof(xen_db['VM'][vm_id]['consoles'][0]) != 'undefined' && typeof(xen_db['VM'][vm_id]['consoles'][0]) != 'undefined'  && typeof(xen_db['console'][xen_db['VM'][vm_id]['consoles'][0]]['location']) != 'undefined' )
  41.152 +if(typeof(xen_db['vm'][vm_id]['consoles']) != 'undefined' && typeof(xen_db['vm'][vm_id]['consoles'][0]) != 'undefined' && typeof(xen_db['vm'][vm_id]['consoles'][0]) != 'undefined'  && typeof(xen_db['console'][xen_db['vm'][vm_id]['consoles'][0]]['location']) != 'undefined' )
  41.153  {
  41.154 -console_stuff['location']=xen_db['console'][xen_db['VM'][vm_id]['consoles'][0]]['location'];
  41.155 +console_stuff['location']=xen_db['console'][xen_db['vm'][vm_id]['consoles'][0]]['location'];
  41.156  console_stuff['session_id']=xen_db['session_id'];
  41.157  return console_stuff;
  41.158  }
  41.159 @@ -58,12 +161,69 @@ return 0;
  41.160  
  41.161  function xen_vm_get_allowed_operations(ref)
  41.162  {
  41.163 -return xen_db['VM'][ref]['allowed_operations'];
  41.164 +return xen_db['vm'][ref]['allowed_operations'];
  41.165  }
  41.166  
  41.167  function xen_vm_get_power_state(ref)
  41.168  {
  41.169 -return xen_db['VM'][ref]['power_state'];
  41.170 +return xen_db['vm'][ref]['power_state'];
  41.171 +}
  41.172 +
  41.173 +function xen_set_affinity(vm_id,host_id)
  41.174 +{
  41.175 +var params=new Array();
  41.176 +params[0]=xen_db['session_id'];
  41.177 +params[1]=vm_id;
  41.178 +params[2]=host_id;
  41.179 +ApiCall('VM.set_affinity',params,true,0,0,0,0);
  41.180 +return;
  41.181 +}
  41.182 +
  41.183 +function xen_vm_set_other_config(ref,other_config)
  41.184 +{
  41.185 +var params=new Array();
  41.186 +	params[0]=xen_db['session_id'];
  41.187 +params[1]=ref;
  41.188 +params[2]=other_config;
  41.189 +ApiCall('VM.set_other_config',params,true,0,0,0,0);
  41.190 +return;
  41.191 +}
  41.192 +
  41.193 +function xen_vm_set_name_description(ref,name_label)
  41.194 +{
  41.195 +var params=new Array();
  41.196 +	params[0]=xen_db['session_id'];
  41.197 +params[1]=ref;
  41.198 +params[2]=name_label;
  41.199 +ApiCall('VM.set_name_description',params,true,0,0,0,0);
  41.200 +return;
  41.201 +}
  41.202 +
  41.203 +function xen_vm_provision(ref)
  41.204 +{
  41.205 +var params=new Array();
  41.206 +params[0]=xen_db['session_id'];
  41.207 +params[1]=ref;
  41.208 +return ApiCall('VM.provision',params,true,0,0,0,0);
  41.209 +}
  41.210 +
  41.211 +function xen_vm_clone_sync(ref,name_label)
  41.212 +{
  41.213 +var params=new Array();
  41.214 +params[0]=xen_db['session_id'];
  41.215 +params[1]=ref;
  41.216 +params[2]=name_label;
  41.217 +return ApiCall('VM.clone',params,false,0,0,0,0);
  41.218 +}
  41.219 +
  41.220 +
  41.221 +function xen_vm_clone(ref,name_label)
  41.222 +{
  41.223 +var params=new Array();
  41.224 +params[0]=xen_db['session_id'];
  41.225 +params[1]=ref;
  41.226 +params[2]=name_label;
  41.227 +return ApiCall('VM.clone',params,true,0,0,0,0);
  41.228  }
  41.229  
  41.230  function xen_vm_get_possible_hosts(ref)
  41.231 @@ -71,9 +231,69 @@ function xen_vm_get_possible_hosts(ref)
  41.232  var params=new Array();
  41.233  params[0]=xen_db['session_id'];
  41.234  params[1]=ref;
  41.235 -return ApiCall('VM.get_possible_hosts',params,false,0,0,0,0);;
  41.236 +return ApiCall('VM.get_possible_hosts',params,false,0,0,0,0);
  41.237 +}
  41.238 +
  41.239 +function xen_vm_set_memory_static_min(ref,memory)
  41.240 +{
  41.241 +var params=new Array();
  41.242 +params[0]=xen_db['session_id'];
  41.243 +params[1]=ref;
  41.244 +params[2]=memory.toString();
  41.245 +ApiCall('VM.set_memory_static_min',params,true,0,0,0,0);
  41.246 +return ;
  41.247 +}
  41.248 +
  41.249 +function xen_vm_set_memory_dynamic_min(ref,memory)
  41.250 +{
  41.251 +var params=new Array();
  41.252 +params[0]=xen_db['session_id'];
  41.253 +params[1]=ref;
  41.254 +params[2]=memory.toString();
  41.255 +ApiCall('VM.set_memory_dynamic_min',params,true,0,0,0,0);
  41.256 +return ;
  41.257  }
  41.258  
  41.259 +function xen_vm_set_memory_static_max(ref,memory)
  41.260 +{
  41.261 +var params=new Array();
  41.262 +params[0]=xen_db['session_id'];
  41.263 +params[1]=ref;
  41.264 +params[2]=memory.toString();
  41.265 +ApiCall('VM.set_memory_static_max',params,true,0,0,0,0);
  41.266 +return ;
  41.267 +}
  41.268 +
  41.269 +function xen_vm_set_memory_dynamic_max(ref,memory)
  41.270 +{
  41.271 +var params=new Array();
  41.272 +params[0]=xen_db['session_id'];
  41.273 +params[1]=ref;
  41.274 +params[2]=memory.toString();
  41.275 +ApiCall('VM.set_memory_dynamic_max',params,true,0,0,0,0);
  41.276 +return ;
  41.277 +}
  41.278 +
  41.279 +function xen_vm_set_VCPUs_max(ref,vcpus)
  41.280 +{
  41.281 +var params=new Array();
  41.282 +params[0]=xen_db['session_id'];
  41.283 +params[1]=ref;
  41.284 +params[2]=vcpus.toString();
  41.285 +ApiCall('VM.set_VCPUs_max',params,true,0,0,0,0);
  41.286 +return ;
  41.287 +}
  41.288 +
  41.289 +function xen_vm_set_VCPUs_at_startup(ref,vcpus)
  41.290 +{
  41.291 +var params=new Array();
  41.292 +params[0]=xen_db['session_id'];
  41.293 +params[1]=ref;
  41.294 +params[2]=vcpus.toString();
  41.295 +ApiCall('VM.set_VCPUs_at_startup',params,true,0,0,0,0);
  41.296 +return ; 
  41.297 +}
  41.298 +		
  41.299  function xen_vm_clean_shutdown(ref)
  41.300  {
  41.301  var params=new Array();
  41.302 @@ -110,6 +330,15 @@ ApiCall('VM.hard_reboot',params,true,0,0
  41.303  return ;
  41.304  }
  41.305  
  41.306 +function xen_vm_destroy(ref)
  41.307 +{
  41.308 +var params=new Array();
  41.309 +params[0]=xen_db['session_id'];
  41.310 +params[1]=ref;
  41.311 +ApiCall('VM.destroy',params,true,0,0,0,0);
  41.312 +return ;
  41.313 +}
  41.314 +
  41.315  function xen_vm_pause(ref)
  41.316  {
  41.317  var params=new Array();
  41.318 @@ -142,6 +371,8 @@ function xen_vm_resume(ref)
  41.319  var params=new Array();
  41.320  params[0]=xen_db['session_id'];
  41.321  params[1]=ref;
  41.322 +params[2]=false;
  41.323 +params[3]=true;
  41.324  ApiCall('VM.resume',params,true,0,0,0,0);
  41.325  return ;
  41.326  }
  41.327 @@ -151,6 +382,8 @@ function xen_vm_start(ref)
  41.328  var params=new Array();
  41.329  params[0]=xen_db['session_id'];
  41.330  params[1]=ref;
  41.331 +params[2]=false;
  41.332 +params[3]=true;
  41.333  ApiCall('VM.start',params,true,0,0,0,0);
  41.334  return ;
  41.335  }
  41.336 @@ -185,6 +418,7 @@ var params=new Array();
  41.337  params[0]=xen_db['session_id'];
  41.338  params[1]=vm_ref;
  41.339  params[2]=host_ref;
  41.340 +params[3]=new Object();
  41.341  ApiCall('VM.pool_migrate',params,true,0,0,0,0);
  41.342  return ;
  41.343  }