Merge lp:~jjo/charms/trusty/swift-proxy/swift_hash-from-JUJU_ENV_UUID-and-service_name into lp:~openstack-charmers-archive/charms/trusty/swift-proxy/next

Proposed by JuanJo Ciarlante
Status: Merged
Approved by: Edward Hope-Morley
Approved revision: 62
Merged at revision: 66
Proposed branch: lp:~jjo/charms/trusty/swift-proxy/swift_hash-from-JUJU_ENV_UUID-and-service_name
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-proxy/next
Diff against target: 34 lines (+5/-5)
1 file modified
hooks/swift_context.py (+5/-5)
To merge this branch: bzr merge lp:~jjo/charms/trusty/swift-proxy/swift_hash-from-JUJU_ENV_UUID-and-service_name
Reviewer Review Type Date Requested Status
Edward Hope-Morley Approve
James Page Needs Information
Review via email: mp+237291@code.launchpad.net

This proposal supersedes a proposal from 2014-10-06.

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

Hi jjo

I just want to check that JUJU_ENV_UUID is going to stick around but this looks entirely sane from my perspective.

review: Needs Fixing
Revision history for this message
James Page (james-page) :
review: Needs Information
Revision history for this message
Edward Hope-Morley (hopem) wrote :

An alternative way to do this would be to have the 'leader' create the hash and use peer relation to distribute but I don't have a problem with this doing it this way for now and since the charm is stuff as it is when using autohash i'm gonna declare it LGTM.

Doing a test deploy now and if passes i'm happy to merge this

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/swift_context.py'
2--- hooks/swift_context.py 2014-09-25 06:20:53 +0000
3+++ hooks/swift_context.py 2014-10-06 15:40:02 +0000
4@@ -4,7 +4,8 @@
5 relation_ids,
6 related_units,
7 relation_get,
8- unit_get
9+ unit_get,
10+ service_name
11 )
12
13 from charmhelpers.contrib.openstack.context import (
14@@ -26,6 +27,7 @@
15 from charmhelpers.contrib.openstack.utils import get_host_ip
16 import subprocess
17 import os
18+import uuid
19
20
21 from charmhelpers.contrib.hahelpers.apache import (
22@@ -230,10 +232,8 @@
23 with open(SWIFT_HASH_FILE, 'w') as hashfile:
24 hashfile.write(swift_hash)
25 else:
26- cmd = ['od', '-t', 'x8', '-N', '8', '-A', 'n']
27- rand = open('/dev/random', 'r')
28- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=rand)
29- swift_hash = p.communicate()[0].strip()
30+ swift_hash = str(uuid.uuid3(uuid.UUID(os.environ.get("JUJU_ENV_UUID")),
31+ service_name()))
32 with open(SWIFT_HASH_FILE, 'w') as hashfile:
33 hashfile.write(swift_hash)
34 return swift_hash

Subscribers

People subscribed via source and target branches