2016-03-16 09:12:22 +01:00
Ext . define ( 'PVE.qemu.Options' , {
2017-12-06 18:02:00 +01:00
extend : 'Proxmox.grid.PendingObjectGrid' ,
2016-03-16 09:12:22 +01:00
alias : [ 'widget.PVE.qemu.Options' ] ,
2016-11-02 16:57:10 +01:00
onlineHelp : 'qm_options' ,
2021-01-19 17:39:15 +01:00
initComponent : function ( ) {
2016-03-16 09:12:22 +01:00
var me = this ;
var nodename = me . pveSelNode . data . node ;
if ( ! nodename ) {
throw "no node name specified" ;
}
var vmid = me . pveSelNode . data . vmid ;
if ( ! vmid ) {
throw "no VM ID specified" ;
}
var caps = Ext . state . Manager . get ( 'GuiCap' ) ;
var rows = {
name : {
required : true ,
defaultValue : me . pveSelNode . data . name ,
header : gettext ( 'Name' ) ,
editor : caps . vms [ 'VM.Config.Options' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'Name' ) ,
items : {
2016-07-05 17:06:54 +02:00
xtype : 'inputpanel' ,
2021-01-19 17:39:15 +01:00
items : {
2016-07-05 17:06:54 +02:00
xtype : 'textfield' ,
name : 'name' ,
vtype : 'DnsName' ,
value : '' ,
fieldLabel : gettext ( 'Name' ) ,
2021-01-19 17:31:03 +01:00
allowBlank : true ,
2016-07-05 17:06:54 +02:00
} ,
onGetValues : function ( values ) {
var params = values ;
if ( values . name === undefined ||
values . name === null ||
values . name === '' ) {
2021-01-19 17:39:15 +01:00
params = { 'delete' : 'name' } ;
2016-07-05 17:06:54 +02:00
}
return params ;
2021-01-19 17:31:03 +01:00
} ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
onboot : {
header : gettext ( 'Start at boot' ) ,
defaultValue : '' ,
2018-01-15 15:18:09 +01:00
renderer : Proxmox . Utils . format _boolean ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.Config.Options' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'Start at boot' ) ,
items : {
2017-12-05 14:06:40 +01:00
xtype : 'proxmoxcheckbox' ,
2016-03-16 09:12:22 +01:00
name : 'onboot' ,
uncheckedValue : 0 ,
defaultValue : 0 ,
deleteDefaultValue : true ,
2021-01-19 17:31:03 +01:00
fieldLabel : gettext ( 'Start at boot' ) ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
startup : {
header : gettext ( 'Start/Shutdown order' ) ,
defaultValue : '' ,
renderer : PVE . Utils . render _kvm _startup ,
2021-01-19 17:39:15 +01:00
editor : caps . vms [ 'VM.Config.Options' ] && caps . nodes [ 'Sys.Modify' ]
? {
2016-12-05 14:48:06 +01:00
xtype : 'pveWindowStartupEdit' ,
2021-01-19 17:31:03 +01:00
onlineHelp : 'qm_startup_and_shutdown' ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
ostype : {
header : gettext ( 'OS Type' ) ,
editor : caps . vms [ 'VM.Config.Options' ] ? 'PVE.qemu.OSTypeEdit' : undefined ,
renderer : PVE . Utils . render _kvm _ostype ,
2021-01-19 17:31:03 +01:00
defaultValue : 'other' ,
2016-03-16 09:12:22 +01:00
} ,
bootdisk : {
2021-01-19 17:31:03 +01:00
visible : false ,
2016-03-16 09:12:22 +01:00
} ,
boot : {
2017-01-18 09:46:03 +01:00
header : gettext ( 'Boot Order' ) ,
2016-03-16 09:12:22 +01:00
defaultValue : 'cdn' ,
editor : caps . vms [ 'VM.Config.Disk' ] ? 'PVE.qemu.BootOrderEdit' : undefined ,
2016-04-26 14:41:57 +02:00
multiKey : [ 'boot' , 'bootdisk' ] ,
2016-03-16 09:12:22 +01:00
renderer : function ( order , metaData , record , rowIndex , colIndex , store , pending ) {
2020-10-06 15:32:18 +02:00
if ( /^\s*$/ . test ( order ) ) {
return gettext ( '(No boot device selected)' ) ;
}
let boot = PVE . Parser . parsePropertyString ( order , "legacy" ) ;
if ( boot . order ) {
let list = boot . order . split ( ';' ) ;
let ret = '' ;
list . forEach ( dev => {
if ( ret ) {
ret += ', ' ;
}
ret += dev ;
} ) ;
return ret ;
}
// legacy style and fallback
2021-05-18 14:12:14 +02:00
let i ;
2016-03-16 09:12:22 +01:00
var text = '' ;
var bootdisk = me . getObjectValue ( 'bootdisk' , undefined , pending ) ;
2020-10-06 15:32:18 +02:00
order = boot . legacy || 'cdn' ;
2016-03-16 09:12:22 +01:00
for ( i = 0 ; i < order . length ; i ++ ) {
if ( text ) {
text += ', ' ;
}
2020-10-06 15:32:18 +02:00
var sel = order . substring ( i , i + 1 ) ;
2016-03-16 09:12:22 +01:00
if ( sel === 'c' ) {
if ( bootdisk ) {
2020-10-06 15:32:18 +02:00
text += bootdisk ;
2016-03-16 09:12:22 +01:00
} else {
2022-09-28 09:54:52 +02:00
text += gettext ( 'first disk' ) ;
2016-03-16 09:12:22 +01:00
}
} else if ( sel === 'n' ) {
2020-10-06 15:32:18 +02:00
text += gettext ( 'any net' ) ;
2016-03-16 09:12:22 +01:00
} else if ( sel === 'a' ) {
2020-10-06 15:32:18 +02:00
text += gettext ( 'Floppy' ) ;
2016-03-16 09:12:22 +01:00
} else if ( sel === 'd' ) {
2020-10-06 15:32:18 +02:00
text += gettext ( 'any CD-ROM' ) ;
2016-03-16 09:12:22 +01:00
} else {
text += sel ;
}
}
return text ;
2021-01-19 17:31:03 +01:00
} ,
2016-03-16 09:12:22 +01:00
} ,
tablet : {
header : gettext ( 'Use tablet for pointer' ) ,
defaultValue : true ,
2018-01-15 15:18:09 +01:00
renderer : Proxmox . Utils . format _boolean ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.Config.HWType' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'Use tablet for pointer' ) ,
items : {
2017-12-05 14:06:40 +01:00
xtype : 'proxmoxcheckbox' ,
2016-03-16 09:12:22 +01:00
name : 'tablet' ,
checked : true ,
uncheckedValue : 0 ,
defaultValue : 1 ,
deleteDefaultValue : true ,
2021-01-19 17:31:03 +01:00
fieldLabel : gettext ( 'Enabled' ) ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
hotplug : {
header : gettext ( 'Hotplug' ) ,
defaultValue : 'disk,network,usb' ,
2021-01-19 17:39:15 +01:00
renderer : PVE . Utils . render _hotplug _features ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.Config.HWType' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'Hotplug' ) ,
items : {
xtype : 'pveHotplugFeatureSelector' ,
name : 'hotplug' ,
value : '' ,
multiSelect : true ,
fieldLabel : gettext ( 'Hotplug' ) ,
2021-01-19 17:31:03 +01:00
allowBlank : true ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
acpi : {
header : gettext ( 'ACPI support' ) ,
defaultValue : true ,
2018-01-15 15:18:09 +01:00
renderer : Proxmox . Utils . format _boolean ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.Config.HWType' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'ACPI support' ) ,
items : {
2017-12-05 14:06:40 +01:00
xtype : 'proxmoxcheckbox' ,
2016-03-16 09:12:22 +01:00
name : 'acpi' ,
checked : true ,
uncheckedValue : 0 ,
defaultValue : 1 ,
deleteDefaultValue : true ,
2021-01-19 17:31:03 +01:00
fieldLabel : gettext ( 'Enabled' ) ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
kvm : {
header : gettext ( 'KVM hardware virtualization' ) ,
defaultValue : true ,
2018-01-15 15:18:09 +01:00
renderer : Proxmox . Utils . format _boolean ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.Config.HWType' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'KVM hardware virtualization' ) ,
items : {
2017-12-05 14:06:40 +01:00
xtype : 'proxmoxcheckbox' ,
2016-03-16 09:12:22 +01:00
name : 'kvm' ,
checked : true ,
uncheckedValue : 0 ,
defaultValue : 1 ,
deleteDefaultValue : true ,
2021-01-19 17:31:03 +01:00
fieldLabel : gettext ( 'Enabled' ) ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
freeze : {
header : gettext ( 'Freeze CPU at startup' ) ,
defaultValue : false ,
2018-01-15 15:18:09 +01:00
renderer : Proxmox . Utils . format _boolean ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.PowerMgmt' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'Freeze CPU at startup' ) ,
items : {
2017-12-05 14:06:40 +01:00
xtype : 'proxmoxcheckbox' ,
2016-03-16 09:12:22 +01:00
name : 'freeze' ,
uncheckedValue : 0 ,
defaultValue : 0 ,
deleteDefaultValue : true ,
labelWidth : 140 ,
2021-01-19 17:31:03 +01:00
fieldLabel : gettext ( 'Freeze CPU at startup' ) ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
localtime : {
header : gettext ( 'Use local time for RTC' ) ,
2020-05-19 10:12:19 +02:00
defaultValue : '__default__' ,
renderer : PVE . Utils . render _localtime ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.Config.Options' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'Use local time for RTC' ) ,
2020-05-26 19:12:57 +02:00
width : 400 ,
2016-03-16 09:12:22 +01:00
items : {
2020-05-19 10:12:19 +02:00
xtype : 'proxmoxKVComboBox' ,
2016-03-16 09:12:22 +01:00
name : 'localtime' ,
2020-05-19 10:12:19 +02:00
value : '__default__' ,
comboItems : [
[ '__default__' , PVE . Utils . render _localtime ( '__default__' ) ] ,
[ 1 , PVE . Utils . render _localtime ( 1 ) ] ,
[ 0 , PVE . Utils . render _localtime ( 0 ) ] ,
] ,
2016-03-16 09:12:22 +01:00
labelWidth : 140 ,
2021-01-19 17:31:03 +01:00
fieldLabel : gettext ( 'Use local time for RTC' ) ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
startdate : {
header : gettext ( 'RTC start date' ) ,
defaultValue : 'now' ,
editor : caps . vms [ 'VM.Config.Options' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'RTC start date' ) ,
items : {
2018-01-15 15:17:51 +01:00
xtype : 'proxmoxtextfield' ,
2016-03-16 09:12:22 +01:00
name : 'startdate' ,
deleteEmpty : true ,
value : 'now' ,
fieldLabel : gettext ( 'RTC start date' ) ,
vtype : 'QemuStartDate' ,
2021-01-19 17:31:03 +01:00
allowBlank : true ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
smbios1 : {
header : gettext ( 'SMBIOS settings (type1)' ) ,
defaultValue : '' ,
renderer : Ext . String . htmlEncode ,
2021-01-19 17:31:03 +01:00
editor : caps . vms [ 'VM.Config.HWType' ] ? 'PVE.qemu.Smbios1Edit' : undefined ,
2016-03-16 09:12:22 +01:00
} ,
agent : {
2019-10-10 11:53:36 +02:00
header : 'QEMU Guest Agent' ,
2016-03-16 09:12:22 +01:00
defaultValue : false ,
2018-08-01 20:29:07 +02:00
renderer : PVE . Utils . render _qga _features ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.Config.Options' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-03-16 09:12:22 +01:00
subject : gettext ( 'Qemu Agent' ) ,
2019-10-10 11:53:36 +02:00
width : 350 ,
2021-01-25 15:54:10 +01:00
onlineHelp : 'qm_qemu_agent' ,
2016-03-16 09:12:22 +01:00
items : {
2018-08-01 20:29:07 +02:00
xtype : 'pveAgentFeatureSelector' ,
2021-01-19 17:31:03 +01:00
name : 'agent' ,
} ,
} : undefined ,
2016-03-16 09:12:22 +01:00
} ,
protection : {
2016-04-04 16:59:52 +02:00
header : gettext ( 'Protection' ) ,
2016-03-16 09:12:22 +01:00
defaultValue : false ,
2018-01-15 15:18:09 +01:00
renderer : Proxmox . Utils . format _boolean ,
2016-03-16 09:12:22 +01:00
editor : caps . vms [ 'VM.Config.Options' ] ? {
2017-12-06 18:12:41 +01:00
xtype : 'proxmoxWindowEdit' ,
2016-04-04 16:59:52 +02:00
subject : gettext ( 'Protection' ) ,
2016-03-16 09:12:22 +01:00
items : {
2017-12-05 14:06:40 +01:00
xtype : 'proxmoxcheckbox' ,
2016-03-16 09:12:22 +01:00
name : 'protection' ,
uncheckedValue : 0 ,
defaultValue : 0 ,
deleteDefaultValue : true ,
2021-01-19 17:31:03 +01:00
fieldLabel : gettext ( 'Enabled' ) ,
} ,
} : undefined ,
2019-01-29 16:28:46 +01:00
} ,
2019-10-07 15:23:52 +02:00
spice _enhancements : {
header : gettext ( 'Spice Enhancements' ) ,
defaultValue : false ,
2021-01-19 17:39:15 +01:00
renderer : PVE . Utils . render _spice _enhancements ,
2019-10-07 15:23:52 +02:00
editor : caps . vms [ 'VM.Config.Options' ] ? {
xtype : 'proxmoxWindowEdit' ,
subject : gettext ( 'Spice Enhancements' ) ,
onlineHelp : 'qm_spice_enhancements' ,
items : {
xtype : 'pveSpiceEnhancementSelector' ,
name : 'spice_enhancements' ,
2021-01-19 17:31:03 +01:00
} ,
} : undefined ,
2019-10-07 15:23:52 +02:00
} ,
2019-12-09 15:27:02 +01:00
vmstatestorage : {
header : gettext ( 'VM State storage' ) ,
defaultValue : '' ,
renderer : val => val || gettext ( 'Automatic' ) ,
editor : caps . vms [ 'VM.Config.Options' ] ? {
xtype : 'proxmoxWindowEdit' ,
subject : gettext ( 'VM State storage' ) ,
2019-12-11 09:01:10 +01:00
onlineHelp : 'chapter_virtual_machines' , // FIXME: use 'qm_vmstatestorage' once available
2019-12-11 09:18:58 +01:00
width : 350 ,
2019-12-09 15:27:02 +01:00
items : {
xtype : 'pveStorageSelector' ,
storageContent : 'images' ,
allowBlank : true ,
2019-12-11 09:18:58 +01:00
emptyText : gettext ( "Automatic (Storage used by the VM, or 'local')" ) ,
2019-12-09 15:27:02 +01:00
autoSelect : false ,
deleteEmpty : true ,
skipEmptyText : true ,
nodename : nodename ,
name : 'vmstatestorage' ,
2021-01-19 17:31:03 +01:00
} ,
} : undefined ,
2019-12-09 15:27:02 +01:00
} ,
2019-01-29 16:28:46 +01:00
hookscript : {
2021-01-19 17:31:03 +01:00
header : gettext ( 'Hookscript' ) ,
} ,
2016-03-16 09:12:22 +01:00
} ;
var baseurl = 'nodes/' + nodename + '/qemu/' + vmid + '/config' ;
var edit _btn = new Ext . Button ( {
text : gettext ( 'Edit' ) ,
disabled : true ,
2021-01-19 17:31:03 +01:00
handler : function ( ) { me . run _editor ( ) ; } ,
2016-03-16 09:12:22 +01:00
} ) ;
2019-10-30 15:49:15 +01:00
var revert _btn = new PVE . button . PendingRevert ( ) ;
2016-03-16 09:12:22 +01:00
var set _button _status = function ( ) {
var sm = me . getSelectionModel ( ) ;
var rec = sm . getSelection ( ) [ 0 ] ;
if ( ! rec ) {
edit _btn . disable ( ) ;
return ;
}
var key = rec . data . key ;
2021-01-19 17:45:01 +01:00
var pending = rec . data . delete || me . hasPendingChanges ( key ) ;
2016-03-16 09:12:22 +01:00
var rowdef = rows [ key ] ;
edit _btn . setDisabled ( ! rowdef . editor ) ;
revert _btn . setDisabled ( ! pending ) ;
} ;
2016-03-21 10:53:13 +01:00
Ext . apply ( me , {
2016-03-16 09:12:22 +01:00
url : "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/pending" ,
interval : 5000 ,
2016-05-10 15:01:54 +02:00
cwidth1 : 250 ,
2021-01-19 17:39:15 +01:00
tbar : [ edit _btn , revert _btn ] ,
2016-03-16 09:12:22 +01:00
rows : rows ,
2017-12-06 17:54:30 +01:00
editorConfig : {
2021-01-19 17:31:03 +01:00
url : "/api2/extjs/" + baseurl ,
2017-12-06 17:54:30 +01:00
} ,
2016-03-16 09:12:22 +01:00
listeners : {
2017-12-06 17:54:30 +01:00
itemdblclick : me . run _editor ,
2021-01-19 17:31:03 +01:00
selectionchange : set _button _status ,
} ,
2016-03-16 09:12:22 +01:00
} ) ;
me . callParent ( ) ;
2020-05-22 17:16:35 +02:00
me . on ( 'activate' , ( ) => me . rstore . startUpdate ( ) ) ;
me . on ( 'destroy' , ( ) => me . rstore . stopUpdate ( ) ) ;
me . on ( 'deactivate' , ( ) => me . rstore . stopUpdate ( ) ) ;
2016-03-16 09:12:22 +01:00
2019-10-29 15:50:17 +01:00
me . mon ( me . getStore ( ) , 'datachanged' , function ( ) {
2016-03-16 09:12:22 +01:00
set _button _status ( ) ;
} ) ;
2021-01-19 17:31:03 +01:00
} ,
2016-03-16 09:12:22 +01:00
} ) ;