Merge lp:~tribaal/landscape-client/rename-metadata-annotations into lp:~landscape/landscape-client/trunk

Proposed by Chris Glass
Status: Merged
Approved by: Chris Glass
Approved revision: 732
Merged at revision: 725
Proposed branch: lp:~tribaal/landscape-client/rename-metadata-annotations
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 310 lines (+64/-53)
8 files modified
landscape/configuration.py (+3/-2)
landscape/deployment.py (+3/-3)
landscape/message_schemas.py (+2/-4)
landscape/monitor/computerinfo.py (+13/-11)
landscape/monitor/tests/test_computerinfo.py (+27/-19)
landscape/tests/test_configuration.py (+5/-5)
landscape/tests/test_deployment.py (+5/-5)
landscape/user/management.py (+6/-4)
To merge this branch: bzr merge lp:~tribaal/landscape-client/rename-metadata-annotations
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Alberto Donato (community) Approve
Review via email: mp+185990@code.launchpad.net

Commit message

This branch renames the meta-data.d/ directory to annotations.d/

Description of the change

This branch renames the meta-data.d/ directory to annotations.d/

One small non-related change too, where the log for the User credential were referring to "metadata" while it is in fact not meta data.

I would like to get an initial review on this, but I may have to retarget the branch depending on the release strategy we want to adopt (should we release the whole trunk since last release or just backport changes).

To post a comment you must log in.
726. By Chris Glass

Fix typo in docstring

Revision history for this message
Alberto Donato (ack) wrote :

Great! +1

#1:
- meta_data_dir = self.monitor.config.meta_data_path
+ meta_data_dir = self.monitor.config.annotations_path
         os.mkdir(meta_data_dir)
         create_file(os.path.join(meta_data_dir, "juju-env-uuid"), "uuid1")
         create_file(os.path.join(meta_data_dir, "juju-unit-name"), "unit/0")

I'd s/test_meta_data/test_annotations/ for those tests, and s/meta_data_dir/annotations_dir/.
Also it'd be nice to use generic key/values, not juju info specifically, as we're going to push them in a different message.

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

Just as a note, the landscape-client charm will be broken when this lands, as it relies on config.meta_data_path.
My charm branch (lp:~ack/charms/precise/landscape-client/separate-juju-info) in review fixes that.

727. By Chris Glass

Addresses comment #1 - using generic annotations instead of juju-specific ones
to avoid confusion.
Renamed variables and test methods.

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

A few things to fix, re the releasing strategy we agreed on backporting, which should be a straight patch as we didn't touch much this code (if at all).

[1]

We need to disable the fetching of cloud meta data too (which would currently end up in the annotations). It's a very small change and should go in this branch.

[2]

The ComputerInfo plugin is still using "meta-data" as message type name (line 92).

[3]

The message type name is still "meta-data" in landscape/message_schemas.py as well.

review: Needs Fixing
Revision history for this message
Chris Glass (tribaal) wrote :

I have in progress bugs and branches for those exact points - would you rather have me smash them all together in this branch?

Works for me either way.

728. By Chris Glass

Merging second development branch into this one.
The merge branch changes the message key from "meta-data" to "annotations".

Remains to be done: One branch to deactivate the EC2 reporting code (in a separate branch so that we can reactivate it easily in the future).

729. By Chris Glass

Reanamed internal variable from meta_data to annotations.

730. By Chris Glass

Lint fixes

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Thanks, looks good to me, it seems the only point left is [1] and will go in the other branch. +1!

review: Approve
731. By Chris Glass

Deactivate EC2 reporting for the time being.

732. By Chris Glass

Added bug number to "deactivated" comments.

Revision history for this message
Chris Glass (tribaal) wrote :

I changed my mind and added the removal in this branch since it's very cheap.

Please add a quick comment if it's still +1

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

+1!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/configuration.py'
2--- landscape/configuration.py 2013-09-16 08:09:10 +0000
3+++ landscape/configuration.py 2013-09-18 08:41:57 +0000
4@@ -588,9 +588,10 @@
5 """Create the client directories tree."""
6 bootstrap_list = [
7 BootstrapDirectory("$data_path", "landscape", "root", 0755),
8- BootstrapDirectory("$meta_data_path", "landscape", "landscape", 0755)]
9+ BootstrapDirectory("$annotations_path", "landscape", "landscape",
10+ 0755)]
11 BootstrapList(bootstrap_list).bootstrap(
12- data_path=config.data_path, meta_data_path=config.meta_data_path)
13+ data_path=config.data_path, annotations_path=config.annotations_path)
14
15
16 def store_public_key_data(config, certificate_data):
17
18=== modified file 'landscape/deployment.py'
19--- landscape/deployment.py 2013-09-16 08:09:10 +0000
20+++ landscape/deployment.py 2013-09-18 08:41:57 +0000
21@@ -399,12 +399,12 @@
22 return os.path.join(self.data_path, "sockets")
23
24 @property
25- def meta_data_path(self):
26+ def annotations_path(self):
27 """
28- Return the path to the directory where additional meta-data files can
29+ Return the path to the directory where additional annotation files can
30 be stored.
31 """
32- return os.path.join(self.data_path, "meta-data.d")
33+ return os.path.join(self.data_path, "annotations.d")
34
35
36 def get_versioned_persist(service):
37
38=== modified file 'landscape/message_schemas.py'
39--- landscape/message_schemas.py 2013-08-21 16:33:46 +0000
40+++ landscape/message_schemas.py 2013-09-18 08:41:57 +0000
41@@ -69,12 +69,10 @@
42 {"hostname": utf8,
43 "total-memory": Int(),
44 "total-swap": Int(),
45- "meta-data": Dict(utf8, utf8),
46- "extra-meta-data": Dict(utf8, utf8)},
47+ "annotations": Dict(utf8, utf8)},
48 # Not sure why these are all optional, but it's explicitly tested
49 # in the server
50- optional=["hostname", "total-memory", "total-swap", "meta-data",
51- "extra-meta-data"])
52+ optional=["hostname", "total-memory", "total-swap", "annotations"])
53
54 DISTRIBUTION_INFO = Message(
55 "distribution-info",
56
57=== modified file 'landscape/monitor/computerinfo.py'
58--- landscape/monitor/computerinfo.py 2013-09-07 22:06:20 +0000
59+++ landscape/monitor/computerinfo.py 2013-09-18 08:41:57 +0000
60@@ -36,7 +36,7 @@
61
62 def register(self, registry):
63 super(ComputerInfo, self).register(registry)
64- self._meta_data_path = registry.config.meta_data_path
65+ self._annotations_path = registry.config.annotations_path
66 self.call_on_accepted("computer-info",
67 self.send_computer_message, True)
68 self.call_on_accepted("distribution-info",
69@@ -75,21 +75,23 @@
70 self._add_if_new(message, "total-memory",
71 total_memory)
72 self._add_if_new(message, "total-swap", total_swap)
73- meta_data = {}
74- if os.path.exists(self._meta_data_path):
75- for key in os.listdir(self._meta_data_path):
76- meta_data[key] = read_file(
77- os.path.join(self._meta_data_path, key))
78+ annotations = {}
79+ if os.path.exists(self._annotations_path):
80+ for key in os.listdir(self._annotations_path):
81+ annotations[key] = read_file(
82+ os.path.join(self._annotations_path, key))
83
84 if (self._cloud_meta_data is None and
85 self._cloud_retries < METADATA_RETRY_MAX):
86 self._cloud_meta_data = yield self._fetch_ec2_meta_data()
87
88- if self._cloud_meta_data:
89- meta_data = dict(
90- meta_data.items() + self._cloud_meta_data.items())
91- if meta_data:
92- self._add_if_new(message, "meta-data", meta_data)
93+ # XXX: Deactivated EC2 reporting for the time being, until #1226605 is
94+ # implemented.
95+ if False: # if self._cloud_meta_data:
96+ annotations = dict(
97+ annotations.items() + self._cloud_meta_data.items())
98+ if annotations:
99+ self._add_if_new(message, "annotations", annotations)
100 returnValue(message)
101
102 def _add_if_new(self, message, key, value):
103
104=== modified file 'landscape/monitor/tests/test_computerinfo.py'
105--- landscape/monitor/tests/test_computerinfo.py 2013-09-06 19:48:16 +0000
106+++ landscape/monitor/tests/test_computerinfo.py 2013-09-18 08:41:57 +0000
107@@ -310,9 +310,15 @@
108 computer_info = {"type": "computer-info", "hostname": "ooga.local",
109 "timestamp": 0, "total-memory": 1510,
110 "total-swap": 1584,
111- "meta-data": {u"ami-id": u"ami-00002",
112- u"instance-id": u"i00001",
113- u"instance-type": u"hs1.8xlarge"}}
114+ "annotations": {u"ami-id": u"ami-00002",
115+ u"instance-id": u"i00001",
116+ u"instance-type": u"hs1.8xlarge"}}
117+ # XXX: The tested code is deactivated, so this will not produce
118+ # annotations for the time being. It should be plugged in again
119+ # once #1226605 is implemented.
120+ computer_info = {"type": "computer-info", "hostname": "ooga.local",
121+ "timestamp": 0, "total-memory": 1510,
122+ "total-swap": 1584}
123 dist_info = {"type": "distribution-info",
124 "code-name": "dapper", "description": "Ubuntu 6.06.1 LTS",
125 "distributor-id": "Ubuntu", "release": "6.06"}
126@@ -358,9 +364,9 @@
127 self.mstore.set_accepted_types(["distribution-info", "computer-info"])
128 self.assertMessages(list(self.mstore.get_pending_messages()), [])
129
130- def test_meta_data(self):
131+ def test_annotations(self):
132 """
133- L{ComputerInfo} sends extra meta data from the meta-data.d directory
134+ L{ComputerInfo} sends extra meta data from the annotations.d directory
135 if it's present.
136
137 Each file name is used as a key in the meta-data dict and the file's
138@@ -369,10 +375,10 @@
139 This allows, for example, the landscape-client charm to send
140 information about the juju environment to the landscape server.
141 """
142- meta_data_dir = self.monitor.config.meta_data_path
143- os.mkdir(meta_data_dir)
144- create_file(os.path.join(meta_data_dir, "juju-env-uuid"), "uuid1")
145- create_file(os.path.join(meta_data_dir, "juju-unit-name"), "unit/0")
146+ annotations_dir = self.monitor.config.annotations_path
147+ os.mkdir(annotations_dir)
148+ create_file(os.path.join(annotations_dir, "annotation1"), "value1")
149+ create_file(os.path.join(annotations_dir, "annotation2"), "value2")
150 self.mstore.set_accepted_types(["computer-info"])
151
152 plugin = ComputerInfo()
153@@ -381,16 +387,17 @@
154 plugin.exchange()
155 messages = self.mstore.get_pending_messages()
156 self.assertEqual(1, len(messages))
157- meta_data = messages[0]["meta-data"]
158+ meta_data = messages[0]["annotations"]
159 self.assertEqual(2, len(meta_data))
160- self.assertEqual("uuid1", meta_data["juju-env-uuid"])
161- self.assertEqual("unit/0", meta_data["juju-unit-name"])
162+ self.assertEqual("value1", meta_data["annotation1"])
163+ self.assertEqual("value2", meta_data["annotation2"])
164
165- def test_meta_data_cloud(self):
166+ def deactivated_test_annotations_cloud(self):
167 """
168 L{ComputerInfo} includes the meta-data key when cloud information
169 is available.
170 """
171+ # XXX The tested code is deactivated until #1226605 is implemented.
172 self.mstore.set_accepted_types(["computer-info"])
173
174 plugin = ComputerInfo()
175@@ -399,11 +406,12 @@
176 plugin.exchange()
177 messages = self.mstore.get_pending_messages()
178 self.assertEqual(1, len(messages))
179- self.assertIn("meta-data", messages[0])
180- self.assertEqual("i00001", messages[0]["meta-data"]["instance-id"])
181+ self.assertIn("annotations", messages[0])
182+ self.assertEqual("i00001", messages[0]["annotations"]["instance-id"])
183
184- def test_with_cloud_info(self):
185+ def deactivated_test_with_cloud_info(self):
186 """Fetch cloud information"""
187+ # XXX: The tested code is deactivated until #1226605 is implemented.
188 self.config.cloud = True
189 self.mstore.set_accepted_types(["computer-info"])
190
191@@ -412,11 +420,11 @@
192 plugin.exchange()
193 messages = self.mstore.get_pending_messages()
194 self.assertEqual(1, len(messages))
195- self.assertIn("meta-data", messages[0])
196+ self.assertIn("annotations", messages[0])
197
198 self.assertEqual({"instance-id": u"i00001", "ami-id": u"ami-00002",
199 "instance-type": u"hs1.8xlarge"},
200- messages[0]["meta-data"])
201+ messages[0]["annotations"])
202
203 def test_no_fetch_ec2_meta_data_when_cloud_retries_is_max(self):
204 """
205@@ -431,7 +439,7 @@
206 plugin.exchange()
207 messages = self.mstore.get_pending_messages()
208 self.assertEqual(1, len(messages))
209- self.assertNotIn("meta-data", messages[0])
210+ self.assertNotIn("annotations", messages[0])
211
212 @inlineCallbacks
213 def test_fetch_ec2_meta_data(self):
214
215=== modified file 'landscape/tests/test_configuration.py'
216--- landscape/tests/test_configuration.py 2013-09-16 07:45:45 +0000
217+++ landscape/tests/test_configuration.py 2013-09-18 08:41:57 +0000
218@@ -639,21 +639,21 @@
219
220 def test_bootstrap_tree(self):
221 """
222- The L{bootstrap_tree} function creates the client dir and /meta-data.d
223- under it with the correct permissions.
224+ The L{bootstrap_tree} function creates the client dir and
225+ /annotations.d under it with the correct permissions.
226 """
227 client_path = self.makeDir()
228- meta_data_path = os.path.join(client_path, "meta-data.d")
229+ annotations_path = os.path.join(client_path, "annotations.d")
230
231 mock_chmod = self.mocker.replace("os.chmod")
232 mock_chmod(client_path, 0755)
233- mock_chmod(meta_data_path, 0755)
234+ mock_chmod(annotations_path, 0755)
235 self.mocker.replay()
236
237 config = self.get_config([], data_path=client_path)
238 bootstrap_tree(config)
239 self.assertTrue(os.path.isdir(client_path))
240- self.assertTrue(os.path.isdir(meta_data_path))
241+ self.assertTrue(os.path.isdir(annotations_path))
242
243
244 class ConfigurationFunctionsTest(LandscapeConfigurationTest):
245
246=== modified file 'landscape/tests/test_deployment.py'
247--- landscape/tests/test_deployment.py 2013-09-16 08:10:04 +0000
248+++ landscape/tests/test_deployment.py 2013-09-18 08:41:57 +0000
249@@ -600,14 +600,14 @@
250 self.assertEqual(self.config.sockets_path,
251 "/var/lib/landscape/client/sockets")
252
253- def test_meta_data_path(self):
254+ def test_annotations_path(self):
255 """
256- The L{Configuration.meta_data_path} property returns the path to the
257- socket directory.
258+ The L{Configuration.annotations_path} property returns the path to the
259+ annotations directory.
260 """
261 self.assertEqual(
262- "/var/lib/landscape/client/meta-data.d",
263- self.config.meta_data_path)
264+ "/var/lib/landscape/client/annotations.d",
265+ self.config.annotations_path)
266
267 def test_clone(self):
268 """The L{Configuration.clone} method clones a configuration."""
269
270=== modified file 'landscape/user/management.py'
271--- landscape/user/management.py 2008-06-17 09:49:54 +0000
272+++ landscape/user/management.py 2013-09-18 08:41:57 +0000
273@@ -41,7 +41,7 @@
274 self._set_password(username, password)
275 if require_password_reset:
276 result, new_output = self.call_popen(["passwd", username, "-e"])
277- if result !=0:
278+ if result != 0:
279 raise UserManagementError("Error resetting password for user "
280 "%s.\n%s" % (username, new_output))
281 else:
282@@ -75,7 +75,7 @@
283 primary_group_name=None):
284 """Update details for the account matching C{uid}."""
285 uid = self._provider.get_uid(username)
286- logging.info("Updating metadata for user %s (UID %d).", username, uid)
287+ logging.info("Updating data for user %s (UID %d).", username, uid)
288 if password:
289 self._set_password(username, password)
290
291@@ -166,7 +166,8 @@
292 gid = self._provider.get_gid(groupname)
293 logging.info("Adding user %s (UID %d) to group %s (GID %d).",
294 username, uid, groupname, gid)
295- result, output = self.call_popen(["gpasswd", "-a", username, groupname])
296+ result, output = self.call_popen(["gpasswd", "-a", username,
297+ groupname])
298 if result != 0:
299 raise UserManagementError("Error adding user %s (UID %d) to "
300 "group %s (GID %d).\n%s" %
301@@ -182,7 +183,8 @@
302 gid = self._provider.get_gid(groupname)
303 logging.info("Removing user %s (UID %d) from group %s (GID %d).",
304 username, uid, groupname, gid)
305- result, output = self.call_popen(["gpasswd", "-d", username, groupname])
306+ result, output = self.call_popen(["gpasswd", "-d", username,
307+ groupname])
308 if result != 0:
309 raise UserManagementError("Error removing user %s (UID %d) "
310 "from group %s (GID (%d).\n%s"

Subscribers

People subscribed via source and target branches

to all changes: