]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Utils.js
add right-click menu for nodes
[pve-manager.git] / www / manager6 / Utils.js
index 2c536aab18a44cda127faaed1e4df268a0cd72be..d1ada771f02bc37ca56edfe27de190f43ca4ece8 100644 (file)
@@ -2,19 +2,19 @@ Ext.ns('PVE');
 
 // avoid errors related to Accessible Rich Internet Applications
 // (access for people with disabilities)
-// TODO reenable after all components are upgraded 
+// TODO reenable after all components are upgraded
 Ext.enableAria = false;
 Ext.enableAriaButtons = false;
 Ext.enableAriaPanels = false;
 
 // avoid errors when running without development tools
-if (!Ext.isDefined(Ext.global.console)) {   
-    var console = { 
-       dir: function() {}, 
-       log: function() {} 
+if (!Ext.isDefined(Ext.global.console)) {
+    var console = {
+       dir: function() {},
+       log: function() {}
     };
 }
-console.log("Starting PVE Manager"); 
+console.log("Starting PVE Manager");
 
 Ext.Ajax.defaultHeaders = {
     'Accept': 'application/json'
@@ -22,45 +22,20 @@ Ext.Ajax.defaultHeaders = {
 
 Ext.Ajax.on('beforerequest', function(conn, options) {
     if (PVE.CSRFPreventionToken) {
-       if (!options.headers) { 
+       if (!options.headers) {
            options.headers = {};
        }
        options.headers.CSRFPreventionToken = PVE.CSRFPreventionToken;
     }
 });
 
-var IPV4_OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])";
-var IPV4_REGEXP = "(?:(?:" + IPV4_OCTET + "\\.){3}" + IPV4_OCTET + ")";
-var IPV6_H16 = "(?:[0-9a-fA-F]{1,4})";
-var IPV6_LS32 = "(?:(?:" + IPV6_H16 + ":" + IPV6_H16 + ")|" + IPV4_REGEXP + ")";
+Ext.define('PVE.Utils', { utilities: {
 
+    // this singleton contains miscellaneous utilities
 
-var IP4_match = new RegExp("^(?:" + IPV4_REGEXP + ")$");
-var IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/[1-3][0-9]?$");
+    toolkit: undefined, // (extjs|touch), set inside Toolkit.js
 
-var IPV6_REGEXP = "(?:" +
-    "(?:(?:"                                                  + "(?:" + IPV6_H16 + ":){6})" + IPV6_LS32 + ")|" +
-    "(?:(?:"                                         +   "::" + "(?:" + IPV6_H16 + ":){5})" + IPV6_LS32 + ")|" +
-    "(?:(?:(?:"                           + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){4})" + IPV6_LS32 + ")|" +
-    "(?:(?:(?:(?:" + IPV6_H16 + ":){0,1}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){3})" + IPV6_LS32 + ")|" +
-    "(?:(?:(?:(?:" + IPV6_H16 + ":){0,2}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){2})" + IPV6_LS32 + ")|" +
-    "(?:(?:(?:(?:" + IPV6_H16 + ":){0,3}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){1})" + IPV6_LS32 + ")|" +
-    "(?:(?:(?:(?:" + IPV6_H16 + ":){0,4}" + IPV6_H16 + ")?::" +                         ")" + IPV6_LS32 + ")|" +
-    "(?:(?:(?:(?:" + IPV6_H16 + ":){0,5}" + IPV6_H16 + ")?::" +                         ")" + IPV6_H16  + ")|" +
-    "(?:(?:(?:(?:" + IPV6_H16 + ":){0,7}" + IPV6_H16 + ")?::" +                         ")"             + ")"  +
-    ")";
-
-var IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
-var IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/[0-9]{1,3}?$");
-var IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
-
-var IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
-
-Ext.define('PVE.Utils', { statics: {
-
-    // this class only contains static functions
-
-    toolkit: undefined, // (extjs|touch), set inside Toolkit.js 
+    bus_match: /^(ide|sata|virtio|scsi)\d+$/,
 
     log_severity_hash: {
        0: "panic",
@@ -88,19 +63,74 @@ Ext.define('PVE.Utils', { statics: {
        w2k: 'Microsoft Windows 2000',
        w2k8: 'Microsoft Windows Vista/2008',
        win7: 'Microsoft Windows 7/2008r2',
-       win8: 'Microsoft Windows 8/2012',
+       win8: 'Microsoft Windows 8.x/2012/2012r2',
+       win10: 'Microsoft Windows 10/2016',
        l24: 'Linux 2.4 Kernel',
        l26: 'Linux 4.X/3.X/2.6 Kernel',
        solaris: 'Solaris Kernel'
     },
 
+    get_health_icon: function(state, circle) {
+       if (circle === undefined) {
+           circle = false;
+       }
+
+       if (state === undefined) {
+           state = 'uknown';
+       }
+
+       var icon = 'faded fa-question';
+       switch(state) {
+           case 'good':
+               icon = 'good fa-check';
+               break;
+           case 'warning':
+               icon = 'warning fa-exclamation';
+               break;
+           case 'critical':
+               icon = 'critical fa-times';
+               break;
+           default: break;
+       }
+
+       if (circle) {
+           icon += '-circle';
+       }
+
+       return icon;
+    },
+
+    map_ceph_health: {
+       'HEALTH_OK':'good',
+       'HEALTH_WARN':'warning',
+       'HEALTH_ERR':'critical'
+    },
+
+    render_ceph_health: function(record) {
+       var state = {
+           iconCls: PVE.Utils.get_health_icon(),
+           text: ''
+       };
+
+       if (!record || !record.data) {
+           return state;
+       }
+
+       var health = PVE.Utils.map_ceph_health[record.data.health.overall_status];
+
+       state.iconCls = PVE.Utils.get_health_icon(health, true);
+       state.text = record.data.health.overall_status;
+
+       return state;
+    },
+
     render_kvm_ostype: function (value) {
        if (!value) {
            return gettext('Other OS types');
        }
        var text = PVE.Utils.kvm_ostypes[value];
        if (text) {
-           return text + ' (' + value + ')';
+           return text;
        }
        return value;
     },
@@ -109,7 +139,11 @@ Ext.define('PVE.Utils', { statics: {
        var fa = [];
 
        if (!value || (value === '0')) {
-           return gettext('disabled');
+           return gettext('Disabled');
+       }
+
+       if (value === '1') {
+           value = 'disk,network,usb';
        }
 
        Ext.each(value.split(','), function(el) {
@@ -118,7 +152,7 @@ Ext.define('PVE.Utils', { statics: {
            } else if (el === 'network') {
                fa.push(gettext('Network'));
            } else if (el === 'usb') {
-               fa.push(gettext('USB'));
+               fa.push('USB');
            } else if (el === 'memory') {
                fa.push(gettext('Memory'));
            } else if (el === 'cpu') {
@@ -142,7 +176,7 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     render_network_iface_type: function(value) {
-       return PVE.Utils.network_iface_types[value] || 
+       return PVE.Utils.network_iface_types[value] ||
            PVE.Utils.unknownText;
     },
 
@@ -168,7 +202,9 @@ Ext.define('PVE.Utils', { statics: {
        } else if (value === 'megasas') {
            return 'MegaRAID SAS 8708EM2';
        } else if (value === 'virtio-scsi-pci') {
-           return 'VIRTIO';
+           return 'VirtIO SCSI';
+       } else if (value === 'virtio-scsi-single') {
+           return 'VirtIO SCSI single';
        } else if (value === 'pvscsi') {
            return 'VMware PVSCSI';
        } else {
@@ -181,29 +217,29 @@ Ext.define('PVE.Utils', { statics: {
     kvm_keymaps: {
        //ar: 'Arabic',
        da: 'Danish',
-       de: 'German', 
-       'de-ch': 'German (Swiss)', 
-       'en-gb': 'English (UK)', 
+       de: 'German',
+       'de-ch': 'German (Swiss)',
+       'en-gb': 'English (UK)',
        'en-us': 'English (USA)',
        es: 'Spanish',
        //et: 'Estonia',
        fi: 'Finnish',
-       //fo: 'Faroe Islands', 
-       fr: 'French', 
-       'fr-be': 'French (Belgium)', 
+       //fo: 'Faroe Islands',
+       fr: 'French',
+       'fr-be': 'French (Belgium)',
        'fr-ca': 'French (Canada)',
        'fr-ch': 'French (Swiss)',
        //hr: 'Croatia',
        hu: 'Hungarian',
        is: 'Icelandic',
-       it: 'Italian', 
+       it: 'Italian',
        ja: 'Japanese',
        lt: 'Lithuanian',
        //lv: 'Latvian',
-       mk: 'Macedonian', 
+       mk: 'Macedonian',
        nl: 'Dutch',
        //'nl-be': 'Dutch (Belgium)',
-       no: 'Norwegian', 
+       no: 'Norwegian',
        pl: 'Polish',
        pt: 'Portuguese',
        'pt-br': 'Portuguese (Brazil)',
@@ -216,7 +252,7 @@ Ext.define('PVE.Utils', { statics: {
 
     kvm_vga_drivers: {
        std: gettext('Standard VGA'),
-       vmware: gettext('VMWare compatible'),
+       vmware: gettext('VMware compatible'),
        cirrus: 'Cirrus Logic GD5446',
        qxl: 'SPICE',
        qxl2: 'SPICE dual monitor',
@@ -307,7 +343,7 @@ Ext.define('PVE.Utils', { statics: {
            return PVE.Utils.defaultText;
        }
        var text = PVE.Utils.kvm_vga_drivers[value];
-       if (text) { 
+       if (text) {
            return text + ' (' + value + ')';
        }
        return value;
@@ -352,7 +388,7 @@ Ext.define('PVE.Utils', { statics: {
     // fixme: remove - not needed?
     gridLineHeigh: function() {
        return 21;
-       
+
        //if (Ext.isGecko)
        //return 23;
        //return 21;
@@ -372,10 +408,10 @@ Ext.define('PVE.Utils', { statics: {
            if (verbose && Ext.isObject(result.errors)) {
                msg += "<br>";
                Ext.Object.each(result.errors, function(prop, desc) {
-                   msg += "<br><b>" + Ext.htmlEncode(prop) + "</b>: " + 
+                   msg += "<br><b>" + Ext.htmlEncode(prop) + "</b>: " +
                        Ext.htmlEncode(desc);
                });
-           }   
+           }
        }
 
        return msg;
@@ -528,6 +564,7 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     task_desc_table: {
+       diskinit: [ 'Disk', gettext('Initialize Disk with GPT') ],
        vncproxy: [ 'VM/CT', gettext('Console') ],
        spiceproxy: [ 'VM/CT', gettext('Console') + ' (Spice)' ],
        vncshell: [ '', gettext('Shell') ],
@@ -586,7 +623,7 @@ Ext.define('PVE.Utils', { statics: {
        migrateall: [ '', gettext('Migrate all VMs and Containers') ]
     },
 
-    format_task_description: function(type, id) {      
+    format_task_description: function(type, id) {
        var farray = PVE.Utils.task_desc_table[type];
        if (!farray) {
            return type;
@@ -594,7 +631,7 @@ Ext.define('PVE.Utils', { statics: {
        var prefix = farray[0];
        var text = farray[1];
        if (prefix) {
-           return prefix + ' ' + id + ' - ' + text; 
+           return prefix + ' ' + id + ' - ' + text;
        }
        return text;
     },
@@ -637,7 +674,7 @@ Ext.define('PVE.Utils', { statics: {
        return "<div class='pve-bar-wrap'>" + text + "<div class='pve-bar-border'>" +
            "<div class='pve-bar-inner' style='width:" + per + "%;'></div>" +
            "</div></div>";
-       
+
     },
 
     format_cpu_bar: function(per1, per2, text) {
@@ -645,7 +682,7 @@ Ext.define('PVE.Utils', { statics: {
        return "<div class='pve-bar-border'>" +
            "<div class='pve-bar-inner' style='width:" + per1 + "%;'></div>" +
            "<div class='pve-bar-inner2' style='width:" + per2 + "%;'></div>" +
-           "<div class='pve-bar-text'>" + text + "</div>" + 
+           "<div class='pve-bar-text'>" + text + "</div>" +
            "</div>";
     },
 
@@ -657,7 +694,7 @@ Ext.define('PVE.Utils', { statics: {
 
        return "<div class='pve-largebar-border'>" +
            "<div class='pve-largebar-inner' style='width:" + per + "%;'></div>" +
-           "<div class='pve-largebar-text'>" + text + "</div>" + 
+           "<div class='pve-largebar-text'>" + text + "</div>" +
            "</div>";
     },
 
@@ -679,7 +716,7 @@ Ext.define('PVE.Utils', { statics: {
 
        if (days) {
            var ds = days > 1 ? PVE.Utils.daysText : PVE.Utils.dayText;
-           return days.toString() + ' ' + ds + ' ' + 
+           return days.toString() + ' ' + ds + ' ' +
                hours_str + ':' + mins_str + ':' + ut_str;
        } else {
            return hours_str + ':' + mins_str + ':' + ut_str;
@@ -687,7 +724,7 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     format_duration_short: function(ut) {
-       
+
        if (ut < 60) {
            return ut.toString() + 's';
        }
@@ -703,11 +740,13 @@ Ext.define('PVE.Utils', { statics: {
        }
 
        var days = ut / 86400;
-       return days.toFixed(0) + 'd';   
+       return days.toFixed(0) + 'd';
     },
 
     yesText: gettext('Yes'),
     noText: gettext('No'),
+    enabledText: gettext('Enabled'),
+    disabledText: gettext('Disabled'),
     noneText: gettext('none'),
     errorText: gettext('Error'),
     unknownText: gettext('Unknown'),
@@ -725,6 +764,8 @@ Ext.define('PVE.Utils', { statics: {
     vztmplText: gettext('Container template'),
     isoImageText: gettext('ISO image'),
     containersText: gettext('Container'),
+    stateText: gettext('State'),
+    groupText: gettext('Group'),
 
     format_expire: function(date) {
        if (!date) {
@@ -778,6 +819,24 @@ Ext.define('PVE.Utils', { statics: {
        return !value ? PVE.Utils.yesText : PVE.Utils.noText;
     },
 
+    format_enabled_toggle: function(value) {
+       return value ? PVE.Utils.enabledText :PVE.Utils.disabledText;
+    },
+
+    format_ha: function(value) {
+       var text = PVE.Utils.format_boolean(value.managed);
+
+       if (value.managed) {
+           text += ', ' + PVE.Utils.stateText + ': ';
+           text += value.state || PVE.Utils.noneText;
+
+           text += ', ' +  PVE.Utils.groupText + ': ';
+           text += value.group || PVE.Utils.noneText;
+       }
+
+       return text;
+    },
+
     format_content_types: function(value) {
        var cta = [];
 
@@ -803,8 +862,8 @@ Ext.define('PVE.Utils', { statics: {
        if (Ext.isNumber(data.channel) &&
            Ext.isNumber(data.id) &&
            Ext.isNumber(data.lun)) {
-           return "CH " + 
-               Ext.String.leftPad(data.channel,2, '0') + 
+           return "CH " +
+               Ext.String.leftPad(data.channel,2, '0') +
                " ID " + data.id + " LUN " + data.lun;
        }
        return data.volid.replace(/^.*:(.*\/)?/,'');
@@ -825,7 +884,7 @@ Ext.define('PVE.Utils', { statics: {
        if (!Ext.isNumeric(maxcpu) && (maxcpu >= 1)) {
            return '';
        }
-       
+
        var per = value * 100;
 
        return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
@@ -841,16 +900,57 @@ Ext.define('PVE.Utils', { statics: {
        return PVE.Utils.format_size(value);
     },
 
+    render_bandwidth: function(value) {
+       if (!Ext.isNumeric(value)) {
+           return '';
+       }
+
+       return PVE.Utils.format_size(value) + '/s';
+    },
+
     render_timestamp: function(value, metaData, record, rowIndex, colIndex, store) {
        var servertime = new Date(value * 1000);
        return Ext.Date.format(servertime, 'Y-m-d H:i:s');
     },
 
+    render_timestamp_human_readable: function(value) {
+       return Ext.Date.format(new Date(value * 1000), 'l d F Y H:i:s');
+    },
+
+    calculate_mem_usage: function(data) {
+       if (!Ext.isNumeric(data.mem) ||
+           data.maxmem === 0 ||
+           data.uptime < 1) {
+           return -1;
+       }
+
+       return (data.mem / data.maxmem);
+    },
+
+    render_mem_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
+       if (!Ext.isNumeric(value) || value === -1) {
+           return '';
+       }
+       if (value > 1 ) {
+           // we got no percentage but bytes
+           var mem = value;
+           var maxmem = record.data.maxmem;
+           if (!record.data.uptime ||
+               maxmem === 0 ||
+               !Ext.isNumeric(mem)) {
+               return '';
+           }
+
+           return ((mem*100)/maxmem).toFixed(1) + " %";
+       }
+       return (value*100).toFixed(1) + " %";
+    },
+
     render_mem_usage: function(value, metaData, record, rowIndex, colIndex, store) {
 
        var mem = value;
        var maxmem = record.data.maxmem;
-       
+
        if (!record.data.uptime) {
            return '';
        }
@@ -859,23 +959,43 @@ Ext.define('PVE.Utils', { statics: {
            return '';
        }
 
-       var per = (mem * 100) / maxmem;
+       return PVE.Utils.render_size(value);
+    },
+
+    calculate_disk_usage: function(data) {
+
+       if (!Ext.isNumeric(data.disk) ||
+           data.type === 'qemu' ||
+           (data.type === 'lxc' && data.uptime === 0) ||
+           data.maxdisk === 0) {
+           return -1;
+       }
+
+       return (data.disk / data.maxdisk);
+    },
 
-       return per.toFixed(1) + '%';
+    render_disk_usage_percent: function(value, metaData, record, rowIndex, colIndex, store) {
+       if (!Ext.isNumeric(value) || value === -1) {
+           return '';
+       }
+
+       return (value * 100).toFixed(1) + " %";
     },
 
     render_disk_usage: function(value, metaData, record, rowIndex, colIndex, store) {
 
        var disk = value;
        var maxdisk = record.data.maxdisk;
+       var type = record.data.type;
 
-       if (!(Ext.isNumeric(disk) && maxdisk)) {
+       if (!Ext.isNumeric(disk) ||
+           type === 'qemu' ||
+           maxdisk === 0 ||
+           (type === 'lxc' && record.data.uptime === 0)) {
            return '';
        }
 
-       var per = (disk * 100) / maxdisk;
-
-       return per.toFixed(1) + '%';
+       return PVE.Utils.render_size(value);
     },
 
     render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
@@ -910,11 +1030,16 @@ Ext.define('PVE.Utils', { statics: {
            }
        } else if (value === 'node') {
            if (record.data.running) {
-               gridcls = '-online'
+               gridcls = '-online';
            }
        }
 
-       var fa = '<i class="fa fa-fw x-fa-grid' + gridcls  +  ' fa-' + icon  + '"></i> '
+       // overwrite anything else
+       if (record.data.hastate === 'error') {
+           gridcls = '-offline';
+       }
+
+       var fa = '<i class="fa fa-fw x-fa-grid' + gridcls  +  ' fa-' + icon  + '"></i> ';
        return fa + value;
     },
 
@@ -925,7 +1050,7 @@ Ext.define('PVE.Utils', { statics: {
        if (uptime === undefined) {
            return '';
        }
-       
+
        if (uptime <= 0) {
            return '-';
        }
@@ -937,13 +1062,43 @@ Ext.define('PVE.Utils', { statics: {
        return PVE.Utils.support_level_hash[value] || '-';
     },
 
-    render_upid: function(value, metaData, record) { 
+    render_upid: function(value, metaData, record) {
        var type = record.data.type;
        var id = record.data.id;
 
        return PVE.Utils.format_task_description(type, id);
     },
 
+    /* render functions for new status panel */
+
+    render_usage: function(val) {
+       return (val*100).toFixed(2) + '%';
+    },
+
+    render_cpu_usage: function(val, max) {
+       return Ext.String.format(gettext('{0}% of {1}') +
+           ' ' + gettext('CPU(s)'), (val*100).toFixed(2), max);
+    },
+
+    render_size_usage: function(val, max) {
+       if (max === 0) {
+           return gettext('N/A');
+       }
+       return (val*100/max).toFixed(2) + '% '+ '(' +
+           Ext.String.format(gettext('{0} of {1}'),
+           PVE.Utils.render_size(val), PVE.Utils.render_size(max)) + ')';
+    },
+
+    /* this is different for nodes */
+    render_node_cpu_usage: function(value, record) {
+       return PVE.Utils.render_cpu_usage(value, record.cpus);
+    },
+
+    /* this is different for nodes */
+    render_node_size_usage: function(record) {
+       return PVE.Utils.render_size_usage(record.used, record.total);
+    },
+
     dialog_title: function(subject, create, isAdd) {
        if (create) {
            if (isAdd) {
@@ -957,10 +1112,10 @@ Ext.define('PVE.Utils', { statics: {
     },
 
     windowHostname: function() {
-       return window.location.hostname.replace(IP6_bracket_match,
+       return window.location.hostname.replace(PVE.Utils.IP6_bracket_match,
             function(m, addr, offset, original) { return addr; });
     },
+
     openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) {
        var dv = PVE.Utils.defaultViewer(allowSpice);
        PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname);
@@ -1063,13 +1218,13 @@ Ext.define('PVE.Utils', { statics: {
                });
                var url = 'data:application/x-virt-viewer;charset=UTF-8,' +
                    encodeURIComponent(raw);
-                   
+
                downloadWithName(url, "pve-spice.vv");
            }
        });
     },
 
-    // comp.setLoading() is buggy in ExtJS 4.0.7, so we 
+    // comp.setLoading() is buggy in ExtJS 4.0.7, so we
     // use el.mask() instead
     setErrorMask: function(comp, msg) {
        var el = comp.el;
@@ -1115,7 +1270,138 @@ Ext.define('PVE.Utils', { statics: {
            }
            PVE.Utils.setErrorMask(me, msg);
        });
-    }
+    },
+
+    openTreeConsole: function(tree, record, item, index, e) {
+       e.stopEvent();
+       var nodename = record.data.node;
+       var vmid = record.data.vmid;
+       var vmname = record.data.name;
+       if (record.data.type === 'qemu' && !record.data.template) {
+           PVE.Utils.API2Request({
+               url: '/nodes/' + nodename + '/qemu/' + vmid + '/status/current',
+               failure: function(response, opts) {
+                   Ext.Msg.alert('Error', response.htmlStatus);
+               },
+               success: function(response, opts) {
+                   var allowSpice = response.result.data.spice;
+                   PVE.Utils.openDefaultConsoleWindow(allowSpice, 'kvm', vmid, nodename, vmname);
+               }
+           });
+       } else if (record.data.type === 'lxc' && !record.data.template) {
+           PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname);
+       }
+    },
+
+    // test automation helper
+    call_menu_handler: function(menu, text) {
 
-}});
+       var list = menu.query('menuitem');
+
+       Ext.Array.each(list, function(item) {
+           if (item.text === text) {
+               if (item.handler) {
+                   item.handler();
+                   return 1;
+               } else {
+                   return undefined;
+               }
+           }
+       });
+    },
+
+    createCmdMenu: function(v, record, item, index, event) {
+       event.stopEvent();
+       if (!(v instanceof Ext.tree.View)) {
+           v.select(record);
+       }
+       var menu;
+
+       if (record.data.type === 'qemu' && !record.data.template) {
+           menu = Ext.create('PVE.qemu.CmdMenu', {
+               pveSelNode: record
+           });
+       } else if (record.data.type === 'qemu' && record.data.template) {
+           menu = Ext.create('PVE.qemu.TemplateMenu', {
+               pveSelNode: record
+           });
+       } else if (record.data.type === 'lxc' && !record.data.template) {
+           menu = Ext.create('PVE.lxc.CmdMenu', {
+               pveSelNode: record
+           });
+       } else if (record.data.type === 'lxc' && record.data.template) {
+           /* since clone does not work reliably, disable for now
+           menu = Ext.create('PVE.lxc.TemplateMenu', {
+               pveSelNode: record
+           });
+           */
+           return;
+
+       } else if (record.data.type === 'node' ){
+           menu = Ext.create('PVE.node.CmdMenu', {
+               nodename: record.data.node
+           });
+
+       } else {
+           return;
+       }
+
+       menu.showAt(event.getXY());
+    }},
+
+    // helper for deleting field which are set to there default values
+    delete_if_default: function(values, fieldname, default_val, create) {
+       if (values[fieldname] === '' || values[fieldname] === default_val) {
+           if (!create) {
+               if (values['delete']) {
+                   values['delete'] += ',' + fieldname;
+               } else {
+                   values['delete'] = fieldname;
+               }
+           }
+
+           delete values[fieldname];
+       }
+    },
+
+    singleton: true,
+    constructor: function() {
+       var me = this;
+       Ext.apply(me, me.utilities);
+
+       var IPV4_OCTET = "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])";
+       var IPV4_REGEXP = "(?:(?:" + IPV4_OCTET + "\\.){3}" + IPV4_OCTET + ")";
+       var IPV6_H16 = "(?:[0-9a-fA-F]{1,4})";
+       var IPV6_LS32 = "(?:(?:" + IPV6_H16 + ":" + IPV6_H16 + ")|" + IPV4_REGEXP + ")";
+
+
+       me.IP4_match = new RegExp("^(?:" + IPV4_REGEXP + ")$");
+       me.IP4_cidr_match = new RegExp("^(?:" + IPV4_REGEXP + ")\/([0-9]{1,2})$");
+
+       var IPV6_REGEXP = "(?:" +
+           "(?:(?:"                                                  + "(?:" + IPV6_H16 + ":){6})" + IPV6_LS32 + ")|" +
+           "(?:(?:"                                         +   "::" + "(?:" + IPV6_H16 + ":){5})" + IPV6_LS32 + ")|" +
+           "(?:(?:(?:"                           + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){4})" + IPV6_LS32 + ")|" +
+           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,1}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){3})" + IPV6_LS32 + ")|" +
+           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,2}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){2})" + IPV6_LS32 + ")|" +
+           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,3}" + IPV6_H16 + ")?::" + "(?:" + IPV6_H16 + ":){1})" + IPV6_LS32 + ")|" +
+           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,4}" + IPV6_H16 + ")?::" +                         ")" + IPV6_LS32 + ")|" +
+           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,5}" + IPV6_H16 + ")?::" +                         ")" + IPV6_H16  + ")|" +
+           "(?:(?:(?:(?:" + IPV6_H16 + ":){0,7}" + IPV6_H16 + ")?::" +                         ")"             + ")"  +
+           ")";
+
+       me.IP6_match = new RegExp("^(?:" + IPV6_REGEXP + ")$");
+       me.IP6_cidr_match = new RegExp("^(?:" + IPV6_REGEXP + ")\/([0-9]{1,3})$");
+       me.IP6_bracket_match = new RegExp("^\\[(" + IPV6_REGEXP + ")\\]");
+
+       me.IP64_match = new RegExp("^(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + ")$");
+
+       var DnsName_REGEXP = "(?:(([a-zA-Z0-9]([a-zA-Z0-9\\-]*[a-zA-Z0-9])?)\\.)*([A-Za-z0-9]([A-Za-z0-9\\-]*[A-Za-z0-9])?))";
+       me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$");
+
+       me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(:\\d+)?$");
+       me.HostPortBrackets_match = new RegExp("^\\[(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](:\\d+)?$");
+       me.IP6_dotnotation_match = new RegExp("^" + IPV6_REGEXP + "(\\.\\d+)?$");
+    }
+});