// Some configuration values are complex strings -
// so we need parsers/generators for them.
-Ext.define('PVE.Parser', { statics: {
+Ext.define('PVE.Parser', {
+ statics: {
// this class only contains static functions
+ printACME: function(value) {
+ if (Ext.isArray(value.domains)) {
+ value.domains = value.domains.join(';');
+ }
+ return PVE.Parser.printPropertyString(value);
+ },
+
parseACME: function(value) {
if (!value) {
- return;
+ return {};
}
var res = {};
},
printQemuNetwork: function(net) {
-
var netstr = net.model;
if (net.macaddr) {
netstr += "=" + net.macaddr;
},
printQemuDrive: function(drive) {
-
var drivestr = drive.file;
Ext.Object.each(drive, function(key, value) {
errors = true;
return false; // break
}
- if (match_res[1] === 'bridge'){
+ if (match_res[1] === 'bridge') {
var bridgevlanf = match_res[2];
var bridge_res = bridgevlanf.match(/^(vmbr(\d+))(v(\d+))?(f)?$/);
if (!bridge_res) {
}
data.bridge = bridge_res[1];
data.tag = bridge_res[4];
- /*jslint confusion: true*/
data.firewall = bridge_res[5] ? 1 : 0;
- /*jslint confusion: false*/
} else {
data[match_res[1]] = match_res[2];
}
Ext.Object.each(netif, function(iface, data) {
var tmparray = [];
- Ext.Array.each(['ifname', 'mac', 'bridge', 'host_ifname' , 'host_mac', 'mac_filter', 'tag', 'firewall'], function(key) {
+ Ext.Array.each(['ifname', 'mac', 'bridge', 'host_ifname', 'host_mac', 'mac_filter', 'tag', 'firewall'], function(key) {
var value = data[key];
- if (key === 'bridge'){
- if(data.tag){
+ if (key === 'bridge') {
+ if (data.tag) {
value = value + 'v' + data.tag;
}
- if (data.firewall){
+ if (data.firewall) {
value = value + 'f';
}
}
if (value) {
tmparray.push(key + '=' + value);
}
-
});
netarray.push(tmparray.join(','));
});
}
});
- /*jslint confusion: true*/
if (data.rate > 0) {
tmparray.push('rate=' + data.rate);
}
- /*jslint confusion: false*/
return tmparray.join(',');
},
},
parseQemuSmbios1: function(value) {
- var res = value.split(',').reduce(function (accumulator, currentValue) {
+ var res = value.split(',').reduce(function(accumulator, currentValue) {
var splitted = currentValue.split(new RegExp("=(.+)"));
accumulator[splitted[0]] = splitted[1];
return accumulator;
},
printQemuSmbios1: function(data) {
-
var datastr = '';
var base64 = false;
Ext.Object.each(data, function(key, value) {
},
parseTfaType: function(value) {
- /*jslint confusion: true*/
var match;
if (!value || !value.length) {
return undefined;
return {
type: m[1],
key: m[2],
- comment: m[3]
+ comment: m[3],
};
}
if (m[2].match(typere)) {
options: m[1],
type: m[2],
key: m[3],
- comment: m[4]
+ comment: m[4],
};
}
return null;
- }
-}});
+ },
+
+ parseACMEPluginData: function(data) {
+ let res = {};
+ let extradata = [];
+ data.split('\n').forEach((line) => {
+ // capture everything after the first = as value
+ let [key, value] = line.split(/=(.+)/);
+ if (value !== undefined) {
+ res[key] = value;
+ } else {
+ extradata.push(line);
+ }
+ });
+ return [res, extradata];
+ },
+}
+});