Merge lp:~adalbas/ibmcharms/departed into lp:ibmcharms

Proposed by Adalberto Medeiros
Status: Needs review
Proposed branch: lp:~adalbas/ibmcharms/departed
Merge into: lp:ibmcharms
Diff against target: 60 lines (+40/-0)
2 files modified
charms/trusty/gpfs/hooks/common-relation-departed (+34/-0)
charms/trusty/gpfs/hooks/gpfshooklib.py (+6/-0)
To merge this branch: bzr merge lp:~adalbas/ibmcharms/departed
Reviewer Review Type Date Requested Status
Michael Chase-Salerno Approve
Review via email: mp+252491@code.launchpad.net

This proposal supersedes a proposal from 2015-03-09.

Commit message

Add departed hooks for manager-client relation

This removes the client node from the cluster.

Description of the change

Add departed hooks for manager-client relation

This removes the client node from the cluster.

To post a comment you must log in.
Revision history for this message
Michael Chase-Salerno (mcs-chasal) wrote : Posted in a previous version of this proposal

Unresolved merge conflict included

review: Needs Fixing
lp:~adalbas/ibmcharms/departed updated
27. By Adalberto Medeiros

merge with parent branch

Revision history for this message
Michael Chase-Salerno (mcs-chasal) :
review: Approve

Unmerged revisions

27. By Adalberto Medeiros

merge with parent branch

26. By Adalberto Medeiros

merget to main branch

25. By Adalberto Medeiros

small fixes for departed hook

24. By Adalberto Medeiros

Add relation-departed hooks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added symlink 'charms/trusty/gpfs/hooks/client-relation-departed'
2=== target is u'common-relation-departed'
3=== added file 'charms/trusty/gpfs/hooks/common-relation-departed'
4--- charms/trusty/gpfs/hooks/common-relation-departed 1970-01-01 00:00:00 +0000
5+++ charms/trusty/gpfs/hooks/common-relation-departed 2015-03-10 18:29:38 +0000
6@@ -0,0 +1,34 @@
7+#!/usr/bin/python
8+
9+import os
10+import sys
11+import socket
12+
13+sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))
14+
15+import gpfshooklib
16+from charmhelpers.core import (
17+ hookenv,
18+)
19+
20+log = hookenv.log
21+hooks = hookenv.Hooks()
22+
23+
24+@hooks.hook('manager-relation-departed')
25+def manager_departed():
26+ runit = hookenv.remote_unit()
27+ relid = hookenv.relation_id()
28+ nodename = hookenv.relation_get(attribute='lhostname', unit=runit,
29+ rid=relid)
30+ gpfshooklib.delete_node(nodename)
31+
32+
33+@hooks.hook('client-relation-departed')
34+def client_departed():
35+ # Nothing to do, only the manager removes the node from the cluster
36+ pass
37+
38+
39+if __name__ == '__main__':
40+ hooks.execute(sys.argv)
41
42=== modified file 'charms/trusty/gpfs/hooks/gpfshooklib.py'
43--- charms/trusty/gpfs/hooks/gpfshooklib.py 2015-03-09 15:25:51 +0000
44+++ charms/trusty/gpfs/hooks/gpfshooklib.py 2015-03-10 18:29:38 +0000
45@@ -191,6 +191,12 @@
46 log('Node %s could not be added. Manager not defined' % nodename)
47
48
49+def delete_node(nodename):
50+ if node_exists(nodename):
51+ log('Trying to delete node %s:' % nodename)
52+ log(check_output(split('mmdelnode -N %s' % nodename)))
53+
54+
55 def apply_license(nodename):
56 check_output(split('mmchlicense server --accept -N %s' % nodename))
57
58
59=== added symlink 'charms/trusty/gpfs/hooks/manager-relation-departed'
60=== target is u'common-relation-departed'

Subscribers

People subscribed via source and target branches