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

Proposed by Alberto Donato
Status: Merged
Merged at revision: 27
Proposed branch: lp:~ack/charms/precise/landscape-client/separate-juju-info
Merge into: lp:charms/landscape-client
Diff against target: 69 lines (+16/-19)
3 files modified
hooks/common.py (+6/-0)
hooks/container-relation-joined (+10/-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
Fernando Correa Neto (community) Approve
Chris Glass Approve
Review via email: mp+186592@code.launchpad.net

This proposal supersedes a proposal from 2013-09-13.

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 : Posted in a previous version of this proposal

Looks good! +1

review: Approve
Revision history for this message
Chris Glass (tribaal) wrote : Posted in a previous version of this proposal

Looks good. +1

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

I changed the branch a bit, writing juju info to a single JSON file rather than creating multiple files in a directory.

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

+1! Even better :)

review: Approve
29. By Alberto Donato

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

30. By Alberto Donato

No need to filter empty values.

Revision history for this message
Fernando Correa Neto (fcorrea) wrote :

Great! +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/common.py'
--- hooks/common.py 2013-06-12 13:46:25 +0000
+++ hooks/common.py 2013-09-20 07:19:31 +0000
@@ -137,3 +137,9 @@
137 """Change file owner and group to landscape."""137 """Change file owner and group to landscape."""
138 user = getpwnam("landscape")138 user = getpwnam("landscape")
139 os.chown(filename, user.pw_uid, user.pw_gid)139 os.chown(filename, user.pw_uid, user.pw_gid)
140
141
142def write_json_file(filename, content):
143 """Dump content in JSON format to the specified file."""
144 with open(filename, "w") as dumpfile:
145 json.dump(content, dumpfile)
140146
=== modified file 'hooks/container-relation-joined'
--- hooks/container-relation-joined 2013-06-20 12:40:36 +0000
+++ hooks/container-relation-joined 2013-09-20 07:19:31 +0000
@@ -4,7 +4,8 @@
4import sys4import sys
55
6from common import (6from common import (
7 get_client_config, update_client_config, get_relation_config, chown)7 get_client_config, update_client_config, get_relation_config, chown,
8 write_json_file)
89
910
10exit_code = update_client_config(11exit_code = update_client_config(
@@ -14,22 +15,13 @@
14relation_conf = get_relation_config()15relation_conf = get_relation_config()
15# We use the remote unit for the unit name, since we want to associate this16# We use the remote unit for the unit name, since we want to associate this
16# client with the unit it's managing, not its own unit.17# client with the unit it's managing, not its own unit.
17juju_info = {"juju-env-uuid": os.environ.get("JUJU_ENV_UUID"),18juju_info = {
18 "juju-unit-name": os.environ.get("JUJU_REMOTE_UNIT"),19 "environment-uuid": os.environ.get("JUJU_ENV_UUID"),
19 "juju-api-addresses": os.environ.get("JUJU_API_ADDRESSES"),20 "unit-name": os.environ.get("JUJU_REMOTE_UNIT"),
20 "juju-private-address": relation_conf.get("private-address")}21 "api-addresses": os.environ.get("JUJU_API_ADDRESSES"),
2122 "private-address": relation_conf.get("private-address")}
22# Temporary workaround until the new client is released. It provides23juju_info_file = os.path.join(client_config.data_path, "juju-info.json")
23# meta_data_path as a config option.24write_json_file(juju_info_file, juju_info)
24meta_data_dir = os.path.join(client_config.data_path, "meta-data.d")25chown(juju_info_file)
25
26meta_data_dir = getattr(client_config, "meta_data_path", meta_data_dir)
27for key, value in juju_info.items():
28 if not value:
29 continue
30 filename = os.path.join(meta_data_dir, key)
31 with open(filename, "w") as juju_info_file:
32 juju_info_file.write(value)
33 chown(filename)
3426
35sys.exit(exit_code)27sys.exit(exit_code)
3628
=== modified file 'hooks/install'
--- hooks/install 2013-06-14 15:08:04 +0000
+++ hooks/install 2013-09-20 07:19:31 +0000
@@ -89,6 +89,5 @@
89# released.89# released.
90make_tree() {90make_tree() {
91 install -o landscape -g root -m 755 -d "$DATA_PATH"91 install -o landscape -g root -m 755 -d "$DATA_PATH"
92 install -o landscape -g landscape -m 755 -d "$DATA_PATH"/meta-data.d
93}92}
94landscape-config --init -d "$DATA_PATH" || make_tree93landscape-config --init -d "$DATA_PATH" || make_tree

Subscribers

People subscribed via source and target branches