Merge lp:~simpoir/landscape-charm/1682105_revisit_config into lp:~landscape/landscape-charm/trunk
- 1682105_revisit_config
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Simon Poirier | ||||||||
Approved revision: | 406 | ||||||||
Merged at revision: | 408 | ||||||||
Proposed branch: | lp:~simpoir/landscape-charm/1682105_revisit_config | ||||||||
Merge into: | lp:~landscape/landscape-charm/trunk | ||||||||
Diff against target: |
374 lines (+225/-21) 5 files modified
config.yaml (+23/-0) lib/callbacks/scripts.py (+43/-12) lib/callbacks/tests/test_scripts.py (+144/-7) lib/services.py (+7/-2) lib/tests/stubs.py (+8/-0) |
||||||||
To merge this branch: | bzr merge lp:~simpoir/landscape-charm/1682105_revisit_config | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
🤖 Landscape Builder | test results | Approve | |
Kevin Nasto | Approve | ||
Review via email:
|
Commit message
Make proxy, system-email and root-url configurations updatable through the charm config.
Description of the change
Adds a few configuration to the charm.
Those were previously only updatable from the UI (proxy, system-email, root-url) or on bootstrap.
Requires changes which are fix-commited to landscape/trunk, for it to do anything.
Testing:
I have repackaged 19.10 with the trunk patch to actually be able to test this branch.
Trying to change those conf with the current 19.10 ppa will do nothing (the branch checks if the flag exists)
download https:/
juju deploy ./bundle.yml
juju config landscape-server system-
log to the ui, check the settings tab.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
🤖 Landscape Builder (landscape-builder) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
🤖 Landscape Builder (landscape-builder) wrote : | # |
- 405. By Simon Poirier
-
lint
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
🤖 Landscape Builder (landscape-builder) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
🤖 Landscape Builder (landscape-builder) wrote : | # |
Command: make ci-test
Result: Success
Revno: 405
Branch: lp:~simpoir/landscape-charm/1682105_revisit_config
Jenkins: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Kevin Nasto (silverdrake11) wrote : | # |
LGTM except for the typo in the yaml
- 406. By Simon Poirier
-
typo
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
🤖 Landscape Builder (landscape-builder) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
🤖 Landscape Builder (landscape-builder) wrote : | # |
Command: make ci-test
Result: Success
Revno: 406
Branch: lp:~simpoir/landscape-charm/1682105_revisit_config
Jenkins: https:/
Preview Diff
1 | === modified file 'config.yaml' | |||
2 | --- config.yaml 2021-11-09 09:20:31 +0000 | |||
3 | +++ config.yaml 2021-12-08 22:56:37 +0000 | |||
4 | @@ -99,6 +99,11 @@ | |||
5 | 99 | IP of the first related HAproxy unit will be used instead. | 99 | IP of the first related HAproxy unit will be used instead. |
6 | 100 | type: string | 100 | type: string |
7 | 101 | default: "" | 101 | default: "" |
8 | 102 | system-email: | ||
9 | 103 | type: string | ||
10 | 104 | description: | | ||
11 | 105 | The address emails from Landscape will appear to come from. | ||
12 | 106 | default: "" | ||
13 | 102 | ssl-cert: | 107 | ssl-cert: |
14 | 103 | type: string | 108 | type: string |
15 | 104 | description: | | 109 | description: | |
16 | @@ -117,6 +122,24 @@ | |||
17 | 117 | description: | | 122 | description: | |
18 | 118 | The SMTP server to use to deliver outgoing mail. | 123 | The SMTP server to use to deliver outgoing mail. |
19 | 119 | default: "" | 124 | default: "" |
20 | 125 | http-proxy: | ||
21 | 126 | default: | ||
22 | 127 | type: string | ||
23 | 128 | description: | | ||
24 | 129 | The http proxy URL Landscape will use. If left blank, the | ||
25 | 130 | model-config value will be used. | ||
26 | 131 | https-proxy: | ||
27 | 132 | default: | ||
28 | 133 | type: string | ||
29 | 134 | description: | | ||
30 | 135 | The https proxy Landscape will use. If left blank, the model-config | ||
31 | 136 | value will be used. | ||
32 | 137 | no-proxy: | ||
33 | 138 | default: | ||
34 | 139 | type: string | ||
35 | 140 | description: | | ||
36 | 141 | Comma separated list of hosts for which no proxy should be used. | ||
37 | 142 | If left blank, the model-config value will be used. | ||
38 | 120 | site-name: | 143 | site-name: |
39 | 121 | type: string | 144 | type: string |
40 | 122 | default: '' | 145 | default: '' |
41 | 123 | 146 | ||
42 | === modified file 'lib/callbacks/scripts.py' | |||
43 | --- lib/callbacks/scripts.py 2019-07-10 19:02:28 +0000 | |||
44 | +++ lib/callbacks/scripts.py 2021-12-08 22:56:37 +0000 | |||
45 | @@ -1,4 +1,3 @@ | |||
46 | 1 | import os | ||
47 | 2 | import subprocess | 1 | import subprocess |
48 | 3 | 2 | ||
49 | 4 | from charmhelpers.core import hookenv | 3 | from charmhelpers.core import hookenv |
50 | @@ -14,12 +13,15 @@ | |||
51 | 14 | # Database relation keys for which, in case of change, a restart is not needed. | 13 | # Database relation keys for which, in case of change, a restart is not needed. |
52 | 15 | NO_RESTART_DB_RELATION_KEYS = {"allowed-units"} | 14 | NO_RESTART_DB_RELATION_KEYS = {"allowed-units"} |
53 | 16 | 15 | ||
54 | 16 | CONFIG_ONLY_FLAG = "--configure-lds-only" | ||
55 | 17 | |||
56 | 17 | 18 | ||
57 | 18 | class ScriptCallback(ManagerCallback): | 19 | class ScriptCallback(ManagerCallback): |
58 | 19 | """Callback class for invoking Landscape scripts.""" | 20 | """Callback class for invoking Landscape scripts.""" |
59 | 20 | 21 | ||
61 | 21 | def __init__(self, subprocess=subprocess): | 22 | def __init__(self, subprocess=subprocess, hookenv=hookenv): |
62 | 22 | self._subprocess = subprocess | 23 | self._subprocess = subprocess |
63 | 24 | self._hookenv = hookenv | ||
64 | 23 | 25 | ||
65 | 24 | def _run(self, name, options=()): | 26 | def _run(self, name, options=()): |
66 | 25 | """Run the script with the given name and options.""" | 27 | """Run the script with the given name and options.""" |
67 | @@ -34,12 +36,21 @@ | |||
68 | 34 | This will invoke the schema script with the --bootstrap flag, if it hasn't | 36 | This will invoke the schema script with the --bootstrap flag, if it hasn't |
69 | 35 | been called yet. | 37 | been called yet. |
70 | 36 | """ | 38 | """ |
71 | 39 | |||
72 | 37 | def __call__(self, manager, service_name, event_name): | 40 | def __call__(self, manager, service_name, event_name): |
73 | 41 | self._schema_doc = self._subprocess.check_output([SCHEMA_SCRIPT, "-h"]) | ||
74 | 38 | if not manager.was_ready(service_name): | 42 | if not manager.was_ready(service_name): |
75 | 39 | options = ["--bootstrap"] | 43 | options = ["--bootstrap"] |
76 | 40 | options.extend(self._get_proxy_options()) | 44 | options.extend(self._get_proxy_options()) |
77 | 41 | self._run(SCHEMA_SCRIPT, options) | 45 | self._run(SCHEMA_SCRIPT, options) |
78 | 42 | 46 | ||
79 | 47 | if CONFIG_ONLY_FLAG in self._schema_doc: | ||
80 | 48 | options = [CONFIG_ONLY_FLAG] | ||
81 | 49 | options.extend(self._get_proxy_options()) | ||
82 | 50 | options.extend(self._get_settings_options()) | ||
83 | 51 | if len(options) > 1: | ||
84 | 52 | self._run(SCHEMA_SCRIPT, options) | ||
85 | 53 | |||
86 | 43 | def _get_proxy_options(self): | 54 | def _get_proxy_options(self): |
87 | 44 | """Return the HTTP proxy options to set. | 55 | """Return the HTTP proxy options to set. |
88 | 45 | 56 | ||
89 | @@ -48,15 +59,39 @@ | |||
90 | 48 | at the environment variables that Juju sets for us. | 59 | at the environment variables that Juju sets for us. |
91 | 49 | """ | 60 | """ |
92 | 50 | options = [] | 61 | options = [] |
93 | 62 | config = self._hookenv.config() | ||
94 | 51 | 63 | ||
97 | 52 | help_output = self._subprocess.check_output([SCHEMA_SCRIPT, "-h"]) | 64 | if "--with-http-proxy" in self._schema_doc: |
96 | 53 | if "--with-http-proxy" in help_output: | ||
98 | 54 | # Forward any proxy configuration set in the environment | 65 | # Forward any proxy configuration set in the environment |
99 | 66 | model_proxy = self._hookenv.env_proxy_settings() or {} | ||
100 | 55 | for proxy_variable in ("http_proxy", "https_proxy", "no_proxy"): | 67 | for proxy_variable in ("http_proxy", "https_proxy", "no_proxy"): |
105 | 56 | if proxy_variable in os.environ: | 68 | model_proxy_value = model_proxy.get(proxy_variable, "") |
106 | 57 | options.append("--with-%s=%s" % ( | 69 | |
107 | 58 | proxy_variable.replace("_", "-"), | 70 | # XXX There is no charm hook for model-config changes, |
108 | 59 | os.environ[proxy_variable])) | 71 | # so updating proxies has to be done using charm config. |
109 | 72 | # See juju issue (LP: #1835050). | ||
110 | 73 | proxy_variable = proxy_variable.replace("_", "-") | ||
111 | 74 | proxy_value = config.get(proxy_variable) | ||
112 | 75 | if proxy_value is None: | ||
113 | 76 | proxy_value = model_proxy_value | ||
114 | 77 | options.append("--with-{}".format(proxy_variable)) | ||
115 | 78 | options.append(proxy_value) | ||
116 | 79 | |||
117 | 80 | return options | ||
118 | 81 | |||
119 | 82 | def _get_settings_options(self): | ||
120 | 83 | """Return options for updating charm-managed settings.""" | ||
121 | 84 | config = self._hookenv.config() | ||
122 | 85 | options = [] | ||
123 | 86 | root_url = config.get("root-url") | ||
124 | 87 | if root_url: | ||
125 | 88 | options.append("--with-root-url") | ||
126 | 89 | options.append(root_url) | ||
127 | 90 | |||
128 | 91 | system_email = config.get("system-email") | ||
129 | 92 | if system_email: | ||
130 | 93 | options.append("--with-system-email") | ||
131 | 94 | options.append(system_email) | ||
132 | 60 | 95 | ||
133 | 61 | return options | 96 | return options |
134 | 62 | 97 | ||
135 | @@ -64,10 +99,6 @@ | |||
136 | 64 | class LSCtl(ScriptCallback): | 99 | class LSCtl(ScriptCallback): |
137 | 65 | """Call the lsctl script to start or stop services.""" | 100 | """Call the lsctl script to start or stop services.""" |
138 | 66 | 101 | ||
139 | 67 | def __init__(self, subprocess=subprocess, hookenv=hookenv): | ||
140 | 68 | super(LSCtl, self).__init__(subprocess=subprocess) | ||
141 | 69 | self._hookenv = hookenv | ||
142 | 70 | |||
143 | 71 | def __call__(self, manager, service_name, event_name): | 102 | def __call__(self, manager, service_name, event_name): |
144 | 72 | current_status, current_status_message = self._hookenv.status_get() | 103 | current_status, current_status_message = self._hookenv.status_get() |
145 | 73 | action_status_message = "" | 104 | action_status_message = "" |
146 | 74 | 105 | ||
147 | === modified file 'lib/callbacks/tests/test_scripts.py' | |||
148 | --- lib/callbacks/tests/test_scripts.py 2019-07-15 20:01:06 +0000 | |||
149 | +++ lib/callbacks/tests/test_scripts.py 2021-12-08 22:56:37 +0000 | |||
150 | @@ -3,7 +3,7 @@ | |||
151 | 3 | from charmhelpers.core.services.base import ServiceManager | 3 | from charmhelpers.core.services.base import ServiceManager |
152 | 4 | 4 | ||
153 | 5 | from lib.paths import LSCTL, SCHEMA_SCRIPT | 5 | from lib.paths import LSCTL, SCHEMA_SCRIPT |
155 | 6 | from lib.callbacks.scripts import SchemaBootstrap, LSCtl | 6 | from lib.callbacks.scripts import SchemaBootstrap, LSCtl, CONFIG_ONLY_FLAG |
156 | 7 | from lib.utils import update_persisted_data | 7 | from lib.utils import update_persisted_data |
157 | 8 | from lib.tests.helpers import HookenvTest | 8 | from lib.tests.helpers import HookenvTest |
158 | 9 | from lib.tests.stubs import SubprocessStub | 9 | from lib.tests.stubs import SubprocessStub |
159 | @@ -19,7 +19,8 @@ | |||
160 | 19 | self.subprocess = SubprocessStub() | 19 | self.subprocess = SubprocessStub() |
161 | 20 | self.subprocess.add_fake_executable(SCHEMA_SCRIPT) | 20 | self.subprocess.add_fake_executable(SCHEMA_SCRIPT) |
162 | 21 | self.manager = ServiceManager(services=[{"service": "landscape"}]) | 21 | self.manager = ServiceManager(services=[{"service": "landscape"}]) |
164 | 22 | self.callback = SchemaBootstrap(subprocess=self.subprocess) | 22 | self.callback = SchemaBootstrap( |
165 | 23 | subprocess=self.subprocess, hookenv=self.hookenv) | ||
166 | 23 | 24 | ||
167 | 24 | def test_options(self): | 25 | def test_options(self): |
168 | 25 | """ | 26 | """ |
169 | @@ -56,18 +57,154 @@ | |||
170 | 56 | self.callback(self.manager, "landscape", None) | 57 | self.callback(self.manager, "landscape", None) |
171 | 57 | self.assertEqual( | 58 | self.assertEqual( |
172 | 58 | ["/usr/bin/landscape-schema", "--bootstrap", | 59 | ["/usr/bin/landscape-schema", "--bootstrap", |
176 | 59 | "--with-http-proxy=http://foo:3128", | 60 | "--with-http-proxy", "http://foo:3128", |
177 | 60 | "--with-https-proxy=http://bar:3128", | 61 | "--with-https-proxy", "http://bar:3128", |
178 | 61 | "--with-no-proxy=localhost"], | 62 | "--with-no-proxy", "localhost"], |
179 | 62 | self.subprocess.calls[1][0]) | 63 | self.subprocess.calls[1][0]) |
180 | 63 | 64 | ||
181 | 64 | def test_was_ready(self): | 65 | def test_was_ready(self): |
182 | 65 | """ | 66 | """ |
184 | 66 | If the services was ready, the schema script is not invoked again. | 67 | If the services was ready, the schema bootstrap is not invoked again. |
185 | 67 | """ | 68 | """ |
186 | 68 | self.manager.save_ready("landscape") | 69 | self.manager.save_ready("landscape") |
187 | 69 | self.callback(self.manager, "landscape", None) | 70 | self.callback(self.manager, "landscape", None) |
189 | 70 | self.assertEqual([], self.subprocess.calls) | 71 | self.assertEqual([ |
190 | 72 | (['/usr/bin/landscape-schema', '-h'], {})], self.subprocess.calls) | ||
191 | 73 | |||
192 | 74 | def test_update_config(self): | ||
193 | 75 | """Updating config are updated in Landscape.""" | ||
194 | 76 | self.subprocess.add_fake_executable( | ||
195 | 77 | SCHEMA_SCRIPT, args=["-h"], stdout="Usage: " + CONFIG_ONLY_FLAG) | ||
196 | 78 | |||
197 | 79 | self.hookenv.hook = "config-changed" | ||
198 | 80 | config = self.hookenv.config() | ||
199 | 81 | config["root-url"] = "https://old.sad/" | ||
200 | 82 | config.save() | ||
201 | 83 | self.manager.save_ready("landscape") | ||
202 | 84 | |||
203 | 85 | config["root-url"] = "https://happy.new/" | ||
204 | 86 | self.callback(self.manager, "landscape", None) | ||
205 | 87 | self.assertEqual([ | ||
206 | 88 | (["/usr/bin/landscape-schema", "-h"], {}), | ||
207 | 89 | (["/usr/bin/landscape-schema", CONFIG_ONLY_FLAG, "--with-root-url", | ||
208 | 90 | "https://happy.new/"], {}), | ||
209 | 91 | ], self.subprocess.calls) | ||
210 | 92 | |||
211 | 93 | def test_update_config_unsupported_flag(self): | ||
212 | 94 | """Configuration is NOOP if the configure-lds flag is not supported.""" | ||
213 | 95 | self.subprocess.add_fake_executable( | ||
214 | 96 | SCHEMA_SCRIPT, args=["-h"], stdout="Usage: --spam") | ||
215 | 97 | |||
216 | 98 | self.hookenv.hook = "config-changed" | ||
217 | 99 | config = self.hookenv.config() | ||
218 | 100 | config["root-url"] = "https://old.sad/" | ||
219 | 101 | config.save() | ||
220 | 102 | self.manager.save_ready("landscape") | ||
221 | 103 | config["root-url"] = "https://happy.new/" | ||
222 | 104 | |||
223 | 105 | self.callback(self.manager, "landscape", None) | ||
224 | 106 | self.assertEqual([ | ||
225 | 107 | (["/usr/bin/landscape-schema", "-h"], {}), | ||
226 | 108 | ], self.subprocess.calls) | ||
227 | 109 | |||
228 | 110 | def test_bootstrap_and_configure(self): | ||
229 | 111 | """Configuration is done after bootstrap, if config values exist.""" | ||
230 | 112 | self.subprocess.add_fake_executable( | ||
231 | 113 | SCHEMA_SCRIPT, args=["-h"], stdout="Usage: " + CONFIG_ONLY_FLAG) | ||
232 | 114 | |||
233 | 115 | self.hookenv.hook = "config-changed" | ||
234 | 116 | config = self.hookenv.config() | ||
235 | 117 | config["system-email"] = "noreply@spam" | ||
236 | 118 | config.save() | ||
237 | 119 | config["system-email"] = "noreply@scape" | ||
238 | 120 | |||
239 | 121 | self.callback(self.manager, "landscape", None) | ||
240 | 122 | self.assertEqual([ | ||
241 | 123 | (["/usr/bin/landscape-schema", "-h"], {}), | ||
242 | 124 | (["/usr/bin/landscape-schema", "--bootstrap"], {}), | ||
243 | 125 | (["/usr/bin/landscape-schema", CONFIG_ONLY_FLAG, | ||
244 | 126 | "--with-system-email", "noreply@scape"], {}), | ||
245 | 127 | ], self.subprocess.calls) | ||
246 | 128 | |||
247 | 129 | def test_inherit_model_proxy(self): | ||
248 | 130 | """Proxy config is inherited from the model if unset on charm.""" | ||
249 | 131 | self.subprocess.add_fake_executable( | ||
250 | 132 | SCHEMA_SCRIPT, args=["-h"], | ||
251 | 133 | stdout="Usage: --with-http-proxy " + CONFIG_ONLY_FLAG) | ||
252 | 134 | self.hookenv.hook = "config-changed" | ||
253 | 135 | config = self.hookenv.config() | ||
254 | 136 | config["http-proxy"] = "spam" | ||
255 | 137 | config["https-proxy"] = "spam" | ||
256 | 138 | config["no-proxy"] = "spam" | ||
257 | 139 | config.save() | ||
258 | 140 | del config["http-proxy"] | ||
259 | 141 | del config["https-proxy"] | ||
260 | 142 | del config["no-proxy"] | ||
261 | 143 | self.useFixture(EnvironmentVariable("http_proxy", "http://foo:3128")) | ||
262 | 144 | self.useFixture(EnvironmentVariable("https_proxy", "http://bar:3128")) | ||
263 | 145 | self.useFixture(EnvironmentVariable("no_proxy", "localhost")) | ||
264 | 146 | self.manager.save_ready("landscape") | ||
265 | 147 | |||
266 | 148 | self.callback(self.manager, "landscape", None) | ||
267 | 149 | self.assertEqual([ | ||
268 | 150 | (["/usr/bin/landscape-schema", "-h"], {}), | ||
269 | 151 | (["/usr/bin/landscape-schema", CONFIG_ONLY_FLAG, | ||
270 | 152 | "--with-http-proxy", "http://foo:3128", | ||
271 | 153 | "--with-https-proxy", "http://bar:3128", | ||
272 | 154 | "--with-no-proxy", "localhost"], {}), | ||
273 | 155 | ], self.subprocess.calls) | ||
274 | 156 | |||
275 | 157 | def test_change_model_proxy(self): | ||
276 | 158 | """Proxy config override model proxy if configured on charm.""" | ||
277 | 159 | self.subprocess.add_fake_executable( | ||
278 | 160 | SCHEMA_SCRIPT, args=["-h"], | ||
279 | 161 | stdout="Usage: --with-http-proxy " + CONFIG_ONLY_FLAG) | ||
280 | 162 | self.hookenv.hook = "config-changed" | ||
281 | 163 | config = self.hookenv.config() | ||
282 | 164 | self.useFixture(EnvironmentVariable("http_proxy", "spam")) | ||
283 | 165 | self.useFixture(EnvironmentVariable("https_proxy", "spam")) | ||
284 | 166 | self.useFixture(EnvironmentVariable("no_proxy", "spam")) | ||
285 | 167 | self.manager.save_ready("landscape") | ||
286 | 168 | config["http-proxy"] = "http://foo:3128" | ||
287 | 169 | config["https-proxy"] = "http://bar:3128" | ||
288 | 170 | config["no-proxy"] = "localhost" | ||
289 | 171 | |||
290 | 172 | self.callback(self.manager, "landscape", None) | ||
291 | 173 | self.assertEqual([ | ||
292 | 174 | (["/usr/bin/landscape-schema", "-h"], {}), | ||
293 | 175 | (["/usr/bin/landscape-schema", CONFIG_ONLY_FLAG, | ||
294 | 176 | "--with-http-proxy", "http://foo:3128", | ||
295 | 177 | "--with-https-proxy", "http://bar:3128", | ||
296 | 178 | "--with-no-proxy", "localhost"], {}), | ||
297 | 179 | ], self.subprocess.calls) | ||
298 | 180 | |||
299 | 181 | def test_unset_model_proxy(self): | ||
300 | 182 | """Proxy config can explicitly unset model proxy.""" | ||
301 | 183 | self.subprocess.add_fake_executable( | ||
302 | 184 | SCHEMA_SCRIPT, args=["-h"], | ||
303 | 185 | stdout="Usage: --with-http-proxy " + CONFIG_ONLY_FLAG) | ||
304 | 186 | self.hookenv.hook = "config-changed" | ||
305 | 187 | config = self.hookenv.config() | ||
306 | 188 | self.useFixture(EnvironmentVariable("http_proxy", "spam")) | ||
307 | 189 | self.useFixture(EnvironmentVariable("https_proxy", "spam")) | ||
308 | 190 | self.useFixture(EnvironmentVariable("no_proxy", "spam")) | ||
309 | 191 | self.manager.save_ready("landscape") | ||
310 | 192 | config["http-proxy"] = "" | ||
311 | 193 | config["https-proxy"] = "" | ||
312 | 194 | config["no-proxy"] = "" | ||
313 | 195 | |||
314 | 196 | self.callback(self.manager, "landscape", None) | ||
315 | 197 | self.assertEqual([ | ||
316 | 198 | (["/usr/bin/landscape-schema", "-h"], {}), | ||
317 | 199 | (["/usr/bin/landscape-schema", CONFIG_ONLY_FLAG, | ||
318 | 200 | "--with-http-proxy", "", | ||
319 | 201 | "--with-https-proxy", "", | ||
320 | 202 | "--with-no-proxy", ""], {}), | ||
321 | 203 | ], self.subprocess.calls) | ||
322 | 204 | |||
323 | 205 | def test_reconfigure_noop(self): | ||
324 | 206 | """Nothing happens if there is no proxy and no config change.""" | ||
325 | 207 | # TODO | ||
326 | 71 | 208 | ||
327 | 72 | 209 | ||
328 | 73 | class LSCtlTest(HookenvTest): | 210 | class LSCtlTest(HookenvTest): |
329 | 74 | 211 | ||
330 | === modified file 'lib/services.py' | |||
331 | --- lib/services.py 2021-11-09 09:20:31 +0000 | |||
332 | +++ lib/services.py 2021-12-08 22:56:37 +0000 | |||
333 | @@ -86,7 +86,8 @@ | |||
334 | 86 | subprocess=self._subprocess), | 86 | subprocess=self._subprocess), |
335 | 87 | EnsureConfigDir(paths=self._paths), | 87 | EnsureConfigDir(paths=self._paths), |
336 | 88 | WriteCustomSSLCertificate(paths=self._paths), | 88 | WriteCustomSSLCertificate(paths=self._paths), |
338 | 89 | SchemaBootstrap(subprocess=self._subprocess), | 89 | SchemaBootstrap( |
339 | 90 | subprocess=self._subprocess, hookenv=self._hookenv), | ||
340 | 90 | WriteLicenseFile(host=self._host, paths=self._paths), | 91 | WriteLicenseFile(host=self._host, paths=self._paths), |
341 | 91 | ConfigureSMTP( | 92 | ConfigureSMTP( |
342 | 92 | hookenv=self._hookenv, subprocess=self._subprocess), | 93 | hookenv=self._hookenv, subprocess=self._subprocess), |
343 | @@ -95,4 +96,8 @@ | |||
344 | 95 | ], | 96 | ], |
345 | 96 | "start": LSCtl(subprocess=self._subprocess, hookenv=self._hookenv), | 97 | "start": LSCtl(subprocess=self._subprocess, hookenv=self._hookenv), |
346 | 97 | }]) | 98 | }]) |
348 | 98 | manager.manage() | 99 | try: |
349 | 100 | manager.manage() | ||
350 | 101 | except Exception as e: | ||
351 | 102 | self._hookenv.log(str(e), level=hookenv.ERROR) | ||
352 | 103 | raise | ||
353 | 99 | 104 | ||
354 | === modified file 'lib/tests/stubs.py' | |||
355 | --- lib/tests/stubs.py 2021-11-10 05:34:36 +0000 | |||
356 | +++ lib/tests/stubs.py 2021-12-08 22:56:37 +0000 | |||
357 | @@ -1,3 +1,4 @@ | |||
358 | 1 | import os | ||
359 | 1 | import subprocess | 2 | import subprocess |
360 | 2 | 3 | ||
361 | 3 | from charmhelpers.core.hookenv import Config | 4 | from charmhelpers.core.hookenv import Config |
362 | @@ -33,6 +34,13 @@ | |||
363 | 33 | def config(self): | 34 | def config(self): |
364 | 34 | return self._config | 35 | return self._config |
365 | 35 | 36 | ||
366 | 37 | def env_proxy_settings(self): | ||
367 | 38 | return { | ||
368 | 39 | k: os.environ[k] | ||
369 | 40 | for k in ("http_proxy", "https_proxy", "no_proxy") | ||
370 | 41 | if k in os.environ | ||
371 | 42 | } or None | ||
372 | 43 | |||
373 | 36 | def relations_of_type(self, reltype): | 44 | def relations_of_type(self, reltype): |
374 | 37 | return self.relations.get(reltype, None) | 45 | return self.relations.get(reltype, None) |
375 | 38 | 46 |
Command: make ci-test /jenkins. canonical. com/landscape/ job/latch- test-xenial/ 1476/
Result: Fail
Revno: 404
Branch: lp:~simpoir/landscape-charm/1682105_revisit_config
Jenkins: https:/