This reverts commit 6ff21acf4c4d4ef08bbef419ba582cade4da8da7.
This commit has broken config options with colons in them.
The following is a sample configuration that no longer works:
[[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]
[restproxy]
server_ssl=False
servers=10.211.1.9:80
server_ssl=False
With the above config and the code present that this reverts,
the 'servers' option will come out blank.
Change-Id: I328852d2d941605051a1bf5eaf0f7674191f8c48
| ... | ... |
@@ -119,33 +119,6 @@ function ini_has_option {
|
| 119 | 119 |
[ -n "$line" ] |
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 |
-# Add another config line for a multi-line option. |
|
| 123 |
-# It's normally called after iniset of the same option and assumes |
|
| 124 |
-# that the section already exists. |
|
| 125 |
-# |
|
| 126 |
-# Note that iniset_multiline requires all the 'lines' to be supplied |
|
| 127 |
-# in the argument list. Doing that will cause incorrect configuration |
|
| 128 |
-# if spaces are used in the config values. |
|
| 129 |
-# |
|
| 130 |
-# iniadd_literal config-file section option value |
|
| 131 |
-function iniadd_literal {
|
|
| 132 |
- local xtrace=$(set +o | grep xtrace) |
|
| 133 |
- set +o xtrace |
|
| 134 |
- local file=$1 |
|
| 135 |
- local section=$2 |
|
| 136 |
- local option=$3 |
|
| 137 |
- local value=$4 |
|
| 138 |
- |
|
| 139 |
- [[ -z $section || -z $option ]] && return |
|
| 140 |
- |
|
| 141 |
- # Add it |
|
| 142 |
- sed -i -e "/^\[$section\]/ a\\ |
|
| 143 |
-$option = $value |
|
| 144 |
-" "$file" |
|
| 145 |
- |
|
| 146 |
- $xtrace |
|
| 147 |
-} |
|
| 148 |
- |
|
| 149 | 122 |
# Set an option in an INI file |
| 150 | 123 |
# iniset config-file section option value |
| 151 | 124 |
function iniset {
|
| ... | ... |
@@ -86,11 +86,7 @@ function merge_config_file {
|
| 86 | 86 |
# having to do nasty quoting games |
| 87 | 87 |
get_meta_section $file $matchgroup $configfile | \ |
| 88 | 88 |
$CONFIG_AWK_CMD -v configfile=$configfile ' |
| 89 |
- BEGIN {
|
|
| 90 |
- section = "" |
|
| 91 |
- last_section = "" |
|
| 92 |
- section_count = 0 |
|
| 93 |
- } |
|
| 89 |
+ BEGIN { section = "" }
|
|
| 94 | 90 |
/^\[.+\]/ {
|
| 95 | 91 |
gsub("[][]", "", $1);
|
| 96 | 92 |
section=$1 |
| ... | ... |
@@ -110,48 +106,10 @@ function merge_config_file {
|
| 110 | 110 |
# need to strip leading & trailing whitespace from value |
| 111 | 111 |
sub(/^[ \t]*/, "", value) |
| 112 | 112 |
sub(/[ \t]*$/, "", value) |
| 113 |
- |
|
| 114 |
- # cfg_attr_count: number of config lines per [section, attr] |
|
| 115 |
- # cfg_attr: two dimensional array to keep all the config lines per [section, attr] |
|
| 116 |
- # cfg_section: keep the section names in the same order as they appear in local.conf |
|
| 117 |
- # cfg_sec_attr_name: keep the attr names in the same order as they appear in local.conf |
|
| 118 |
- if (! (section, attr) in cfg_attr_count) {
|
|
| 119 |
- if (section != last_section) {
|
|
| 120 |
- cfg_section[section_count++] = section |
|
| 121 |
- last_section = section |
|
| 122 |
- } |
|
| 123 |
- attr_count = cfg_sec_attr_count[section_count - 1]++ |
|
| 124 |
- cfg_sec_attr_name[section_count - 1][attr_count] = attr |
|
| 125 |
- |
|
| 126 |
- cfg_attr[section, attr][0] = value |
|
| 127 |
- cfg_attr_count[section, attr] = 1 |
|
| 128 |
- } else {
|
|
| 129 |
- lno = cfg_attr_count[section, attr]++ |
|
| 130 |
- cfg_attr[section, attr][lno] = value |
|
| 131 |
- } |
|
| 132 |
- } |
|
| 133 |
- END {
|
|
| 134 |
- # Process each section in order |
|
| 135 |
- for (sno = 0; sno < section_count; sno++) {
|
|
| 136 |
- section = cfg_section[sno] |
|
| 137 |
- # The ini routines simply append a config item immediately |
|
| 138 |
- # after the section header. To keep the same order as defined |
|
| 139 |
- # in local.conf, invoke the ini routines in the reverse order |
|
| 140 |
- for (attr_no = cfg_sec_attr_count[sno] - 1; attr_no >=0; attr_no--) {
|
|
| 141 |
- attr = cfg_sec_attr_name[sno][attr_no] |
|
| 142 |
- if (cfg_attr_count[section, attr] == 1) |
|
| 143 |
- print "iniset " configfile " " section " " attr " \x27" cfg_attr[section, attr][0] "\x27" |
|
| 144 |
- else {
|
|
| 145 |
- # For multiline, invoke the ini routines in the reverse order |
|
| 146 |
- count = cfg_attr_count[section, attr] |
|
| 147 |
- print "iniset " configfile " " section " " attr " \x27" cfg_attr[section, attr][count - 1] "\x27" |
|
| 148 |
- for (l = count -2; l >= 0; l--) |
|
| 149 |
- print "iniadd_literal " configfile " " section " " attr " \x27" cfg_attr[section, attr][l] "\x27" |
|
| 150 |
- } |
|
| 151 |
- } |
|
| 152 |
- } |
|
| 113 |
+ print "iniset " configfile " " section " " attr " \x27" value "\x27" |
|
| 153 | 114 |
} |
| 154 | 115 |
' | while read a; do eval "$a"; done |
| 116 |
+ |
|
| 155 | 117 |
} |
| 156 | 118 |
|
| 157 | 119 |
|
| ... | ... |
@@ -104,27 +104,6 @@ drivers = driver=python.import.path.Driver |
| 104 | 104 |
[DEFAULT] |
| 105 | 105 |
# next line has trailing space |
| 106 | 106 |
attr = strip_trailing_space |
| 107 |
- |
|
| 108 |
-[[test-multi-sections|test-multi-sections.conf]] |
|
| 109 |
-[sec-1] |
|
| 110 |
-cfg_item1 = abcd |
|
| 111 |
-cfg_item2 = efgh |
|
| 112 |
- |
|
| 113 |
-[sec-2] |
|
| 114 |
-cfg_item1 = abcd |
|
| 115 |
-cfg_item3 = /1/2/3/4:5 |
|
| 116 |
-cfg_item4 = end |
|
| 117 |
- |
|
| 118 |
-[sec-3] |
|
| 119 |
-cfg_item5 = 5555 |
|
| 120 |
-cfg_item6 = 6666 |
|
| 121 |
-cfg_item5 = 5555another |
|
| 122 |
- |
|
| 123 |
-[[test-multiline|test-multiline.conf]] |
|
| 124 |
-[multi] |
|
| 125 |
-cfg_item1 = "ab":"cd", "ef": "gh" |
|
| 126 |
-cfg_item1 = abcd |
|
| 127 |
-cfg_item2 = efgh |
|
| 128 | 107 |
EOF |
| 129 | 108 |
|
| 130 | 109 |
echo -n "get_meta_section_files: test0 doesn't exist: " |
| ... | ... |
@@ -206,39 +185,8 @@ VAL=$(cat test2a.conf) |
| 206 | 206 |
# iniset adds a blank line if it creates the file... |
| 207 | 207 |
EXPECT_VAL=" |
| 208 | 208 |
[ddd] |
| 209 |
-type = new |
|
| 210 |
-additional = true" |
|
| 211 |
-check_result "$VAL" "$EXPECT_VAL" |
|
| 212 |
- |
|
| 213 |
-echo -n "merge_config_file test-multi-sections: " |
|
| 214 |
-rm -f test-multi-sections.conf |
|
| 215 |
-merge_config_file test.conf test-multi-sections test-multi-sections.conf |
|
| 216 |
-VAL=$(cat test-multi-sections.conf) |
|
| 217 |
-EXPECT_VAL=' |
|
| 218 |
-[sec-1] |
|
| 219 |
-cfg_item1 = abcd |
|
| 220 |
-cfg_item2 = efgh |
|
| 221 |
- |
|
| 222 |
-[sec-2] |
|
| 223 |
-cfg_item1 = abcd |
|
| 224 |
-cfg_item3 = /1/2/3/4:5 |
|
| 225 |
-cfg_item4 = end |
|
| 226 |
- |
|
| 227 |
-[sec-3] |
|
| 228 |
-cfg_item5 = 5555 |
|
| 229 |
-cfg_item5 = 5555another |
|
| 230 |
-cfg_item6 = 6666' |
|
| 231 |
-check_result "$VAL" "$EXPECT_VAL" |
|
| 232 |
- |
|
| 233 |
-echo -n "merge_config_file test-multiline: " |
|
| 234 |
-rm -f test-multiline.conf |
|
| 235 |
-merge_config_file test.conf test-multiline test-multiline.conf |
|
| 236 |
-VAL=$(cat test-multiline.conf) |
|
| 237 |
-EXPECT_VAL=' |
|
| 238 |
-[multi] |
|
| 239 |
-cfg_item1 = "ab":"cd", "ef": "gh" |
|
| 240 |
-cfg_item1 = abcd |
|
| 241 |
-cfg_item2 = efgh' |
|
| 209 |
+additional = true |
|
| 210 |
+type = new" |
|
| 242 | 211 |
check_result "$VAL" "$EXPECT_VAL" |
| 243 | 212 |
|
| 244 | 213 |
echo -n "merge_config_group test2: " |
| ... | ... |
@@ -248,8 +196,8 @@ VAL=$(cat test2a.conf) |
| 248 | 248 |
# iniset adds a blank line if it creates the file... |
| 249 | 249 |
EXPECT_VAL=" |
| 250 | 250 |
[ddd] |
| 251 |
-type = new |
|
| 252 |
-additional = true" |
|
| 251 |
+additional = true |
|
| 252 |
+type = new" |
|
| 253 | 253 |
check_result "$VAL" "$EXPECT_VAL" |
| 254 | 254 |
|
| 255 | 255 |
echo -n "merge_config_group test2 no conf file: " |
| ... | ... |
@@ -320,5 +268,4 @@ attr = strip_trailing_space" |
| 320 | 320 |
check_result "$VAL" "$EXPECT_VAL" |
| 321 | 321 |
|
| 322 | 322 |
rm -f test.conf test1c.conf test2a.conf test-quote.conf test-space.conf test-equals.conf test-strip.conf |
| 323 |
-rm -f test-multiline.conf test-multi-sections.conf |
|
| 324 | 323 |
rm -rf test-etc |