Merge lp:~frankban/juju-gui/bug-1229939-service-set into lp:juju-gui/experimental

Proposed by Francesco Banconi
Status: Rejected
Rejected by: Francesco Banconi
Proposed branch: lp:~frankban/juju-gui/bug-1229939-service-set
Merge into: lp:juju-gui/experimental
Diff against target: 211 lines (+50/-61)
6 files modified
app/store/env/go.js (+10/-10)
app/store/env/sandbox.js (+26/-35)
test/test_env_go.js (+6/-8)
test/test_inspector_settings.js (+1/-1)
test/test_sandbox_go.js (+4/-4)
test/test_service_config_view.js (+3/-3)
To merge this branch: bzr merge lp:~frankban/juju-gui/bug-1229939-service-set
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+187544@code.launchpad.net

Description of the change

Fix settings update in juju-core.

When sending ServiceSet requests, the GUI included
a Config parameter where juju-core expects an
Option one.
While I was looking at that code, I decided instead to
switch to the newer ServiceUpdate API call, which
handles both map[string]string and YAML settings.

QA:
- deploy and expose the GUI in a juju-core env;
- switch to this branch:
    juju set juju-gui juju-gui-source=lp:~frankban/juju-gui/bug-1229939-service-set
- try to change settings (e.g. juju-gui-debug);
- refresh.

The settings viewlet should reflect the changes and,
after a while (after config-changed runs),
the new settings should be applied.

To post a comment you must log in.
Revision history for this message
Francesco Banconi (frankban) wrote :

Reviewers: mp+187544_code.launchpad.net,

Message:
Please take a look.

Description:
Fix settings update in juju-core.

When sending ServiceSet requests, the GUI included
a Config parameter where juju-core expects an
Option one.
While I was looking at that code, I decided instead to
switch to the newer ServiceUpdate API call, which
handles both map[string]string and YAML settings.

QA:
- deploy and expose the GUI in a juju-core env;
- switch to this branch:
     juju set juju-gui
juju-gui-source=lp:~frankban/juju-gui/bug-1229939-service-set
- try to change settings (e.g. juju-gui-debug);
- refresh.

The settings viewlet should reflect the changes and,
after a while (after config-changed runs),
the new settings should be applied.

https://code.launchpad.net/~frankban/juju-gui/bug-1229939-service-set/+merge/187544

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/13900044/

Affected files (+52, -61 lines):
   A [revision details]
   M app/store/env/go.js
   M app/store/env/sandbox.js
   M test/test_env_go.js
   M test/test_inspector_settings.js
   M test/test_sandbox_go.js
   M test/test_service_config_view.js

Revision history for this message
Francesco Banconi (frankban) wrote :

Unmerged revisions

1087. By Francesco Banconi

Checkpoint.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/store/env/go.js'
2--- app/store/env/go.js 2013-09-13 21:49:15 +0000
3+++ app/store/env/go.js 2013-09-25 15:43:51 +0000
4@@ -1008,25 +1008,25 @@
5 (!Y.Lang.isValue(config) && !Y.Lang.isValue(data))) {
6 throw 'Exactly one of config and data must be provided';
7 }
8- var intermediateCallback, sendData;
9+ var intermediateCallback;
10 if (callback) {
11 // Capture the callback and serviceName. No context is passed.
12 intermediateCallback = Y.bind(this.handleServiceCalls, null,
13 callback, serviceName);
14 }
15- sendData = {
16- Type: 'Client',
17- Params: {ServiceName: serviceName}
18- };
19+ var params = {ServiceName: serviceName};
20 if (data) {
21- sendData.Request = 'ServiceSetYAML';
22- sendData.Params.ConfigYAML = data;
23+ params.SettingsYAML = data;
24 } else {
25 config = utils.removeUnchangedConfigOptions(config, serviceConfig);
26- sendData.Request = 'ServiceSet';
27- sendData.Params.Config = stringifyObjectValues(config);
28+ params.SettingsStrings = stringifyObjectValues(config);
29 }
30- this._send_rpc(sendData, intermediateCallback);
31+ var request = {
32+ Type: 'Client',
33+ Request: 'ServiceUpdate',
34+ Params: params
35+ };
36+ this._send_rpc(request, intermediateCallback);
37 },
38
39 /**
40
41=== modified file 'app/store/env/sandbox.js'
42--- app/store/env/sandbox.js 2013-09-18 18:15:19 +0000
43+++ app/store/env/sandbox.js 2013-09-25 15:43:51 +0000
44@@ -1126,42 +1126,33 @@
45 },
46
47 /**
48- Handle ServiceSet messages
49-
50- @method handleClientServiceSet
51- @param {Object} data The contents of the API arguments.
52- @param {Object} client The active ClientConnection.
53- @param {Object} state An instance of FakeBackend.
54- @return {undefined} Side effects only.
55- */
56- handleClientServiceSet: function(data, client, state) {
57- var result = state.setConfig(data.Params.ServiceName, data.Params.Config);
58- this._basicReceive(data, client, result);
59- },
60-
61- /**
62- Handle ServiceSetYAML messages
63-
64- @method handleClientServiceSetYAML
65- @param {Object} data The contents of the API arguments.
66- @param {Object} client The active ClientConnection.
67- @param {Object} state An instance of FakeBackend.
68- @return {undefined} Side effects only.
69- */
70- handleClientServiceSetYAML: function(data, client, state) {
71- var config = {};
72- try {
73- config = jsyaml.safeLoad(data.Params.ConfigYAML);
74- } catch (e) {
75- if (e instanceof jsyaml.YAMLException) {
76- this._basicReceive(data, client,
77- {error: 'Error parsing YAML.\n' + e});
78- return;
79- }
80- throw e;
81- }
82+ Handle ServiceUpdate messages.
83+
84+ @method handleClientServiceUpdate
85+ @param {Object} data The contents of the API arguments.
86+ @param {Object} client The active ClientConnection.
87+ @param {Object} state An instance of FakeBackend.
88+ @return {undefined} Side effects only.
89+ */
90+ handleClientServiceUpdate: function(data, client, state) {
91 var serviceName = data.Params.ServiceName;
92- var result = state.setConfig(serviceName, config[serviceName]);
93+ var settings;
94+ if (data.Params.SettingsYAML) {
95+ try {
96+ settings = jsyaml.safeLoad(data.Params.SettingsYAML);
97+ } catch (e) {
98+ if (e instanceof jsyaml.YAMLException) {
99+ this._basicReceive(data, client,
100+ {error: 'Error parsing YAML.\n' + e});
101+ return;
102+ }
103+ throw e;
104+ }
105+ settings = settings[serviceName];
106+ } else {
107+ settings = data.Params.SettingsStrings;
108+ }
109+ var result = state.setConfig(serviceName, settings);
110 this._basicReceive(data, client, result);
111 },
112
113
114=== modified file 'test/test_env_go.js'
115--- test/test_env_go.js 2013-09-16 15:57:12 +0000
116+++ test/test_env_go.js 2013-09-25 15:43:51 +0000
117@@ -843,15 +843,13 @@
118 });
119 msg = conn.last_message();
120 var expected = {
121+ RequestId: msg.RequestId,
122 Type: 'Client',
123+ Request: 'ServiceUpdate',
124 Params: {
125 ServiceName: 'mysql',
126- Config: {
127- 'cfg-key': 'cfg-val'
128- }
129- },
130- Request: 'ServiceSet',
131- RequestId: msg.RequestId
132+ SettingsStrings: {'cfg-key': 'cfg-val'}
133+ }
134 };
135 assert.deepEqual(expected, msg);
136 });
137@@ -865,10 +863,10 @@
138 var expected = {
139 RequestId: msg.RequestId,
140 Type: 'Client',
141- Request: 'ServiceSetYAML',
142+ Request: 'ServiceUpdate',
143 Params: {
144 ServiceName: 'mysql',
145- ConfigYAML: data
146+ SettingsYAML: data
147 }
148 };
149 assert.deepEqual(expected, msg);
150
151=== modified file 'test/test_inspector_settings.js'
152--- test/test_inspector_settings.js 2013-09-20 17:29:21 +0000
153+++ test/test_inspector_settings.js 2013-09-25 15:43:51 +0000
154@@ -326,7 +326,7 @@
155 input, inspector.viewletManager.viewlets.config);
156 button.simulate('click');
157 var message = env.ws.last_message();
158- assert.equal('foo', message.Params.Config.admins);
159+ assert.equal('foo', message.Params.SettingsStrings.admins);
160 // Send back a success message.
161 env.ws.msg({RequestId: message.RequestId});
162 assert.equal(button.getHTML(), 'Save changes');
163
164=== modified file 'test/test_sandbox_go.js'
165--- test/test_sandbox_go.js 2013-09-18 18:15:19 +0000
166+++ test/test_sandbox_go.js 2013-09-25 15:43:51 +0000
167@@ -516,10 +516,10 @@
168 state.deploy('cs:precise/wordpress-15', function() {
169 var data = {
170 Type: 'Client',
171- Request: 'ServiceSet',
172+ Request: 'ServiceUpdate',
173 Params: {
174 ServiceName: 'wordpress',
175- Config: { engine: 'apache' }
176+ SettingsStrings: { engine: 'apache' }
177 },
178 RequestId: 42
179 };
180@@ -564,10 +564,10 @@
181 state.deploy('cs:precise/wordpress-15', function() {
182 var data = {
183 Type: 'Client',
184- Request: 'ServiceSetYAML',
185+ Request: 'ServiceUpdate',
186 Params: {
187 ServiceName: 'wordpress',
188- ConfigYAML: 'wordpress:\n engine: apache'
189+ SettingsYAML: 'wordpress:\n engine: apache'
190 },
191 RequestId: 42
192 };
193
194=== modified file 'test/test_service_config_view.js'
195--- test/test_service_config_view.js 2013-09-17 13:27:43 +0000
196+++ test/test_service_config_view.js 2013-09-25 15:43:51 +0000
197@@ -161,11 +161,11 @@
198 view.saveConfig();
199 var message = conn.last_message();
200 var params = message.Params;
201- assert.equal('ServiceSet', message.Request);
202+ assert.equal('ServiceUpdate', message.Request);
203 assert.equal('mysql', params.ServiceName);
204- assert.equal('new value', params.Config.option0);
205+ assert.equal('new value', params.SettingsStrings.option0);
206 // undefined because it should only set the changed values
207- assert.equal(undefined, params.Config.option1);
208+ assert.equal(undefined, params.SettingsStrings.option1);
209 });
210
211 it('should reenable the "Update" button if RPC fails', function() {

Subscribers

People subscribed via source and target branches