Merge lp:~adalbas/ibmcharms/gpfs-config into lp:ibmcharms
- gpfs-config
- Merge into devel
Proposed by
Adalberto Medeiros
Status: | Merged |
---|---|
Merged at revision: | 27 |
Proposed branch: | lp:~adalbas/ibmcharms/gpfs-config |
Merge into: | lp:ibmcharms |
Diff against target: |
482 lines (+167/-64) 10 files modified
charms/trusty/gpfs/README.md (+5/-1) charms/trusty/gpfs/config.yaml (+6/-0) charms/trusty/gpfs/hooks/common-relation-changed (+5/-3) charms/trusty/gpfs/hooks/common-relation-joined (+6/-3) charms/trusty/gpfs/hooks/config-changed (+35/-2) charms/trusty/gpfs/hooks/gpfshooklib.py (+90/-12) charms/trusty/gpfs/hooks/install (+18/-42) charms/trusty/gpfs/hooks/start (+1/-0) charms/trusty/gpfs/hooks/stop (+1/-0) charms/trusty/gpfs/tests/10-deploy (+0/-1) |
To merge this branch: | bzr merge lp:~adalbas/ibmcharms/gpfs-config |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Chase-Salerno | Approve | ||
Review via email: mp+251319@code.launchpad.net |
Commit message
Description of the change
Add install to gpfshooklib.py
Add config-changed. Installation is done here if gpfs_url was not set before.
Add unit test. Still not fully tested
To post a comment you must log in.
- 27. By Adalberto Medeiros
-
Changes on installation for config-changed
- 28. By Adalberto Medeiros
-
Merge with dnsfixes
- 29. By Adalberto Medeiros
-
Fix pep8
- 30. By Adalberto Medeiros
-
merge tests
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'charms/trusty/gpfs/README.md' | |||
2 | --- charms/trusty/gpfs/README.md 2015-01-27 12:40:23 +0000 | |||
3 | +++ charms/trusty/gpfs/README.md 2015-03-09 15:35:58 +0000 | |||
4 | @@ -30,13 +30,17 @@ | |||
5 | 30 | Configure config.yaml with the repository url | 30 | Configure config.yaml with the repository url |
6 | 31 | 31 | ||
7 | 32 | gpfs_url: "http://<server-name>/debs/gpfs4.1" | 32 | gpfs_url: "http://<server-name>/debs/gpfs4.1" |
9 | 33 | **Packages.gz should be on the same directory as the packages. The install hook will add Linux/x86_64 to the URL | 33 | **Packages.gz should be on the same directory as the packages. The install hook will add Linux/x86_64 to the URL** |
10 | 34 | 34 | ||
11 | 35 | You can also set gpfs_url with "juju set" after deploy the charm | ||
12 | 35 | ## Deploy | 36 | ## Deploy |
13 | 36 | 37 | ||
14 | 37 | juju deploy gpfs gpfs-manager | 38 | juju deploy gpfs gpfs-manager |
15 | 38 | juju deploy gpfs gpfs-client | 39 | juju deploy gpfs gpfs-client |
16 | 39 | 40 | ||
17 | 41 | # If gpfs_url is not set | ||
18 | 42 | juju set gpfs-manager gpfs_url="http://<server-name>/debs/gpfs4.1" | ||
19 | 43 | |||
20 | 40 | juju add relation gpfs-manager:manager gpfs-client:client | 44 | juju add relation gpfs-manager:manager gpfs-client:client |
21 | 41 | 45 | ||
22 | 42 | # Configuration | 46 | # Configuration |
23 | 43 | 47 | ||
24 | === modified file 'charms/trusty/gpfs/config.yaml' | |||
25 | --- charms/trusty/gpfs/config.yaml 2015-01-27 12:19:54 +0000 | |||
26 | +++ charms/trusty/gpfs/config.yaml 2015-03-09 15:35:58 +0000 | |||
27 | @@ -11,3 +11,9 @@ | |||
28 | 11 | type: string | 11 | type: string |
29 | 12 | default: "4.1" | 12 | default: "4.1" |
30 | 13 | description: "Version of GPFS" | 13 | description: "Version of GPFS" |
31 | 14 | quorum: | ||
32 | 15 | type: string | ||
33 | 16 | default: "quorum" | ||
34 | 17 | description: > | ||
35 | 18 | Designation for nodes. Values can be quorum, | ||
36 | 19 | non-quorum or empty string (this assumes non-quorum) | ||
37 | 14 | 20 | ||
38 | === modified file 'charms/trusty/gpfs/hooks/common-relation-changed' | |||
39 | --- charms/trusty/gpfs/hooks/common-relation-changed 2015-03-03 17:57:57 +0000 | |||
40 | +++ charms/trusty/gpfs/hooks/common-relation-changed 2015-03-09 15:35:58 +0000 | |||
41 | @@ -24,13 +24,15 @@ | |||
42 | 24 | rlhn = hookenv.relation_get(attribute='lhostname', unit=runit, rid=relid) | 24 | rlhn = hookenv.relation_get(attribute='lhostname', unit=runit, rid=relid) |
43 | 25 | llhn = socket.getfqdn() | 25 | llhn = socket.getfqdn() |
44 | 26 | if not rlhn is None: | 26 | if not rlhn is None: |
46 | 27 | gpfshooklib.chk_dns(rlhn,rip) | 27 | gpfshooklib.chk_dns(rlhn, rip) |
47 | 28 | 28 | ||
48 | 29 | if hookname == "client-relation-changed": | 29 | if hookname == "client-relation-changed": |
49 | 30 | # Save the keypair from the manager | 30 | # Save the keypair from the manager |
50 | 31 | log("Copying keys to client") | 31 | log("Copying keys to client") |
53 | 32 | pubkey = hookenv.relation_get(attribute='pubkey', unit=runit, rid=relid) | 32 | pubkey = hookenv.relation_get(attribute='pubkey', unit=runit, |
54 | 33 | privkey = hookenv.relation_get(attribute='privkey', unit=runit, rid=relid) | 33 | rid=relid) |
55 | 34 | privkey = hookenv.relation_get(attribute='privkey', unit=runit, | ||
56 | 35 | rid=relid) | ||
57 | 34 | gpfshooklib.set_ssh_key(pubkey, private=False) | 36 | gpfshooklib.set_ssh_key(pubkey, private=False) |
58 | 35 | gpfshooklib.set_ssh_key(privkey, private=True) | 37 | gpfshooklib.set_ssh_key(privkey, private=True) |
59 | 36 | if hookname == "manager-relation-changed" and not rlhn is None: | 38 | if hookname == "manager-relation-changed" and not rlhn is None: |
60 | 37 | 39 | ||
61 | === modified file 'charms/trusty/gpfs/hooks/common-relation-joined' | |||
62 | --- charms/trusty/gpfs/hooks/common-relation-joined 2015-03-03 17:57:57 +0000 | |||
63 | +++ charms/trusty/gpfs/hooks/common-relation-joined 2015-03-09 15:35:58 +0000 | |||
64 | @@ -12,6 +12,7 @@ | |||
65 | 12 | ) | 12 | ) |
66 | 13 | 13 | ||
67 | 14 | log = hookenv.log | 14 | log = hookenv.log |
68 | 15 | config = hookenv.config() | ||
69 | 15 | 16 | ||
70 | 16 | 17 | ||
71 | 17 | def main(): | 18 | def main(): |
72 | @@ -34,11 +35,13 @@ | |||
73 | 34 | }) | 35 | }) |
74 | 35 | if hookname == "client-relation-joined": | 36 | if hookname == "client-relation-joined": |
75 | 36 | # Set the node designation values and hostname | 37 | # Set the node designation values and hostname |
76 | 38 | quorum = gpfshooklib.validate_quorum(config.get('quorum')) | ||
77 | 37 | hookenv.relation_set(hookenv.relation_id(), { | 39 | hookenv.relation_set(hookenv.relation_id(), { |
79 | 38 | 'quorum': 'quorum', | 40 | 'hostname': socket.gethostname(), |
80 | 41 | 'quorum': quorum, | ||
81 | 39 | 'client': 'client' | 42 | 'client': 'client' |
84 | 40 | }) | 43 | }) |
85 | 41 | 44 | ||
86 | 42 | # Configure sshd to allow root ssh | 45 | # Configure sshd to allow root ssh |
87 | 43 | # Avoid the host key confirmation (all relation-joined) | 46 | # Avoid the host key confirmation (all relation-joined) |
88 | 44 | gpfshooklib.configure_ssh() | 47 | gpfshooklib.configure_ssh() |
89 | 45 | 48 | ||
90 | === modified file 'charms/trusty/gpfs/hooks/config-changed' | |||
91 | --- charms/trusty/gpfs/hooks/config-changed 2015-01-21 19:48:09 +0000 | |||
92 | +++ charms/trusty/gpfs/hooks/config-changed 2015-03-09 15:35:58 +0000 | |||
93 | @@ -9,8 +9,7 @@ | |||
94 | 9 | hookenv, | 9 | hookenv, |
95 | 10 | host, | 10 | host, |
96 | 11 | ) | 11 | ) |
99 | 12 | 12 | import gpfshooklib | |
98 | 13 | #from start import start | ||
100 | 14 | 13 | ||
101 | 15 | hooks = hookenv.Hooks() | 14 | hooks = hookenv.Hooks() |
102 | 16 | log = hookenv.log | 15 | log = hookenv.log |
103 | @@ -22,15 +21,49 @@ | |||
104 | 22 | def config_changed(): | 21 | def config_changed(): |
105 | 23 | config = hookenv.config() | 22 | config = hookenv.config() |
106 | 24 | 23 | ||
107 | 24 | install_bool = False | ||
108 | 25 | for key in config: | 25 | for key in config: |
109 | 26 | if config.changed(key): | 26 | if config.changed(key): |
110 | 27 | log("config['{}'] changed from {} to {}".format( | 27 | log("config['{}'] changed from {} to {}".format( |
111 | 28 | key, config.previous(key), config[key])) | 28 | key, config.previous(key), config[key])) |
112 | 29 | if key in ['gpfs_url', 'version', 'update']: | ||
113 | 30 | install_bool = True | ||
114 | 31 | |||
115 | 32 | # If installation configuration has changed, reinstall gpfs | ||
116 | 33 | log("Installation: %s" % install_bool) | ||
117 | 34 | gpfs_url = config['gpfs_url'] | ||
118 | 35 | version = config['version'] | ||
119 | 36 | update = config['update'] | ||
120 | 37 | |||
121 | 38 | # exit if there is no source | ||
122 | 39 | gpfshooklib.check_empty_source(gpfs_url) | ||
123 | 40 | # If source changed, install packages from new source | ||
124 | 41 | if install_bool: | ||
125 | 42 | install_gpfs(gpfs_url, version, update) | ||
126 | 43 | |||
127 | 44 | # if quorum changed, change node designation | ||
128 | 45 | if config.changed('quorum'): | ||
129 | 46 | unit = hookenv.local_unit() | ||
130 | 47 | quorum = config.get('quorum') | ||
131 | 48 | change_node_designation(unit, quorum) | ||
132 | 29 | 49 | ||
133 | 30 | config.save() | 50 | config.save() |
134 | 31 | #start.start() | 51 | #start.start() |
135 | 32 | 52 | ||
136 | 33 | 53 | ||
137 | 54 | def install_gpfs(gpfs_url, version, update): | ||
138 | 55 | # install gpfs | ||
139 | 56 | |||
140 | 57 | gpfshooklib.gpfs_install(gpfs_url, version) | ||
141 | 58 | gpfshooklib.gpfs_install_updates(gpfs_url, version, update) | ||
142 | 59 | gpfshooklib.build_modules() | ||
143 | 60 | |||
144 | 61 | |||
145 | 62 | def change_node_designation(unit, quorum='quorum'): | ||
146 | 63 | # TODO, change unit designation to quorum or non-quorum | ||
147 | 64 | pass | ||
148 | 65 | |||
149 | 66 | |||
150 | 34 | if __name__ == "__main__": | 67 | if __name__ == "__main__": |
151 | 35 | # execute a hook based on the name the program is called by | 68 | # execute a hook based on the name the program is called by |
152 | 36 | hooks.execute(sys.argv) | 69 | hooks.execute(sys.argv) |
153 | 37 | 70 | ||
154 | === modified file 'charms/trusty/gpfs/hooks/gpfshooklib.py' | |||
155 | --- charms/trusty/gpfs/hooks/gpfshooklib.py 2015-03-03 17:57:57 +0000 | |||
156 | +++ charms/trusty/gpfs/hooks/gpfshooklib.py 2015-03-09 15:35:58 +0000 | |||
157 | @@ -7,24 +7,75 @@ | |||
158 | 7 | import tempfile | 7 | import tempfile |
159 | 8 | import socket | 8 | import socket |
160 | 9 | from shlex import split | 9 | from shlex import split |
161 | 10 | import subprocess | ||
162 | 10 | from subprocess import ( | 11 | from subprocess import ( |
163 | 11 | call, | 12 | call, |
164 | 12 | check_call, | 13 | check_call, |
166 | 13 | check_output | 14 | check_output, |
167 | 15 | Popen, | ||
168 | 16 | CalledProcessError | ||
169 | 14 | ) | 17 | ) |
170 | 15 | 18 | ||
171 | 16 | sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib')) | 19 | sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib')) |
172 | 17 | 20 | ||
173 | 21 | from charmhelpers import fetch | ||
174 | 18 | from charmhelpers.core import ( | 22 | from charmhelpers.core import ( |
175 | 19 | hookenv, | 23 | hookenv, |
176 | 20 | ) | 24 | ) |
177 | 21 | log = hookenv.log | 25 | log = hookenv.log |
178 | 22 | 26 | ||
179 | 27 | GPFS_PATH = '/Linux/x86_64' | ||
180 | 28 | |||
181 | 29 | |||
182 | 23 | def add_to_path(p, new): | 30 | def add_to_path(p, new): |
183 | 24 | return p if new in p.split(':') else p + ':' + new | 31 | return p if new in p.split(':') else p + ':' + new |
184 | 25 | 32 | ||
185 | 26 | os.environ['PATH'] = add_to_path(os.environ['PATH'], '/usr/lpp/mmfs/bin') | 33 | os.environ['PATH'] = add_to_path(os.environ['PATH'], '/usr/lpp/mmfs/bin') |
186 | 27 | 34 | ||
187 | 35 | |||
188 | 36 | ## installation methods ## | ||
189 | 37 | def _get_source(url, source_dir=""): | ||
190 | 38 | return "deb %s%s ./" % (url, source_dir) | ||
191 | 39 | |||
192 | 40 | |||
193 | 41 | def check_empty_source(gpfs_url): | ||
194 | 42 | # Check if there is a repository to install from | ||
195 | 43 | # TODO: check if packages are already installed | ||
196 | 44 | if not gpfs_url: | ||
197 | 45 | log("No GPFS source available. Use juju set gpfs gpfs_url=<url> " | ||
198 | 46 | "to install packages. See README for more info.", log.ERROR) | ||
199 | 47 | sys.exit(0) | ||
200 | 48 | |||
201 | 49 | |||
202 | 50 | def gpfs_install(url, version): | ||
203 | 51 | # install main gpfs packages | ||
204 | 52 | gpfs_source = _get_source(url, source_dir=GPFS_PATH) | ||
205 | 53 | log('Gpfs source' + gpfs_source) | ||
206 | 54 | |||
207 | 55 | # Add gpfs source and update apt | ||
208 | 56 | fetch.add_source(gpfs_source) | ||
209 | 57 | try: | ||
210 | 58 | fetch.apt_update(fatal=True) | ||
211 | 59 | # Install gpfs packages | ||
212 | 60 | fetch.apt_install("gpfs*", options=["--allow-unauthenticated"], | ||
213 | 61 | fatal=True) | ||
214 | 62 | except CalledProcessError: | ||
215 | 63 | #TODO: verify source was configured correctly | ||
216 | 64 | raise | ||
217 | 65 | |||
218 | 66 | |||
219 | 67 | def gpfs_install_updates(url, version, update=True): | ||
220 | 68 | # install update packages (patches), if given | ||
221 | 69 | if update: | ||
222 | 70 | log('Applying patches') | ||
223 | 71 | source_dir = '/gpfs' + version + '_patches' + GPFS_PATH | ||
224 | 72 | patch_source = _get_source(url, source_dir=source_dir) | ||
225 | 73 | fetch.add_source(patch_source) | ||
226 | 74 | fetch.apt_update(fatal=True) | ||
227 | 75 | fetch.apt_install("gpfs*", options=["--allow-unauthenticated"], | ||
228 | 76 | fatal=True) | ||
229 | 77 | |||
230 | 78 | |||
231 | 28 | ## ssh key methods ## | 79 | ## ssh key methods ## |
232 | 29 | def create_ssh_keys(): | 80 | def create_ssh_keys(): |
233 | 30 | # Generate ssh keys if needed | 81 | # Generate ssh keys if needed |
234 | @@ -34,7 +85,8 @@ | |||
235 | 34 | # Ensure permissions are good | 85 | # Ensure permissions are good |
236 | 35 | os.chmod('/root/.ssh/id_rsa.pub', 0600) | 86 | os.chmod('/root/.ssh/id_rsa.pub', 0600) |
237 | 36 | os.chmod('/root/.ssh/id_rsa', 0600) | 87 | os.chmod('/root/.ssh/id_rsa', 0600) |
239 | 37 | 88 | ||
240 | 89 | |||
241 | 38 | def get_ssh_keys(): | 90 | def get_ssh_keys(): |
242 | 39 | # get public and private ssh keys | 91 | # get public and private ssh keys |
243 | 40 | with open("/root/.ssh/id_rsa.pub", "r") as idfile: | 92 | with open("/root/.ssh/id_rsa.pub", "r") as idfile: |
244 | @@ -48,9 +100,10 @@ | |||
245 | 48 | idfile.close() | 100 | idfile.close() |
246 | 49 | return [privkey, pubkey] | 101 | return [privkey, pubkey] |
247 | 50 | 102 | ||
248 | 103 | |||
249 | 51 | def set_ssh_key(key, private=False): | 104 | def set_ssh_key(key, private=False): |
250 | 52 | if key: | 105 | if key: |
252 | 53 | if private == False: | 106 | if private is False: |
253 | 54 | f = open("/root/.ssh/id_rsa.pub", "w") | 107 | f = open("/root/.ssh/id_rsa.pub", "w") |
254 | 55 | f.write(key) | 108 | f.write(key) |
255 | 56 | f.close() | 109 | f.close() |
256 | @@ -65,6 +118,7 @@ | |||
257 | 65 | f.close() | 118 | f.close() |
258 | 66 | os.chmod('/root/.ssh/id_rsa', 0600) | 119 | os.chmod('/root/.ssh/id_rsa', 0600) |
259 | 67 | 120 | ||
260 | 121 | |||
261 | 68 | def configure_ssh(): | 122 | def configure_ssh(): |
262 | 69 | # Configure sshd_config file to allow root | 123 | # Configure sshd_config file to allow root |
263 | 70 | sshconf = open("/etc/ssh/sshd_config", 'r') | 124 | sshconf = open("/etc/ssh/sshd_config", 'r') |
264 | @@ -91,53 +145,78 @@ | |||
265 | 91 | idfile.write("StrictHostKeyChecking no\n") | 145 | idfile.write("StrictHostKeyChecking no\n") |
266 | 92 | idfile.close() | 146 | idfile.close() |
267 | 93 | 147 | ||
268 | 148 | |||
269 | 149 | ## Other utility methods## | ||
270 | 150 | def validate_quorum(quorum): | ||
271 | 151 | valid_values = ['', 'quorum', 'non-quorum'] | ||
272 | 152 | return quorum if quorum in valid_values else '' | ||
273 | 153 | |||
274 | 154 | |||
275 | 94 | ## cluster management methods ## | 155 | ## cluster management methods ## |
276 | 156 | def build_modules(): | ||
277 | 157 | # build binary gpfs modules after installation | ||
278 | 158 | try: | ||
279 | 159 | check_call(["mmbuildgpl"]) | ||
280 | 160 | except CalledProcessError: | ||
281 | 161 | log('mmbuildgpl was not executed', level=hookenv.WARNING) | ||
282 | 162 | except OSError: | ||
283 | 163 | log('mmbuildgpl not found/installed') | ||
284 | 164 | |||
285 | 95 | 165 | ||
286 | 96 | def start(): | 166 | def start(): |
287 | 97 | # Only manager can start/stop cluster | 167 | # Only manager can start/stop cluster |
288 | 98 | if is_manager(): | 168 | if is_manager(): |
289 | 99 | log(check_output(split('mmstartup -a'))) | 169 | log(check_output(split('mmstartup -a'))) |
290 | 100 | 170 | ||
291 | 171 | |||
292 | 101 | def stop(): | 172 | def stop(): |
293 | 102 | # stop the server | 173 | # stop the server |
294 | 103 | if is_manager(): | 174 | if is_manager(): |
295 | 104 | check_output(split('mmshutdown -a')) | 175 | check_output(split('mmshutdown -a')) |
296 | 105 | 176 | ||
297 | 177 | |||
298 | 106 | def node_exists(nodename): | 178 | def node_exists(nodename): |
299 | 107 | # Check if node has already been added to cluster | 179 | # Check if node has already been added to cluster |
300 | 108 | lscluster = check_output('mmlscluster') | 180 | lscluster = check_output('mmlscluster') |
301 | 109 | node = re.search('^.*\d+.*%s.*\n' % nodename, lscluster, re.M) | 181 | node = re.search('^.*\d+.*%s.*\n' % nodename, lscluster, re.M) |
302 | 110 | return False if node is None else True | 182 | return False if node is None else True |
303 | 111 | 183 | ||
304 | 184 | |||
305 | 112 | def add_node(nodename, m_designation='client', q_designation='nonquorum'): | 185 | def add_node(nodename, m_designation='client', q_designation='nonquorum'): |
306 | 113 | # add new node to the cluster | 186 | # add new node to the cluster |
307 | 114 | if cluster_exists() and not node_exists(nodename): | 187 | if cluster_exists() and not node_exists(nodename): |
310 | 115 | log(check_output(split('mmaddnode -N %s:%s-%s' % \ | 188 | log(check_output(split('mmaddnode -N %s:%s-%s' % |
311 | 116 | (nodename, m_designation, q_designation)))) | 189 | (nodename, m_designation, q_designation)))) |
312 | 117 | else: | 190 | else: |
313 | 118 | log('Node %s could not be added. Manager not defined' % nodename) | 191 | log('Node %s could not be added. Manager not defined' % nodename) |
315 | 119 | 192 | ||
316 | 193 | |||
317 | 120 | def apply_license(nodename): | 194 | def apply_license(nodename): |
318 | 121 | check_output(split('mmchlicense server --accept -N %s' % nodename)) | 195 | check_output(split('mmchlicense server --accept -N %s' % nodename)) |
319 | 122 | 196 | ||
320 | 197 | |||
321 | 123 | def set_manager_file(): | 198 | def set_manager_file(): |
322 | 124 | # define a file that indicates the node is a manager | 199 | # define a file that indicates the node is a manager |
324 | 125 | open("/var/mmfs/.manager","a").close() | 200 | open("/var/mmfs/.manager", "a").close() |
325 | 201 | |||
326 | 126 | 202 | ||
327 | 127 | def is_manager(): | 203 | def is_manager(): |
328 | 128 | # check if the node is a manager | 204 | # check if the node is a manager |
329 | 129 | if os.path.exists("/var/mmfs/.manager"): | 205 | if os.path.exists("/var/mmfs/.manager"): |
330 | 130 | return True | 206 | return True |
331 | 131 | 207 | ||
332 | 208 | |||
333 | 132 | def cluster_exists(): | 209 | def cluster_exists(): |
334 | 133 | # Check if cluster is already defined | 210 | # Check if cluster is already defined |
335 | 134 | return True if call('mmlscluster') == 0 else False | 211 | return True if call('mmlscluster') == 0 else False |
337 | 135 | 212 | ||
338 | 213 | |||
339 | 136 | def create_cluster(hostname): | 214 | def create_cluster(hostname): |
340 | 137 | # create the cluster for the hostname, manager only | 215 | # create the cluster for the hostname, manager only |
341 | 138 | if is_manager() and not cluster_exists(): | 216 | if is_manager() and not cluster_exists(): |
344 | 139 | log(check_output(split('mmcrcluster -N %s:quorum-manager' % \ | 217 | log(check_output(split('mmcrcluster -N %s:quorum-manager' % |
345 | 140 | hostname + ' -r /usr/bin/ssh -R /usr/bin/scp'))) | 218 | hostname + ' -r /usr/bin/ssh -R /usr/bin/scp'))) |
346 | 219 | |||
347 | 141 | 220 | ||
348 | 142 | def chk_dns(hostname, ip): | 221 | def chk_dns(hostname, ip): |
349 | 143 | try: | 222 | try: |
350 | @@ -145,6 +224,5 @@ | |||
351 | 145 | except: | 224 | except: |
352 | 146 | log("Hostname not resolving, adding to /etc/hosts") | 225 | log("Hostname not resolving, adding to /etc/hosts") |
353 | 147 | with open("/etc/hosts", "a") as hostfile: | 226 | with open("/etc/hosts", "a") as hostfile: |
355 | 148 | hostfile.write("%s %s\n" % (ip, hostname) ) | 227 | hostfile.write("%s %s\n" % (ip, hostname)) |
356 | 149 | hostfile.close() | 228 | hostfile.close() |
357 | 150 | |||
358 | 151 | 229 | ||
359 | === modified file 'charms/trusty/gpfs/hooks/install' | |||
360 | --- charms/trusty/gpfs/hooks/install 2015-02-09 11:42:31 +0000 | |||
361 | +++ charms/trusty/gpfs/hooks/install 2015-03-09 15:35:58 +0000 | |||
362 | @@ -11,66 +11,42 @@ | |||
363 | 11 | hookenv, | 11 | hookenv, |
364 | 12 | ) | 12 | ) |
365 | 13 | 13 | ||
366 | 14 | import gpfshooklib | ||
367 | 15 | |||
368 | 14 | hooks = hookenv.Hooks() | 16 | hooks = hookenv.Hooks() |
369 | 15 | log = hookenv.log | 17 | log = hookenv.log |
370 | 16 | config = hookenv.config() | 18 | config = hookenv.config() |
371 | 17 | 19 | ||
374 | 18 | SERVICE = 'gpfs' | 20 | # development packages needed to build kernel modules for GPFS cluster |
373 | 19 | |||
375 | 20 | PREREQS = ["ksh", "binutils", "m4", "libaio1", "g++", "cpp", "make", "gcc"] | 21 | PREREQS = ["ksh", "binutils", "m4", "libaio1", "g++", "cpp", "make", "gcc"] |
380 | 21 | # TODO: gpfs.msg.en_us - change it to any language | 22 | |
377 | 22 | GPFS_PKGS = ["gpfs.base", "gpfs.crypto", "gpfs.docs", "gpfs.ext", | ||
378 | 23 | "gpfs.gpl", "gpfs.gski", "gpfs.msg.en_us"] | ||
379 | 24 | GPFS_PATH = '/Linux/x86_64' | ||
381 | 25 | 23 | ||
382 | 26 | @hooks.hook('install') | 24 | @hooks.hook('install') |
383 | 27 | def install(): | 25 | def install(): |
384 | 28 | log('Installing gpfs') | 26 | log('Installing gpfs') |
385 | 29 | 27 | ||
386 | 30 | # Things that need to happen here | 28 | # Things that need to happen here |
387 | 31 | # Fetch GPFS packages from user given location? | ||
388 | 32 | gpfs_url = config.get('gpfs_url') | 29 | gpfs_url = config.get('gpfs_url') |
389 | 33 | version = config.get('version') | 30 | version = config.get('version') |
390 | 34 | update = config.get('update') # boolean value whether to apply patches | 31 | update = config.get('update') # boolean value whether to apply patches |
391 | 35 | 32 | ||
401 | 36 | gpfs_source = get_source(gpfs_url, source_dir=GPFS_PATH) | 33 | # install kernel prereq and other prereqs |
393 | 37 | log('Gpfs source' + gpfs_source) | ||
394 | 38 | |||
395 | 39 | # Add gpfs source and update apt | ||
396 | 40 | fetch.add_source(gpfs_source) | ||
397 | 41 | fetch.apt_update() | ||
398 | 42 | # Apt install prereqs | ||
399 | 43 | fetch.apt_install(PREREQS) | ||
400 | 44 | # install kernel prereq | ||
402 | 45 | linux_headers = "linux-headers-%s" % get_kernel_version() | 34 | linux_headers = "linux-headers-%s" % get_kernel_version() |
428 | 46 | fetch.apt_install(linux_headers) | 35 | fetch.apt_install(PREREQS + [linux_headers]) |
429 | 47 | 36 | ||
430 | 48 | # Install gpfs packages | 37 | if gpfs_url == "": |
431 | 49 | fetch.apt_install("gpfs*", options=["--allow-unauthenticated"]) | 38 | log("""No GPFS source packages. Use juju set gpfs gpfs_url=<url> |
432 | 50 | 39 | to install packages. See README for more info""", | |
433 | 51 | # Apply patch packages | 40 | level=hookenv.ERROR) |
434 | 52 | if update: | 41 | sys.exit(0) |
435 | 53 | log('Applying patches') | 42 | |
436 | 54 | source_dir = '/gpfs' + version + '_patches' + GPFS_PATH | 43 | gpfshooklib.gpfs_install(gpfs_url, version) |
437 | 55 | patch_source = get_source(gpfs_url, source_dir=source_dir) | 44 | gpfshooklib.gpfs_install_updates(gpfs_url, version, update) |
438 | 56 | fetch.add_source(patch_source) | 45 | gpfshooklib.build_modules() |
439 | 57 | fetch.apt_update() | 46 | |
415 | 58 | fetch.apt_install("gpfs*", options=["--allow-unauthenticated"]) | ||
416 | 59 | |||
417 | 60 | # Build binary modules | ||
418 | 61 | os.environ['PATH'] += (':/usr/lpp/mmfs/bin') | ||
419 | 62 | try: | ||
420 | 63 | subprocess.check_call(["mmbuildgpl"]) | ||
421 | 64 | except subprocess.CalledProcessError: | ||
422 | 65 | log('mmbuildgpl was not executed', level=hookenv.WARNING) | ||
423 | 66 | except OSError: | ||
424 | 67 | log('mmbuildgpl not found/installed') | ||
425 | 68 | |||
426 | 69 | def get_source(url, source_dir=""): | ||
427 | 70 | return "deb %s%s ./" % (url,source_dir) | ||
440 | 71 | 47 | ||
441 | 72 | def get_kernel_version(): | 48 | def get_kernel_version(): |
443 | 73 | return subprocess.check_output(['uname','-r']).strip() | 49 | return subprocess.check_output(['uname', '-r']).strip() |
444 | 74 | 50 | ||
445 | 75 | if __name__ == "__main__": | 51 | if __name__ == "__main__": |
446 | 76 | # execute a hook based on the name the program is called by | 52 | # execute a hook based on the name the program is called by |
447 | 77 | 53 | ||
448 | === modified file 'charms/trusty/gpfs/hooks/start' | |||
449 | --- charms/trusty/gpfs/hooks/start 2015-02-10 02:11:55 +0000 | |||
450 | +++ charms/trusty/gpfs/hooks/start 2015-03-09 15:35:58 +0000 | |||
451 | @@ -15,6 +15,7 @@ | |||
452 | 15 | hooks = hookenv.Hooks() | 15 | hooks = hookenv.Hooks() |
453 | 16 | log = hookenv.log | 16 | log = hookenv.log |
454 | 17 | 17 | ||
455 | 18 | |||
456 | 18 | @hooks.hook('start') | 19 | @hooks.hook('start') |
457 | 19 | def start(): | 20 | def start(): |
458 | 20 | log("Starting cluster (manager only)") | 21 | log("Starting cluster (manager only)") |
459 | 21 | 22 | ||
460 | === modified file 'charms/trusty/gpfs/hooks/stop' | |||
461 | --- charms/trusty/gpfs/hooks/stop 2015-02-10 02:11:55 +0000 | |||
462 | +++ charms/trusty/gpfs/hooks/stop 2015-03-09 15:35:58 +0000 | |||
463 | @@ -14,6 +14,7 @@ | |||
464 | 14 | hooks = hookenv.Hooks() | 14 | hooks = hookenv.Hooks() |
465 | 15 | log = hookenv.log | 15 | log = hookenv.log |
466 | 16 | 16 | ||
467 | 17 | |||
468 | 17 | @hooks.hook('stop') | 18 | @hooks.hook('stop') |
469 | 18 | def stop(): | 19 | def stop(): |
470 | 19 | gpfshooklib.stop() | 20 | gpfshooklib.stop() |
471 | 20 | 21 | ||
472 | === modified file 'charms/trusty/gpfs/tests/10-deploy' | |||
473 | --- charms/trusty/gpfs/tests/10-deploy 2015-03-09 15:24:07 +0000 | |||
474 | +++ charms/trusty/gpfs/tests/10-deploy 2015-03-09 15:35:58 +0000 | |||
475 | @@ -25,7 +25,6 @@ | |||
476 | 25 | 25 | ||
477 | 26 | unit_manager_0 = d.sentry.unit['gpfs/0'] | 26 | unit_manager_0 = d.sentry.unit['gpfs/0'] |
478 | 27 | unit_client_0 = d.sentry.unit['gpfs-client/0'] | 27 | unit_client_0 = d.sentry.unit['gpfs-client/0'] |
479 | 28 | |||
480 | 29 | print(unit_manager_0.info) | 28 | print(unit_manager_0.info) |
481 | 30 | 29 | ||
482 | 31 | # verify unit_manager is manager | 30 | # verify unit_manager is manager |
Looks good to me.