Merge lp:~free.ekanayaka/landscape-client/client-api-bump into lp:~landscape/landscape-client/trunk
- client-api-bump
- Merge into trunk
Proposed by
Free Ekanayaka
Status: | Merged |
---|---|
Merge reported by: | Free Ekanayaka |
Merged at revision: | not available |
Proposed branch: | lp:~free.ekanayaka/landscape-client/client-api-bump |
Merge into: | lp:~landscape/landscape-client/trunk |
Diff against target: |
356 lines (+48/-38) 9 files modified
landscape/__init__.py (+11/-1) landscape/broker/exchange.py (+3/-3) landscape/broker/store.py (+2/-2) landscape/broker/tests/test_exchange.py (+8/-8) landscape/broker/tests/test_store.py (+6/-6) landscape/broker/transport.py (+3/-3) landscape/manager/tests/test_customgraph.py (+9/-9) landscape/manager/tests/test_shutdownmanager.py (+3/-3) landscape/monitor/tests/test_activeprocessinfo.py (+3/-3) |
To merge this branch: | bzr merge lp:~free.ekanayaka/landscape-client/client-api-bump |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thomas Herve (community) | Approve | ||
Sidnei da Silva (community) | Approve | ||
Review via email: mp+17884@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 196. By Free Ekanayaka
-
Add some comments to SERVER_API and CLIENT_API
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote : | # |
Thanks!
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'landscape/__init__.py' |
2 | --- landscape/__init__.py 2010-01-22 08:24:19 +0000 |
3 | +++ landscape/__init__.py 2010-01-22 13:14:13 +0000 |
4 | @@ -1,7 +1,17 @@ |
5 | DEBIAN_REVISION = "" |
6 | UPSTREAM_VERSION = "1.4.4" |
7 | VERSION = "%s%s" % (UPSTREAM_VERSION, DEBIAN_REVISION) |
8 | -API = "3.2" |
9 | + |
10 | +# The "server-api" field of outgoing messages will be set to this value, and |
11 | +# used by the server message system to lookup the correct MessageAPI adapter |
12 | +# for handling the messages sent by the client. Bump it when the schema of any |
13 | +# of the messages sent by the client changes in a backward-incompatible way. |
14 | +SERVER_API = "3.2" |
15 | + |
16 | +# The "client-api" field of outgoing messages will be set to this value, and |
17 | +# used by the server to know which schema do the message types accepted by the |
18 | +# client support. Bump it when the schema of an accepted message type changes. |
19 | +CLIENT_API = "3.3" |
20 | |
21 | from twisted.python import util |
22 | |
23 | |
24 | === modified file 'landscape/broker/exchange.py' |
25 | --- landscape/broker/exchange.py 2009-08-23 07:05:22 +0000 |
26 | +++ landscape/broker/exchange.py 2010-01-22 13:14:13 +0000 |
27 | @@ -7,7 +7,7 @@ |
28 | |
29 | from landscape.lib.message import got_next_expected, ANCIENT |
30 | from landscape.log import format_delta |
31 | -from landscape import API |
32 | +from landscape import SERVER_API, CLIENT_API |
33 | |
34 | |
35 | class MessageExchange(object): |
36 | @@ -266,9 +266,9 @@ |
37 | # missing API must be 2.0. |
38 | server_api = "2.0" |
39 | else: |
40 | - server_api = API |
41 | + server_api = SERVER_API |
42 | payload = {"server-api": server_api, |
43 | - "client-api": API, |
44 | + "client-api": CLIENT_API, |
45 | "sequence": store.get_sequence(), |
46 | "messages": messages, |
47 | "total-messages": total_messages, |
48 | |
49 | === modified file 'landscape/broker/store.py' |
50 | --- landscape/broker/store.py 2009-04-02 10:25:04 +0000 |
51 | +++ landscape/broker/store.py 2010-01-22 13:14:13 +0000 |
52 | @@ -8,7 +8,7 @@ |
53 | from landscape.lib import bpickle |
54 | from landscape.lib.persist import Persist |
55 | from landscape.lib.monitor import Monitor |
56 | -from landscape import API |
57 | +from landscape import SERVER_API |
58 | |
59 | |
60 | HELD = "h" |
61 | @@ -38,7 +38,7 @@ |
62 | and is entirely unrelated to the stored messages. |
63 | """ |
64 | |
65 | - api = API |
66 | + api = SERVER_API |
67 | |
68 | def __init__(self, persist, directory, directory_size=1000, |
69 | monitor_interval=60*60, get_time=time.time): |
70 | |
71 | === modified file 'landscape/broker/tests/test_exchange.py' |
72 | --- landscape/broker/tests/test_exchange.py 2009-08-23 07:05:22 +0000 |
73 | +++ landscape/broker/tests/test_exchange.py 2010-01-22 13:14:13 +0000 |
74 | @@ -1,5 +1,5 @@ |
75 | |
76 | -from landscape import API |
77 | +from landscape import SERVER_API, CLIENT_API |
78 | from landscape.lib.persist import Persist |
79 | from landscape.lib.hashlib import md5 |
80 | from landscape.schema import Message, Int |
81 | @@ -47,7 +47,7 @@ |
82 | messages = self.transport.payloads[0]["messages"] |
83 | self.assertEquals(messages, [{"type": "empty", |
84 | "timestamp": 0, |
85 | - "api": API}]) |
86 | + "api": SERVER_API}]) |
87 | |
88 | def test_send_urgent(self): |
89 | """ |
90 | @@ -423,9 +423,9 @@ |
91 | # the client API. |
92 | payload = self.transport.payloads[-1] |
93 | self.assertMessages(payload["messages"], []) |
94 | - self.assertEquals(payload.get("client-api"), API) |
95 | - self.assertEquals(payload.get("server-api"), API) |
96 | - self.assertEquals(self.transport.message_api, API) |
97 | + self.assertEquals(payload.get("client-api"), CLIENT_API) |
98 | + self.assertEquals(payload.get("server-api"), SERVER_API) |
99 | + self.assertEquals(self.transport.message_api, SERVER_API) |
100 | |
101 | self.mstore.add({"type": "a", "api": "1.0"}) |
102 | self.mstore.add({"type": "b", "api": "1.0"}) |
103 | @@ -442,7 +442,7 @@ |
104 | self.assertMessages(payload["messages"], |
105 | [{"type": "a", "api": "1.0"}, |
106 | {"type": "b", "api": "1.0"}]) |
107 | - self.assertEquals(payload.get("client-api"), API) |
108 | + self.assertEquals(payload.get("client-api"), CLIENT_API) |
109 | self.assertEquals(payload.get("server-api"), "1.0") |
110 | self.assertEquals(self.transport.message_api, "1.0") |
111 | |
112 | @@ -452,7 +452,7 @@ |
113 | self.assertMessages(payload["messages"], |
114 | [{"type": "c", "api": "1.1"}, |
115 | {"type": "d", "api": "1.1"}]) |
116 | - self.assertEquals(payload.get("client-api"), API) |
117 | + self.assertEquals(payload.get("client-api"), CLIENT_API) |
118 | self.assertEquals(payload.get("server-api"), "1.1") |
119 | self.assertEquals(self.transport.message_api, "1.1") |
120 | |
121 | @@ -462,7 +462,7 @@ |
122 | self.assertMessages(payload["messages"], |
123 | [{"type": "e", "api": None}, |
124 | {"type": "f", "api": None}]) |
125 | - self.assertEquals(payload.get("client-api"), API) |
126 | + self.assertEquals(payload.get("client-api"), CLIENT_API) |
127 | self.assertEquals(payload.get("server-api"), "2.0") |
128 | self.assertEquals(self.transport.message_api, "2.0") |
129 | |
130 | |
131 | === modified file 'landscape/broker/tests/test_store.py' |
132 | --- landscape/broker/tests/test_store.py 2009-08-07 22:36:33 +0000 |
133 | +++ landscape/broker/tests/test_store.py 2010-01-22 13:14:13 +0000 |
134 | @@ -8,7 +8,7 @@ |
135 | |
136 | from landscape.tests.helpers import LandscapeTest |
137 | from landscape.tests.mocker import ANY |
138 | -from landscape import API |
139 | +from landscape import SERVER_API |
140 | |
141 | |
142 | class MessageStoreTest(LandscapeTest): |
143 | @@ -123,7 +123,7 @@ |
144 | self.assertMessages(messages, |
145 | [{"type": "data", |
146 | "data": "A thing", |
147 | - "api": API}]) |
148 | + "api": SERVER_API}]) |
149 | |
150 | def test_max_pending(self): |
151 | for i in range(10): |
152 | @@ -260,7 +260,7 @@ |
153 | messages = self.store.get_pending_messages() |
154 | |
155 | self.assertEquals(messages, [{"type": "data", "data": "2", |
156 | - "api": API}]) |
157 | + "api": SERVER_API}]) |
158 | |
159 | self.store.set_pending_offset(len(messages)) |
160 | |
161 | @@ -291,10 +291,10 @@ |
162 | self.mocker.verify() |
163 | self.mocker.reset() |
164 | self.assertEquals(self.store.get_pending_messages(), |
165 | - [{"type": "data", "data": 1, "api": API}]) |
166 | + [{"type": "data", "data": 1, "api": SERVER_API}]) |
167 | |
168 | def test_api_attribute(self): |
169 | - self.assertEquals(self.store.api, API) |
170 | + self.assertEquals(self.store.api, SERVER_API) |
171 | new_api = "New API version!" |
172 | self.store.api = new_api |
173 | self.assertEquals(self.store.api, new_api) |
174 | @@ -302,7 +302,7 @@ |
175 | def test_default_api_on_messages(self): |
176 | self.store.add({"type": "empty"}) |
177 | self.assertEquals(self.store.get_pending_messages(), |
178 | - [{"type": "empty", "api": API}]) |
179 | + [{"type": "empty", "api": SERVER_API}]) |
180 | |
181 | def test_custom_api_on_store(self): |
182 | self.store.api = "X.Y" |
183 | |
184 | === modified file 'landscape/broker/transport.py' |
185 | --- landscape/broker/transport.py 2009-04-02 10:25:04 +0000 |
186 | +++ landscape/broker/transport.py 2010-01-22 13:14:13 +0000 |
187 | @@ -8,7 +8,7 @@ |
188 | from landscape.lib.fetch import fetch |
189 | from landscape.lib import bpickle |
190 | from landscape.log import format_delta |
191 | -from landscape import API, VERSION |
192 | +from landscape import SERVER_API, VERSION |
193 | |
194 | |
195 | class HTTPTransport(object): |
196 | @@ -40,7 +40,7 @@ |
197 | return (curl, fetch(self._url, post=True, data=payload, |
198 | headers=headers, cainfo=self._pubkey, curl=curl)) |
199 | |
200 | - def exchange(self, payload, computer_id=None, message_api=API): |
201 | + def exchange(self, payload, computer_id=None, message_api=SERVER_API): |
202 | """Exchange message data with the server. |
203 | |
204 | @param payload: The object to send, it must be L{bpickle}-compatible. |
205 | @@ -105,7 +105,7 @@ |
206 | def set_url(self, url): |
207 | self._url = url |
208 | |
209 | - def exchange(self, payload, computer_id=None, message_api=API): |
210 | + def exchange(self, payload, computer_id=None, message_api=SERVER_API): |
211 | self.payloads.append(payload) |
212 | self.computer_id = computer_id |
213 | self.message_api = message_api |
214 | |
215 | === modified file 'landscape/manager/tests/test_customgraph.py' |
216 | --- landscape/manager/tests/test_customgraph.py 2009-08-18 16:49:00 +0000 |
217 | +++ landscape/manager/tests/test_customgraph.py 2010-01-22 13:14:13 +0000 |
218 | @@ -5,7 +5,7 @@ |
219 | from twisted.internet.error import ProcessDone |
220 | from twisted.python.failure import Failure |
221 | |
222 | -from landscape import API |
223 | +from landscape import SERVER_API |
224 | |
225 | from landscape.manager.customgraph import CustomGraphPlugin |
226 | from landscape.manager.store import ManagerStore |
227 | @@ -456,7 +456,7 @@ |
228 | self.graph_manager.exchange() |
229 | self.assertMessages( |
230 | self.broker_service.message_store.get_pending_messages(), |
231 | - [{"api": API, |
232 | + [{"api": SERVER_API, |
233 | "data": {123: {"error": u"", |
234 | "script-hash": "e00a2f44dbc7b6710ce32af2348aec9b", |
235 | "values": []}}, |
236 | @@ -479,7 +479,7 @@ |
237 | self.graph_manager.exchange() |
238 | self.assertMessages( |
239 | self.broker_service.message_store.get_pending_messages(), |
240 | - [{"api": API, |
241 | + [{"api": SERVER_API, |
242 | "data": {}, |
243 | "timestamp": 0, |
244 | "type": "custom-graph"}]) |
245 | @@ -504,13 +504,13 @@ |
246 | self.graph_manager.exchange() |
247 | self.assertMessages( |
248 | self.broker_service.message_store.get_pending_messages(), |
249 | - [{"api": API, |
250 | + [{"api": SERVER_API, |
251 | "data": {123: {"error": u"", |
252 | "script-hash": "e00a2f44dbc7b6710ce32af2348aec9b", |
253 | "values": []}}, |
254 | "timestamp": 0, |
255 | "type": "custom-graph"}, |
256 | - {"api": API, |
257 | + {"api": SERVER_API, |
258 | "data": {123: {"error": u"", |
259 | "script-hash": "e00a2f44dbc7b6710ce32af2348aec9b", |
260 | "values": []}}, |
261 | @@ -538,13 +538,13 @@ |
262 | self.graph_manager.exchange() |
263 | self.assertMessages( |
264 | self.broker_service.message_store.get_pending_messages(), |
265 | - [{"api": API, |
266 | + [{"api": SERVER_API, |
267 | "data": {123: {"error": u"", |
268 | "script-hash": "e00a2f44dbc7b6710ce32af2348aec9b", |
269 | "values": []}}, |
270 | "timestamp": 0, |
271 | "type": "custom-graph"}, |
272 | - {"api": API, |
273 | + {"api": SERVER_API, |
274 | "data": {123: {"error": u"", |
275 | "script-hash": "d483816dc0fbb51ede42502a709b0e2a", |
276 | "values": []}}, |
277 | @@ -587,7 +587,7 @@ |
278 | self.graph_manager.exchange() |
279 | self.assertMessages( |
280 | self.broker_service.message_store.get_pending_messages(), |
281 | - [{"api": API, |
282 | + [{"api": SERVER_API, |
283 | "data": {123: {"error": u"", |
284 | "script-hash": |
285 | "991e15a81929c79fe1d243b2afd99c62", |
286 | @@ -629,7 +629,7 @@ |
287 | self.graph_manager.exchange() |
288 | self.assertMessages( |
289 | self.broker_service.message_store.get_pending_messages(), |
290 | - [{"api": API, "data": {}, "timestamp": 0, "type": |
291 | + [{"api": SERVER_API, "data": {}, "timestamp": 0, "type": |
292 | "custom-graph"}]) |
293 | return result.addCallback(check) |
294 | |
295 | |
296 | === modified file 'landscape/manager/tests/test_shutdownmanager.py' |
297 | --- landscape/manager/tests/test_shutdownmanager.py 2008-07-18 17:42:25 +0000 |
298 | +++ landscape/manager/tests/test_shutdownmanager.py 2010-01-22 13:14:13 +0000 |
299 | @@ -1,7 +1,7 @@ |
300 | from twisted.python.failure import Failure |
301 | from twisted.internet.error import ProcessTerminated |
302 | |
303 | -from landscape import API |
304 | +from landscape import SERVER_API |
305 | from landscape.manager.manager import SUCCEEDED, FAILED |
306 | from landscape.manager.shutdownmanager import ( |
307 | ShutdownManager, ShutdownProcessProtocol) |
308 | @@ -43,7 +43,7 @@ |
309 | self.assertTrue(self.broker_service.exchanger.is_urgent()) |
310 | self.assertEquals( |
311 | self.broker_service.message_store.get_pending_messages(), |
312 | - [{"type": "operation-result", "api": API, |
313 | + [{"type": "operation-result", "api": SERVER_API, |
314 | "operation-id": 100, "timestamp": 10, "status": SUCCEEDED, |
315 | "result-text": u"Data may arrive in batches."}]) |
316 | |
317 | @@ -80,7 +80,7 @@ |
318 | self.assertTrue(self.broker_service.exchanger.is_urgent()) |
319 | self.assertEquals( |
320 | self.broker_service.message_store.get_pending_messages(), |
321 | - [{"type": "operation-result", "api": API, |
322 | + [{"type": "operation-result", "api": SERVER_API, |
323 | "operation-id": 100, "timestamp": 0, "status": FAILED, |
324 | "result-text": u"Failure text is reported."}]) |
325 | |
326 | |
327 | === modified file 'landscape/monitor/tests/test_activeprocessinfo.py' |
328 | --- landscape/monitor/tests/test_activeprocessinfo.py 2009-10-06 14:16:02 +0000 |
329 | +++ landscape/monitor/tests/test_activeprocessinfo.py 2010-01-22 13:14:13 +0000 |
330 | @@ -10,7 +10,7 @@ |
331 | from landscape.tests.helpers import (LandscapeTest, MonitorHelper, |
332 | ProcessDataBuilder) |
333 | from landscape.tests.mocker import ANY |
334 | -from landscape import API |
335 | +from landscape import SERVER_API |
336 | |
337 | |
338 | class ActiveProcessInfoTest(LandscapeTest): |
339 | @@ -470,7 +470,7 @@ |
340 | messages = self.mstore.get_pending_messages() |
341 | self.assertEquals(len(messages), 2) |
342 | self.assertMessages(messages, [{"timestamp": 0, |
343 | - "api": API, |
344 | + "api": SERVER_API, |
345 | "type": "active-process-info", |
346 | "kill-all-processes": True, |
347 | "add-processes": [{"start-time": 110, |
348 | @@ -482,7 +482,7 @@ |
349 | "vm-size": 11676, |
350 | "uid": 0}]}, |
351 | {"timestamp": 0, |
352 | - "api": API, |
353 | + "api": SERVER_API, |
354 | "type": "active-process-info", |
355 | "update-processes": [{"start-time": 110, |
356 | "name": u"init", |
Looks good to me. +1!