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
=== modified file 'landscape/configuration.py'
--- landscape/configuration.py 2013-09-16 08:09:10 +0000
+++ landscape/configuration.py 2013-09-18 08:41:57 +0000
@@ -588,9 +588,10 @@
588 """Create the client directories tree."""588 """Create the client directories tree."""
589 bootstrap_list = [589 bootstrap_list = [
590 BootstrapDirectory("$data_path", "landscape", "root", 0755),590 BootstrapDirectory("$data_path", "landscape", "root", 0755),
591 BootstrapDirectory("$meta_data_path", "landscape", "landscape", 0755)]591 BootstrapDirectory("$annotations_path", "landscape", "landscape",
592 0755)]
592 BootstrapList(bootstrap_list).bootstrap(593 BootstrapList(bootstrap_list).bootstrap(
593 data_path=config.data_path, meta_data_path=config.meta_data_path)594 data_path=config.data_path, annotations_path=config.annotations_path)
594595
595596
596def store_public_key_data(config, certificate_data):597def store_public_key_data(config, certificate_data):
597598
=== modified file 'landscape/deployment.py'
--- landscape/deployment.py 2013-09-16 08:09:10 +0000
+++ landscape/deployment.py 2013-09-18 08:41:57 +0000
@@ -399,12 +399,12 @@
399 return os.path.join(self.data_path, "sockets")399 return os.path.join(self.data_path, "sockets")
400400
401 @property401 @property
402 def meta_data_path(self):402 def annotations_path(self):
403 """403 """
404 Return the path to the directory where additional meta-data files can404 Return the path to the directory where additional annotation files can
405 be stored.405 be stored.
406 """406 """
407 return os.path.join(self.data_path, "meta-data.d")407 return os.path.join(self.data_path, "annotations.d")
408408
409409
410def get_versioned_persist(service):410def get_versioned_persist(service):
411411
=== modified file 'landscape/message_schemas.py'
--- landscape/message_schemas.py 2013-08-21 16:33:46 +0000
+++ landscape/message_schemas.py 2013-09-18 08:41:57 +0000
@@ -69,12 +69,10 @@
69 {"hostname": utf8,69 {"hostname": utf8,
70 "total-memory": Int(),70 "total-memory": Int(),
71 "total-swap": Int(),71 "total-swap": Int(),
72 "meta-data": Dict(utf8, utf8),72 "annotations": Dict(utf8, utf8)},
73 "extra-meta-data": Dict(utf8, utf8)},
74 # Not sure why these are all optional, but it's explicitly tested73 # Not sure why these are all optional, but it's explicitly tested
75 # in the server74 # in the server
76 optional=["hostname", "total-memory", "total-swap", "meta-data",75 optional=["hostname", "total-memory", "total-swap", "annotations"])
77 "extra-meta-data"])
7876
79DISTRIBUTION_INFO = Message(77DISTRIBUTION_INFO = Message(
80 "distribution-info",78 "distribution-info",
8179
=== modified file 'landscape/monitor/computerinfo.py'
--- landscape/monitor/computerinfo.py 2013-09-07 22:06:20 +0000
+++ landscape/monitor/computerinfo.py 2013-09-18 08:41:57 +0000
@@ -36,7 +36,7 @@
3636
37 def register(self, registry):37 def register(self, registry):
38 super(ComputerInfo, self).register(registry)38 super(ComputerInfo, self).register(registry)
39 self._meta_data_path = registry.config.meta_data_path39 self._annotations_path = registry.config.annotations_path
40 self.call_on_accepted("computer-info",40 self.call_on_accepted("computer-info",
41 self.send_computer_message, True)41 self.send_computer_message, True)
42 self.call_on_accepted("distribution-info",42 self.call_on_accepted("distribution-info",
@@ -75,21 +75,23 @@
75 self._add_if_new(message, "total-memory",75 self._add_if_new(message, "total-memory",
76 total_memory)76 total_memory)
77 self._add_if_new(message, "total-swap", total_swap)77 self._add_if_new(message, "total-swap", total_swap)
78 meta_data = {}78 annotations = {}
79 if os.path.exists(self._meta_data_path):79 if os.path.exists(self._annotations_path):
80 for key in os.listdir(self._meta_data_path):80 for key in os.listdir(self._annotations_path):
81 meta_data[key] = read_file(81 annotations[key] = read_file(
82 os.path.join(self._meta_data_path, key))82 os.path.join(self._annotations_path, key))
8383
84 if (self._cloud_meta_data is None and84 if (self._cloud_meta_data is None and
85 self._cloud_retries < METADATA_RETRY_MAX):85 self._cloud_retries < METADATA_RETRY_MAX):
86 self._cloud_meta_data = yield self._fetch_ec2_meta_data()86 self._cloud_meta_data = yield self._fetch_ec2_meta_data()
8787
88 if self._cloud_meta_data:88 # XXX: Deactivated EC2 reporting for the time being, until #1226605 is
89 meta_data = dict(89 # implemented.
90 meta_data.items() + self._cloud_meta_data.items())90 if False: # if self._cloud_meta_data:
91 if meta_data:91 annotations = dict(
92 self._add_if_new(message, "meta-data", meta_data)92 annotations.items() + self._cloud_meta_data.items())
93 if annotations:
94 self._add_if_new(message, "annotations", annotations)
93 returnValue(message)95 returnValue(message)
9496
95 def _add_if_new(self, message, key, value):97 def _add_if_new(self, message, key, value):
9698
=== modified file 'landscape/monitor/tests/test_computerinfo.py'
--- landscape/monitor/tests/test_computerinfo.py 2013-09-06 19:48:16 +0000
+++ landscape/monitor/tests/test_computerinfo.py 2013-09-18 08:41:57 +0000
@@ -310,9 +310,15 @@
310 computer_info = {"type": "computer-info", "hostname": "ooga.local",310 computer_info = {"type": "computer-info", "hostname": "ooga.local",
311 "timestamp": 0, "total-memory": 1510,311 "timestamp": 0, "total-memory": 1510,
312 "total-swap": 1584,312 "total-swap": 1584,
313 "meta-data": {u"ami-id": u"ami-00002",313 "annotations": {u"ami-id": u"ami-00002",
314 u"instance-id": u"i00001",314 u"instance-id": u"i00001",
315 u"instance-type": u"hs1.8xlarge"}}315 u"instance-type": u"hs1.8xlarge"}}
316 # XXX: The tested code is deactivated, so this will not produce
317 # annotations for the time being. It should be plugged in again
318 # once #1226605 is implemented.
319 computer_info = {"type": "computer-info", "hostname": "ooga.local",
320 "timestamp": 0, "total-memory": 1510,
321 "total-swap": 1584}
316 dist_info = {"type": "distribution-info",322 dist_info = {"type": "distribution-info",
317 "code-name": "dapper", "description": "Ubuntu 6.06.1 LTS",323 "code-name": "dapper", "description": "Ubuntu 6.06.1 LTS",
318 "distributor-id": "Ubuntu", "release": "6.06"}324 "distributor-id": "Ubuntu", "release": "6.06"}
@@ -358,9 +364,9 @@
358 self.mstore.set_accepted_types(["distribution-info", "computer-info"])364 self.mstore.set_accepted_types(["distribution-info", "computer-info"])
359 self.assertMessages(list(self.mstore.get_pending_messages()), [])365 self.assertMessages(list(self.mstore.get_pending_messages()), [])
360366
361 def test_meta_data(self):367 def test_annotations(self):
362 """368 """
363 L{ComputerInfo} sends extra meta data from the meta-data.d directory369 L{ComputerInfo} sends extra meta data from the annotations.d directory
364 if it's present.370 if it's present.
365371
366 Each file name is used as a key in the meta-data dict and the file's372 Each file name is used as a key in the meta-data dict and the file's
@@ -369,10 +375,10 @@
369 This allows, for example, the landscape-client charm to send375 This allows, for example, the landscape-client charm to send
370 information about the juju environment to the landscape server.376 information about the juju environment to the landscape server.
371 """377 """
372 meta_data_dir = self.monitor.config.meta_data_path378 annotations_dir = self.monitor.config.annotations_path
373 os.mkdir(meta_data_dir)379 os.mkdir(annotations_dir)
374 create_file(os.path.join(meta_data_dir, "juju-env-uuid"), "uuid1")380 create_file(os.path.join(annotations_dir, "annotation1"), "value1")
375 create_file(os.path.join(meta_data_dir, "juju-unit-name"), "unit/0")381 create_file(os.path.join(annotations_dir, "annotation2"), "value2")
376 self.mstore.set_accepted_types(["computer-info"])382 self.mstore.set_accepted_types(["computer-info"])
377383
378 plugin = ComputerInfo()384 plugin = ComputerInfo()
@@ -381,16 +387,17 @@
381 plugin.exchange()387 plugin.exchange()
382 messages = self.mstore.get_pending_messages()388 messages = self.mstore.get_pending_messages()
383 self.assertEqual(1, len(messages))389 self.assertEqual(1, len(messages))
384 meta_data = messages[0]["meta-data"]390 meta_data = messages[0]["annotations"]
385 self.assertEqual(2, len(meta_data))391 self.assertEqual(2, len(meta_data))
386 self.assertEqual("uuid1", meta_data["juju-env-uuid"])392 self.assertEqual("value1", meta_data["annotation1"])
387 self.assertEqual("unit/0", meta_data["juju-unit-name"])393 self.assertEqual("value2", meta_data["annotation2"])
388394
389 def test_meta_data_cloud(self):395 def deactivated_test_annotations_cloud(self):
390 """396 """
391 L{ComputerInfo} includes the meta-data key when cloud information397 L{ComputerInfo} includes the meta-data key when cloud information
392 is available.398 is available.
393 """399 """
400 # XXX The tested code is deactivated until #1226605 is implemented.
394 self.mstore.set_accepted_types(["computer-info"])401 self.mstore.set_accepted_types(["computer-info"])
395402
396 plugin = ComputerInfo()403 plugin = ComputerInfo()
@@ -399,11 +406,12 @@
399 plugin.exchange()406 plugin.exchange()
400 messages = self.mstore.get_pending_messages()407 messages = self.mstore.get_pending_messages()
401 self.assertEqual(1, len(messages))408 self.assertEqual(1, len(messages))
402 self.assertIn("meta-data", messages[0])409 self.assertIn("annotations", messages[0])
403 self.assertEqual("i00001", messages[0]["meta-data"]["instance-id"])410 self.assertEqual("i00001", messages[0]["annotations"]["instance-id"])
404411
405 def test_with_cloud_info(self):412 def deactivated_test_with_cloud_info(self):
406 """Fetch cloud information"""413 """Fetch cloud information"""
414 # XXX: The tested code is deactivated until #1226605 is implemented.
407 self.config.cloud = True415 self.config.cloud = True
408 self.mstore.set_accepted_types(["computer-info"])416 self.mstore.set_accepted_types(["computer-info"])
409417
@@ -412,11 +420,11 @@
412 plugin.exchange()420 plugin.exchange()
413 messages = self.mstore.get_pending_messages()421 messages = self.mstore.get_pending_messages()
414 self.assertEqual(1, len(messages))422 self.assertEqual(1, len(messages))
415 self.assertIn("meta-data", messages[0])423 self.assertIn("annotations", messages[0])
416424
417 self.assertEqual({"instance-id": u"i00001", "ami-id": u"ami-00002",425 self.assertEqual({"instance-id": u"i00001", "ami-id": u"ami-00002",
418 "instance-type": u"hs1.8xlarge"},426 "instance-type": u"hs1.8xlarge"},
419 messages[0]["meta-data"])427 messages[0]["annotations"])
420428
421 def test_no_fetch_ec2_meta_data_when_cloud_retries_is_max(self):429 def test_no_fetch_ec2_meta_data_when_cloud_retries_is_max(self):
422 """430 """
@@ -431,7 +439,7 @@
431 plugin.exchange()439 plugin.exchange()
432 messages = self.mstore.get_pending_messages()440 messages = self.mstore.get_pending_messages()
433 self.assertEqual(1, len(messages))441 self.assertEqual(1, len(messages))
434 self.assertNotIn("meta-data", messages[0])442 self.assertNotIn("annotations", messages[0])
435443
436 @inlineCallbacks444 @inlineCallbacks
437 def test_fetch_ec2_meta_data(self):445 def test_fetch_ec2_meta_data(self):
438446
=== modified file 'landscape/tests/test_configuration.py'
--- landscape/tests/test_configuration.py 2013-09-16 07:45:45 +0000
+++ landscape/tests/test_configuration.py 2013-09-18 08:41:57 +0000
@@ -639,21 +639,21 @@
639639
640 def test_bootstrap_tree(self):640 def test_bootstrap_tree(self):
641 """641 """
642 The L{bootstrap_tree} function creates the client dir and /meta-data.d642 The L{bootstrap_tree} function creates the client dir and
643 under it with the correct permissions.643 /annotations.d under it with the correct permissions.
644 """644 """
645 client_path = self.makeDir()645 client_path = self.makeDir()
646 meta_data_path = os.path.join(client_path, "meta-data.d")646 annotations_path = os.path.join(client_path, "annotations.d")
647647
648 mock_chmod = self.mocker.replace("os.chmod")648 mock_chmod = self.mocker.replace("os.chmod")
649 mock_chmod(client_path, 0755)649 mock_chmod(client_path, 0755)
650 mock_chmod(meta_data_path, 0755)650 mock_chmod(annotations_path, 0755)
651 self.mocker.replay()651 self.mocker.replay()
652652
653 config = self.get_config([], data_path=client_path)653 config = self.get_config([], data_path=client_path)
654 bootstrap_tree(config)654 bootstrap_tree(config)
655 self.assertTrue(os.path.isdir(client_path))655 self.assertTrue(os.path.isdir(client_path))
656 self.assertTrue(os.path.isdir(meta_data_path))656 self.assertTrue(os.path.isdir(annotations_path))
657657
658658
659class ConfigurationFunctionsTest(LandscapeConfigurationTest):659class ConfigurationFunctionsTest(LandscapeConfigurationTest):
660660
=== modified file 'landscape/tests/test_deployment.py'
--- landscape/tests/test_deployment.py 2013-09-16 08:10:04 +0000
+++ landscape/tests/test_deployment.py 2013-09-18 08:41:57 +0000
@@ -600,14 +600,14 @@
600 self.assertEqual(self.config.sockets_path,600 self.assertEqual(self.config.sockets_path,
601 "/var/lib/landscape/client/sockets")601 "/var/lib/landscape/client/sockets")
602602
603 def test_meta_data_path(self):603 def test_annotations_path(self):
604 """604 """
605 The L{Configuration.meta_data_path} property returns the path to the605 The L{Configuration.annotations_path} property returns the path to the
606 socket directory.606 annotations directory.
607 """607 """
608 self.assertEqual(608 self.assertEqual(
609 "/var/lib/landscape/client/meta-data.d",609 "/var/lib/landscape/client/annotations.d",
610 self.config.meta_data_path)610 self.config.annotations_path)
611611
612 def test_clone(self):612 def test_clone(self):
613 """The L{Configuration.clone} method clones a configuration."""613 """The L{Configuration.clone} method clones a configuration."""
614614
=== modified file 'landscape/user/management.py'
--- landscape/user/management.py 2008-06-17 09:49:54 +0000
+++ landscape/user/management.py 2013-09-18 08:41:57 +0000
@@ -41,7 +41,7 @@
41 self._set_password(username, password)41 self._set_password(username, password)
42 if require_password_reset:42 if require_password_reset:
43 result, new_output = self.call_popen(["passwd", username, "-e"])43 result, new_output = self.call_popen(["passwd", username, "-e"])
44 if result !=0:44 if result != 0:
45 raise UserManagementError("Error resetting password for user "45 raise UserManagementError("Error resetting password for user "
46 "%s.\n%s" % (username, new_output))46 "%s.\n%s" % (username, new_output))
47 else:47 else:
@@ -75,7 +75,7 @@
75 primary_group_name=None):75 primary_group_name=None):
76 """Update details for the account matching C{uid}."""76 """Update details for the account matching C{uid}."""
77 uid = self._provider.get_uid(username)77 uid = self._provider.get_uid(username)
78 logging.info("Updating metadata for user %s (UID %d).", username, uid)78 logging.info("Updating data for user %s (UID %d).", username, uid)
79 if password:79 if password:
80 self._set_password(username, password)80 self._set_password(username, password)
8181
@@ -166,7 +166,8 @@
166 gid = self._provider.get_gid(groupname)166 gid = self._provider.get_gid(groupname)
167 logging.info("Adding user %s (UID %d) to group %s (GID %d).",167 logging.info("Adding user %s (UID %d) to group %s (GID %d).",
168 username, uid, groupname, gid)168 username, uid, groupname, gid)
169 result, output = self.call_popen(["gpasswd", "-a", username, groupname])169 result, output = self.call_popen(["gpasswd", "-a", username,
170 groupname])
170 if result != 0:171 if result != 0:
171 raise UserManagementError("Error adding user %s (UID %d) to "172 raise UserManagementError("Error adding user %s (UID %d) to "
172 "group %s (GID %d).\n%s" %173 "group %s (GID %d).\n%s" %
@@ -182,7 +183,8 @@
182 gid = self._provider.get_gid(groupname)183 gid = self._provider.get_gid(groupname)
183 logging.info("Removing user %s (UID %d) from group %s (GID %d).",184 logging.info("Removing user %s (UID %d) from group %s (GID %d).",
184 username, uid, groupname, gid)185 username, uid, groupname, gid)
185 result, output = self.call_popen(["gpasswd", "-d", username, groupname])186 result, output = self.call_popen(["gpasswd", "-d", username,
187 groupname])
186 if result != 0:188 if result != 0:
187 raise UserManagementError("Error removing user %s (UID %d) "189 raise UserManagementError("Error removing user %s (UID %d) "
188 "from group %s (GID (%d).\n%s"190 "from group %s (GID (%d).\n%s"

Subscribers

People subscribed via source and target branches

to all changes: