Merge lp:~andreserl/charm-tools/juju_rc_path-helpers into lp:~openstack-charmers/charm-tools/pyrewrite-helpers

Proposed by Andres Rodriguez
Status: Merged
Merged at revision: 53
Proposed branch: lp:~andreserl/charm-tools/juju_rc_path-helpers
Merge into: lp:~openstack-charmers/charm-tools/pyrewrite-helpers
Diff against target: 23 lines (+4/-2)
1 file modified
charmhelpers/contrib/openstack/openstack_utils.py (+4/-2)
To merge this branch: bzr merge lp:~andreserl/charm-tools/juju_rc_path-helpers
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+174259@code.launchpad.net

Commit message

make sure juju_rc_path is created. use charm_dir to determine the base path.

To post a comment you must log in.
Revision history for this message
James Page (james-page) :
review: Approve
Revision history for this message
James Page (james-page) wrote :

Urgh - sorry - just spotted this:

 + if not os.path.exists(os.path.dirname(juju_rc_path)):
19 + os.mkdir(os.path.dirname(juju_rc_path))

If charm_dir does not exists things are pretty broken - so I'd not bother with the check.

review: Needs Fixing
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Hi James!

I believe that the check is still required. This function is used in config_changed, which means is gonna be called in such event. If the check would not be there, the function would always try to create juju_rc_path, but when the directory exists, it will fail. However, with the check, it will only create the directory when it does not exists (and this is not charm_dir, but the script path)

Cheers.

Revision history for this message
James Page (james-page) wrote :

Yes - you are correct - +1 with a drop of the unit_name buildout as its no longer required.

review: Approve
54. By Andres Rodriguez

Remove unit_name buildout as it is no longer required

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/openstack_utils.py'
2--- charmhelpers/contrib/openstack/openstack_utils.py 2013-07-09 22:18:52 +0000
3+++ charmhelpers/contrib/openstack/openstack_utils.py 2013-07-16 14:17:26 +0000
4@@ -11,6 +11,7 @@
5
6 from charmhelpers.core.hookenv import (
7 config,
8+ charm_dir,
9 )
10
11 CLOUD_ARCHIVE_URL = "http://ubuntu-cloud.archive.canonical.com/ubuntu"
12@@ -246,8 +247,9 @@
13 updated config information necessary to perform health checks or
14 service changes.
15 """
16- unit_name = os.getenv('JUJU_UNIT_NAME').replace('/', '-')
17- juju_rc_path = "/var/lib/juju/units/%s/charm/%s" % (unit_name, script_path)
18+ juju_rc_path = "%s/%s" % (charm_dir(), script_path)
19+ if not os.path.exists(os.path.dirname(juju_rc_path)):
20+ os.mkdir(os.path.dirname(juju_rc_path))
21 with open(juju_rc_path, 'wb') as rc_script:
22 rc_script.write(
23 "#!/bin/bash\n")

Subscribers

People subscribed via source and target branches