summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dague <sean@dague.net>2017-02-10 17:01:42 -0500
committerSean Dague <sean@dague.net>2017-02-10 17:01:42 -0500
commitcf9093ec580806d973a11220dd8a87f3d5b95ad7 (patch)
treef411a21a960ef1353466c4337cda58e945b02d0e
parentde46354ed3eb8ef7489e368d0995c36e218a8d33 (diff)
rename set_local_raw to set_local0.2.0
set_local_raw is the new set_local, adjust the code to use the better name. Change-Id: I0f16ca647ada37049bdaf570b4695a73b60007ec
Notes
Notes (review): Code-Review+2: Sean Dague <sean@dague.net> Workflow+1: Sean Dague <sean@dague.net> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 13 Feb 2017 12:19:56 +0000 Reviewed-on: https://review.openstack.org/432476 Project: openstack/devstack-tools Branch: refs/heads/master
-rw-r--r--devstack/cmd.py4
-rw-r--r--devstack/dsconf.py17
-rw-r--r--devstack/tests/test_localconf_set_local.py8
3 files changed, 8 insertions, 21 deletions
diff --git a/devstack/cmd.py b/devstack/cmd.py
index 837866b..5c97523 100644
--- a/devstack/cmd.py
+++ b/devstack/cmd.py
@@ -43,11 +43,11 @@ def extract_config(local_conf, args):
43 43
44 44
45def setlc(local_conf, args): 45def setlc(local_conf, args):
46 local_conf.set_local(args.name, args.value) 46 local_conf.set_local("%s=%s" % (args.name, args.value))
47 47
48 48
49def setlc_raw(local_conf, args): 49def setlc_raw(local_conf, args):
50 local_conf.set_raw(" ".join(args.items)) 50 local_conf.set_local(" ".join(args.items))
51 51
52 52
53def setlc_conf(local_conf, args): 53def setlc_conf(local_conf, args):
diff --git a/devstack/dsconf.py b/devstack/dsconf.py
index 8b4d6f3..217db1c 100644
--- a/devstack/dsconf.py
+++ b/devstack/dsconf.py
@@ -209,7 +209,7 @@ class LocalConf(object):
209 if not done: 209 if not done:
210 func(writer, None) 210 func(writer, None)
211 211
212 def set_local_raw(self, line): 212 def set_local(self, line):
213 if not os.path.exists(self.fname): 213 if not os.path.exists(self.fname):
214 with open(self.fname, "w+") as writer: 214 with open(self.fname, "w+") as writer:
215 writer.write("[[local|localrc]]\n") 215 writer.write("[[local|localrc]]\n")
@@ -292,20 +292,7 @@ class LocalConf(object):
292 for group, conf in groups: 292 for group, conf in groups:
293 if group == "local": 293 if group == "local":
294 for line in lc._section(group, conf): 294 for line in lc._section(group, conf):
295 self.set_local_raw(line) 295 self.set_local(line)
296 # if line.startswith('#'):
297 # continue
298 # m = re.match(r"([^#=\s]+)\s*\=\s*(.+)", line)
299
300 # if m:
301 # self.set_local(m.group(1), m.group(2))
302 # elif re.match("(enable|disable)", line):
303 # # special case appending enable* disable*
304 # # function lines
305 # self.set_local_raw(line)
306 # else:
307 # print("SKIPPING ``%s`` from '%s'" %
308 # (line.lstrip(), lcfile))
309 else: 296 else:
310 for section, name, value in lc._conf(group, conf): 297 for section, name, value in lc._conf(group, conf):
311 self.set(group, conf, section, name, value) 298 self.set(group, conf, section, name, value)
diff --git a/devstack/tests/test_localconf_set_local.py b/devstack/tests/test_localconf_set_local.py
index 8e9f019..8ba6003 100644
--- a/devstack/tests/test_localconf_set_local.py
+++ b/devstack/tests/test_localconf_set_local.py
@@ -90,22 +90,22 @@ class TestLcSet(testtools.TestCase):
90 90
91 def test_set_new(self): 91 def test_set_new(self):
92 conf = dsconf.LocalConf(self._path) 92 conf = dsconf.LocalConf(self._path)
93 conf.set_local_raw("g=2") 93 conf.set_local("g=2")
94 with open(self._path) as f: 94 with open(self._path) as f:
95 content = f.read() 95 content = f.read()
96 self.assertEqual(content, RESULT1) 96 self.assertEqual(content, RESULT1)
97 97
98 def test_set_existing(self): 98 def test_set_existing(self):
99 conf = dsconf.LocalConf(self._path) 99 conf = dsconf.LocalConf(self._path)
100 conf.set_local_raw("a=2") 100 conf.set_local("a=2")
101 with open(self._path) as f: 101 with open(self._path) as f:
102 content = f.read() 102 content = f.read()
103 self.assertEqual(content, RESULT2) 103 self.assertEqual(content, RESULT2)
104 104
105 def test_set_raw(self): 105 def test_set_raw(self):
106 conf = dsconf.LocalConf(self._path) 106 conf = dsconf.LocalConf(self._path)
107 conf.set_local_raw("enable_plugin foo http://foo branch") 107 conf.set_local("enable_plugin foo http://foo branch")
108 conf.set_local_raw("enable_plugin bar http://foo branch") 108 conf.set_local("enable_plugin bar http://foo branch")
109 with open(self._path) as f: 109 with open(self._path) as f:
110 content = f.read() 110 content = f.read()
111 self.assertEqual(content, RESULT3) 111 self.assertEqual(content, RESULT3)