Merge lp:~mcs-chasal/ibmcharms/dnsfix into lp:ibmcharms

Proposed by Michael Chase-Salerno
Status: Merged
Approved by: Michael Chase-Salerno
Approved revision: 27
Merged at revision: 25
Proposed branch: lp:~mcs-chasal/ibmcharms/dnsfix
Merge into: lp:ibmcharms
Diff against target: 120 lines (+38/-29)
3 files modified
charms/trusty/gpfs/hooks/common-relation-changed (+21/-26)
charms/trusty/gpfs/hooks/common-relation-joined (+5/-2)
charms/trusty/gpfs/hooks/gpfshooklib.py (+12/-1)
To merge this branch: bzr merge lp:~mcs-chasal/ibmcharms/dnsfix
Reviewer Review Type Date Requested Status
Adalberto Medeiros Needs Fixing
Review via email: mp+251024@code.launchpad.net

Description of the change

Added creation of /etc/hosts entries if hostnames are not resolving on the systems.

To post a comment you must log in.
Revision history for this message
Adalberto Medeiros (adalbas) wrote :

There are a few comments regarding how the hostname and ip is being handled by the local unit and a few improvements.

Other than that, will you add that to peers relation as well? Is it necessary?

Revision history for this message
Adalberto Medeiros (adalbas) :
review: Needs Fixing
lp:~mcs-chasal/ibmcharms/dnsfix updated
27. By Michael Chase-Salerno

Incorporating review comments and fixing startup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charms/trusty/gpfs/hooks/common-relation-changed'
--- charms/trusty/gpfs/hooks/common-relation-changed 2015-02-10 12:24:34 +0000
+++ charms/trusty/gpfs/hooks/common-relation-changed 2015-03-03 17:58:00 +0000
@@ -15,38 +15,33 @@
1515
16def main():16def main():
17 hookname = hookenv.hook_name()17 hookname = hookenv.hook_name()
18 relid = hookenv.relation_id()
19 runit = hookenv.remote_unit()
20 unit = hookenv.local_unit()
21
22 # Get hosts in relationship and configure /etc/hosts if needed
23 rip = hookenv.relation_get(attribute='pip', unit=runit, rid=relid)
24 rlhn = hookenv.relation_get(attribute='lhostname', unit=runit, rid=relid)
25 llhn = socket.getfqdn()
26 if not rlhn is None:
27 gpfshooklib.chk_dns(rlhn,rip)
28
18 if hookname == "client-relation-changed":29 if hookname == "client-relation-changed":
19 # Save the keypair from the manager30 # Save the keypair from the manager
20 log("Copying keys to client")31 log("Copying keys to client")
21 relid = hookenv.relation_id()32 pubkey = hookenv.relation_get(attribute='pubkey', unit=runit, rid=relid)
22 unit = hookenv.remote_unit()33 privkey = hookenv.relation_get(attribute='privkey', unit=runit, rid=relid)
23 pubkey = hookenv.relation_get(attribute='pubkey', unit=unit, rid=relid)
24 privkey = hookenv.relation_get(attribute='privkey', unit=unit, rid=relid)
25 log("Public key config: %s" % pubkey)
26 gpfshooklib.set_ssh_key(pubkey, private=False)34 gpfshooklib.set_ssh_key(pubkey, private=False)
27 gpfshooklib.set_ssh_key(privkey, private=True)35 gpfshooklib.set_ssh_key(privkey, private=True)
28 # start gpfs36 if hookname == "manager-relation-changed" and not rlhn is None:
29 # set the node to the manager
30 #call(split('mmstartup -a'))
31 if hookname == "manager-relation-changed":
32 log("Creating GPFS cluster")37 log("Creating GPFS cluster")
33 relid = hookenv.relation_id()38 gpfshooklib.create_cluster(llhn)
34 runit = hookenv.remote_unit()39 gpfshooklib.apply_license(llhn)
35 hostname = socket.gethostname()
36 gpfshooklib.create_cluster(hostname)
37 gpfshooklib.apply_license(hostname)
38 chostname = hookenv.relation_get(attribute='hostname',
39 unit=runit, rid=relid)
40 log("Adding remote client")40 log("Adding remote client")
41 gpfshooklib.add_node(chostname)41 gpfshooklib.add_node(rlhn)
42 gpfshooklib.apply_license(chostname)42 gpfshooklib.apply_license(rlhn)
43 # Create disk stanza43 log("Starting cluster")
44 # Create nsd44 gpfshooklib.start()
45 # mmcrnsd -F stanza.txt45
46 # create and mount fs
47 # mmcrfs gpfs1 -F stanza.txt -A yes -T /gpfs
48 # mmmount gpfs1 -a
49 # start gpfs
50 #call(split('mmstartup -a'))
51if __name__ == '__main__':46if __name__ == '__main__':
52 main()47 main()
5348
=== modified file 'charms/trusty/gpfs/hooks/common-relation-joined'
--- charms/trusty/gpfs/hooks/common-relation-joined 2015-02-09 11:42:31 +0000
+++ charms/trusty/gpfs/hooks/common-relation-joined 2015-03-03 17:58:00 +0000
@@ -17,9 +17,13 @@
17def main():17def main():
18 hookname = hookenv.hook_name()18 hookname = hookenv.hook_name()
19 hookenv.relation_set(hookenv.relation_id(), {19 hookenv.relation_set(hookenv.relation_id(), {
20 'hostname': socket.gethostname()20 'lhostname': socket.getfqdn(),
21 'pip': hookenv.unit_private_ip()
21 })22 })
23
22 if hookname == "manager-relation-joined":24 if hookname == "manager-relation-joined":
25 # Denote this as a manager
26 gpfshooklib.set_manager_file()
23 # Generate ssh keys if needed27 # Generate ssh keys if needed
24 gpfshooklib.create_ssh_keys()28 gpfshooklib.create_ssh_keys()
25 privkey, pubkey = gpfshooklib.get_ssh_keys()29 privkey, pubkey = gpfshooklib.get_ssh_keys()
@@ -31,7 +35,6 @@
31 if hookname == "client-relation-joined":35 if hookname == "client-relation-joined":
32 # Set the node designation values and hostname36 # Set the node designation values and hostname
33 hookenv.relation_set(hookenv.relation_id(), {37 hookenv.relation_set(hookenv.relation_id(), {
34 'hostname': socket.gethostname(),
35 'quorum': 'quorum',38 'quorum': 'quorum',
36 'client': 'client'39 'client': 'client'
37 }) 40 })
3841
=== modified file 'charms/trusty/gpfs/hooks/gpfshooklib.py'
--- charms/trusty/gpfs/hooks/gpfshooklib.py 2015-02-19 12:46:34 +0000
+++ charms/trusty/gpfs/hooks/gpfshooklib.py 2015-03-03 17:58:00 +0000
@@ -5,6 +5,7 @@
5import sys5import sys
6import shutil6import shutil
7import tempfile7import tempfile
8import socket
8from shlex import split9from shlex import split
9from subprocess import (10from subprocess import (
10 call,11 call,
@@ -134,6 +135,16 @@
134 135
135def create_cluster(hostname):136def create_cluster(hostname):
136 # create the cluster for the hostname, manager only137 # create the cluster for the hostname, manager only
137 if not is_manager() and not cluster_exists():138 if is_manager() and not cluster_exists():
138 log(check_output(split('mmcrcluster -N %s:quorum-manager' % \139 log(check_output(split('mmcrcluster -N %s:quorum-manager' % \
139 hostname + ' -r /usr/bin/ssh -R /usr/bin/scp')))140 hostname + ' -r /usr/bin/ssh -R /usr/bin/scp')))
141
142def chk_dns(hostname, ip):
143 try:
144 socket.gethostbyname(hostname)
145 except:
146 log("Hostname not resolving, adding to /etc/hosts")
147 with open("/etc/hosts", "a") as hostfile:
148 hostfile.write("%s %s\n" % (ip, hostname) )
149 hostfile.close()
150

Subscribers

People subscribed via source and target branches