[pve-devel] [PATCH v3 manager 2/3] added new parameter to pass a command to the newly opened terminal

Tim Marx t.marx at proxmox.com
Wed Jan 23 09:44:27 CET 2019


> Dominik Csapak <d.csapak at proxmox.com> hat am 22. Januar 2019 um 14:19 geschrieben:
> 
> 
> hi, looks good, one nitpick inline
> 
> On 1/22/19 12:22 PM, Tim Marx wrote:
> > Signed-off-by: Tim Marx <t.marx at proxmox.com>
> > ---
> >   www/manager6/Utils.js                | 21 +++++++++++++--------
> >   www/manager6/button/ConsoleButton.js | 12 +++++++-----
> >   2 files changed, 20 insertions(+), 13 deletions(-)
> > 
> > diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
> > index a190a7ab..39f9a402 100644
> > --- a/www/manager6/Utils.js
> > +++ b/www/manager6/Utils.js
> > @@ -817,12 +817,12 @@ Ext.define('PVE.Utils', { utilities: {
> >               function(m, addr, offset, original) { return addr; });
> >       },
> >   
> > -    openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname) {
> > +    openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname, cmd) {
> >   	var dv = PVE.Utils.defaultViewer(consoles);
> > -	PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname);
> > +	PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname, cmd);
> >       },
> >   
> > -    openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname) {
> > +    openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname, cmd) {
> >   	// kvm, lxc, shell, upgrade
> >   
> >   	if (vmid == undefined && (vmtype === 'kvm' || vmtype === 'lxc')) {
> > @@ -834,9 +834,9 @@ Ext.define('PVE.Utils', { utilities: {
> >   	}
> >   
> >   	if (viewer === 'html5') {
> > -	    PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname);
> > +	    PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, cmd);
> >   	} else if (viewer === 'xtermjs') {
> > -	    Proxmox.Utils.openXtermJsViewer(vmtype, vmid, nodename, vmname);
> > +	    Proxmox.Utils.openXtermJsViewer(vmtype, vmid, nodename, vmname, cmd);
> >   	} else if (viewer === 'vv') {
> >   	    var url;
> >   	    var params = { proxy: PVE.Utils.windowHostname() };
> > @@ -853,6 +853,10 @@ Ext.define('PVE.Utils', { utilities: {
> >   		url = '/nodes/' + nodename + '/spiceshell';
> >   		params.upgrade = 1;
> >   		PVE.Utils.openSpiceViewer(url, params);
> > +	    } else if (vmtype === 'cmd') {
> > +		url = '/nodes/' + nodename + '/spiceshell';
> > +		params.cmd = cmd;
> > +		PVE.Utils.openSpiceViewer(url, params);
> >   	    }
> >   	} else {
> >   	    throw "unknown viewer type";
> > @@ -879,14 +883,15 @@ Ext.define('PVE.Utils', { utilities: {
> >   	return dv;
> >       },
> >   
> > -    openVNCViewer: function(vmtype, vmid, nodename, vmname) {
> > -	var url = Ext.urlEncode({
> > +    openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) {
> > +	var url = Ext.Object.toQueryString({
> 
> it is very ok to replace deprecated Extjs calls, but i
> would have liked a note in the commit message,
> otherwise readers (like me) try to infer why this changed
> seemingly without reason
> 

Will add a comment in a v4 along with the missing general error check. Thanks for looking at it.

> >   	    console: vmtype, // kvm, lxc, upgrade or shell
> >   	    novnc: 1,
> >   	    vmid: vmid,
> >   	    vmname: vmname,
> >   	    node: nodename,
> > -	    resize: 'off'
> > +	    resize: 'off',
> > +	    cmd: cmd
> >   	});
> >   	var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
> >   	nw.focus();
> > diff --git a/www/manager6/button/ConsoleButton.js b/www/manager6/button/ConsoleButton.js
> > index d825e1fb..0451bf59 100644
> > --- a/www/manager6/button/ConsoleButton.js
> > +++ b/www/manager6/button/ConsoleButton.js
> > @@ -2,7 +2,9 @@ Ext.define('PVE.button.ConsoleButton', {
> >       extend: 'Ext.button.Split',
> >       alias: 'widget.pveConsoleButton',
> >   
> > -    consoleType: 'shell', // one of 'shell', 'kvm', 'lxc', 'upgrade'
> > +    consoleType: 'shell', // one of 'shell', 'kvm', 'lxc', 'upgrade', 'cmd'
> > +
> > +    cmd: undefined,
> >   
> >       consoleName: undefined,
> >   
> > @@ -38,7 +40,7 @@ Ext.define('PVE.button.ConsoleButton', {
> >   	    xtermjs: me.enableXtermjs
> >   	};
> >   	PVE.Utils.openDefaultConsoleWindow(consoles, me.consoleType, me.vmid,
> > -					   me.nodename, me.consoleName);
> > +					   me.nodename, me.consoleName, me.cmd);
> >       },
> >   
> >       menu: [
> > @@ -49,7 +51,7 @@ Ext.define('PVE.button.ConsoleButton', {
> >   	    type: 'html5',
> >   	    handler: function(button) {
> >   		var me = this.up('button');
> > -		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName);
> > +		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName, me.cmd);
> >   	    }
> >   	},
> >   	{
> > @@ -60,7 +62,7 @@ Ext.define('PVE.button.ConsoleButton', {
> >   	    iconCls: 'pve-itype-icon-virt-viewer',
> >   	    handler: function(button) {
> >   		var me = this.up('button');
> > -		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName);
> > +		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName, me.cmd);
> >   	    }
> >   	},
> >   	{
> > @@ -70,7 +72,7 @@ Ext.define('PVE.button.ConsoleButton', {
> >   	    type: 'xtermjs',
> >   	    handler: function(button) {
> >   		var me = this.up('button');
> > -		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName);
> > +		PVE.Utils.openConsoleWindow(button.type, me.consoleType, me.vmid, me.nodename, me.consoleName, me.cmd);
> >   	    }
> >   	}
> >       ],
> > 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list