[pve-devel] [PATCH manager 2/4] parser: parseLxcMountPoint, printLxcMountPoint

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Feb 22 14:33:40 CET 2016


---
 www/manager/Parser.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/www/manager/Parser.js b/www/manager/Parser.js
index f6f5cf0..550e2aa 100644
--- a/www/manager/Parser.js
+++ b/www/manager/Parser.js
@@ -267,6 +267,62 @@ Ext.define('PVE.Parser', { statics: {
 	return tmparray.join(',');
     },
 
+    parseLxcMountPoint: function(value) {
+	if (!value) {
+	    return;
+	}
+
+	var res = {};
+
+	var errors = false;
+	Ext.Array.each(value.split(','), function(p) {
+	    if (!p || p.match(/^\s*$/)) {
+		return; // continue
+	    }
+	    var match_res = p.match(/^([a-z_]+)=(\S+)$/);
+	    if (!match_res) {
+		if (!p.match(/\=/)) {
+		    res.file = p;
+		    return; // continue
+		}
+		errors = true;
+		return false; // break
+	    }
+	    var k = match_res[1];
+	    if (k === 'volume') {
+		k = 'file';
+	    }
+
+	    if (Ext.isDefined(res[k])) {
+		errors = true;
+		return false; // break
+	    }
+
+	    var v = match_res[2];
+
+	    res[k] = v;
+	});
+
+	if (errors || !res.file) {
+	    return;
+	}
+
+	return res;
+    },
+
+    printLxcMountPoint: function(mp) {
+	var drivestr = mp.file;
+
+	Ext.Object.each(mp, function(key, value) {
+	    if (!Ext.isDefined(value) || key === 'file') {
+		return; // continue
+	    }
+	    drivestr += ',' + key + '=' + value;
+	});
+
+	return drivestr;
+    },
+
     parseStartup: function(value) {
 	if (value === undefined) {
 	    return;
-- 
2.1.4





More information about the pve-devel mailing list