Merge lp:~ack/charms/precise/landscape-client/separate-juju-info into lp:charms/landscape-client

Proposed by Alberto Donato
Status: Superseded
Proposed branch: lp:~ack/charms/precise/landscape-client/separate-juju-info
Merge into: lp:charms/landscape-client
Diff against target: 70 lines (+17/-19)
3 files modified
hooks/common.py (+6/-0)
hooks/container-relation-joined (+11/-18)
hooks/install (+0/-1)
To merge this branch: bzr merge lp:~ack/charms/precise/landscape-client/separate-juju-info
Reviewer Review Type Date Requested Status
Chris Glass Approve
Fernando Correa Neto (community) Approve
Review via email: mp+185511@code.launchpad.net

This proposal has been superseded by a proposal from 2013-09-19.

Description of the change

Replace the use of meta-data.d for juju information, putting them in landscape-client $data_path/juju-info.json file instead.

To post a comment you must log in.
Revision history for this message
Fernando Correa Neto (fcorrea) wrote :

Looks good! +1

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

Looks good. +1

review: Approve
28. By Alberto Donato

Drop juju-info directory, make it a json file instead.

29. By Alberto Donato

Use a dict comprehension (from fcorrea's review).

30. By Alberto Donato

No need to filter empty values.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/common.py'
2--- hooks/common.py 2013-06-12 13:46:25 +0000
3+++ hooks/common.py 2013-09-19 17:13:10 +0000
4@@ -137,3 +137,9 @@
5 """Change file owner and group to landscape."""
6 user = getpwnam("landscape")
7 os.chown(filename, user.pw_uid, user.pw_gid)
8+
9+
10+def write_json_file(filename, content):
11+ """Dump content in JSON format to the specified file."""
12+ with open(filename, "w") as dumpfile:
13+ json.dump(content, dumpfile)
14
15=== modified file 'hooks/container-relation-joined'
16--- hooks/container-relation-joined 2013-06-20 12:40:36 +0000
17+++ hooks/container-relation-joined 2013-09-19 17:13:10 +0000
18@@ -4,7 +4,8 @@
19 import sys
20
21 from common import (
22- get_client_config, update_client_config, get_relation_config, chown)
23+ get_client_config, update_client_config, get_relation_config, chown,
24+ write_json_file)
25
26
27 exit_code = update_client_config(
28@@ -14,22 +15,14 @@
29 relation_conf = get_relation_config()
30 # We use the remote unit for the unit name, since we want to associate this
31 # client with the unit it's managing, not its own unit.
32-juju_info = {"juju-env-uuid": os.environ.get("JUJU_ENV_UUID"),
33- "juju-unit-name": os.environ.get("JUJU_REMOTE_UNIT"),
34- "juju-api-addresses": os.environ.get("JUJU_API_ADDRESSES"),
35- "juju-private-address": relation_conf.get("private-address")}
36-
37-# Temporary workaround until the new client is released. It provides
38-# meta_data_path as a config option.
39-meta_data_dir = os.path.join(client_config.data_path, "meta-data.d")
40-
41-meta_data_dir = getattr(client_config, "meta_data_path", meta_data_dir)
42-for key, value in juju_info.items():
43- if not value:
44- continue
45- filename = os.path.join(meta_data_dir, key)
46- with open(filename, "w") as juju_info_file:
47- juju_info_file.write(value)
48- chown(filename)
49+juju_info = {"environment-uuid": os.environ.get("JUJU_ENV_UUID"),
50+ "unit-name": os.environ.get("JUJU_REMOTE_UNIT"),
51+ "api-addresses": os.environ.get("JUJU_API_ADDRESSES"),
52+ "private-address": relation_conf.get("private-address")}
53+juju_info = dict((key, value) for key, value in juju_info.iteritems() if value)
54+
55+juju_info_file = os.path.join(client_config.data_path, "juju-info.json")
56+write_json_file(juju_info_file, juju_info)
57+chown(juju_info_file)
58
59 sys.exit(exit_code)
60
61=== modified file 'hooks/install'
62--- hooks/install 2013-06-14 15:08:04 +0000
63+++ hooks/install 2013-09-19 17:13:10 +0000
64@@ -89,6 +89,5 @@
65 # released.
66 make_tree() {
67 install -o landscape -g root -m 755 -d "$DATA_PATH"
68- install -o landscape -g landscape -m 755 -d "$DATA_PATH"/meta-data.d
69 }
70 landscape-config --init -d "$DATA_PATH" || make_tree

Subscribers

People subscribed via source and target branches