xcpweb

changeset 11:5c39c6cef4b4

Console, Error Windows, tasks, and bug fixes
author Nikola Nikov <nikolanikov@webconnect.bg>
date Sun Aug 01 14:29:29 2010 +0300 (2010-08-01)
parents 0803fe338c81
children 696f0228e887
files interface/index.html interface/js/interface_init.js interface/templates/cloud_pool.css interface/templates/cloud_pool.js interface/templates/login.html interface/templates/main.css interface/templates/main.js interface/xcp.css libxen/callbacks.js libxen/core.js libxen/db_callbacks.js libxen/libxen_host.js libxen/libxen_init.js libxen/libxen_vm.js
line diff
     1.1 --- a/interface/index.html	Mon Jul 19 03:31:59 2010 +0300
     1.2 +++ b/interface/index.html	Sun Aug 01 14:29:29 2010 +0300
     1.3 @@ -11,20 +11,16 @@ var libxen_path='/libxen';
     1.4  </script>
     1.5  
     1.6  <script type="text/javascript" src="/interface/js/interface_init.js"></script>
     1.7 +<script type="text/javascript" src="/interface/js/global_functions.js"></script>
     1.8  <script type="text/javascript" src="/libxen/libxen_init.js"></script>
     1.9 -
    1.10 -
    1.11  <link href="/interface/xcp.css" rel="stylesheet" type="text/css" />
    1.12 -<link href="/interface/templates/login.css" rel="stylesheet" type="text/css" />
    1.13 -<link href="/interface/templates/main.css" rel="stylesheet" type="text/css" />
    1.14 -<link href="/interface/templates/cloud_pool.css" rel="stylesheet" type="text/css" />
    1.15  
    1.16  </head>
    1.17 -<body onLoad="templates.LoadJS(interface_path+'/templates/login.js');templates.LoadTemplate(interface_path+'/templates/login.html','content');">
    1.18 -
    1.19 +<body onLoad="templates.LoadJS(interface_path+'/templates/login.js');templates.LoadCSS(interface_path+'/templates/login.css');templates.LoadTemplate(interface_path+'/templates/login.html','content');">
    1.20 +<div id="popupwindows"></div>
    1.21  <div class="page">
    1.22  
    1.23 -<div class="header" id="header">&nbsp;</div>
    1.24 +<div class="header" id="header">&nbsp;<div class="task_box" id="task_box" style="display:none"><table id="task_box_table"></table></div></div>
    1.25  <div class="content" id="content">&nbsp;</div>
    1.26  
    1.27  </div>
     2.1 --- a/interface/js/interface_init.js	Mon Jul 19 03:31:59 2010 +0300
     2.2 +++ b/interface/js/interface_init.js	Sun Aug 01 14:29:29 2010 +0300
     2.3 @@ -58,6 +58,15 @@ function templates_req() {
     2.4  	imageObj = new Image();
     2.5  	imageObj.src=img;
     2.6  	}
     2.7 +	this.LoadCSS = function(css) {
     2.8 +		var head = document.getElementsByTagName('head')[0];
     2.9 +		var style = document.createElement('link');
    2.10 +		style.setAttribute('rel','stylesheet');
    2.11 +		style.setAttribute('href',css);
    2.12 +		style.setAttribute('type','text/css');
    2.13 +		style.setAttribute('media','all');
    2.14 +		head.appendChild(style);
    2.15 +	}
    2.16  	// other functions
    2.17  	
    2.18  	this.findPos = function(fobj) {
    2.19 @@ -464,7 +473,260 @@ function xcp_Menu() {
    2.20  	
    2.21  }
    2.22  var xcp_menu = new xcp_Menu();
    2.23 +// Popup Windows
    2.24 +
    2.25 +function PopupWindow() {
    2.26 +	var bw=document.getElementById&&!document.all;
    2.27 +	var self = this;
    2.28 +	var resizeObj = false;
    2.29 +	var resize = false;
    2.30 +	var oresize = false;
    2.31 +	var drag = false;
    2.32 +	var path = '/interface/';
    2.33 +	var offx = 0;
    2.34 +	var offy = 0;
    2.35 +	var id=0;
    2.36 +	var created_windows = new Array();
    2.37 +	this.error_windows=0;
    2.38 +	this.mouseX = function(e) { return e ? Number(e.clientX) : Number(event.clientX); }
    2.39 +	this.mouseY = function(e) { return e ? Number(e.clientY) : Number(event.clientY); }
    2.40 +	
    2.41 +	this.create = function(id,titlebar,content) {
    2.42 +		if(created_windows[id])return false;
    2.43 +		created_windows[id]=1;
    2.44 +		var tpl = '<div id="window'+id+'" class="window" win="'+id+'" onmouseout="popup.backCursor(this,event)" onmouseover="popup.changeCursor(this,event);">';
    2.45 +		tpl += '<div class="win-titlebar" dragwin="window'+id+'">';
    2.46 +		tpl += '<div class="title" dragwin="window'+id+'">'+titlebar+'</div>';
    2.47 +		tpl += '<div class="close"><img onclick="popup.destroy(\''+id+'\');" src="'+path+'img/close.png" alt="" /></div>';
    2.48 +		tpl += '<div class="clear"></div>';
    2.49 +		tpl += '</div>';
    2.50 +		tpl += '<div class="win-content" id="resize-'+id+'">';
    2.51 +		tpl += '<div class="cnt" id="wincnt'+id+'"></div>';
    2.52 +		tpl += '<img class="corner" src="'+path+'img/corner.png" />';
    2.53 +		tpl += '</div>';
    2.54 +		tpl += '</div>';
    2.55 +		try {
    2.56 +			document.getElementById('popupwindows').innerHTML += tpl;
    2.57 +			if(typeof(content)=='undefined')return id;
    2.58 +			else if(typeof(content)=='object')document.getElementById('wincnt'+id).appendChild(content);
    2.59 +			else document.getElementById('wincnt'+id).innerHTML=content;
    2.60 +			return id;
    2.61 +		}
    2.62 +		catch(e) { return false; }
    2.63 +		
    2.64 +		
    2.65 +	
    2.66 +	}
    2.67 +	
    2.68 +	this.create_error = function(titlebar,content) {
    2.69 +		self.error_windows++;
    2.70 +		id='error_'+self.error_windows;
    2.71 +		if(created_windows[id])return false;
    2.72 +		created_windows[id]=1;
    2.73 +		var tpl = '<div id="window'+id+'" class="window_error" win="'+id+'" onmouseout="popup.backCursor(this,event)" onmouseover="popup.changeCursor(this,event);">';
    2.74 +		tpl += '<div class="win-titlebar" dragwin="window'+id+'">';
    2.75 +		tpl += '<div class="title" dragwin="window'+id+'">'+titlebar+'</div>';
    2.76 +		tpl += '<div class="close"><img onclick="popup.destroy(\''+id+'\');" src="'+path+'img/close_grey.png" alt="" /></div>';
    2.77 +		tpl += '<div class="clear"></div>';
    2.78 +		tpl += '</div>';
    2.79 +		tpl += '<div class="win-content" id="resize-'+id+'">';
    2.80 +		tpl += '<div class="cnt" id="wincnt'+id+'"></div>';
    2.81 +		tpl += '<img class="corner" src="'+path+'img/corner.png" />';
    2.82 +		tpl += '</div>';
    2.83 +		tpl += '</div>';
    2.84 +		try {
    2.85 +			document.getElementById('popupwindows').innerHTML += tpl;
    2.86 +			if(typeof(content)=='undefined')return id;
    2.87 +			else if(typeof(content)=='object')document.getElementById('wincnt'+id).appendChild(content);
    2.88 +			else document.getElementById('wincnt'+id).innerHTML=content;
    2.89 +			return id;
    2.90 +		}
    2.91 +		catch(e) { return false; }
    2.92 +		
    2.93 +		
    2.94 +	
    2.95 +	}
    2.96 +	
    2.97 +	this.destroy = function(win) {
    2.98 +		if (document.getElementById('window'+win)) {
    2.99 +			document.getElementById('window'+win).parentNode.removeChild(document.getElementById('window'+win));
   2.100 +		}
   2.101 +		if(created_windows[win])created_windows[win]=undefined;
   2.102 +	}
   2.103 +	this.mousedown = function(e) {
   2.104 +		var fobj = bw ? e.target : event.srcElement;
   2.105 +		if (!fobj) { return true; }
   2.106 +		if (fobj.getAttribute('dragwin')) {
   2.107 +			drag = document.getElementById(fobj.getAttribute('dragwin'));
   2.108 +			offx = (templates.findPosX(drag) - self.mouseX(e));
   2.109 +			offy = (templates.findPosY(drag) - self.mouseY(e));
   2.110 +			return false;
   2.111 +		}
   2.112 +		else {
   2.113 +			if (oresize) {
   2.114 +				self.startResize(fobj,e);
   2.115 +				return false;
   2.116 +			}
   2.117 +		}
   2.118 +		return true;
   2.119 +	}
   2.120 +	this.mousemove = function(e) {
   2.121 +		if (drag) {
   2.122 +			drag.style.top = (self.mouseY(e) + offy)+'px';
   2.123 +			drag.style.left = (self.mouseX(e) + offx)+'px';
   2.124 +			return false;
   2.125 +		}
   2.126 +		else {
   2.127 +			var fobj = bw ? e.target : event.srcElement;
   2.128 +			if (self.moveCursor(fobj,e)) { return true; }
   2.129 +		}
   2.130 +	}
   2.131 +	this.mouseup = function(e) {
   2.132 +		if (drag) { drag = false; return false; }
   2.133 +		if (resize) {
   2.134 +			var fobj = bw ? e.target : event.srcElement;
   2.135 +			self.stopResize(fobj,e);
   2.136 +			return false;
   2.137 +		}
   2.138 +		return true;
   2.139 +	}
   2.140 +	this.changeCursor = function(win,e) {
   2.141 +		if (!drag && !resize) {
   2.142 +			offx = Number(templates.findPosX(win) + Number(win.clientWidth));
   2.143 +			offy = Number(templates.findPosY(win) + Number(win.clientHeight));
   2.144 +			resizeObj = win;
   2.145 +		}
   2.146 +		else { resizeObj = false; }
   2.147 +	}
   2.148 +	this.moveCursor = function(win,e) {
   2.149 +		if (!drag && !resize && offy && offx && resizeObj) {
   2.150 +			var mx = self.mouseX(e);
   2.151 +			var my = self.mouseY(e);
   2.152 +			var eres = false,sres = false;
   2.153 +			if ((offy - my) < 15) { sres = true; }
   2.154 +			if ((offx - mx) < 15) { eres = true; }
   2.155 +			if (sres && eres) { resizeObj.style.cursor = 'se-resize'; oresize = 'se'; }
   2.156 +			else {
   2.157 +				if (sres) { resizeObj.style.cursor = 's-resize'; oresize = 's'; }
   2.158 +				else if (eres) { resizeObj.style.cursor = 'e-resize'; oresize = 'e'; }
   2.159 +				else {
   2.160 +					if (resizeObj) { resizeObj.style.cursor = ''; }
   2.161 +					oresize = false; resizeObj = false;
   2.162 +				}
   2.163 +			}
   2.164 +		}
   2.165 +		if (resize) {
   2.166 +			if (oresize == 'e' || oresize == 'se') {
   2.167 +				var mx = self.mouseX(e);
   2.168 +				resize.style.width = (mx - templates.findPosX(resize.parentNode)) + 'px';
   2.169 +			}
   2.170 +			if (oresize == 's' || oresize == 'se') {
   2.171 +				var my = self.mouseY(e);
   2.172 +				resize.style.height = ((my - templates.findPosY(resize.parentNode)) - 26) + 'px';
   2.173 +			}
   2.174 +			return true;
   2.175 +		}
   2.176 +		return false;
   2.177 +	}
   2.178 +	this.startResize = function(win,e) {
   2.179 +		if (oresize && resizeObj) { resize = document.getElementById('resize-'+resizeObj.getAttribute('win')); }
   2.180 +	}
   2.181 +	this.stopResize = function(win,e) {
   2.182 +		if (resize) { oresize = false; resize = false; resizeObj = false; }
   2.183 +	}
   2.184 +	this.backCursor = function(win) {
   2.185 +		if (resize || oresize) {
   2.186 +			win.style.cursor = '';
   2.187 +			offy = 0;
   2.188 +			offx = 0;
   2.189 +		}
   2.190 +	}
   2.191 +}
   2.192 +var popup = new PopupWindow();
   2.193 +
   2.194  
   2.195  //Events
   2.196 -document.onmousedown = xcp_menu.mousedown;
   2.197 +
   2.198 +document.onmousedown = function(e) {
   2.199 +var bw=document.getElementById&&!document.all;
   2.200 +var fobj = bw ? e.target : event.srcElement;
   2.201 +				xcp_menu.mousedown(e);
   2.202 +                popup.mousedown(e);
   2.203 +if (fobj.tagName == 'INPUT' || fobj.tagName == 'BUTTON' || fobj.tagName == 'A') {  return true; }
   2.204 +
   2.205 +				return false; 
   2.206 +        }
   2.207 +
   2.208 +document.onmousemove = popup.mousemove;
   2.209 +document.onmouseup = popup.mouseup;
   2.210 +
   2.211 +//The Error Default handling
   2.212 +
   2.213 +function isINT(param)
   2.214 +{
   2.215 +   var ValidChars="0123456789";
   2.216 +   var isINT=1;
   2.217 +
   2.218 +   for (i=0;i<param.length && isINT==1; i++)if(ValidChars.indexOf(param.charAt(i))==-1)isINT=0;
   2.219 +      
   2.220 +return isINT;
   2.221 +}
   2.222 +
   2.223 +
   2.224 +function error_callback_default(raw,xmldoc,param_pass)
   2.225 +{
   2.226 +var cur=xmldoc;
   2.227 +var error=0;
   2.228 +var title='';
   2.229 +var description='';
   2.230 +while(cur.nodeName!='struct' && typeof(cur.childNodes[0])!='undefined')cur=cur.childNodes[0];
   2.231 +if(cur.nodeName!='struct')error=1;
   2.232  
   2.233 +var par=cur;
   2.234 +for(var i in par.childNodes)
   2.235 +{
   2.236 +if(isINT(i))
   2.237 +{
   2.238 +if(par.childNodes[i].nodeName=='member')
   2.239 +	{
   2.240 +	cur=par.childNodes[i];
   2.241 +		if(typeof(cur)!='undefined')
   2.242 +		{
   2.243 +			if(cur.childNodes[0].childNodes[0].nodeValue=='Status')title=cur.childNodes[1].childNodes[0].nodeValue;
   2.244 +		}
   2.245 +		else error=1;
   2.246 +		
   2.247 +		if(typeof(cur)!='undefined')
   2.248 +		{
   2.249 +			if(cur.childNodes[0].childNodes[0].nodeValue=='ErrorDescription')
   2.250 +			{
   2.251 +			description='<h4>Error Description</h4><br />';
   2.252 +			cur=cur.childNodes[1].getElementsByTagName("value");
   2.253 +			for(var desc in cur)
   2.254 +			{
   2.255 +				if(isINT(desc))
   2.256 +				{
   2.257 +				try {description+=cur[desc].childNodes[0].nodeValue+'<br />';}catch(err){}
   2.258 +				}
   2.259 +			}
   2.260 +			}
   2.261 +		}
   2.262 +		else error=1;
   2.263 +		
   2.264 +	
   2.265 +	}
   2.266 +else error=1;
   2.267 +}
   2.268 +}
   2.269 +
   2.270 +if(error==1)
   2.271 +	{
   2.272 +	title='Raw Error';
   2.273 +	description=raw;
   2.274 +	}
   2.275 +	
   2.276 +popup.create_error(title,description);
   2.277 +return ;
   2.278 +}
   2.279 +
   2.280 +
     3.1 --- a/interface/templates/cloud_pool.css	Mon Jul 19 03:31:59 2010 +0300
     3.2 +++ b/interface/templates/cloud_pool.css	Sun Aug 01 14:29:29 2010 +0300
     3.3 @@ -158,13 +158,3 @@ width: 60px;
     3.4  }
     3.5  
     3.6  
     3.7 -#Bar
     3.8 -{
     3.9 -	width: 101px; height: 10px;
    3.10 -	text-align: center;
    3.11 -	background: url(/interface/img/meter.gif) repeat-x bottom left;
    3.12 -	margin-left: 3px;
    3.13 -	margin-right: 3px;
    3.14 -	margin-top: 3px;
    3.15 -	float: left;
    3.16 -}
     4.1 --- a/interface/templates/cloud_pool.js	Mon Jul 19 03:31:59 2010 +0300
     4.2 +++ b/interface/templates/cloud_pool.js	Sun Aug 01 14:29:29 2010 +0300
     4.3 @@ -23,7 +23,7 @@ var is_hidden = 0;
     4.4  		document.getElementById('vm_show_hide').src='/interface/img/minus_big.png';
     4.5  		document.getElementById('vm_show_hide').style.top='-3px';
     4.6  		document.getElementById('vm_box_content').style.display='';
     4.7 -		is_hidden=0; 
     4.8 +		is_hidden=0;
     4.9  		}
    4.10  	else
    4.11  		{
    4.12 @@ -33,7 +33,19 @@ var is_hidden = 0;
    4.13  		is_hidden=1;
    4.14  		}
    4.15  	}
    4.16 -
    4.17 +	
    4.18 +	this.create_non_resident_host_table = function()
    4.19 +	{
    4.20 +	var pool = document.createElement('table');
    4.21 +	pool.width='100%';
    4.22 +	pool.id='pool_non_resident_vms';
    4.23 +	var y=document.getElementById('pool_server').insertRow(-1).insertCell(0);
    4.24 +	y.colSpan=5;
    4.25 +	y.appendChild(pool);
    4.26 +	
    4.27 +	return pool;
    4.28 +	}
    4.29 +	
    4.30  	this.addHost = function(id,params)
    4.31  	{
    4.32  	var x=document.getElementById('pool_server').insertRow(-1);
    4.33 @@ -76,6 +88,7 @@ var is_hidden = 0;
    4.34  	{
    4.35  	var x=host_table.insertRow(-1);
    4.36  	var tempcell;
    4.37 +	var memory_percent=0;
    4.38  	x.className="vm_row";
    4.39  	x.id=id;
    4.40  	x.onclick = function(e) {cp_submenus.vm(id,e);}
    4.41 @@ -93,10 +106,10 @@ var is_hidden = 0;
    4.42  	tempcell=x.insertCell(2);
    4.43  	tempcell.className="vm_row_description";
    4.44  	tempcell.innerHTML=params['name_description'];
    4.45 -	
    4.46 +	if(parseInt(params['max_memory'])>0)memory_percent=((parseInt(params['memory_total'])/parseInt(params['max_memory']))*100);
    4.47  	tempcell=x.insertCell(3);
    4.48  	tempcell.className="vm_row_memory";
    4.49 -	tempcell.innerHTML='<div class="memory_usage_text">Memory Usage : </div><div id="Bar"><div style="float: left; height: 10px; padding: 0; background-image: url(/interface/img/bar.png); width: '+((parseInt(params['memory_total'])/parseInt(params['max_memory']))*100)+'px;" /></div></div><div class="memory_usage_text"> '+params['memory_total']+'M</div>';
    4.50 +	tempcell.innerHTML='<div class="memory_usage_text">Memory Usage : </div><div id="Bar"><div style="float: left; height: 10px; padding: 0; background-image: url(/interface/img/bar.png); width: '+memory_percent+'px;" /></div></div><div class="memory_usage_text"> '+params['memory_total']+'M</div>';
    4.51  	
    4.52  	tempcell=x.insertCell(4);
    4.53  	tempcell.className="vm_row_cpus cpus_count";
    4.54 @@ -113,107 +126,72 @@ var is_hidden = 0;
    4.55  	return x;
    4.56  	}
    4.57  	
    4.58 +	this.createConsole = function (width,height,url,session,title)
    4.59 +	//function (640,500,url,session)
    4.60 +	{
    4.61 +	var msie=0;
    4.62 +	var consolestuff='';
    4.63 +	if (navigator.browserName=="Microsoft Internet Explorer")
    4.64 +	{
    4.65 +	msie=1;
    4.66 +	}
    4.67 +	
    4.68 +	if(msie)
    4.69 +	{
    4.70 +	consolestuff += '<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" type="application/x-java-applet" width="'+width+'",height="'+height+'">';
    4.71 +	consolestuff += '<param name="code" value="com.citrix.xenserver.console.Initialize">';
    4.72 +	}
    4.73 +	else 
    4.74 +	{
    4.75 +	consolestuff += '<object height="'+height+'" width="'+width+'" classid="java:com.citrix.xenserver.console.Initialize.class" type="application/x-java-applet" archive="XenServerConsole.jar">';
    4.76 +	consolestuff += '<param name="code" value="com.citrix.xenserver.console.Initialize.class">';
    4.77 +	}	
    4.78 +		consolestuff += '<param name="ipaddress" value="127.0.0.1"><param name="archive" value="XenServerConsole.jar"><param name="scriptable" value="false"><param name="password" value="none"><param name="port" value="5900"><param name="useurl" value="true"><param name="backcolor" value="ff:ff:ff">';
    4.79 +		consolestuff += '<param name="url" value="'+url+'">';
    4.80 +		consolestuff += '<param name="session" value="'+session+'">';
    4.81 +		consolestuff += '</object>';
    4.82 + 
    4.83 +	popup.create(url,title,consolestuff);
    4.84 +	}
    4.85  	
    4.86  	this.initBox = function()
    4.87  	{
    4.88 -	
    4.89 -	
    4.90 -	/* //only for testing purposes
    4.91 -	var vm_pool=new Array();
    4.92 -	vm_pool['quote:some_test_server_id_0']=new Array();
    4.93 -	vm_pool['quote:some_test_server_id_0']['name_label']='server_name';
    4.94 -	vm_pool['quote:some_test_server_id_0']['server_description']=' Some description for the server. ';
    4.95 -	vm_pool['quote:some_test_server_id_0']['actual_memory']='5120';
    4.96 -	vm_pool['quote:some_test_server_id_0']['max_memory']='10240';
    4.97 -	vm_pool['quote:some_test_server_id_0']['cpu_usage']='40';
    4.98 -	
    4.99 -	vm_pool['quote:some_test_server_id_0']['vm_list']=new Array();
   4.100 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']=new Array();
   4.101 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']['name_label']='xcpweb-server';
   4.102 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']['vm_description']='DDK virtual machine';
   4.103 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']['actual_memory']='512';
   4.104 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']['vm_state']='running';
   4.105 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']['max_memory']=vm_pool['quote:some_test_server_id_0']['max_memory'];
   4.106 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']['vm_cpus_count']='1';
   4.107 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']['vm_cpus_weight']='256';
   4.108 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_0']['vm_cpus_cap']='95';
   4.109 -	
   4.110 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']=new Array();
   4.111 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']['name_label']='testvm';
   4.112 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']['vm_description']='Debian Lenny Server';
   4.113 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']['actual_memory']='512';
   4.114 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']['vm_state']='paused';
   4.115 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']['max_memory']=vm_pool['quote:some_test_server_id_0']['max_memory'];
   4.116 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']['vm_cpus_count']='2';
   4.117 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']['vm_cpus_weight']='512';
   4.118 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_1']['vm_cpus_cap']='150';
   4.119 -	
   4.120 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_2']=new Array();
   4.121 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_2']['name_label']='centos';
   4.122 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_2']['vm_description']='CentOS 5.4 Virtual Machine';
   4.123 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_2']['actual_memory']='512';
   4.124 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_2']['max_memory']=vm_pool['quote:some_test_server_id_0']['max_memory'];
   4.125 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_2']['vm_cpus_count']='1';
   4.126 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_2']['vm_cpus_weight']='256';
   4.127 -	vm_pool['quote:some_test_server_id_0']['vm_list']['quote:some_test_server_vm_2']['vm_cpus_cap']='95';
   4.128 -	
   4.129 +	self.clearBox();
   4.130 +	//non resident
   4.131 +	var non_resident=xen_get_vm_list_non_resident();
   4.132 +	if(non_resident.length>0)
   4.133 +	{
   4.134 +		var non_resident_table_id=self.create_non_resident_host_table();
   4.135 +		for ( var vm_id in non_resident ) // every vm
   4.136 +		{ 
   4.137 +		var current_vm=xen_vm_get_details(non_resident[vm_id]);
   4.138 +		current_vm['max_memory']=0;
   4.139 +		self.addVM(non_resident[vm_id],current_vm,non_resident_table_id);
   4.140 +		}
   4.141 +	}
   4.142  	
   4.143 -	vm_pool['quote:some_test_server_id_1']=new Array();
   4.144 -	vm_pool['quote:some_test_server_id_1']['server_name']='other_server';
   4.145 -	vm_pool['quote:some_test_server_id_1']['server_description']=' Some description for the server. ';
   4.146 -	vm_pool['quote:some_test_server_id_1']['actual_memory']='2048';
   4.147 -	vm_pool['quote:some_test_server_id_1']['max_memory']='10240';
   4.148 -	vm_pool['quote:some_test_server_id_1']['cpu_usage']='10';
   4.149 -	
   4.150 -	vm_pool['quote:some_test_server_id_1']['vm_list']=new Array();
   4.151 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_0']=new Array();
   4.152 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_0']['name_label']='backup-server';
   4.153 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_0']['vm_description']='DDK virtual machine';
   4.154 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_0']['actual_memory']='512';
   4.155 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_0']['vm_cpus_count']='1';
   4.156 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_0']['vm_cpus_weight']='256';
   4.157 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_0']['vm_cpus_cap']='95';
   4.158 -	
   4.159 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_1']=new Array();
   4.160 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_1']['name_label']='testvm2';
   4.161 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_1']['vm_description']='Debian Backup Server';
   4.162 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_1']['actual_memory']='512';
   4.163 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_1']['vm_cpus_count']='2';
   4.164 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_1']['vm_cpus_weight']='512';
   4.165 -	vm_pool['quote:some_test_server_id_1']['vm_list']['quote:some_test_server_vm_1']['vm_cpus_cap']='150';
   4.166 -	// TODO: to get the arrays from the xcp server part
   4.167 -	
   4.168 -
   4.169 -	for ( var server_id in vm_pool )
   4.170 -	{
   4.171 -	
   4.172 -	vm_pool[server_id]['table_id']=self.addHost(server_id,vm_pool[server_id]);
   4.173 -    
   4.174 -		for ( var vm_id in vm_pool[server_id]['vm_list'] )
   4.175 -		{
   4.176 -				self.addVM(vm_id,vm_pool[server_id]['vm_list'][vm_id],vm_pool[server_id]['table_id']);
   4.177 -		}
   4.178 -	
   4.179 -	
   4.180 -	}
   4.181 -	*/
   4.182 -	
   4.183 -	
   4.184 -	var vm_pool=xen_get_vm_list_hosts();
   4.185 -	for ( var server_id in vm_pool )
   4.186 -	{
   4.187 -	vm_pool[server_id]['table_id']=self.addHost(server_id,vm_pool[server_id]);
   4.188 +	//resident
   4.189 +	 var vm_pool=xen_get_vm_list_hosts();
   4.190 +	 for ( var server_id in vm_pool )
   4.191 +	 {
   4.192 +	 vm_pool[server_id]['table_id']=self.addHost(server_id,vm_pool[server_id]);
   4.193  	
   4.194  		for ( var vm_id in vm_pool[server_id]['resident_VMs'] ) // every vm
   4.195 -		{
   4.196 -		var current_vm=xen_get_vm_list_vm(vm_pool[server_id]['resident_VMs'][vm_id]);
   4.197 +		{ 
   4.198 +		var current_vm=xen_vm_get_details(vm_pool[server_id]['resident_VMs'][vm_id]);
   4.199  		current_vm['max_memory']=vm_pool[server_id]['memory_total'];
   4.200  		self.addVM(vm_pool[server_id]['resident_VMs'][vm_id],current_vm,vm_pool[server_id]['table_id']);
   4.201  		}
   4.202  	
   4.203 +	 }
   4.204 +	
   4.205 +	
   4.206  	}
   4.207  	
   4.208 -	
   4.209 +	this.clearBox = function()
   4.210 +	{
   4.211 +	var x=document.getElementById('pool_server');
   4.212 +	for(var i=x.rows.length-1;i>=0;i--)x.deleteRow(i);
   4.213  	}
   4.214  
   4.215  }
   4.216 @@ -229,18 +207,21 @@ this.vm = function(param,e)
   4.217  	if (xcp_menu.getMenu(param)) { xcp_menu.dropMenu(param); }
   4.218  	var allowed_operations=xen_vm_get_allowed_operations(param);
   4.219  	var power_state=xen_vm_get_power_state(param);
   4.220 +	var console_stuff=xen_vm_get_console(param);
   4.221  	var possible_hosts=xen_vm_get_possible_hosts(param);
   4.222  	var possible_hosts_label=new Array();
   4.223  	var possible_hosts_num = 0;
   4.224 +	var vm_details=xen_vm_get_details(param);
   4.225  	
   4.226  	for (var i in possible_hosts) {
   4.227  	possible_hosts_num++;
   4.228  	possible_hosts_label[i]=xen_host_get_name_label(possible_hosts[i]);
   4.229  	}
   4.230 +
   4.231  	
   4.232  	var currentMenu = xcp_menu.createMenu(param);
   4.233  	if (typeof(currentMenu) == 'object') {
   4.234 -		xcp_menu.appendInMenu(currentMenu,'console','Console',"",'/interface/img/menu_terminal.png');
   4.235 +		if(console_stuff)xcp_menu.appendInMenu(currentMenu,'console','Console',"cp_vm_box.createConsole(640,420,'"+console_stuff['location']+"','"+console_stuff['session_id']+"','Console : "+vm_details['name_label']+"')",'/interface/img/menu_terminal.png');
   4.236  		var subcurrent = xcp_menu.appendSubInMenu(currentMenu,'oprations','Operations','/interface/img/menu_operations.png');
   4.237  		if (typeof(subcurrent) == 'object') {
   4.238  			if(power_state=='Running' && possible_hosts_num)
   4.239 @@ -297,7 +278,8 @@ this.host = function(param,e)
   4.240  	{
   4.241  	//the param is the host ref
   4.242  	var allowed_operations=xen_host_get_allowed_operations(param);
   4.243 -	
   4.244 +	var console_stuff=xen_host_get_console(param);
   4.245 +	var host_details=xen_host_get_details(param);
   4.246  	
   4.247  	if (xcp_menu.getMenu(param)) { xcp_menu.dropMenu(param); }
   4.248  	var currentMenu = xcp_menu.createMenu(param);
   4.249 @@ -308,14 +290,15 @@ this.host = function(param,e)
   4.250  		allowed_operations.push('shutdown');
   4.251  		allowed_operations.push('reboot');
   4.252  		*/
   4.253 +		if(console_stuff)xcp_menu.appendInMenu(currentMenu,'console','Console',"cp_vm_box.createConsole(640,420,'"+console_stuff['location']+"','"+console_stuff['session_id']+"','Console : "+host_details['name_label']+"')",'/interface/img/menu_terminal.png');
   4.254  		for(var op_id in allowed_operations)
   4.255  		{
   4.256  		if(allowed_operations[op_id]=='evacuate')xcp_menu.appendInMenu(currentMenu,'evacuate','Evacuate',"xen_host_evacuate('"+param+"');",'/interface/img/menu_arrow.png');
   4.257  		if(allowed_operations[op_id]=='shutdown')xcp_menu.appendInMenu(currentMenu,'shutdown','Shutdown',"xen_host_shutdown('"+param+"');",'/interface/img/menu_shutdown.png');
   4.258  		if(allowed_operations[op_id]=='reboot')xcp_menu.appendInMenu(currentMenu,'reboot','Reboot',"xen_host_reboot('"+param+"');",'/interface/img/menu_reboot.png');
   4.259  		}
   4.260 -		xcp_menu.appendInMenu(currentMenu,'disable','Disable',"xen_host_disable('"+param+"');",'/interface/img/menu_disable.png');
   4.261 -		xcp_menu.appendInMenu(currentMenu,'enable','Enable',"xen_host_enable'("+param+"');",'/interface/img/menu_enable.png');
   4.262 +		xcp_menu.appendInMenu(currentMenu,'disable','Disable',"xen_host_disable('"+param+"');",'/interface/img/menu_missing.png');
   4.263 +		xcp_menu.appendInMenu(currentMenu,'enable','Enable',"xen_host_enable'("+param+"');",'/interface/img/menu_missing.png');
   4.264  		xcp_menu.appendInMenu(currentMenu,'settings','Settings',"alert('Settings');",'/interface/img/menu_settings.png');
   4.265  		xcp_menu.openRightMenu('menu_'+param,e);
   4.266  		}
     5.1 --- a/interface/templates/login.html	Mon Jul 19 03:31:59 2010 +0300
     5.2 +++ b/interface/templates/login.html	Sun Aug 01 14:29:29 2010 +0300
     5.3 @@ -5,8 +5,8 @@
     5.4  <div style="clear:both;">
     5.5  <form name="login_form" onSubmit="alert('a');">
     5.6  <table width="100%">
     5.7 -<tr height="44"><td align="right" class="small_label">Username :</td><td align="center"><input type="text" class="textfield" id="login_username" onKeyDown="if(event.keyCode==13)login.try_login();"></td></tr>
     5.8 -<tr height="44"><td align="right" class="small_label">Password :</td><td align="center"><input type="password" class="textfield" id="login_password" onKeyDown="if(event.keyCode==13)login.try_login();"></td></tr>
     5.9 +<tr height="44"><td align="right" class="small_label">Username :</td><td align="center"><input type="text" class="textfield" id="login_username" onKeyDown="if(event.keyCode==13)login.try_login();" /></td></tr>
    5.10 +<tr height="44"><td align="right" class="small_label">Password :</td><td align="center"><input type="password" class="textfield" id="login_password" onKeyDown="if(event.keyCode==13)login.try_login();" /></td></tr>
    5.11  <tr height="54"><td>&nbsp;</td><td align="center"><div class="login_button" onClick="login.try_login();"></div></td></tr>
    5.12  </table>
    5.13  </form>
     6.1 --- a/interface/templates/main.css	Mon Jul 19 03:31:59 2010 +0300
     6.2 +++ b/interface/templates/main.css	Sun Aug 01 14:29:29 2010 +0300
     6.3 @@ -63,3 +63,39 @@ float:left;
     6.4  clear:both;
     6.5  }
     6.6  
     6.7 +/*tasks*/
     6.8 +.task_box
     6.9 +{
    6.10 +margin: 0 auto;
    6.11 +clear:none;
    6.12 +float:right;
    6.13 +min-width: 150px;
    6.14 +min-height: 24px;
    6.15 +background-color:#fff8d6;
    6.16 +border: 1px solid #fbc27f;
    6.17 +-moz-border-radius: 4px;
    6.18 +-webkit-border-radius: 4px;
    6.19 +border-radius: 4px;
    6.20 +font-family: Arial;
    6.21 +font-size: 13px;
    6.22 +font-weight: bold;
    6.23 +text-align: center;
    6.24 +padding-top: 4px;
    6.25 +}
    6.26 +
    6.27 +.task_box .cell_padding
    6.28 +{
    6.29 +padding-left: 4px;
    6.30 +padding-right: 4px;
    6.31 +}
    6.32 +
    6.33 +#Bar
    6.34 +{
    6.35 +	width: 101px; height: 10px;
    6.36 +	text-align: center;
    6.37 +	background: url(/interface/img/meter.gif) repeat-x bottom left;
    6.38 +	margin-left: 3px;
    6.39 +	margin-right: 3px;
    6.40 +	margin-top: 3px;
    6.41 +	float: left;
    6.42 +}
     7.1 --- a/interface/templates/main.js	Mon Jul 19 03:31:59 2010 +0300
     7.2 +++ b/interface/templates/main.js	Sun Aug 01 14:29:29 2010 +0300
     7.3 @@ -2,6 +2,88 @@ templates.LoadImage('/interface/img/clou
     7.4  templates.LoadImage('/interface/img/create_new_button_active.png');
     7.5  templates.LoadImage('/interface/img/settings_button_active.png');
     7.6  
     7.7 +function TaskManager()
     7.8 +{
     7.9 +var self = this;
    7.10 +var is_hidden = 0;
    7.11 +
    7.12 +this.addTask = function(id,params)
    7.13 +	{
    7.14 +	var x=document.getElementById('task_box_table').insertRow(-1);
    7.15 +	x.id=id;
    7.16 +	
    7.17 +	tempcell=x.insertCell(0);
    7.18 +	tempcell.className="cell_padding";
    7.19 +	tempcell.innerHTML=params['name_label'];
    7.20 +	/*
    7.21 +	tempcell=x.insertCell(1);
    7.22 +	//tempcell.className="";
    7.23 +	tempcell.innerHTML='<div id="Bar"><div style="float: left; height: 10px; padding: 0; background-image: url(/interface/img/bar.png); width: '+params['percent']+'px;" /></div>';
    7.24 +	
    7.25 +	
    7.26 +	tempcell=x.insertCell(2);
    7.27 +	tempcell.innerHTML=params['percent']+'%';
    7.28 +	*/
    7.29 +	
    7.30 +	tempcell=x.insertCell(1);
    7.31 +	//tempcell.className="cell_padding";
    7.32 +	tempcell.innerHTML=params['status'];
    7.33 +	
    7.34 +	tempcell=x.insertCell(2);
    7.35 +	tempcell.className="cell_padding";
    7.36 +	tempcell.innerHTML='<img src="/interface/img/close.png" style="cursor:pointer;" />';
    7.37 +	tempcell.onclick = function(e) {self.closeMenu(id,e);}
    7.38 +	
    7.39 +	return x;
    7.40 +	}
    7.41 +
    7.42 +this.closeMenu = function(param,e)
    7.43 +	{	
    7.44 +	var allowed_operations=xen_task_get_allowed_operations(param);
    7.45 +	if (xcp_menu.getMenu(param)) { xcp_menu.dropMenu(param); }
    7.46 +	var currentMenu = xcp_menu.createMenu(param);
    7.47 +	if (typeof(currentMenu) == 'object') {
    7.48 +		
    7.49 +		for(var op_id in allowed_operations)
    7.50 +			{
    7.51 +			if(allowed_operations[op_id]=='cancel')xcp_menu.appendInMenu(currentMenu,'cancel','Cancel',"xen_task_cancel('"+param+"');",'/interface/img/menu_missing.png');
    7.52 +			if(allowed_operations[op_id]=='destroy')xcp_menu.appendInMenu(currentMenu,'destroy','Destroy',"xen_task_destroy'("+param+"');",'/interface/img/menu_missing.png');
    7.53 +			}
    7.54 +		xcp_menu.openRightMenu('menu_'+param,e);
    7.55 +		}
    7.56 +	}
    7.57 +
    7.58 +this.clear = function()
    7.59 +	{
    7.60 +	var x=document.getElementById('task_box_table');
    7.61 +	if(typeof(x.rows)!='undefined')
    7.62 +		{
    7.63 +		for(var i=x.rows.length-1;i>=0;i--)x.deleteRow(i);
    7.64 +		}
    7.65 +	}
    7.66 +	
    7.67 +this.reinitTasks = function()
    7.68 +	{
    7.69 +	var task_num=0;
    7.70 +	self.clear();
    7.71 +	var task_pool=xen_task_get_list();
    7.72 +	for ( var task_id in task_pool )
    7.73 +		{
    7.74 +		task_num++;
    7.75 +		self.addTask(task_id,task_pool[task_id]);
    7.76 +		}
    7.77 +		
    7.78 +	var x=document.getElementById('task_box');
    7.79 +		if(task_num)x.style.display='';
    7.80 +		else x.style.display='none'
    7.81 +		
    7.82 +	}
    7.83 +
    7.84 +}
    7.85 +
    7.86 +var task_manager=new TaskManager();
    7.87 +xen_register_db_event('task',task_manager.reinitTasks);
    7.88 +
    7.89  function main_buttons_req()
    7.90  {
    7.91  var img_path ='/interface/img/'
    7.92 @@ -21,6 +103,7 @@ var make_active = function(button_id)
    7.93  this.cloud_pool = function()
    7.94  	{
    7.95  	make_active('cloud_pool_button');
    7.96 +	templates.LoadCSS(interface_path+'/templates/cloud_pool.css');
    7.97  	templates.LoadJS(interface_path+'/templates/cloud_pool.js');
    7.98  	return ;
    7.99  	}
   7.100 @@ -44,4 +127,5 @@ this.settings = function()
   7.101  }
   7.102  var main_buttons = new main_buttons_req();
   7.103  
   7.104 +templates.LoadCSS(interface_path+'/templates/main.css');
   7.105  templates.LoadTemplate(interface_path+'/templates/main.html','content',main_buttons.cloud_pool);
     8.1 --- a/interface/xcp.css	Mon Jul 19 03:31:59 2010 +0300
     8.2 +++ b/interface/xcp.css	Sun Aug 01 14:29:29 2010 +0300
     8.3 @@ -23,7 +23,7 @@ body
     8.4  {
     8.5  margin: 0 auto;
     8.6  text-align: left;
     8.7 -height:700px;
     8.8 +min-height:650px;
     8.9  width:1000px;
    8.10  background-color:#fff;
    8.11  border: 1px solid #89b1c1;
    8.12 @@ -178,3 +178,155 @@ clear:both;
    8.13  	padding-right:3px;
    8.14  	padding-left:6px;
    8.15  }
    8.16 +
    8.17 +#popupwindows 
    8.18 +{
    8.19 +	position:fixed;
    8.20 +	width:0;
    8.21 +	height:0;
    8.22 +	background:transparent;
    8.23 +	top:0;
    8.24 +	left:0;
    8.25 +}
    8.26 +
    8.27 +.window 
    8.28 +{
    8.29 +	-moz-border-radius: 5px;
    8.30 +	-webkit-border-radius: 5px;
    8.31 +	border-radius: 5px;
    8.32 +	border: 1px solid #cccccc;
    8.33 +	font-family: Arial, Helvetica, sans-serif;
    8.34 +	font-size: small;
    8.35 +	position: fixed;
    8.36 +	z-index:20;
    8.37 +	padding-bottom:2px;
    8.38 +	min-width:250px;
    8.39 +	min-height:250px;
    8.40 +	background-color: white;
    8.41 +}
    8.42 +.window .win-titlebar 
    8.43 +{
    8.44 +	clear: both;
    8.45 +	padding-top: 4px;
    8.46 +	background-color: #3fb7c8;
    8.47 +	height: 22px;
    8.48 +	cursor:move;
    8.49 +}
    8.50 +.window .win-titlebar .close 
    8.51 +{
    8.52 +	float: right;
    8.53 +	padding-right: 8px;
    8.54 +	cursor:pointer;
    8.55 +}
    8.56 +.window .win-titlebar .title 
    8.57 +{
    8.58 +	float: left;
    8.59 +	padding-left: 8px;
    8.60 +	font-weight: bold;
    8.61 +	color: #FFFFFF;
    8.62 +	cursor:move;
    8.63 +}
    8.64 +.window .win-content 
    8.65 +{
    8.66 +	width: 650px;
    8.67 +	height: 450px;
    8.68 +	min-width:250px;
    8.69 +	min-height:250px;
    8.70 +	position: relative;
    8.71 +	overflow: auto;
    8.72 +	background-color:#FFFFFF;
    8.73 +}
    8.74 +.window .win-content .cnt 
    8.75 +{
    8.76 +	padding-top: 12px;
    8.77 +	padding-right: 8px;
    8.78 +	padding-bottom: 12px;
    8.79 +	padding-left: 8px;
    8.80 +	word-wrap: break-word;
    8.81 +	background-color:#ffffff;
    8.82 +	z-index:1;
    8.83 +}
    8.84 +.window .win-content .corner 
    8.85 +{
    8.86 +	position:absolute;
    8.87 +	bottom:1px;
    8.88 +	right:3px;
    8.89 +	z-index:2;
    8.90 +}
    8.91 +
    8.92 +
    8.93 +.window_error 
    8.94 +{
    8.95 +	-moz-border-radius: 5px;
    8.96 +	-webkit-border-radius: 5px;
    8.97 +	border-radius: 5px;
    8.98 +	border: 1px solid #cccccc;
    8.99 +	font-family: Arial, Helvetica, sans-serif;
   8.100 +	font-size: small;
   8.101 +	position: fixed;
   8.102 +	z-index:21;
   8.103 +	padding-bottom:2px;
   8.104 +	min-width:250px;
   8.105 +	min-height:140px;
   8.106 +	background-color: #f4dfdf;
   8.107 +}
   8.108 +.window_error .win-titlebar 
   8.109 +{
   8.110 +	clear: both;
   8.111 +	padding-top: 4px;
   8.112 +	background-color: #ff0203;
   8.113 +	height: 22px;
   8.114 +	cursor:move;
   8.115 +}
   8.116 +.window_error .win-titlebar .close 
   8.117 +{
   8.118 +	float: right;
   8.119 +	padding-right: 8px;
   8.120 +	cursor:pointer;
   8.121 +}
   8.122 +.window_error .win-titlebar .title 
   8.123 +{
   8.124 +	float: left;
   8.125 +	padding-left: 8px;
   8.126 +	font-weight: bold;
   8.127 +	color: #FFFFFF;
   8.128 +	cursor:move;
   8.129 +}
   8.130 +.window_error .win-content 
   8.131 +{
   8.132 +	width: 350px;
   8.133 +	height: 200px;
   8.134 +	min-width:250px;
   8.135 +	min-height:140px;
   8.136 +	position: relative;
   8.137 +	overflow: auto;
   8.138 +	background-color:#f4dfdf;
   8.139 +}
   8.140 +.window_error .win-content .cnt 
   8.141 +{
   8.142 +	padding-top: 12px;
   8.143 +	padding-right: 8px;
   8.144 +	padding-bottom: 12px;
   8.145 +	padding-left: 8px;
   8.146 +	word-wrap: break-word;
   8.147 +	background-color:#f4dfdf;
   8.148 +	z-index:1;
   8.149 +}
   8.150 +.window_error .win-content .corner 
   8.151 +{
   8.152 +	position:absolute;
   8.153 +	bottom:1px;
   8.154 +	right:3px;
   8.155 +	z-index:2;
   8.156 +}
   8.157 +
   8.158 +
   8.159 +.clear 
   8.160 +{
   8.161 +	clear: both;
   8.162 +}
   8.163 +
   8.164 +.window .clear
   8.165 +{
   8.166 +	clear: both;
   8.167 +}
     9.1 --- a/libxen/callbacks.js	Mon Jul 19 03:31:59 2010 +0300
     9.2 +++ b/libxen/callbacks.js	Sun Aug 01 14:29:29 2010 +0300
     9.3 @@ -1,1 +1,1 @@
     9.4 -function xen_callback_proceed_init(result,xmldoc,param_pass)
{
var params=new Array();
var event_params=new Array();
params[0]=xen_db['session_id'];
event_params[0]=xen_db['session_id'];
event_params[1]=new Array('*');

var initCalls=new Array('VM.get_all_records','task.get_all_records','VBD.get_all_records','VBD_metrics.get_all_records','VDI.get_all_records','network.get_all_records','PIF.get_all_records','PIF_metrics.get_all_records','PBD.get_all_records','VIF.get_all_records','VIF_metrics.get_all_records','VM_guest_metrics.get_all_records','VM_metrics.get_all_records','host_metrics.get_all_records','host_cpu.get_all_records','Bond.get_all_records','pool_patch.get_all_records','host_patch.get_all_records','console.get_all_records','host.get_all_records','pool.get_all_records','SR.get_all_records','message.get_all_records');
for (call_id in initCalls)ApiCall(initCalls[call_id],params,false,1,0,0,0); //TODO callback error
ApiCall('event.register',event_params,true,0,xen_callback_get_next_event,0,0); //TODO callback error and to make it sync after the xen_db structure is inicialized to call the event.register
param_pass();
return ;
}

function xen_callback_get_next_event(result,xmldoc,param_pass)
{
//this calls the next event function
var params=new Array();
params[0]=xen_db['session_id'];

ApiCall('event.next',params,true,1,xen_callback_get_next_event,0,0); //TODO callback error
}
     9.5 \ No newline at end of file
     9.6 +var xen_sync_calls_array;

function xen_callback_proceed_init(result,xmldoc,param_pass)
{
var params=new Array();
params[0]=xen_db['session_id'];
var params_pass=new Array();

var initCalls=new Array('VM.get_all_records','task.get_all_records','VBD.get_all_records','VBD_metrics.get_all_records','VDI.get_all_records','network.get_all_records','PIF.get_all_records','PIF_metrics.get_all_records','PBD.get_all_records','VIF.get_all_records','VIF_metrics.get_all_records','VM_guest_metrics.get_all_records','VM_metrics.get_all_records','host_metrics.get_all_records','host_cpu.get_all_records','Bond.get_all_records','pool_patch.get_all_records','host_patch.get_all_records','console.get_all_records','host.get_all_records','pool.get_all_records','SR.get_all_records','message.get_all_records');
xen_sync_calls_array=new Array('VM.get_all_records','task.get_all_records','VBD.get_all_records','VBD_metrics.get_all_records','VDI.get_all_records','network.get_all_records','PIF.get_all_records','PIF_metrics.get_all_records','PBD.get_all_records','VIF.get_all_records','VIF_metrics.get_all_records','VM_guest_metrics.get_all_records','VM_metrics.get_all_records','host_metrics.get_all_records','host_cpu.get_all_records','Bond.get_all_records','pool_patch.get_all_records','host_patch.get_all_records','console.get_all_records','host.get_all_records','pool.get_all_records','SR.get_all_records','message.get_all_records');
params_pass[0]=param_pass;

for (call_id in initCalls)
{
params_pass[1]=initCalls[call_id];
ApiCall(initCalls[call_id],params,false,1,xen_callback_sync_calls,xen_callback_sync_calls,params_pass); //TODO callback error
}

return ;
}

function xen_callback_get_next_event(result,xmldoc,param_pass)
{
//this calls the next event function
var params=new Array();
params[0]=xen_db['session_id'];

ApiCall('event.next',params,true,1,xen_callback_get_next_event,0,0); //TODO callback error
}

function xen_callback_sync_calls(result,xmldoc,param_pass)
{

for(var i in xen_sync_calls_array)
	{
	if(xen_sync_calls_array[i]==param_pass[1])xen_sync_calls_array.splice(i,1);
	}
	
if(!xen_sync_calls_array.length)
	{
	var event_params=new Array();
	event_params[0]=xen_db['session_id'];
	event_params[1]=new Array('*');
	ApiCall('event.register',event_params,true,0,xen_callback_get_next_event,0,0);
	if(typeof(param_pass[0])=='function')param_pass[0]();
	}
	
	
}
     9.7 \ No newline at end of file
    10.1 --- a/libxen/core.js	Mon Jul 19 03:31:59 2010 +0300
    10.2 +++ b/libxen/core.js	Sun Aug 01 14:29:29 2010 +0300
    10.3 @@ -45,11 +45,12 @@ var data=xmlRpc(method, params);
    10.4  return makeRequest(url,method,data,async,doupdate,callback,error_callback,param_pass);
    10.5  }
    10.6  
    10.7 -
    10.8 +/*
    10.9  function parse_xml_to_json(response)
   10.10  {
   10.11  	return response=response.substring(137,response.length - 68); // bad way to make it, but it will be that way for some time
   10.12  }
   10.13 +*/
   10.14  
   10.15  makeRequest=function(url,method,data,async,doupdate,callback,error_callback,param_pass) {
   10.16  rand=parseInt(Math.random()*99999999);
   10.17 @@ -82,6 +83,7 @@ url+='&'+rand;
   10.18  									{ //request error
   10.19  									//alert('error');
   10.20  									if(error_callback)error_callback(httpRequest.responseText,xmldoc,param_pass);
   10.21 +									else if(typeof(error_callback_default) == 'function')error_callback_default(httpRequest.responseText,xmldoc,param_pass);
   10.22  									return false;
   10.23  									}
   10.24  							}
    11.1 --- a/libxen/db_callbacks.js	Mon Jul 19 03:31:59 2010 +0300
    11.2 +++ b/libxen/db_callbacks.js	Sun Aug 01 14:29:29 2010 +0300
    11.3 @@ -1,1 +1,1 @@
    11.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') //TODO: some error happens when there are no result[i].class, because it may load before xen_db
			{
			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;
}
    11.5 \ No newline at end of file
    11.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('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;
}
    11.7 \ No newline at end of file
    12.1 --- a/libxen/libxen_host.js	Mon Jul 19 03:31:59 2010 +0300
    12.2 +++ b/libxen/libxen_host.js	Sun Aug 01 14:29:29 2010 +0300
    12.3 @@ -7,9 +7,17 @@ var vm_pool=new Array();
    12.4  
    12.5   for ( var host_id in xen_db['host'] )
    12.6   {
    12.7 -	vm_pool[host_id] = new Array();
    12.8 -	vm_pool[host_id]['name_label']=xen_db['host'][host_id]['name_label'];
    12.9 -	vm_pool[host_id]['name_description']=xen_db['host'][host_id]['name_description'];
   12.10 +	vm_pool[host_id] = xen_host_get_details(host_id);
   12.11 + }
   12.12 +
   12.13 + return vm_pool;
   12.14 +}
   12.15 +
   12.16 +function xen_host_get_details(host_id)
   12.17 +{
   12.18 +	vm_pool = new Array();
   12.19 +	vm_pool['name_label']=xen_db['host'][host_id]['name_label'];
   12.20 +	vm_pool['name_description']=xen_db['host'][host_id]['name_description'];
   12.21  	
   12.22  	//to get other things from the metrics 
   12.23  	//get the cpu_usage
   12.24 @@ -22,21 +30,38 @@ var vm_pool=new Array();
   12.25  			}
   12.26  		cpu_usage=cpu_usage/cpus;
   12.27  	
   12.28 -	vm_pool[host_id]['cpu_usage']=cpu_usage;
   12.29 +	vm_pool['cpu_usage']=cpu_usage;
   12.30  
   12.31 -	vm_pool[host_id]['memory_free']=Math.floor(parseInt(xen_db['host_metrics'][xen_db['host'][host_id]['metrics']]['memory_free']) / (1024*1024));
   12.32 -	vm_pool[host_id]['memory_total']=Math.floor(parseInt(xen_db['host_metrics'][xen_db['host'][host_id]['metrics']]['memory_total']) / (1024*1024));
   12.33 +	vm_pool['memory_free']=Math.floor(parseInt(xen_db['host_metrics'][xen_db['host'][host_id]['metrics']]['memory_free']) / (1024*1024));
   12.34 +	vm_pool['memory_total']=Math.floor(parseInt(xen_db['host_metrics'][xen_db['host'][host_id]['metrics']]['memory_total']) / (1024*1024));
   12.35  	
   12.36 -	vm_pool[host_id]['resident_VMs']=new Array();
   12.37 +	vm_pool['resident_VMs']=new Array();
   12.38  	for(var id in xen_db['host'][host_id]['resident_VMs'])
   12.39  	{
   12.40  	var vm_id=xen_db['host'][host_id]['resident_VMs'][id];
   12.41 -	if(!xen_db['VM'][vm_id]['is_a_template'] && !xen_db['VM'][vm_id]['is_control_domain'])vm_pool[host_id]['resident_VMs'].push(vm_id);
   12.42 +	if(!xen_db['VM'][vm_id]['is_a_template'] && !xen_db['VM'][vm_id]['is_control_domain'])vm_pool['resident_VMs'].push(vm_id);
   12.43  	}
   12.44  	
   12.45 - }
   12.46 +	return vm_pool;
   12.47 +}
   12.48 +
   12.49 +function xen_host_get_console(host_id)
   12.50 +{
   12.51 +var console_stuff = new Array(); 
   12.52 +var dom0 = 0;
   12.53  
   12.54 - return vm_pool;
   12.55 + for(var id in xen_db['host'][host_id]['resident_VMs'])
   12.56 +	{
   12.57 +	var vm_id=xen_db['host'][host_id]['resident_VMs'][id];
   12.58 +	if(xen_db['VM'][vm_id]['is_control_domain'])dom0=vm_id;
   12.59 +	}
   12.60 +
   12.61 + if(dom0)
   12.62 +	{	
   12.63 +	return xen_vm_get_console(dom0);
   12.64 +	}
   12.65 +	
   12.66 +return 0;
   12.67  }
   12.68  
   12.69  function xen_host_get_allowed_operations(ref)
    13.1 --- a/libxen/libxen_init.js	Mon Jul 19 03:31:59 2010 +0300
    13.2 +++ b/libxen/libxen_init.js	Sun Aug 01 14:29:29 2010 +0300
    13.3 @@ -12,3 +12,4 @@ loadjs(libxen_path+'/core.js');
    13.4  loadjs(libxen_path+'/libxen.js');
    13.5  loadjs(libxen_path+'/libxen_host.js');
    13.6  loadjs(libxen_path+'/libxen_vm.js');
    13.7 +loadjs(libxen_path+'/libxen_task.js');
    14.1 --- a/libxen/libxen_vm.js	Mon Jul 19 03:31:59 2010 +0300
    14.2 +++ b/libxen/libxen_vm.js	Sun Aug 01 14:29:29 2010 +0300
    14.3 @@ -1,21 +1,61 @@
    14.4  // functions to deal with VM part of the xen_db
    14.5  
    14.6 -function xen_get_vm_list_vm(vm_id)
    14.7 +function xen_get_vm_list_hosts()
    14.8 +{
    14.9 +
   14.10 +var vm_pool=new Array();
   14.11 +
   14.12 + for ( var host_id in xen_db['host'] )
   14.13 + {
   14.14 +	vm_pool[host_id] = xen_host_get_details(host_id);
   14.15 + }
   14.16 +
   14.17 + return vm_pool;
   14.18 +}
   14.19 +
   14.20 +function xen_get_vm_list_non_resident()
   14.21 +{
   14.22 +var vm_pool = new Array();
   14.23 +
   14.24 +	for ( var vm_id in xen_db['VM'] )
   14.25 +		{
   14.26 +		   if(typeof(xen_db['VM'][vm_id]['resident_on'])!='undefined')
   14.27 +		   {
   14.28 +		   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);
   14.29 +		   }
   14.30 +		}
   14.31 +
   14.32 +return vm_pool;
   14.33 +}
   14.34 +
   14.35 +function xen_vm_get_details(vm_id)
   14.36  {
   14.37  var vm_pool = new Array();
   14.38  	
   14.39  	vm_pool['name_label']=xen_db['VM'][vm_id]['name_label'];
   14.40  	vm_pool['name_description']=xen_db['VM'][vm_id]['name_description'];
   14.41 -	if(vm_pool['name_description']=='' && typeof(xen_db['VM_guest_metrics'][xen_db['VM'][vm_id]['guest_metrics']])!='undefined')vm_pool['name_description']=xen_db['VM_guest_metrics'][xen_db['VM'][vm_id]['guest_metrics']]['os_version']['name'];
   14.42 +	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){}
   14.43  	
   14.44  	vm_pool['memory_total']=Math.floor(parseInt(xen_db['VM'][vm_id]['memory_target']) / (1024*1024));
   14.45  	vm_pool['power_state']=xen_db['VM'][vm_id]['power_state'];
   14.46  	vm_pool['vm_cpus_count']=xen_db['VM'][vm_id]['VCPUs_max'];
   14.47 -	vm_pool['vm_cpus_weight']='';// TODO
   14.48 +	vm_pool['vm_cpus_weight']='';// TODO 
   14.49  	vm_pool['vm_cpus_cap']='';// TODO
   14.50  return vm_pool;
   14.51  }
   14.52  
   14.53 +function xen_vm_get_console(vm_id)
   14.54 +{
   14.55 +var console_stuff = new Array(); 
   14.56 +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' )
   14.57 +{
   14.58 +console_stuff['location']=xen_db['console'][xen_db['VM'][vm_id]['consoles'][0]]['location'];
   14.59 +console_stuff['session_id']=xen_db['session_id'];
   14.60 +return console_stuff;
   14.61 +}
   14.62 +return 0;
   14.63 +}
   14.64 +
   14.65  function xen_vm_get_allowed_operations(ref)
   14.66  {
   14.67  return xen_db['VM'][ref]['allowed_operations'];
   14.68 @@ -121,6 +161,8 @@ var params=new Array();
   14.69  params[0]=xen_db['session_id'];
   14.70  params[1]=vm_ref;
   14.71  params[2]=host_ref;
   14.72 +params[3]=false;
   14.73 +params[4]=true;
   14.74  ApiCall('VM.start_on',params,true,0,0,0,0);
   14.75  return ;
   14.76  }
   14.77 @@ -131,6 +173,8 @@ var params=new Array();
   14.78  params[0]=xen_db['session_id'];
   14.79  params[1]=vm_ref;
   14.80  params[2]=host_ref;
   14.81 +params[3]=false;
   14.82 +params[4]=true;
   14.83  ApiCall('VM.resume_on',params,true,0,0,0,0);
   14.84  return ;
   14.85  }
   14.86 @@ -144,3 +188,5 @@ params[2]=host_ref;
   14.87  ApiCall('VM.pool_migrate',params,true,0,0,0,0);
   14.88  return ;
   14.89  }
   14.90 +
   14.91 +