]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Utils.js
ui: eslint: enforce "no-unneeded-ternary" rule
[pve-manager.git] / www / manager6 / Utils.js
index cadaa9ce6e166e0123c3781091a142b8daa5aeb4..5d476600b458bfa5caf44c192158ae908310cd19 100644 (file)
@@ -10,16 +10,17 @@ Ext.enableAriaPanels = false;
 // avoid errors when running without development tools
 if (!Ext.isDefined(Ext.global.console)) {
     var console = {
-       log: function() {}
+       log: function() {},
     };
 }
 console.log("Starting PVE Manager");
 
 Ext.Ajax.defaultHeaders = {
-    'Accept': 'application/json'
+    'Accept': 'application/json',
 };
 
-Ext.define('PVE.Utils', { utilities: {
+Ext.define('PVE.Utils', {
+ utilities: {
 
     // this singleton contains miscellaneous utilities
 
@@ -35,14 +36,14 @@ Ext.define('PVE.Utils', { utilities: {
        4: "warning",
        5: "notice",
        6: "info",
-       7: "debug"
+       7: "debug",
     },
 
     support_level_hash: {
        'c': gettext('Community'),
        'b': gettext('Basic'),
        's': gettext('Standard'),
-       'p': gettext('Premium')
+       'p': gettext('Premium'),
     },
 
     noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit <a target="_blank" href="https://www.proxmox.com/products/proxmox-ve/subscription-service-plans">www.proxmox.com</a> to get a list of available options.',
@@ -50,7 +51,7 @@ Ext.define('PVE.Utils', { utilities: {
     kvm_ostypes: {
        'Linux': [
            { desc: '5.x - 2.6 Kernel', val: 'l26' },
-           { desc: '2.4 Kernel', val: 'l24' }
+           { desc: '2.4 Kernel', val: 'l24' },
        ],
        'Microsoft Windows': [
            { desc: '10/2016/2019', val: 'win10' },
@@ -58,14 +59,14 @@ Ext.define('PVE.Utils', { utilities: {
            { desc: '7/2008r2', val: 'win7' },
            { desc: 'Vista/2008', val: 'w2k8' },
            { desc: 'XP/2003', val: 'wxp' },
-           { desc: '2000', val: 'w2k' }
+           { desc: '2000', val: 'w2k' },
        ],
        'Solaris Kernel': [
-           { desc: '-', val: 'solaris'}
+           { desc: '-', val: 'solaris' },
        ],
        'Other': [
-           { desc: '-', val: 'other'}
-       ]
+           { desc: '-', val: 'other' },
+       ],
     },
 
     get_health_icon: function(state, circle) {
@@ -78,7 +79,7 @@ Ext.define('PVE.Utils', { utilities: {
        }
 
        var icon = 'faded fa-question';
-       switch(state) {
+       switch (state) {
            case 'good':
                icon = 'good fa-check';
                break;
@@ -145,7 +146,7 @@ Ext.define('PVE.Utils', { utilities: {
 
            if (av === undefined && bv === undefined) {
                return 0;
-           } else if (av === undefined)  {
+           } else if (av === undefined) {
                return -1;
            } else if (bv === undefined) {
                return 1;
@@ -155,7 +156,6 @@ Ext.define('PVE.Utils', { utilities: {
                // else we need to look at the next parts
            }
        }
-
     },
 
     get_ceph_icon_html: function(health, fw) {
@@ -168,17 +168,17 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     map_ceph_health: {
-       'HEALTH_OK':'good',
-       'HEALTH_UPGRADE':'upgrade',
-       'HEALTH_OLD':'old',
-       'HEALTH_WARN':'warning',
-       'HEALTH_ERR':'critical'
+       'HEALTH_OK': 'good',
+       'HEALTH_UPGRADE': 'upgrade',
+       'HEALTH_OLD': 'old',
+       'HEALTH_WARN': 'warning',
+       'HEALTH_ERR': 'critical',
     },
 
     render_ceph_health: function(healthObj) {
        var state = {
            iconCls: PVE.Utils.get_health_icon(),
-           text: ''
+           text: '',
        };
 
        if (!healthObj || !healthObj.status) {
@@ -194,7 +194,7 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     render_zfs_health: function(value) {
-       if (typeof value == 'undefined'){
+       if (typeof value == 'undefined') {
            return "";
        }
        var iconCls = 'question-circle';
@@ -216,7 +216,138 @@ Ext.define('PVE.Utils', { utilities: {
        }
 
        return '<i class="fa fa-' + iconCls + '"></i> ' + value;
+    },
+
+    render_pbs_fingerprint: fp => fp.substring(0, 23),
+
+    render_backup_encryption: function(v, meta, record) {
+       if (!v) {
+           return gettext('No');
+       }
+
+       let tip = '';
+       if (v.match(/^[a-fA-F0-9]{2}:/)) { // fingerprint
+           tip = `Key fingerprint ${PVE.Utils.render_pbs_fingerprint(v)}`;
+       }
+       let icon = `<i class="fa fa-fw fa-lock good"></i>`;
+       return `<span data-qtip="${tip}">${icon} ${gettext('Encrypted')}</span>`;
+    },
+
+    render_backup_verification: function(v, meta, record) {
+       let i = (cls, txt) => `<i class="fa fa-fw fa-${cls}"></i> ${txt}`;
+       if (v === undefined || v === null) {
+           return i('question-circle-o warning', gettext('None'));
+       }
+       let tip = "";
+       let txt = gettext('Failed');
+       let iconCls = 'times critical';
+       if (v.state === 'ok') {
+           txt = gettext('OK');
+           iconCls = 'check good';
+           let now = Date.now() / 1000;
+           let task = Proxmox.Utils.parse_task_upid(v.upid);
+           let verify_time = Proxmox.Utils.render_timestamp(task.starttime);
+           tip = `Last verify task started on ${verify_time}`;
+           if (now - v.starttime > 30 * 24 * 60 * 60) {
+               tip = `Last verify task over 30 days ago: ${verify_time}`;
+               iconCls = 'check warning';
+           }
+       }
+       return `<span data-qtip="${tip}"> ${i(iconCls, txt)} </span>`;
+    },
+
+    render_backup_status: function(value, meta, record) {
+       if (typeof value == 'undefined') {
+           return "";
+       }
+
+       let iconCls = 'check-circle good';
+       let text = gettext('Yes');
+
+       if (!PVE.Parser.parseBoolean(value.toString())) {
+           iconCls = 'times-circle critical';
+
+           text = gettext('No');
+
+           let reason = record.get('reason');
+           if (typeof reason !== 'undefined') {
+               if (reason in PVE.Utils.backup_reasons_table) {
+                   reason = PVE.Utils.backup_reasons_table[record.get('reason')];
+               }
+               text = `${text} - ${reason}`;
+           }
+       }
 
+       return `<i class="fa fa-${iconCls}"></i> ${text}`;
+    },
+
+    render_backup_days_of_week: function(val) {
+       var dows = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
+       var selected = [];
+       var cur = -1;
+       val.split(',').forEach(function(day) {
+           cur++;
+           var dow = (dows.indexOf(day)+6)%7;
+           if (cur === dow) {
+               if (selected.length === 0 || selected[selected.length-1] === 0) {
+                   selected.push(1);
+               } else {
+                   selected[selected.length-1]++;
+               }
+           } else {
+               while (cur < dow) {
+                   cur++;
+                   selected.push(0);
+               }
+               selected.push(1);
+           }
+       });
+
+       cur = -1;
+       var days = [];
+       selected.forEach(function(item) {
+           cur++;
+           if (item > 2) {
+               days.push(Ext.Date.dayNames[(cur+1)] + '-' + Ext.Date.dayNames[(cur+item)%7]);
+               cur += item-1;
+           } else if (item == 2) {
+               days.push(Ext.Date.dayNames[cur+1]);
+               days.push(Ext.Date.dayNames[(cur+2)%7]);
+               cur++;
+           } else if (item == 1) {
+               days.push(Ext.Date.dayNames[(cur+1)%7]);
+           }
+       });
+       return days.join(', ');
+    },
+
+    render_backup_selection: function(value, metaData, record) {
+       let allExceptText = gettext('All except {0}');
+       let allText = '-- ' + gettext('All') + ' --';
+       if (record.data.all) {
+           if (record.data.exclude) {
+               return Ext.String.format(allExceptText, record.data.exclude);
+           }
+           return allText;
+       }
+       if (record.data.vmid) {
+           return record.data.vmid;
+       }
+
+       if (record.data.pool) {
+           return "Pool '"+ record.data.pool + "'";
+       }
+
+       return "-";
+    },
+
+    backup_reasons_table: {
+       'backup=yes': gettext('Enabled'),
+       'backup=no': gettext('Disabled'),
+       'enabled': gettext('Enabled'),
+       'disabled': gettext('Disabled'),
+       'not a volume': gettext('Not a volume'),
+       'efidisk but no OMVF BIOS': gettext('EFI Disk without OMVF BIOS'),
     },
 
     get_kvm_osinfo: function(value) {
@@ -233,7 +364,7 @@ Ext.define('PVE.Utils', { utilities: {
        return info;
     },
 
-    render_kvm_ostype: function (value) {
+    render_kvm_ostype: function(value) {
        var osinfo = PVE.Utils.get_kvm_osinfo(value);
        if (osinfo.desc && osinfo.desc !== '-') {
            return osinfo.base + ' ' + osinfo.desc;
@@ -242,7 +373,7 @@ Ext.define('PVE.Utils', { utilities: {
        }
     },
 
-    render_hotplug_features: function (value) {
+    render_hotplug_features: function(value) {
        var fa = [];
 
        if (!value || (value === '0')) {
@@ -281,7 +412,7 @@ Ext.define('PVE.Utils', { utilities: {
 
     render_qga_features: function(value) {
        if (!value) {
-           return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText  + ')';
+           return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText + ')';
        }
        var props = PVE.Parser.parsePropertyString(value, 'enabled');
        if (!PVE.Parser.parseBoolean(props.enabled)) {
@@ -292,7 +423,7 @@ Ext.define('PVE.Utils', { utilities: {
        var agentstring = Proxmox.Utils.enabledText;
 
        Ext.Object.each(props, function(key, value) {
-           var keystring = '' ;
+           var keystring = '';
            agentstring += ', ' + key + ': ';
 
            if (key === 'type') {
@@ -412,7 +543,7 @@ Ext.define('PVE.Utils', { utilities: {
        sl: 'Slovenian',
        sv: 'Swedish',
        //th: 'Thai',
-       tr: 'Turkish'
+       tr: 'Turkish',
     },
 
     kvm_vga_drivers: {
@@ -427,10 +558,10 @@ Ext.define('PVE.Utils', { utilities: {
        serial2: gettext('Serial terminal') + ' 2',
        serial3: gettext('Serial terminal') + ' 3',
        virtio: 'VirtIO-GPU',
-       none: Proxmox.Utils.noneText
+       none: Proxmox.Utils.noneText,
     },
 
-    render_kvm_language: function (value) {
+    render_kvm_language: function(value) {
        if (!value || value === '__default__') {
            return Proxmox.Utils.defaultText;
        }
@@ -454,7 +585,7 @@ Ext.define('PVE.Utils', { utilities: {
        '__default__': Proxmox.Utils.defaultText + ' (xterm.js)',
        'vv': 'SPICE (remote-viewer)',
        'html5': 'HTML5 (noVNC)',
-       'xtermjs': 'xterm.js'
+       'xtermjs': 'xterm.js',
     },
 
     render_console_viewer: function(value) {
@@ -471,7 +602,7 @@ Ext.define('PVE.Utils', { utilities: {
        });
     },
 
-    render_kvm_vga_driver: function (value) {
+    render_kvm_vga_driver: function(value) {
        if (!value) {
            return Proxmox.Utils.defaultText;
        }
@@ -541,7 +672,7 @@ Ext.define('PVE.Utils', { utilities: {
        'vztmpl': gettext('Container template'),
        'iso': gettext('ISO image'),
        'rootdir': gettext('Container'),
-       'snippets': gettext('Snippets')
+       'snippets': gettext('Snippets'),
     },
 
     volume_is_qemu_backup: function(volid, format) {
@@ -581,125 +712,144 @@ Ext.define('PVE.Utils', { utilities: {
        dir: {
            name: Proxmox.Utils.directoryText,
            ipanel: 'DirInputPanel',
-           faIcon: 'folder'
+           faIcon: 'folder',
+           backups: true,
        },
        lvm: {
            name: 'LVM',
            ipanel: 'LVMInputPanel',
-           faIcon: 'folder'
+           faIcon: 'folder',
+           backups: false,
        },
        lvmthin: {
            name: 'LVM-Thin',
            ipanel: 'LvmThinInputPanel',
-           faIcon: 'folder'
+           faIcon: 'folder',
+           backups: false,
        },
        nfs: {
            name: 'NFS',
            ipanel: 'NFSInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        cifs: {
            name: 'CIFS',
            ipanel: 'CIFSInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        glusterfs: {
            name: 'GlusterFS',
            ipanel: 'GlusterFsInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        iscsi: {
            name: 'iSCSI',
            ipanel: 'IScsiInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: false,
        },
        cephfs: {
            name: 'CephFS',
            ipanel: 'CephFSInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        pvecephfs: {
            name: 'CephFS (PVE)',
            ipanel: 'CephFSInputPanel',
            hideAdd: true,
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        rbd: {
            name: 'RBD',
            ipanel: 'RBDInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: false,
        },
        pveceph: {
            name: 'RBD (PVE)',
            ipanel: 'RBDInputPanel',
            hideAdd: true,
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: false,
        },
        zfs: {
            name: 'ZFS over iSCSI',
            ipanel: 'ZFSInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: false,
        },
        zfspool: {
            name: 'ZFS',
            ipanel: 'ZFSPoolInputPanel',
-           faIcon: 'folder'
+           faIcon: 'folder',
+           backups: false,
        },
        pbs: {
            name: 'Proxmox Backup Server',
-           //ipanel: '', // TODO
-           hideAdd: true,
-           faIcon: 'database',
+           ipanel: 'PBSInputPanel',
+           faIcon: 'floppy-o',
+           backups: true,
        },
        drbd: {
            name: 'DRBD',
            hideAdd: true,
+           backups: false,
        },
     },
 
     sdnvnetSchema: {
        vnet: {
            name: 'vnet',
-           faIcon: 'folder'
+           faIcon: 'folder',
        },
     },
 
     sdnzoneSchema: {
        zone: {
             name: 'zone',
-            hideAdd: true
+            hideAdd: true,
+       },
+       simple: {
+           name: 'Simple',
+           ipanel: 'SimpleInputPanel',
+           faIcon: 'th',
        },
        vlan: {
            name: 'VLAN',
            ipanel: 'VlanInputPanel',
-           faIcon: 'th'
+           faIcon: 'th',
        },
        qinq: {
            name: 'QinQ',
            ipanel: 'QinQInputPanel',
-           faIcon: 'th'
+           faIcon: 'th',
        },
        vxlan: {
            name: 'VXLAN',
            ipanel: 'VxlanInputPanel',
-           faIcon: 'th'
+           faIcon: 'th',
        },
        evpn: {
            name: 'EVPN',
            ipanel: 'EvpnInputPanel',
-           faIcon: 'th'
+           faIcon: 'th',
        },
     },
 
     sdncontrollerSchema: {
        controller: {
             name: 'controller',
-            hideAdd: true
+            hideAdd: true,
        },
        evpn: {
            name: 'evpn',
            ipanel: 'EvpnInputPanel',
-           faIcon: 'crosshairs'
+           faIcon: 'crosshairs',
        },
     },
 
@@ -747,7 +897,7 @@ Ext.define('PVE.Utils', { utilities: {
        if (value.managed) {
            text = value.state || Proxmox.Utils.noneText;
 
-           text += ', ' +  Proxmox.Utils.groupText + ': ';
+           text += ', ' + Proxmox.Utils.groupText + ': ';
            text += value.group || Proxmox.Utils.noneText;
        }
 
@@ -766,18 +916,17 @@ Ext.define('PVE.Utils', { utilities: {
            Ext.isNumber(data.id) &&
            Ext.isNumber(data.lun)) {
            return "CH " +
-               Ext.String.leftPad(data.channel,2, '0') +
+               Ext.String.leftPad(data.channel, 2, '0') +
                " ID " + data.id + " LUN " + data.lun;
        }
-       return data.volid.replace(/^.*?:(.*?\/)?/,'');
+       return data.volid.replace(/^.*?:(.*?\/)?/, '');
     },
 
-    render_serverity: function (value) {
+    render_serverity: function(value) {
        return PVE.Utils.log_severity_hash[value] || value;
     },
 
     render_cpu: function(value, metaData, record, rowIndex, colIndex, store) {
-
        if (!(record.data.uptime && Ext.isNumeric(value))) {
            return '';
        }
@@ -794,7 +943,6 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     render_size: function(value, metaData, record, rowIndex, colIndex, store) {
-
        if (!Ext.isNumeric(value)) {
            return '';
        }
@@ -828,7 +976,7 @@ Ext.define('PVE.Utils', { utilities: {
        if (!Ext.isNumeric(value) || value === -1) {
            return '';
        }
-       if (value > 1 ) {
+       if (value > 1) {
            // we got no percentage but bytes
            var mem = value;
            var maxmem = record.data.maxmem;
@@ -844,7 +992,6 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     render_mem_usage: function(value, metaData, record, rowIndex, colIndex, store) {
-
        var mem = value;
        var maxmem = record.data.maxmem;
 
@@ -860,7 +1007,6 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     calculate_disk_usage: function(data) {
-
        if (!Ext.isNumeric(data.disk) ||
            data.type === 'qemu' ||
            (data.type === 'lxc' && data.uptime === 0) ||
@@ -880,7 +1026,6 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     render_disk_usage: function(value, metaData, record, rowIndex, colIndex, store) {
-
        var disk = value;
        var maxdisk = record.data.maxdisk;
        var type = record.data.type;
@@ -925,10 +1070,9 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
+       var cls = PVE.Utils.get_object_icon_class(value, record.data);
 
-       var cls = PVE.Utils.get_object_icon_class(value,record.data);
-
-       var fa = '<i class="fa-fw x-grid-icon-custom ' + cls  + '"></i> ';
+       var fa = '<i class="fa-fw x-grid-icon-custom ' + cls + '"></i> ';
        return fa + value;
     },
 
@@ -1006,9 +1150,9 @@ Ext.define('PVE.Utils', { utilities: {
            '2': gettext('Bad Request'),
            '3': gettext('Configuration Unsupported'),
            '4': gettext('Device Ineligible'),
-           '5': gettext('Timeout')
+           '5': gettext('Timeout'),
        };
-       return "U2F Error: "  + ErrorNames[error] || Proxmox.Utils.unknownText;
+       return "U2F Error: " + ErrorNames[error] || Proxmox.Utils.unknownText;
     },
 
     windowHostname: function() {
@@ -1016,54 +1160,46 @@ Ext.define('PVE.Utils', { utilities: {
             function(m, addr, offset, original) { return addr; });
     },
 
-    openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname, cmd) {
+    openDefaultConsoleWindow: function(consoles, consoleType, vmid, nodename, vmname, cmd) {
        var dv = PVE.Utils.defaultViewer(consoles);
-       PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname, cmd);
+       PVE.Utils.openConsoleWindow(dv, consoleType, vmid, nodename, vmname, cmd);
     },
 
-    openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname, cmd) {
-       // kvm, lxc, shell, upgrade
-
-       if (vmid == undefined && (vmtype === 'kvm' || vmtype === 'lxc')) {
+    openConsoleWindow: function(viewer, consoleType, vmid, nodename, vmname, cmd) {
+       if (vmid == undefined && (consoleType === 'kvm' || consoleType === 'lxc')) {
            throw "missing vmid";
        }
-
        if (!nodename) {
            throw "no nodename specified";
        }
 
        if (viewer === 'html5') {
-           PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, cmd);
+           PVE.Utils.openVNCViewer(consoleType, vmid, nodename, vmname, cmd);
        } else if (viewer === 'xtermjs') {
-           Proxmox.Utils.openXtermJsViewer(vmtype, vmid, nodename, vmname, cmd);
+           Proxmox.Utils.openXtermJsViewer(consoleType, vmid, nodename, vmname, cmd);
        } else if (viewer === 'vv') {
-           var url;
-           var params = { proxy: PVE.Utils.windowHostname() };
-           if (vmtype === 'kvm') {
+           let url = '/nodes/' + nodename + '/spiceshell';
+           let params = {
+               proxy: PVE.Utils.windowHostname(),
+           };
+           if (consoleType === 'kvm') {
                url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
-               PVE.Utils.openSpiceViewer(url, params);
-           } else if (vmtype === 'lxc') {
+           } else if (consoleType === 'lxc') {
                url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy';
-               PVE.Utils.openSpiceViewer(url, params);
-           } else if (vmtype === 'shell') {
-               url = '/nodes/' + nodename + '/spiceshell';
-               PVE.Utils.openSpiceViewer(url, params);
-           } else if (vmtype === 'upgrade') {
-               url = '/nodes/' + nodename + '/spiceshell';
-               params.upgrade = 1;
-               PVE.Utils.openSpiceViewer(url, params);
-           } else if (vmtype === 'cmd') {
-               url = '/nodes/' + nodename + '/spiceshell';
+           } else if (consoleType === 'upgrade') {
+               params.cmd = 'upgrade';
+           } else if (consoleType === 'cmd') {
                params.cmd = cmd;
-               PVE.Utils.openSpiceViewer(url, params);
+           } else if (consoleType !== 'shell') {
+               throw `unknown spice viewer type '${consoleType}'`;
            }
+           PVE.Utils.openSpiceViewer(url, params);
        } else {
-           throw "unknown viewer type";
+           throw `unknown viewer type '${viewer}'`;
        }
     },
 
     defaultViewer: function(consoles) {
-
        var allowSpice, allowXtermjs;
 
        if (consoles === true) {
@@ -1096,7 +1232,7 @@ Ext.define('PVE.Utils', { utilities: {
            vmname: vmname,
            node: nodename,
            resize: scaling,
-           cmd: cmd
+           cmd: cmd,
        });
        var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
        if (nw) {
@@ -1104,19 +1240,18 @@ Ext.define('PVE.Utils', { utilities: {
        }
     },
 
-    openSpiceViewer: function(url, params){
-
+    openSpiceViewer: function(url, params) {
        var downloadWithName = function(uri, name) {
            var link = Ext.DomHelper.append(document.body, {
                tag: 'a',
                href: uri,
-               css : 'display:none;visibility:hidden;height:0px;'
+               css: 'display:none;visibility:hidden;height:0px;',
            });
 
            // Note: we need to tell android the correct file name extension
            // but we do not set 'download' tag for other environments, because
            // It can have strange side effects (additional user prompt on firefox)
-           var andriod = navigator.userAgent.match(/Android/i) ? true : false;
+           var andriod = !!navigator.userAgent.match(/Android/i);
            if (andriod) {
                link.download = name;
            }
@@ -1124,8 +1259,8 @@ Ext.define('PVE.Utils', { utilities: {
            if (link.fireEvent) {
                link.fireEvent('onclick');
            } else {
-                var evt = document.createEvent("MouseEvents");
-                evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
+               let evt = document.createEvent("MouseEvents");
+               evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
                link.dispatchEvent(evt);
            }
        };
@@ -1134,10 +1269,10 @@ Ext.define('PVE.Utils', { utilities: {
            url: url,
            params: params,
            method: 'POST',
-           failure: function(response, opts){
+           failure: function(response, opts) {
                Ext.Msg.alert('Error', response.htmlStatus);
            },
-           success: function(response, opts){
+           success: function(response, opts) {
                var raw = "[virt-viewer]\n";
                Ext.Object.each(response.result.data, function(k, v) {
                    raw += k + "=" + v + "\n";
@@ -1146,7 +1281,7 @@ Ext.define('PVE.Utils', { utilities: {
                    encodeURIComponent(raw);
 
                downloadWithName(url, "pve-spice.vv");
-           }
+           },
        });
     },
 
@@ -1168,7 +1303,7 @@ Ext.define('PVE.Utils', { utilities: {
                        xtermjs: !!conf.serial,
                    };
                    PVE.Utils.openDefaultConsoleWindow(consoles, 'kvm', vmid, nodename, vmname);
-               }
+               },
            });
        } else if (record.data.type === 'lxc' && !record.data.template) {
            PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname);
@@ -1177,7 +1312,6 @@ Ext.define('PVE.Utils', { utilities: {
 
     // test automation helper
     call_menu_handler: function(menu, text) {
-
        var list = menu.query('menuitem');
 
        Ext.Array.each(list, function(item) {
@@ -1204,7 +1338,7 @@ Ext.define('PVE.Utils', { utilities: {
        if (template) {
            if (type === 'qemu' || type == 'lxc') {
                menu = Ext.create('PVE.menu.TemplateMenu', {
-                   pveSelNode: record
+                   pveSelNode: record,
                });
            }
        } else if (type === 'qemu' ||
@@ -1212,7 +1346,7 @@ Ext.define('PVE.Utils', { utilities: {
                   type === 'node') {
            menu = Ext.create('PVE.' + type + '.CmdMenu', {
                pveSelNode: record,
-               nodename: record.data.node
+               nodename: record.data.node,
            });
        } else {
            return;
@@ -1260,6 +1394,20 @@ Ext.define('PVE.Utils', { utilities: {
        reader.readAsText(file);
     },
 
+    loadTextFromFile: function(file, callback, maxBytes) {
+       let maxSize = maxBytes || 8192;
+       if (file.size > maxSize) {
+           Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size);
+           return;
+       }
+       /*global
+         FileReader
+       */
+       let reader = new FileReader();
+       reader.onload = evt => callback(evt.target.result);
+       reader.readAsText(file);
+    },
+
     diskControllerMaxIDs: {
        ide: 4,
        sata: 6,
@@ -1275,7 +1423,7 @@ Ext.define('PVE.Utils', { utilities: {
        if (Ext.isArray(types)) {
            busses = types;
        } else if (Ext.isDefined(types)) {
-           busses = [ types ];
+           busses = [types];
        }
 
        // check if we only have valid busses
@@ -1321,7 +1469,7 @@ Ext.define('PVE.Utils', { utilities: {
 
     hardware_counts: { net: 32, usb: 5, hostpci: 16, audio: 1, efidisk: 1, serial: 4, rng: 1 },
 
-    cleanEmptyObjectKeys: function (obj) {
+    cleanEmptyObjectKeys: function(obj) {
        var propName;
        for (propName in obj) {
            if (obj.hasOwnProperty(propName)) {
@@ -1339,26 +1487,20 @@ Ext.define('PVE.Utils', { utilities: {
            acme.domains = [domain];
        } else {
            acme.domains.push(domain);
-           acme.domains = acme.domains.filter((value, index, self) => {
-               return self.indexOf(value) === index;
-           });
+           acme.domains = acme.domains.filter((value, index, self) => self.indexOf(value) === index);
        }
        return acme;
     },
 
     remove_domain_from_acme: function(acme, domain) {
        if (acme.domains !== undefined) {
-           acme.domains = acme.domains.filter((value, index, self) => {
-               return self.indexOf(value) === index && value !== domain;
-           });
+           acme.domains = acme.domains.filter((value, index, self) => self.indexOf(value) === index && value !== domain);
        }
        return acme;
     },
 
     handleStoreErrorOrMask: function(me, store, regex, callback) {
-
-       me.mon(store, 'load', function (proxy, response, success, operation) {
-
+       me.mon(store, 'load', function(proxy, response, success, operation) {
            if (success) {
                Proxmox.Utils.setErrorMask(me, false);
                return;
@@ -1379,15 +1521,15 @@ Ext.define('PVE.Utils', { utilities: {
        });
     },
 
-    showCephInstallOrMask: function(container, msg, nodename, callback){
+    showCephInstallOrMask: function(container, msg, nodename, callback) {
        var regex = new RegExp("not (installed|initialized)", "i");
        if (msg.match(regex)) {
            if (Proxmox.UserName === 'root@pam') {
                container.el.mask();
-               if (!container.down('pveCephInstallWindow')){
-                   var isInstalled = msg.match(/not initialized/i) ? true : false;
+               if (!container.down('pveCephInstallWindow')) {
+                   var isInstalled = !!msg.match(/not initialized/i);
                    var win = Ext.create('PVE.ceph.Install', {
-                       nodename: nodename
+                       nodename: nodename,
                    });
                    win.getViewModel().set('isInstalled', isInstalled);
                    container.add(win);
@@ -1455,12 +1597,138 @@ Ext.define('PVE.Utils', { utilities: {
            }
        });
     },
+
+    cpu_vendor_map: {
+       'default': 'QEMU',
+       'AuthenticAMD': 'AMD',
+       'GenuineIntel': 'Intel',
+    },
+
+    cpu_vendor_order: {
+       "AMD": 1,
+       "Intel": 2,
+       "QEMU": 3,
+       "Host": 4,
+       "_default_": 5, // includes custom models
+    },
+
+    verify_ip64_address_list: function(value, with_suffix) {
+       for (let addr of value.split(/[ ,;]+/)) {
+           if (addr === '') {
+               continue;
+           }
+
+           if (with_suffix) {
+               let parts = addr.split('%');
+               addr = parts[0];
+
+               if (parts.length > 2) {
+                   return false;
+               }
+
+               if (parts.length > 1 && !addr.startsWith('fe80:')) {
+                   return false;
+               }
+           }
+
+           if (!Proxmox.Utils.IP64_match.test(addr)) {
+               return false;
+           }
+       }
+
+       return true;
+    },
 },
 
     singleton: true,
     constructor: function() {
        var me = this;
        Ext.apply(me, me.utilities);
-    }
+
+       Proxmox.Utils.override_task_descriptions({
+           acmedeactivate: ['ACME Account', gettext('Deactivate')],
+           acmenewcert: ['SRV', gettext('Order Certificate')],
+           acmerefresh: ['ACME Account', gettext('Refresh')],
+           acmeregister: ['ACME Account', gettext('Register')],
+           acmerenew: ['SRV', gettext('Renew Certificate')],
+           acmerevoke: ['SRV', gettext('Revoke Certificate')],
+           acmeupdate: ['ACME Account', gettext('Update')],
+           'auth-realm-sync': [gettext('Realm'), gettext('Sync')],
+           'auth-realm-sync-test': [gettext('Realm'), gettext('Sync Preview')],
+           cephcreatemds: ['Ceph Metadata Server', gettext('Create')],
+           cephcreatemgr: ['Ceph Manager', gettext('Create')],
+           cephcreatemon: ['Ceph Monitor', gettext('Create')],
+           cephcreateosd: ['Ceph OSD', gettext('Create')],
+           cephcreatepool: ['Ceph Pool', gettext('Create')],
+           cephdestroymds: ['Ceph Metadata Server', gettext('Destroy')],
+           cephdestroymgr: ['Ceph Manager', gettext('Destroy')],
+           cephdestroymon: ['Ceph Monitor', gettext('Destroy')],
+           cephdestroyosd: ['Ceph OSD', gettext('Destroy')],
+           cephdestroypool: ['Ceph Pool', gettext('Destroy')],
+           cephfscreate: ['CephFS', gettext('Create')],
+           clustercreate: ['', gettext('Create Cluster')],
+           clusterjoin: ['', gettext('Join Cluster')],
+           dircreate: [gettext('Directory Storage'), gettext('Create')],
+           dirremove: [gettext('Directory'), gettext('Remove')],
+           download: ['', gettext('Download')],
+           hamigrate: ['HA', gettext('Migrate')],
+           hashutdown: ['HA', gettext('Shutdown')],
+           hastart: ['HA', gettext('Start')],
+           hastop: ['HA', gettext('Stop')],
+           imgcopy: ['', gettext('Copy data')],
+           imgdel: ['', gettext('Erase data')],
+           lvmcreate: [gettext('LVM Storage'), gettext('Create')],
+           lvmthincreate: [gettext('LVM-Thin Storage'), gettext('Create')],
+           migrateall: ['', gettext('Migrate all VMs and Containers')],
+           'move_volume': ['CT', gettext('Move Volume')],
+           pull_file: ['CT', gettext('Pull file')],
+           push_file: ['CT', gettext('Push file')],
+           qmclone: ['VM', gettext('Clone')],
+           qmconfig: ['VM', gettext('Configure')],
+           qmcreate: ['VM', gettext('Create')],
+           qmdelsnapshot: ['VM', gettext('Delete Snapshot')],
+           qmdestroy: ['VM', gettext('Destroy')],
+           qmigrate: ['VM', gettext('Migrate')],
+           qmmove: ['VM', gettext('Move disk')],
+           qmpause: ['VM', gettext('Pause')],
+           qmreboot: ['VM', gettext('Reboot')],
+           qmreset: ['VM', gettext('Reset')],
+           qmrestore: ['VM', gettext('Restore')],
+           qmresume: ['VM', gettext('Resume')],
+           qmrollback: ['VM', gettext('Rollback')],
+           qmshutdown: ['VM', gettext('Shutdown')],
+           qmsnapshot: ['VM', gettext('Snapshot')],
+           qmstart: ['VM', gettext('Start')],
+           qmstop: ['VM', gettext('Stop')],
+           qmsuspend: ['VM', gettext('Hibernate')],
+           qmtemplate: ['VM', gettext('Convert to template')],
+           spiceproxy: ['VM/CT', gettext('Console') + ' (Spice)'],
+           spiceshell: ['', gettext('Shell') + ' (Spice)'],
+           startall: ['', gettext('Start all VMs and Containers')],
+           stopall: ['', gettext('Stop all VMs and Containers')],
+           unknownimgdel: ['', gettext('Destroy image from unknown guest')],
+           vncproxy: ['VM/CT', gettext('Console')],
+           vncshell: ['', gettext('Shell')],
+           vzclone: ['CT', gettext('Clone')],
+           vzcreate: ['CT', gettext('Create')],
+           vzdelsnapshot: ['CT', gettext('Delete Snapshot')],
+           vzdestroy: ['CT', gettext('Destroy')],
+           vzdump: (type, id) => id ? `VM/CT ${id} - ${gettext('Backup')}` : gettext('Backup Job'),
+           vzmigrate: ['CT', gettext('Migrate')],
+           vzmount: ['CT', gettext('Mount')],
+           vzreboot: ['CT', gettext('Reboot')],
+           vzrestore: ['CT', gettext('Restore')],
+           vzresume: ['CT', gettext('Resume')],
+           vzrollback: ['CT', gettext('Rollback')],
+           vzshutdown: ['CT', gettext('Shutdown')],
+           vzsnapshot: ['CT', gettext('Snapshot')],
+           vzstart: ['CT', gettext('Start')],
+           vzstop: ['CT', gettext('Stop')],
+           vzsuspend: ['CT', gettext('Suspend')],
+           vztemplate: ['CT', gettext('Convert to template')],
+           vzumount: ['CT', gettext('Unmount')],
+           zfscreate: [gettext('ZFS Storage'), gettext('Create')],
+       });
+    },
 
 });