summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dague <sean@dague.net>2017-01-17 15:57:40 -0500
committerSean Dague <sean@dague.net>2017-01-17 15:57:40 -0500
commit2c8054020bec7f43cb4a7de3ac05a87f3b9d0b83 (patch)
treef16cbcf65a778637869486d679774701644af166
parentdae9f3be8d03feafef4b63a8b19771789d659608 (diff)
add the ability for raw line insert during merge0.1.3
Some localrc stanzas, like enable/disable* need to come over during merge. These lines will not have an = in them.
-rw-r--r--devstack/dsconf.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/devstack/dsconf.py b/devstack/dsconf.py
index 3cd4336..1466b51 100644
--- a/devstack/dsconf.py
+++ b/devstack/dsconf.py
@@ -229,6 +229,17 @@ class LocalConf(object):
229 writer.write("%s=%s\n" % (name, value)) 229 writer.write("%s=%s\n" % (name, value))
230 self._at_insert_point_local(name, _do_set) 230 self._at_insert_point_local(name, _do_set)
231 231
232 def set_local_raw(self, line):
233 if not os.path.exists(self.fname):
234 with open(self.fname, "w+") as writer:
235 writer.write("[[local|localrc]]\n")
236 writer.write("%s" % line)
237 return
238
239 def _do_set(writer, no_line):
240 writer.write("%s" % line)
241 self._at_insert_point_local(line, _do_set)
242
232 def _at_insert_point(self, group, conf, section, name, func): 243 def _at_insert_point(self, group, conf, section, name, func):
233 temp = tempfile.NamedTemporaryFile(mode='r') 244 temp = tempfile.NamedTemporaryFile(mode='r')
234 shutil.copyfile(self.fname, temp.name) 245 shutil.copyfile(self.fname, temp.name)
@@ -301,9 +312,16 @@ class LocalConf(object):
301 for group, conf in groups: 312 for group, conf in groups:
302 if group == "local": 313 if group == "local":
303 for line in lc._section(group, conf): 314 for line in lc._section(group, conf):
304 m = re.match(r"(\w+)\s*\=\s*(.+)", line) 315 if line.startswith('#'):
316 continue
317 m = re.match(r"([^#=\s]+)\s*\=\s*(.+)", line)
318
305 if m: 319 if m:
306 self.set_local(m.group(1), m.group(2)) 320 self.set_local(m.group(1), m.group(2))
321 elif re.match("(enable|disable)", line):
322 # special case appending enable* disable*
323 # function lines
324 self.set_local_raw(line)
307 else: 325 else:
308 print("SKIPPING ``%s`` from '%s'" % (line.lstrip(), lcfile)) 326 print("SKIPPING ``%s`` from '%s'" % (line.lstrip(), lcfile))
309 else: 327 else: