[pve-devel] [PATCH pve-manager] replace OpenVZ API calls in mobile UI with LXC

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Sep 17 13:05:50 CEST 2015


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/mobile/LXCSummary.js    | 216 ++++++++++++++++++++++++++++++++++++++++++++
 www/mobile/Makefile         |   2 +-
 www/mobile/Migrate.js       |   8 +-
 www/mobile/NodeSummary.js   |   6 +-
 www/mobile/OpenVzSummary.js | 209 ------------------------------------------
 www/mobile/Workspace.js     |   4 +-
 6 files changed, 226 insertions(+), 219 deletions(-)
 create mode 100644 www/mobile/LXCSummary.js
 delete mode 100644 www/mobile/OpenVzSummary.js

diff --git a/www/mobile/LXCSummary.js b/www/mobile/LXCSummary.js
new file mode 100644
index 0000000..d423249
--- /dev/null
+++ b/www/mobile/LXCSummary.js
@@ -0,0 +1,216 @@
+Ext.define('PVE.LXCSummary', {
+    extend: 'PVE.Page',
+    alias: 'widget.pveLXCSummary',
+
+    statics: {
+	pathMatch: function(loc) {
+	    return loc.match(/^nodes\/([^\s\/]+)\/lxc\/(\d+)$/);
+	}
+    },
+
+    nodename: undefined,
+    vmid: undefined,
+
+    vm_command: function(cmd, params) {
+	var me = this;
+
+	PVE.Utils.API2Request({
+	    params: params,
+	    url: '/nodes/' + me.nodename + '/lxc/' + me.vmid + '/status/' + cmd,
+	    method: 'POST',
+	    success: function(response, opts) {
+		var upid = response.result.data;
+		var page = 'nodes/'  + me.nodename + '/tasks/' + upid;
+		PVE.Workspace.gotoPage(page);
+	    },
+	    failure: function(response, opts) {
+		Ext.Msg.alert('Error', response.htmlStatus);
+	    }
+	});
+    },
+
+    config: {
+	items: [
+	    {
+		xtype: 'titlebar',
+		docked: 'top',
+		items: [
+		    {
+			xtype: 'button',
+			align: 'right',
+			iconCls: 'refresh',
+			handler: function() {
+			    this.up('pvePage').reload();
+			}
+		    },
+		    {
+			xtype: 'pveMenuButton',
+			align: 'right',
+			pveStdMenu: true
+		    }
+		]
+	    },
+	    {
+		xtype: 'component',
+		itemId: 'ctstatus',
+		styleHtmlContent: true,
+		style: 'background-color:white;',
+		tpl: [
+		    '<table style="margin-bottom:0px;">',
+
+		    '<tr><td>Status:</td><td>{status}</td></tr>',
+		    '<tr><td>Memory:</td><td>{[this.meminfo(values)]}</td></tr>',
+		    '<tr><td>CPU:</td><td>{[this.cpuinfo(values)]}</td></tr>',
+		    '<tr><td>Uptime:</td><td>{[PVE.Utils.format_duration_long'+
+		    '(values.uptime)]}</td></tr>',
+
+		    '</table>',
+		    {
+			meminfo: function(values) {
+			    if (!Ext.isDefined(values.mem)) {
+				return '-';
+			    }
+			    return PVE.Utils.format_size(values.mem || 0) + " of " +
+				PVE.Utils.format_size(values.maxmem);
+			},
+			cpuinfo: function(values) {
+			    if (!Ext.isDefined(values.cpu)) {
+				return '-';
+			    }
+			    var per = values.cpu * 100;
+			    return per.toFixed(2) + "% (" + values.cpus + " CPUs)";
+			}
+		    }
+		]
+	    },
+	    {
+		xtype: 'component',
+		padding: 5,
+		html: gettext('Configuration')
+	    },
+	    {
+		xtype: 'container',
+		scrollable: 'both',
+		flex: 1,
+		styleHtmlContent: true,
+		itemId: 'ctconfig',
+		style: 'background-color:white;white-space:pre;',
+		tpl: [
+		    '<table style="margin-bottom:0px;">',
+		    '<tpl for=".">',
+		    '<tr><td>{key}</td><td>{value}</td></tr>',
+		    '</tpl>',
+		    '</table>'
+		]
+	    }
+	]
+    },
+
+    reload: function() {
+	var me = this;
+
+	var cti = me.down('#ctstatus');
+
+	var error_handler = function(response) {
+	    me.setMasked({ xtype: 'loadmask', message: response.htmlStatus} );
+	};
+
+	PVE.Utils.API2Request({
+	    url: '/nodes/' + me.nodename + '/lxc/' + me.vmid + '/status/current',
+	    method: 'GET',
+	    success: function(response) {
+		var d = response.result.data;
+		cti.setData(d);
+	    },
+	    failure: error_handler
+	});
+
+	var ctc = me.down('#ctconfig');
+
+	PVE.Utils.API2Request({
+	    url: '/nodes/' + me.nodename + '/lxc/' + me.vmid + '/config',
+	    method: 'GET',
+	    success: function(response) {
+		var d = response.result.data;
+		var names = ['hostname', 'memory', 'swap', 'cpus', 'ostemplate',
+			     'ip_address', 'nameserver', 'searchdomain',
+			     'netif'];
+		var kv = PVE.Workspace.obj_to_kv(d, names);
+		ctc.setData(kv);
+	    },
+	    failure: error_handler
+	});
+    },
+
+    initialize: function() {
+	var me = this;
+
+	var match = me.self.pathMatch(me.getAppUrl());
+	if (!match) {
+	    throw "pathMatch failed";
+	}
+
+	me.nodename = match[1];
+	me.vmid = match[2];
+
+	me.down('titlebar').setTitle('CT: ' + me.vmid);
+
+	me.down('pveMenuButton').setMenuItems([
+	    {
+		text: gettext('Start'),
+		handler: function() {
+		    me.vm_command("start", {});
+		}
+	    },
+	    {
+		text: gettext('Suspend'),
+		handler: function() {
+		    me.vm_command("suspend", {});
+		}
+	    },
+	    {
+		text: gettext('Resume'),
+		handler: function() {
+		    me.vm_command("resume", {});
+		}
+	    },
+	    {
+		text: gettext('Shutdown'),
+		handler: function() {
+		    me.vm_command("shutdown", {});
+		}
+	    },
+	    {
+		text: gettext('Stop'),
+		handler: function() {
+		    me.vm_command("stop", {});
+		}
+	    },
+	    {
+		text: gettext('Migrate'),
+		handler: function() {
+		    PVE.Workspace.gotoPage('nodes/' + me.nodename + '/lxc/'
+					   + me.vmid + '/migrate');
+		}
+	    },
+	    {
+		text: gettext('Console'),
+		handler: function() {
+		    PVE.Utils.openConsoleWindow('html5', 'lxc', me.vmid,
+					      me.nodename);
+		}
+	    },
+	    {
+		text: gettext('Spice'),
+		handler: function() {
+		    PVE.Utils.openConsoleWindow('vv', 'lxc', me.vmid,
+						me.nodename);
+		}
+	    }
+	]);
+
+	me.reload();
+
+	this.callParent();
+    }
+});
diff --git a/www/mobile/Makefile b/www/mobile/Makefile
index 076de00..4d44259 100644
--- a/www/mobile/Makefile
+++ b/www/mobile/Makefile
@@ -18,7 +18,7 @@ JSSRC= 				                 	\
 	NodeSummary.js					\
 	Migrate.js					\
 	QemuSummary.js					\
-	OpenVzSummary.js				\
+	LXCSummary.js				\
 	app.js
 
 all: pvemanager-mobile.js
diff --git a/www/mobile/Migrate.js b/www/mobile/Migrate.js
index 48a75b5..46eddaf 100644
--- a/www/mobile/Migrate.js
+++ b/www/mobile/Migrate.js
@@ -3,7 +3,7 @@ Ext.define('PVE.MigrateBase', {
 
     nodename: undefined,
     vmid: undefined,
-    vmtype: undefined, // qemu or openvz
+    vmtype: undefined, // qemu or lxc
 
     config: {
 	items: [
@@ -110,14 +110,14 @@ Ext.define('PVE.QemuMigrate', {
     }
 });
 
-Ext.define('PVE.OpenVzMigrate', {
+Ext.define('PVE.LXCMigrate', {
     extend: 'PVE.MigrateBase',
 
-    vmtype: 'openvz',
+    vmtype: 'lxc',
 
     statics: {
 	pathMatch: function(loc) {
-	    return loc.match(/^nodes\/([^\s\/]+)\/openvz\/(\d+)\/migrate$/);
+	    return loc.match(/^nodes\/([^\s\/]+)\/lxc\/(\d+)\/migrate$/);
 	}
     },
 
diff --git a/www/mobile/NodeSummary.js b/www/mobile/NodeSummary.js
index 34f5722..34703c9 100644
--- a/www/mobile/NodeSummary.js
+++ b/www/mobile/NodeSummary.js
@@ -141,14 +141,14 @@ Ext.define('PVE.NodeSummary', {
 	};
 
 	PVE.Utils.API2Request({
-	    url: '/nodes/' + me.nodename + '/openvz',
+	    url: '/nodes/' + me.nodename + '/lxc',
 	    method: 'GET',
 	    success: function(response) {
 		var d = response.result.data;
 		d.nodename = me.nodename;
-		d.forEach(function(el) { el.type = 'openvz'; el.nodename = me.nodename });
+		d.forEach(function(el) { el.type = 'lxc'; el.nodename = me.nodename });
 		me.store.each(function(rec) {
-		    if (rec.get('type') === 'openvz') {
+		    if (rec.get('type') === 'lxc') {
 			rec.destroy();
 		    }
 		});
diff --git a/www/mobile/OpenVzSummary.js b/www/mobile/OpenVzSummary.js
deleted file mode 100644
index 6450bca..0000000
--- a/www/mobile/OpenVzSummary.js
+++ /dev/null
@@ -1,209 +0,0 @@
-Ext.define('PVE.OpenVzSummary', {
-    extend: 'PVE.Page',
-    alias: 'widget.pveOpenVzSummary',
-
-    statics: {
-	pathMatch: function(loc) {
-	    return loc.match(/^nodes\/([^\s\/]+)\/openvz\/(\d+)$/);
-	}
-    },
-
-    nodename: undefined,
-    vmid: undefined,
-
-    vm_command: function(cmd, params) {
-	var me = this;
-
-	PVE.Utils.API2Request({
-	    params: params,
-	    url: '/nodes/' + me.nodename + '/openvz/' + me.vmid + '/status/' + cmd,
-	    method: 'POST',
-	    success: function(response, opts) {
-		var upid = response.result.data;
-		var page = 'nodes/'  + me.nodename + '/tasks/' + upid;
-		PVE.Workspace.gotoPage(page);
-	    },
-	    failure: function(response, opts) {
-		Ext.Msg.alert('Error', response.htmlStatus);
-	    }
-	});
-    },
-
-    config: {
-	items: [
-	    { 
-		xtype: 'titlebar',
-		docked: 'top',
-		items: [
-		    { 
-			xtype: 'button',
-			align: 'right',
-			iconCls: 'refresh',
-			handler: function() {
-			    this.up('pvePage').reload();
-			}
-		    },
-		    {
-			xtype: 'pveMenuButton',
-			align: 'right',
-			pveStdMenu: true,
-		    }
-		]
-	    },
-	    {
-		xtype: 'component',
-		itemId: 'ctstatus',
-		styleHtmlContent: true,
-		style: 'background-color:white;',
-		tpl: [
-		    '<table style="margin-bottom:0px;">',
-		    '<tr><td>Status:</td><td>{status}</td></tr>',
-		    '<tr><td>Memory:</td><td>{[this.meminfo(values)]}</td></tr>',
-		    '<tr><td>CPU:</td><td>{[this.cpuinfo(values)]}</td></tr>',
-		    '<tr><td>Uptime:</td><td>{[PVE.Utils.format_duration_long(values.uptime)]}</td></tr>',
-		    '</table>',
-		    {
-			meminfo: function(values) {
-			    if (!Ext.isDefined(values.mem)) {
-				return '-';
-			    }
-			    return PVE.Utils.format_size(values.mem || 0) + " of " + 
-				PVE.Utils.format_size(values.maxmem);
-			},
-			cpuinfo: function(values) {
-			    if (!Ext.isDefined(values.cpu)) {
-				return '-';
-			    }
-			    var per = values.cpu * 100;
-			    return per.toFixed(2) + "% (" + values.cpus + " CPUs)";
-			}
-		    }
-		]
-	    },
-	    {
-		xtype: 'component',
-		padding: 5,
-		html: gettext('Configuration')
-	    },
-	    {
-                xtype: 'container',
-		scrollable: 'both',
-		flex: 1,
-		styleHtmlContent: true,
-		itemId: 'ctconfig',
-		style: 'background-color:white;white-space:pre;',
-		tpl: [
-		    '<table style="margin-bottom:0px;">',
-		    '<tpl for=".">',
-		    '<tr><td>{key}</td><td>{value}</td></tr>',
-		    '</tpl>',
-		    '</table>'
-		]
-	    }
-   	]
-    },
-
-    reload: function() {
- 	var me = this;
-
-	var cti = me.down('#ctstatus');
-
-	var error_handler = function(response) {
-	    me.setMasked({ xtype: 'loadmask', message: response.htmlStatus} );
-	};
-
-	PVE.Utils.API2Request({
-	    url: '/nodes/' + me.nodename + '/openvz/' + me.vmid + '/status/current',
-	    method: 'GET',
-	    success: function(response) {
-		var d = response.result.data;
-		cti.setData(d);
-	    },
-	    failure: error_handler
-	});
-
-	var ctc = me.down('#ctconfig');
-
-	PVE.Utils.API2Request({
-	    url: '/nodes/' + me.nodename + '/openvz/' + me.vmid + '/config',
-	    method: 'GET',
-	    success: function(response) {
-		var d = response.result.data;
-		var names = ['hostname', 'memory', 'swap', 'cpus', 'ostemplate',
-			     'ip_address', 'nameserver', 'searchdomain', 'netif'];
-		var kv = PVE.Workspace.obj_to_kv(d, names);
-		ctc.setData(kv);
-	    },
-	    failure: error_handler
-	});
-    },
-
-    initialize: function() {
-	var me = this;
-
-	var match = me.self.pathMatch(me.getAppUrl());
-	if (!match) {
-	    throw "pathMatch failed";
-	}
-
-	me.nodename = match[1];
-	me.vmid = match[2];
-
-	me.down('titlebar').setTitle('CT: ' + me.vmid);
-
-	me.down('pveMenuButton').setMenuItems([
-	    {
-		text: gettext('Start'),
-		handler: function() {
-		    me.vm_command("start", {});
-		}
-	    },
-	    { 
-		text: gettext('Suspend'),
-		handler: function() {
-		    me.vm_command("suspend", {});
-		}
-	    },
-	    { 
-		text: gettext('Resume'),
-		handler: function() {
-		    me.vm_command("resume", {});
-		}
-	    },
-	    { 
-		text: gettext('Shutdown'),
-		handler: function() {
-		    me.vm_command("shutdown", {});
-		}
-	    },
-	    { 
-		text: gettext('Stop'),
-		handler: function() {
-		    me.vm_command("stop", {});
-		}
-	    },
-	    { 
-		text: gettext('Migrate'),
-		handler: function() {
-		    PVE.Workspace.gotoPage('nodes/' + me.nodename + '/openvz/' + me.vmid + '/migrate'); 
-		}
-	    },
-	    { 
-		text: gettext('Console'),
-		handler: function() {
-		    PVE.Utils.openConsoleWindow('html5', 'openvz', me.vmid, me.nodename);
-		}
-	    },
-	    { 
-		text: gettext('Spice'),
-		handler: function() {
-		    PVE.Utils.openConsoleWindow('vv', 'openvz', me.vmid, me.nodename);
-		}
-	    }
-	]);
-
-	me.reload();
-
-	this.callParent();
-    }
-});
diff --git a/www/mobile/Workspace.js b/www/mobile/Workspace.js
index 2b9cfc7..63c7589 100644
--- a/www/mobile/Workspace.js
+++ b/www/mobile/Workspace.js
@@ -52,8 +52,8 @@ Ext.define('PVE.Workspace', { statics: {
     history: null,
 
     pages: [ 
-	'PVE.OpenVzMigrate',
-	'PVE.OpenVzSummary',
+	'PVE.LXCMigrate',
+	'PVE.LXCSummary',
 	'PVE.QemuMigrate',
 	'PVE.QemuSummary',
 	'PVE.NodeSummary', 
-- 
2.1.4



More information about the pve-devel mailing list