[pve-devel] [PATCH manager 2/2] add HostList validator and check monhosts with it
Dominik Csapak
d.csapak at proxmox.com
Thu Jul 7 09:04:10 CEST 2016
this adds a vtype which splits the given string into a list by
; or , or space
and checks each individual entry if it is a dnsname
or valid ip
and make the rbd monhost input field use it
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
note: this patch is only really correct with the patch
'rbd: use address-list for monhost' from Wolfgang B
altough the check is better even without the storage
patch
www/manager6/Toolkit.js | 20 +++++++++++++++++++-
www/manager6/storage/RBDEdit.js | 1 +
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
index decaab6..2c0e966 100644
--- a/www/manager6/Toolkit.js
+++ b/www/manager6/Toolkit.js
@@ -101,7 +101,25 @@ Ext.apply(Ext.form.field.VTypes, {
pveMail: function(v) {
return (/^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,63}$/).test(v);
},
- pveMailText: gettext('Example') + ": user at example.com"
+ pveMailText: gettext('Example') + ": user at example.com",
+
+ HostList: function(v) {
+ var list = v.split(/[\ \,\;]+/);
+ var i;
+ for (i = 0; i < list.length; i++) {
+ if (list[i] == "") {
+ continue;
+ }
+
+ if (!IP64_match.test(list[i]) &&
+ !DnsName_match.test(list[i])) {
+ return false;
+ }
+ }
+
+ return true;
+ },
+ HostListText: gettext('Not a valid list of hosts')
});
// ExtJs 5-6 has an issue with caching
diff --git a/www/manager6/storage/RBDEdit.js b/www/manager6/storage/RBDEdit.js
index a38ea52..a046ec3 100644
--- a/www/manager6/storage/RBDEdit.js
+++ b/www/manager6/storage/RBDEdit.js
@@ -39,6 +39,7 @@ Ext.define('PVE.storage.RBDInputPanel', {
{
xtype: me.create ? 'textfield' : 'displayfield',
name: 'monhost',
+ vtype: 'HostList',
value: '',
fieldLabel: gettext('Monitor Host'),
allowBlank: false
--
2.1.4
More information about the pve-devel
mailing list