Merge lp:~ibmcharmers/charms/trusty/ibm-db2/trunk into lp:charms/trusty/ibm-db2
- Trusty Tahr (14.04)
- trunk
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Kevin W Monroe |
Approved revision: | 63 |
Merge reported by: | Cory Johns |
Merged at revision: | not available |
Proposed branch: | lp:~ibmcharmers/charms/trusty/ibm-db2/trunk |
Merge into: | lp:charms/trusty/ibm-db2 |
Diff against target: |
4535 lines (+2938/-1212) 47 files modified
.build.manifest (+298/-0) .gitignore (+2/-0) Makefile (+24/-0) README.md (+78/-64) bin/layer_option (+24/-0) config.yaml (+62/-71) copyright (+1/-1) files/archives/db2inst1.INS (+119/-0) files/archives/db2installresfile/db2inst1.INS (+0/-119) files/archives/db2installresfile/db2server.rsp (+0/-64) files/archives/db2installresfile/db2server_ppcle.rsp (+0/-64) files/archives/db2server.rsp (+64/-0) files/archives/db2server_ppcle.rsp (+64/-0) files/sftp_get.sh (+0/-19) hooks/config-changed (+19/-568) hooks/db-relation-broken (+19/-0) hooks/db-relation-changed (+19/-0) hooks/db-relation-departed (+19/-0) hooks/db-relation-joined (+19/-14) hooks/hook.template (+19/-0) hooks/install (+19/-62) hooks/leader-elected (+19/-0) hooks/leader-settings-changed (+19/-0) hooks/relations/db2/README.md (+66/-0) hooks/relations/db2/interface.yaml (+4/-0) hooks/relations/db2/provides.py (+80/-0) hooks/relations/db2/requires.py (+65/-0) hooks/start (+19/-48) hooks/stop (+19/-30) hooks/update-status (+19/-0) hooks/upgrade-charm (+28/-0) layer.yaml (+22/-0) lib/charms/__init__.py (+2/-0) lib/charms/apt.py (+182/-0) lib/charms/layer/__init__.py (+21/-0) lib/charms/layer/basic.py (+159/-0) lib/charms/layer/execd.py (+138/-0) lib/charms/leadership.py (+58/-0) metadata.yaml (+21/-14) reactive/apt.py (+112/-0) reactive/ibm-base.sh (+107/-0) reactive/ibm-db2.sh (+799/-0) reactive/leadership.py (+68/-0) requirements.txt (+2/-0) tests/00-setup (+10/-24) tests/10-bundles-test.py (+18/-50) tox.ini (+12/-0) |
To merge this branch: | bzr merge lp:~ibmcharmers/charms/trusty/ibm-db2/trunk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kevin W Monroe | Approve | ||
Review Queue (community) | automated testing | Needs Fixing | |
Review via email: mp+294153@code.launchpad.net |
Commit message
Code changes for DB2 Layered charm
Description of the change
Updates for Layered DB2 charm.
Deployable charm can be fond in the
Repo : https:/
And, its source code can be found in the below repository
Repo : https:/
The charm has been pushed into charm store as well
branch : cs:~ibmcharmers
Review Queue (review-queue) wrote : | # |
Review Queue (review-queue) wrote : | # |
This item has failed automated testing! Results available here http://
Cory Johns (johnsca) wrote : | # |
Overall this looks good. I encountered a couple of small rough edges from the ibm-base layer, which can be addressed there. But I did notice that the ibm-db2.
Suchitra Venugopal (suchvenu) wrote : | # |
> Overall this looks good. I encountered a couple of small rough edges from the
> ibm-base layer, which can be addressed there. But I did notice that the ibm-
> db2.client.
> sends SSH keys, all consumers will assume that keys have been sent, and once
> any one consumer departs, all consumers will be blocked even if they
> previously sent SSH keys. I don't know if that was intended, but it seems
> like that state should be set by the interface layer instead, such as in the
> dismiss() method.
Hi Cory,
I have done the changes as per your suggestions. Please review once and let me know.
Thanks,
Suchitra
Kevin W Monroe (kwmonroe) wrote : | # |
Hi Suchitra - to be compatible with recent changes in the db2 interface layer [0], I updated layer-ibm-db2 source so it uses the 'db.connected' state instead of 'db.available'. There is no need to have both states in the interface, so I removed references to the undocumented 'available' state.
The resultant ibm-db2 charms seems ok to me, but I would like you to verify this still works as expected for you. A charm based on these changes is available here:
https:/
And can be deployed with:
juju deploy cs:~ibmcharmers
Please let me know if this works as expected for you. If all is ok, we'll promulgate v35. Thanks!!
[0] - http://
Kevin W Monroe (kwmonroe) wrote : | # |
A diff of the changes from my comment above can be found here:
http://
Apologies for including lint fixes there; you can find relevant changes by searching for 'db.connected' in that diff.
Kevin W Monroe (kwmonroe) wrote : | # |
I made a mistake in the ssh_key handler in the interface, which has now been fixed. A new version of ibm-db2 for test is available here:
juju deploy cs:~ibmcharmers
Suchitra Venugopal (suchvenu) wrote : | # |
Charm is tested with the changes. Few minor changes are done to handle the states properly.
Suchitra Venugopal (suchvenu) wrote : | # |
The new version is available here :
cs:~ibmcharmers
- 62. By Suchitra Venugopal
-
DB2 stopping the apps before db2stop
Kevin W Monroe (kwmonroe) wrote : | # |
Hi Suchitra, I made quite a few tweaks to the layered source:
Some are cosmetic, others are bash-ism tweaks (like comparing strings with == and integers with -eq). The most significant, however, is in the password handling of db2 users.
I didn't realize before that the db2inst1, dasusr1, db2fenc1, and the users for related units all had default passwords. This isn't acceptable for applications providing network services, so I updated this charm to use the 'pwgen' utility to create random passwords for these users.
Have a look at the above diff, which is available for deployment at:
cs:~ibmcharmers
If you're ok with these changes, we can (finally) promulgate v39 :)
Thanks!
-Kevin
Kevin W Monroe (kwmonroe) wrote : | # |
There was a bug in the leadership layer [0] that would cause the config.set.x states to be reset after the 'leader-elected' hook was run. This caused the db2 charm to report blocked even after installation because it thought license.accepted was no longer set.
This has been fixed in cs:~ibmcharmers
We'll need the MP in [0] to be merged before officially promoting v41. Hopefully that will happen in the next few hours.
[0] https:/
Suchitra Venugopal (suchvenu) wrote : | # |
I just removed the 2 functions you added for missing license and curl config , to check whether everything else is working fine.
1. DB2 gets installed but shows the state as
ibm-db2:
charm: local:trusty/
exposed: false
service-status:
current: maintenance
message: Installing binutils,
since: 14 Jul 2016 09:37:15+05:30
units:
ibm-db2/14:
current: maintenance
message: Installing binutils,
since: 14 Jul 2016 09:37:15+05:30
current: idle
since: 14 Jul 2016 10:07:49+05:30
version: 1.25.5.1
machine: "49"
The status history shows like this :
charm@islrpbeix
TIME TYPE STATUS MESSAGE
14 Jul 2016 09:21:59+05:30 workload unknown Waiting for agent initialization to finish
14 Jul 2016 09:21:59+05:30 agent allocating
14 Jul 2016 09:24:51+05:30 workload maintenance installing charm software
14 Jul 2016 09:24:52+05:30 agent executing running install hook
14 Jul 2016 09:26:24+05:30 workload maintenance ibm-base: fetching resource(s)
14 Jul 2016 09:34:38+05:30 workload active ibm-base: curl resource(s) fetched
14 Jul 2016 09:34:39+05:30 workload maintenance Installing pre requisites for IBM DB2
14 Jul 2016 09:34:51+05:30 workload maintenance Installed pre requisites for IBM DB2
14 Jul 2016 09:34:51+05:30 workload maintenance Updating apt cache
14 Jul 2016 09:35:25+05:30 workload maintenance Installing IBM DB2
14 Jul 2016 09:37:15+05:30 workload active IBM DB2 Installed
14 Jul 2016 09:37:15+05:30 workload maintenance Installing binutils,
14 Jul 2016 09:37:15+05:30 workload maintenance Installing binutils,
14 Jul 2016 09:37:20+05:30 agent executing running leader-elected hook
14 Jul 2016 09:37:23+05:30 agent executing running config-changed hook
14 Jul 2016 09:37:26+05:30 agent executing running start hook
14 Jul 2016 09:37:28+05:30 agent executing running update-status hook
14 Jul 2016 09:37:33+05:30 agent idle
14 Jul 2016 09:42:31+05:30 agent executing running update-status hook
14 Jul 2016 09:42:36+05:30 agent idle
14 Jul 2016 09:47:34+05:30 agent executing running update-status hook
14 Jul 2016 09:47:39+05:30 agent idle
14 Jul 2016 09:52:37+05:30 agent executing running update-status hook
14 Jul 2016 09:52:42+05:30 agent idle
14 Jul 2016 09:57:40+05:30 agent executing running update-status hook
14 Jul 2016 09:57:44+05:30 agent idle
14 Jul 2016 10:02:42+05:30 agent ...
Suchitra Venugopal (suchvenu) wrote : | # |
Getting this issue related to removing SSH Key
I am getting the following error in the log:
mmzo2djFG9xK7Ld
2016-07-14 08:41:56 INFO stop mv: cannot stat 'tempfile.txt': No such file or directory
2016-07-14 08:41:56 INFO stop Traceback (most recent call last):
2016-07-14 08:41:56 INFO stop File "/var/lib/
2016-07-14 08:41:56 INFO stop main()
2016-07-14 08:41:56 INFO stop File "/usr/local/
2
I revert back the change you did for remove_sshkeys() function and its working fine.
What was the reason for this change ? I tried testing with 2 consumers and it looks fine for me, while removing the relation between DB2 and this consumer.
Suchitra Venugopal (suchvenu) wrote : | # |
Done the following changes with combined effort from Kevin and myself.
1. Issue related to unordered status fixed.
2. SSH key issue - reverted back the code changes related to this.
3. Updated README file with DB2 limitations
- 63. By Kevin W Monroe
-
new build of layered db2 charm (source lives in lp:~ibmcharmers/charms/trusty/layer-ibm-db2/trunk)
Kevin W Monroe (kwmonroe) wrote : | # |
This has been a long time coming, but it looks good :) The layered ibm-db2 charm is now promulgated (https:/
juju deploy ibm-db2
Thanks for the patience and work to get this charm into a recommended state!
Cory Johns (johnsca) wrote : | # |
Changed status to Merged to drop off queue
Preview Diff
1 | === added file '.build.manifest' |
2 | --- .build.manifest 1970-01-01 00:00:00 +0000 |
3 | +++ .build.manifest 2016-07-14 17:53:24 +0000 |
4 | @@ -0,0 +1,298 @@ |
5 | +{ |
6 | + "layers": [ |
7 | + "layer:ibm-base", |
8 | + "layer:basic", |
9 | + "layer:apt", |
10 | + "layer:leadership", |
11 | + "ibm-db2", |
12 | + "interface:db2", |
13 | + "build" |
14 | + ], |
15 | + "signatures": { |
16 | + "bin/layer_option": [ |
17 | + "layer:basic", |
18 | + "static", |
19 | + "621b556cd208005e131e9f648859294347da9376609745a73ca2e808dd2032f9" |
20 | + ], |
21 | + "hooks/leader-settings-changed": [ |
22 | + "layer:basic", |
23 | + "static", |
24 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
25 | + ], |
26 | + "wheelhouse/pyaml-15.8.2.tar.gz": [ |
27 | + "layer:basic", |
28 | + "dynamic", |
29 | + "9c54fb5f17b58572c4cef50affea60bb73f445ab153580dac07a12383712b5b8" |
30 | + ], |
31 | + "lib/charms/layer/execd.py": [ |
32 | + "layer:basic", |
33 | + "static", |
34 | + "c0eb4c90e93a14f04d851f78bc6592e093226321fbe328125958633397aed014" |
35 | + ], |
36 | + "hooks/leader-elected": [ |
37 | + "layer:basic", |
38 | + "static", |
39 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
40 | + ], |
41 | + "Makefile": [ |
42 | + "layer:basic", |
43 | + "static", |
44 | + "b7ab3a34e5faf79b96a8632039a0ad0aa87f2a9b5f0ba604e007cafb22190301" |
45 | + ], |
46 | + "reactive/__init__.py": [ |
47 | + "layer:leadership", |
48 | + "static", |
49 | + "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" |
50 | + ], |
51 | + "tests/00-setup": [ |
52 | + "ibm-db2", |
53 | + "static", |
54 | + "0307887d397887fbf3f2f60b963535c455a2771615ae84c722b59a937c2185a3" |
55 | + ], |
56 | + "reactive/ibm-db2.sh": [ |
57 | + "ibm-db2", |
58 | + "static", |
59 | + "d28f50f4c6e4441501665edb609b88836af7517b4a234f286b151f5c41b61acc" |
60 | + ], |
61 | + ".build.manifest": [ |
62 | + "build", |
63 | + "dynamic", |
64 | + "unchecked" |
65 | + ], |
66 | + "hooks/upgrade-charm": [ |
67 | + "layer:basic", |
68 | + "static", |
69 | + "8b9c153a61cc78067af8d016a8fa1c764caad3a40c82bb0b5121fc4c4c6a04f1" |
70 | + ], |
71 | + "wheelhouse/charms.reactive-0.4.4.tar.gz": [ |
72 | + "layer:basic", |
73 | + "dynamic", |
74 | + "97455ce944a85adb2ceb897af81a1b93746f43527e6c4ac44798b193132158c7" |
75 | + ], |
76 | + "wheelhouse/Tempita-0.5.2.tar.gz": [ |
77 | + "layer:basic", |
78 | + "dynamic", |
79 | + "cacecf0baa674d356641f1d406b8bff1d756d739c46b869a54de515d08e6fc9c" |
80 | + ], |
81 | + "hooks/relations/db2/README.md": [ |
82 | + "interface:db2", |
83 | + "static", |
84 | + "200642c8fc5863827cd22d596b83b50be20205a6ecaebe7fd177fa52c1e16bb5" |
85 | + ], |
86 | + "reactive/leadership.py": [ |
87 | + "layer:leadership", |
88 | + "static", |
89 | + "e2b233cf861adc3b2d9e9c062134ce2f104953f03283cdddd88f49efee652e8f" |
90 | + ], |
91 | + "lib/charms/layer/basic.py": [ |
92 | + "layer:basic", |
93 | + "static", |
94 | + "d52423911fcef803a418025d355ac7c2e6729c2949c68aaf01bb3f8f24b67831" |
95 | + ], |
96 | + "tox.ini": [ |
97 | + "layer:basic", |
98 | + "static", |
99 | + "00b57a776ac313e92a52daa05d1fdb6056c21b3105b643d32610fd937664321b" |
100 | + ], |
101 | + "reactive/ibm-base.sh": [ |
102 | + "layer:ibm-base", |
103 | + "static", |
104 | + "d6251d7632d5cdd6fbc44db2478ab6ad1a392a1ed99867b28cff93b9402b2a1f" |
105 | + ], |
106 | + "tests/bundles.yaml": [ |
107 | + "ibm-db2", |
108 | + "static", |
109 | + "1f2ad79c72a0c737e7d1e94b8047076a50fd33029100435c5d39fca46f1a4f81" |
110 | + ], |
111 | + "copyright": [ |
112 | + "ibm-db2", |
113 | + "static", |
114 | + "600ba4f95fa249c78ea37dfcf870a1df35a0480509ca29bc221a80c6a7486711" |
115 | + ], |
116 | + "hooks/install": [ |
117 | + "layer:basic", |
118 | + "static", |
119 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
120 | + ], |
121 | + "lib/charms/leadership.py": [ |
122 | + "layer:leadership", |
123 | + "static", |
124 | + "12b52fa768c3e9072556ac6f46f68129dc762f89eb806d8dee921c86497f6707" |
125 | + ], |
126 | + "requirements.txt": [ |
127 | + "layer:basic", |
128 | + "static", |
129 | + "0f1c70d27e26005a96d66ad54482877ae20f7737693c833e29dd72bd6ac24892" |
130 | + ], |
131 | + "wheelhouse/netaddr-0.7.18.tar.gz": [ |
132 | + "layer:basic", |
133 | + "dynamic", |
134 | + "a1f5c9fcf75ac2579b9995c843dade33009543c04f218ff7c007b3c81695bd19" |
135 | + ], |
136 | + ".gitignore": [ |
137 | + "layer:leadership", |
138 | + "static", |
139 | + "54c2eac10d7d0187b02c271ac7a3767bb3d365d562cfb8c1548efb4e84f7b2d5" |
140 | + ], |
141 | + "files/archives/db2server_ppcle.rsp": [ |
142 | + "ibm-db2", |
143 | + "static", |
144 | + "31d1b67b7e5da6c86fcc44999b96b8520e10b4c93602691edc8e75910a0fe6cd" |
145 | + ], |
146 | + "wheelhouse/MarkupSafe-0.23.tar.gz": [ |
147 | + "layer:basic", |
148 | + "dynamic", |
149 | + "a4ec1aff59b95a14b45eb2e23761a0179e98319da5a7eb76b56ea8cdc7b871c3" |
150 | + ], |
151 | + "hooks/relations/db2/interface.yaml": [ |
152 | + "interface:db2", |
153 | + "static", |
154 | + "70f0b2954e6e8ed4e08987d3eea6932cb7cd5d310dcad5ae28b50fd721631861" |
155 | + ], |
156 | + "icon.svg": [ |
157 | + "ibm-db2", |
158 | + "static", |
159 | + "47984b36228e7500edb73a689797e0498babe9bc080573e0807bb3b4ece1b68d" |
160 | + ], |
161 | + "config.yaml": [ |
162 | + "ibm-db2", |
163 | + "dynamic", |
164 | + "6a7919e3802ebd8de302cc661f5647a3d9211bdf253a7040d7db6bd64882be81" |
165 | + ], |
166 | + "lib/charms/layer/__init__.py": [ |
167 | + "layer:basic", |
168 | + "static", |
169 | + "4ffd74384bd81d737572acf2d14fe55431eab8f49d6212d9aabedf24e1d992b2" |
170 | + ], |
171 | + "hooks/stop": [ |
172 | + "layer:basic", |
173 | + "static", |
174 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
175 | + ], |
176 | + "reactive/apt.py": [ |
177 | + "layer:apt", |
178 | + "static", |
179 | + "1d95f16ec99a5c7927b0b02c07ee7f174e51c80b2d64edc702b8d4352c70a258" |
180 | + ], |
181 | + "hooks/relations/db2/provides.py": [ |
182 | + "interface:db2", |
183 | + "static", |
184 | + "472a72180fccde0197681815e3787bab0a0b3bd5d9b12f5f0bff21b77dedd5e7" |
185 | + ], |
186 | + "hooks/hook.template": [ |
187 | + "layer:basic", |
188 | + "static", |
189 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
190 | + ], |
191 | + "hooks/db-relation-joined": [ |
192 | + "interface:db2", |
193 | + "dynamic", |
194 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
195 | + ], |
196 | + "wheelhouse/Jinja2-2.8.tar.gz": [ |
197 | + "layer:basic", |
198 | + "dynamic", |
199 | + "bc1ff2ff88dbfacefde4ddde471d1417d3b304e8df103a7a9437d47269201bf4" |
200 | + ], |
201 | + "hooks/db-relation-departed": [ |
202 | + "interface:db2", |
203 | + "dynamic", |
204 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
205 | + ], |
206 | + "metadata.yaml": [ |
207 | + "ibm-db2", |
208 | + "dynamic", |
209 | + "99910e2c192e818b159d57f763fb422d23342bb6426c87ebc6c3a410c82c265b" |
210 | + ], |
211 | + "wheelhouse/pip-8.1.2.tar.gz": [ |
212 | + "layer:basic", |
213 | + "dynamic", |
214 | + "4d24b03ffa67638a3fa931c09fd9e0273ffa904e95ebebe7d4b1a54c93d7b732" |
215 | + ], |
216 | + "hooks/update-status": [ |
217 | + "layer:basic", |
218 | + "static", |
219 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
220 | + ], |
221 | + "lib/charms/__init__.py": [ |
222 | + "layer:leadership", |
223 | + "static", |
224 | + "4032724b98ed267185b12b8ec78dd9bcb0423ab1c89a6f0dad99397fd51159d9" |
225 | + ], |
226 | + "README.md": [ |
227 | + "ibm-db2", |
228 | + "static", |
229 | + "d2f0f64141542a8ea38b1f90ea0e6ef07128b5d642cc91b95940f8240e748f4a" |
230 | + ], |
231 | + "hooks/start": [ |
232 | + "layer:basic", |
233 | + "static", |
234 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
235 | + ], |
236 | + "hooks/db-relation-changed": [ |
237 | + "interface:db2", |
238 | + "dynamic", |
239 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
240 | + ], |
241 | + "wheelhouse/PyYAML-3.11.zip": [ |
242 | + "layer:basic", |
243 | + "dynamic", |
244 | + "19bb3ac350ef878dda84a62d37c7d5c17a137386dde9c2ce7249c7a21d7f6ac9" |
245 | + ], |
246 | + "files/archives/db2server.rsp": [ |
247 | + "ibm-db2", |
248 | + "static", |
249 | + "708d2e38eab0fb470d4b7543566e3b5285ee49f6bdb53a684b7aa4ad267cc6bc" |
250 | + ], |
251 | + "hooks/relations/db2/requires.py": [ |
252 | + "interface:db2", |
253 | + "static", |
254 | + "b21956a14a95ab341be8ba5e4b12e2d1a93a40db5f4743430e31a1dc15906da4" |
255 | + ], |
256 | + "wheelhouse/charmhelpers-0.8.0.tar.gz": [ |
257 | + "layer:basic", |
258 | + "dynamic", |
259 | + "355c2632049621474c50cfee6a6f7014a863f6f3bac1134ed409479cbe99b102" |
260 | + ], |
261 | + "layer.yaml": [ |
262 | + "ibm-db2", |
263 | + "dynamic", |
264 | + "a32ac0f8ad17673d793fed0188d0f42c92931991821fd4fe1bf175cbdbb54621" |
265 | + ], |
266 | + "hooks/config-changed": [ |
267 | + "layer:basic", |
268 | + "static", |
269 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
270 | + ], |
271 | + "tests/10-bundles-test.py": [ |
272 | + "ibm-db2", |
273 | + "static", |
274 | + "a37aaf266cd0d6b36cfa3f86b22a3169924e3a38eb9be3e161b0929fe5d43e71" |
275 | + ], |
276 | + "hooks/relations/db2/__init__.py": [ |
277 | + "interface:db2", |
278 | + "static", |
279 | + "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" |
280 | + ], |
281 | + "hooks/db-relation-broken": [ |
282 | + "interface:db2", |
283 | + "dynamic", |
284 | + "3a854a5fd180c5bacbb80b501d968a8d8bdc1468361e7123ea4022a1e0363c9a" |
285 | + ], |
286 | + "files/archives/db2inst1.INS": [ |
287 | + "ibm-db2", |
288 | + "static", |
289 | + "accbce657a8c0fbf5bcc05465082af0302970a9a22ae1e4ac44d8541b25d31e8" |
290 | + ], |
291 | + "wheelhouse/six-1.10.0.tar.gz": [ |
292 | + "layer:basic", |
293 | + "dynamic", |
294 | + "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a" |
295 | + ], |
296 | + "lib/charms/apt.py": [ |
297 | + "layer:apt", |
298 | + "static", |
299 | + "1f95351be322b40cf6c01fcac128b3fe338516e96cf4314071a89d84a11387c7" |
300 | + ] |
301 | + } |
302 | +} |
303 | \ No newline at end of file |
304 | |
305 | === added file '.gitignore' |
306 | --- .gitignore 1970-01-01 00:00:00 +0000 |
307 | +++ .gitignore 2016-07-14 17:53:24 +0000 |
308 | @@ -0,0 +1,2 @@ |
309 | +*~ |
310 | +*.pyc |
311 | |
312 | === added file 'Makefile' |
313 | --- Makefile 1970-01-01 00:00:00 +0000 |
314 | +++ Makefile 2016-07-14 17:53:24 +0000 |
315 | @@ -0,0 +1,24 @@ |
316 | +#!/usr/bin/make |
317 | + |
318 | +all: lint unit_test |
319 | + |
320 | + |
321 | +.PHONY: clean |
322 | +clean: |
323 | + @rm -rf .tox |
324 | + |
325 | +.PHONY: apt_prereqs |
326 | +apt_prereqs: |
327 | + @# Need tox, but don't install the apt version unless we have to (don't want to conflict with pip) |
328 | + @which tox >/dev/null || (sudo apt-get install -y python-pip && sudo pip install tox) |
329 | + |
330 | +.PHONY: lint |
331 | +lint: apt_prereqs |
332 | + @tox --notest |
333 | + @PATH=.tox/py34/bin:.tox/py35/bin flake8 $(wildcard hooks reactive lib unit_tests tests) |
334 | + @charm proof |
335 | + |
336 | +.PHONY: unit_test |
337 | +unit_test: apt_prereqs |
338 | + @echo Starting tests... |
339 | + tox |
340 | |
341 | === modified file 'README.md' |
342 | --- README.md 2016-01-12 08:17:38 +0000 |
343 | +++ README.md 2016-07-14 17:53:24 +0000 |
344 | @@ -28,8 +28,12 @@ |
345 | |
346 | Download of Product Binaries |
347 | ---------------------------- |
348 | -For deploying IBM DB2 charm the user needs to download the correct package as mentioned in the `Usage` section into an SFTP server. The IBM DB2 charm will connect to the SFTP server, download and deploy the same. The SFTP server can be any Power Ubuntu/X86 Ubuntu server and should be copied into a directory structure as below |
349 | -`/home/charm/repository/<productname>/<package.tar>`. The complete path where the package is stored is a configurable item in config.yaml file and needs to be configured before deploying the charm. The charm will download the package from this server using SFTP. Hence make sure the SFTP link is accessible. |
350 | +For deploying IBM DB2 charm the user needs to download the correct package as mentioned in the `Usage` section and host it on an SFTP or Web server. The IBM DB2 charm will connect to the server(either by SFTP or HTTP method) to download and deploy the same. The host server can be any Power Ubuntu/X86 Ubuntu servers and should be copied into a directory structure as below |
351 | + |
352 | +`/<path to charm dir>/charm/repository/<productname>/<package.tar>` |
353 | + |
354 | +The complete path where the package is stored is a configurable item which needs to be configured before deploying the charm. |
355 | + |
356 | |
357 | Memory and Disk Requirements |
358 | ---------------------------- |
359 | @@ -39,7 +43,7 @@ |
360 | |
361 | Deploy |
362 | ------ |
363 | -To deploy DB2 charm run the following command: |
364 | +To deploy DB2 charm, run the following command: |
365 | |
366 | 1. Make sure the appropriate memory requirements are made available |
367 | |
368 | @@ -48,43 +52,37 @@ |
369 | juju add-machine |
370 | juju deploy --to <machine number> --repository=<path_to_charms_folder> local:trusty/ibm-db2 |
371 | |
372 | -3. Set all required config values like the SFTP server, package name, directory in SFTP server where package is kept, username and password to connect to SFTP host and checksum value to proceed with installation, by using juju set command. To provide these run the following command: |
373 | - |
374 | - |
375 | - juju set ibm-db2 host=<host-name> |
376 | - juju set ibm-db2 package_dir=<full-path-to-the-directory> |
377 | - juju set ibm-db2 username=<user-name> |
378 | - juju set ibm-db2 password=<passwd> |
379 | - juju set ibm-db2 db2_package_name=<package-name> |
380 | - juju set ibm-db2 sha= <checksum-value> |
381 | - |
382 | - For eg: |
383 | - |
384 | - juju set ibm-db2 host="x.x.x.x" |
385 | - juju set ibm-db2 package_dir="/home/charm/repository/ibm-db2" |
386 | - juju set ibm-db2 username="user1" |
387 | - juju set ibm-db2 password="password" |
388 | - juju set ibm-db2 db2_package_name="DB2_Svr_10.5.0.3_Linux_x86-64.tar.gz" |
389 | - juju set ibm-db2 sha=80501df818faf4f095b5a58210a0e110509fcb70 |
390 | - |
391 | +3. Set all required config values like the curl__opts to log into the host machine and curl_url which specifies the url to download the packages, by using juju set command. To provide these run the following command: |
392 | + |
393 | + juju set ibm-db2 curl_opts=<login credentials> |
394 | + juju set ibm-db2 curl_url=<url to download package?shavalue> |
395 | + |
396 | + For eg: |
397 | + |
398 | + juju set ibm-db2 curl_opts="-u user:password" |
399 | + juju set ibm-db2 curl_url="http://<ipaddress>/debs/ibm-db2/DB2_Svr_10.5.0.3_Linux_x86-64.tar.gz?sha512=ae20be99e3cd2cef24d53a28331871d7193cfc7f7c24c580e6e78dc58c9ffb364cbcc69cb3773d2f0135b8c9be7ee40a7dc4e09fec0a4d731c4864bbba87d31e" |
400 | |
401 | - The command to find the checksum value is `sha1sum <Package Name> | cut -d" " -f1` |
402 | + The command to find the checksum value is `sha512sum <Package Name>` |
403 | + |
404 | + In the above example sha512 is used, you can use sha256 or md5 as well. |
405 | +Also in the above example, the packages are hosted on webserver, so http protocol is used, if you have placed the packages on sftp server, then replace the protocol with sftp. |
406 | |
407 | 4. At this point DB2 install will wait for you to accept the License. To install the downloaded binaries you must agree to the IBM license. The license file(s) can be found in the product binaries you downloaded. |
408 | |
409 | - If you agree to the license, run the following command : |
410 | - |
411 | - juju set ibm-db2 accept-ibm-db2-license=True |
412 | - |
413 | - Juju deploy command will install db2 and will expose the hostname, portnumber, db2 instance, install path and userid to the users. |
414 | +If you agree to the license, run the following command : |
415 | + |
416 | + juju set ibm-db2 license_accepted=True |
417 | + |
418 | + |
419 | +Juju deploy command will install db2 and will expose the hostname, port number, db2 instance, install path and userid to the users. |
420 | |
421 | |
422 | Uninstallation of IBM DB2 |
423 | --------------------------- |
424 | |
425 | -Setting the accept-ibm-db2-license to False will uninstall the product. |
426 | +Setting the license_accepted to False will uninstall the product. |
427 | |
428 | - juju set ibm-db2 accept-ibm-db2-license=False |
429 | + juju set ibm-db2 license_accepted=False |
430 | |
431 | Additional configuration parameters |
432 | ----------------------------------- |
433 | @@ -99,21 +97,10 @@ |
434 | |
435 | juju set ibm-db2 dftdbpath="/tmp" |
436 | |
437 | -* If you want to add a new user/password and instance name for DB2 you can do that by giving the following commands. |
438 | - |
439 | - juju set ibm-db2 db2_user=<newusername> |
440 | - juju set ibm-db2 db2_pw=<newuserpassword> |
441 | - |
442 | - For eg: |
443 | - |
444 | - juju set ibm-db2 db2_user="user1" |
445 | - juju set ibm-db2 db2_pw="user123" |
446 | - |
447 | -If the db2_user and db2_pw is not set, then be default the charm will create db2usr1/db2usr123 using which you can connect and work with DB2. A new instance name with same name as db2_user will also be generated. |
448 | |
449 | Installation Verification |
450 | ------------------------ |
451 | -Once IBM DB2 charm is deployed, the user can log into the container/machine where its deployed and use the db2_user/db2_pw combination to login as the db2 user. The user can run any db2 commands after this. |
452 | +Once IBM DB2 charm is deployed, the user can log into the container/machine where it is deployed using the default user/password (db2inst1/db2inst1). The user can run any db2 commands after this. |
453 | |
454 | * For creating a new DB the user may run the command: |
455 | |
456 | @@ -127,42 +114,57 @@ |
457 | |
458 | db2 |
459 | |
460 | +Relating with other consumer charms |
461 | +---------------------------------- |
462 | +IBM DB2 charm can be related to other consumer charms using the following command. |
463 | + |
464 | + juju add-relation ibm-db2 <consumer-charm> |
465 | + |
466 | +When IBM DB2 charm is related to any consumer charm, it creates a db2instance, username/password as per the service name and will be provided to the consumer charm. IBM DB2 charm also creates DBs as provided by the consumer charm and returns the DB details once they are successfully created. The following code will help the consumer charm authors to pass the DB names to the IBM DB2 charm: |
467 | + |
468 | + @when 'db.connected' |
469 | + function configure_dbs(){ |
470 | + dbnames="db1,db2" |
471 | + relation_call --state=db.connected set_dbs $dbnames || true |
472 | + } |
473 | + |
474 | +If no DB name is provided by consumer charm, IBM DB2 charm by default creates DBs according to the service name. |
475 | + |
476 | +Also to set relation with IBM DB2 charm and make use of all the features, the consumer charm __should__ pass the ssh key from itself to IBM DB2 charm. The following code will help the consumer charm authors to do this : |
477 | + |
478 | + @when 'db.connected' |
479 | + @when_not 'test.sshconfigured' |
480 | + function configure_sshkeys(){ |
481 | + SSH_PATH=/root/.ssh |
482 | + if [ ! -f $SSH_PATH/id_rsa.pub ]; then |
483 | + juju-log "Setting up SSH keys." |
484 | + ssh-keygen -t rsa -f $SSH_PATH/id_rsa -N '' |
485 | + fi |
486 | + key="`cat $SSH_PATH/id_rsa.pub`" |
487 | + relation_call --state=db.connected set_ssh_keys $key || true` |
488 | + set_state 'test.sshconfigured' |
489 | + } |
490 | + |
491 | +Without this IBM DB2 charm will not be ready and will not create the DBs for the related services. |
492 | |
493 | Configuration |
494 | ------------- |
495 | See config.yaml file for more information. |
496 | |
497 | - * `accept-ibm-db2-license`: True to accept license. Before you can use or install IBM DB2, you must accept the terms of International License Agreement for Non-Warranted Programs and additional license information. Please read the license agreement carefully. The license file(s) can be found under the server/db2/license directory after downloading and extracting IBM DB2 there. Set the value of accept-ibm-db2-license to True if you agree to IBM DB2 license. |
498 | - |
499 | - * `sha` : Check sum value to check integrity of IBM DB2 package. The Charm uses sha1sum to check the integrity. If empty, it will fail to deploy DB2. Cryptographic value should be altered by the user only when the package name is changed. Else it should not be altered. The command to find the check sum is |
500 | - |
501 | - sha1sum <Package Name> | cut -d" " -f1 |
502 | - |
503 | - This value can be got from the administrator or the user can run the above command from the sftp server where the package resides. |
504 | + * `license_accepted`: True to accept license. Before you can use or install IBM DB2, you must accept the terms of International License Agreement for Non-Warranted Programs and additional license information. Please read the license agreement carefully. The license file(s) can be found under the server/db2/license directory after downloading and extracting IBM DB2 there. Set the value of license_accepted to True if you agree to IBM DB2 license. |
505 | |
506 | * `dftdbpath` : This parameter contains the default file path used to create databases under the database manager. If no path is specified when a database is created, the database is created under the path specified by the dftdbpath parameter. |
507 | |
508 | - * `db2_user` : The user name to connect to DB2 and work on the same. Db2 will create a new instance with the same name as this user name. |
509 | + * `curl_url` : Location of the IBM product installation file(s). This should be a URL that curl can use to download files. Multiple URLs should be separated by a space. |
510 | |
511 | - * `db2_pw` : The password for db2_user |
512 | - |
513 | - * `host` : SFTP server where IBM DB2 packages is kept |
514 | - |
515 | - * `package_dir` : Path to find the IBM DB2 packages on the SFTP server |
516 | - |
517 | - * `username` : User name to connect to the SFTP server |
518 | - |
519 | - * `password` : Password to connect to the SFTP server |
520 | - |
521 | - * `db2_package_name` : Name of the DB2 package to be deployed |
522 | - |
523 | + * `curl_opts` : The options passed to the 'curl' command when fetching files from curl_url. |
524 | |
525 | Additional product information |
526 | ------------------------------ |
527 | |
528 | ##### Enabling BLU acceleration for DB2 Advanced Enterprise Server Edition/DB2 Advanced Workgroup Server Edition |
529 | |
530 | -The same DB2 charm(DB2 Enterprise Server Edition) can be extended to enable the BLU acceleration(DB2 Advanced Enterprise Server Edition/DB2 Advanced Workgroup Server Edition) by following the below section. The DB2 charm has to be deployed first and then few settings needs to be done to enable the BLU feature. |
531 | +The same DB2 charm(DB2 Enterprise Server Edition) can be extended to enable the BLU acceleration(DB2 Advanced Enterprise Server Edition/DB2 Advanced Workgroup Server Edition) by following the below section. The DB2 charm has to be deployed first and then few settings need to be done to enable the BLU feature. |
532 | |
533 | To upgrade DB2 Enterprise Server Edition (DB2 ESE) to DB2 Advanced Enterprise Server Edition(DB2 AESE) or DB2 Advanced Workgroup Server Edition (DB2 AWSE) the user need to accept the license for the same. Run the following command for accepting the AESE/AWSE license which the user procures on buying the Advanced Enterprise/ Workgroup Server Edition product. The user needs to log in using the configured user name/password to run the below commands. |
534 | |
535 | @@ -185,7 +187,7 @@ |
536 | |
537 | The output Default table organization (DFT_TABLE_ORG) = COLUMN confirms that the DB2 AESE/AWSE with BLU is enabled. If the pre requisites for DB2 for AESE/AWSE is not set (accepting the proper license and setting the registry variable DB2_WORKLOAD) the above command would return Default table organization (DFT_TABLE_ORG) = ROW. Column-organized tables store each column on a separate set of pages on disk. Organizing data by column on disk reduces the amount of I/O needed for processing queries because only columns that are referenced in a query need to be accessed. |
538 | |
539 | -Once this is set all the tables created will be by default COLUMN organized where as without BLU acceleration the tables will be ROW organized. Also without proper license we cannot create COLUMN organized tables. Once we enable COLUMN organized tables, we can create either ROW enabled or COLUMN enabled tables using the option ORGANIZE BY ROW or ORGANIZE BY COLUMN while creating the tables by running the below commands from db2 command prompt. |
540 | +Once this is set all the tables created will be by default COLUMN organized whereas without BLU acceleration the tables will be ROW organized. Also without proper license we cannot create COLUMN organized tables. Once we enable COLUMN organized tables, we can create either ROW enabled or COLUMN enabled tables using the option ORGANIZE BY ROW or ORGANIZE BY COLUMN while creating the tables by running the below commands from db2 command prompt. |
541 | |
542 | create table sales_row(tid integer not null, prod_name varchar(30)) ORGANIZE BY ROW |
543 | create table sales_col(tid integer not null, prod_name varchar(30)) ORGANIZE BY COLUMN |
544 | @@ -196,6 +198,14 @@ |
545 | |
546 | More details on BLU feature can be found in the link [db2-BLU-acceleration] |
547 | |
548 | +IBM DB2 Limitations |
549 | +------------------- |
550 | +If you are running linux containers on a host with kernel < 3.16, be advised that db2start will not succeed because of a hard coded 32MB kernel.shmmax setting. You will need to upgrade your host to kernel 3.16 or greater by following the instructions here: |
551 | + |
552 | +https://wiki.ubuntu.com/Kernel/LTSEnablementStack |
553 | + |
554 | +DB2 also needs to be deployed using a non-zfs filesystem for container deployment. ZFS file system might cause some of the db2 commands to error out. |
555 | + |
556 | IBM DB2 Links and Contacts |
557 | -------------------------- |
558 | |
559 | @@ -237,3 +247,7 @@ |
560 | |
561 | |
562 | |
563 | + |
564 | + |
565 | + |
566 | + |
567 | |
568 | === added directory 'bin' |
569 | === added file 'bin/layer_option' |
570 | --- bin/layer_option 1970-01-01 00:00:00 +0000 |
571 | +++ bin/layer_option 2016-07-14 17:53:24 +0000 |
572 | @@ -0,0 +1,24 @@ |
573 | +#!/usr/bin/env python3 |
574 | + |
575 | +import sys |
576 | +sys.path.append('lib') |
577 | + |
578 | +import argparse |
579 | +from charms.layer import options |
580 | + |
581 | + |
582 | +parser = argparse.ArgumentParser(description='Access layer options.') |
583 | +parser.add_argument('section', |
584 | + help='the section, or layer, the option is from') |
585 | +parser.add_argument('option', |
586 | + help='the option to access') |
587 | + |
588 | +args = parser.parse_args() |
589 | +value = options(args.section).get(args.option, '') |
590 | +if isinstance(value, bool): |
591 | + sys.exit(0 if value else 1) |
592 | +elif isinstance(value, list): |
593 | + for val in value: |
594 | + print(val) |
595 | +else: |
596 | + print(value) |
597 | |
598 | === modified file 'config.yaml' |
599 | --- config.yaml 2015-12-07 02:57:11 +0000 |
600 | +++ config.yaml 2016-07-14 17:53:24 +0000 |
601 | @@ -1,71 +1,62 @@ |
602 | -options: |
603 | - accept-ibm-db2-license: |
604 | - type: boolean |
605 | - default: False |
606 | - description: | |
607 | - The DB2 software can only be used by |
608 | - accepting the terms and conditions for IBM DB2 License. |
609 | - Setting this option to True |
610 | - indicates that you have read and accepted the IBM DB2 terms and |
611 | - conditions found in the license file. The details about accessing |
612 | - the license(s) can be found in the README. |
613 | - Do not set this to False if a relation exists |
614 | - db2_user: |
615 | - type: string |
616 | - default: "db2usr1" |
617 | - description: | |
618 | - The username using which the user can connect to the db2. |
619 | - Once db2 is installed this user name is generated and the user can |
620 | - perform all db2 operations using this user. |
621 | - db2_pw: |
622 | - type: string |
623 | - default: "db2usr123" |
624 | - description: | |
625 | - The password used by the db2_user to connect to db2. |
626 | - dftdbpath: |
627 | - type: string |
628 | - default: "/tmp" |
629 | - description: | |
630 | - This parameter contains the default file path used to create databases under |
631 | - the database manager. If no path is specified when a database is created, the |
632 | - database is created under the path specified by the dftdbpath parameter. |
633 | - host: |
634 | - type: string |
635 | - default: "" |
636 | - description: | |
637 | - SFTP server where IBM DB2 packages is kept. If not set or set |
638 | - incorrectly, the charm cannot find the IBM DB2 software. |
639 | - package_dir: |
640 | - type: string |
641 | - default: "" |
642 | - description: | |
643 | - Path to find the IBM DB2 packages on the SFTP server. If not set or set incorrectly, the charm cannot find the |
644 | - IBM DB2 software. |
645 | - username: |
646 | - type: string |
647 | - default: "" |
648 | - description: | |
649 | - User name to connect to the SFTP server. If not |
650 | - set or set incorrectly, the charm not able to download the software. |
651 | - password: |
652 | - type: string |
653 | - default: "" |
654 | - description: | |
655 | - Password to connect to the SFTP server. If not |
656 | - set or set incorrectly, the charm not able to download the software. |
657 | - db2_package_name: |
658 | - type: string |
659 | - default: "DB2_Svr_10.5.0.3_Linux_x86-64.tar.gz" |
660 | - description: | |
661 | - Name of the DB2 package. If not set, the Charm uses a |
662 | - predefined package name for download from the url location. |
663 | - If the predefined package is not available at url location or |
664 | - if set incorrectly,the charm cannot install the DB2 software. |
665 | - sha: |
666 | - type: string |
667 | - default: "" |
668 | - description: | |
669 | - Checksum value to check integrity of IBM DB2 pacakage. The Charm uses |
670 | - sha1sum to check the integrity. If empty, it throws an error and stop the |
671 | - deployment. The command to find the checksum is |
672 | - sha1sum <Package Name> | cut -d" " -f1 |
673 | +"options": |
674 | + "curl_url": |
675 | + "type": "string" |
676 | + "default": "" |
677 | + "description": | |
678 | + Location of the IBM product installation file(s). This should be a URL |
679 | + that curl can use to download files. Multiple URLs should be separated |
680 | + by a space. NOTE: cryptographic verification is required and must be |
681 | + specified as part of the URL query string with the key a valid hash |
682 | + algorithms md5, sha256, or sha512, and the the checksum value itself |
683 | + (http://<url>?[md5|sha256|sha512]=<checksum>). |
684 | + For example: |
685 | + 'http://example.com/file.tgz?sha256=<sum>' |
686 | + 'sftp://example.com/file1.tgz?md5=<sum> ftp://example.com/file2.tgz?md5=<sum>' |
687 | + "curl_opts": |
688 | + "type": "string" |
689 | + "default": "" |
690 | + "description": | |
691 | + The options passed to the 'curl' command when fetching files from |
692 | + curl_url. For example: |
693 | + '-u <user:password>' |
694 | + "license_accepted": |
695 | + "type": "boolean" |
696 | + "default": !!bool "false" |
697 | + "description": | |
698 | + Some IBM charms require acceptance of a license before installation |
699 | + can proceed. If required, setting this option to True indicates that you |
700 | + have read and accepted the IBM terms and conditions found in the license |
701 | + file referenced by the charm. |
702 | + "extra_packages": |
703 | + "description": "Space separated list of extra deb packages to install.\n" |
704 | + "type": "string" |
705 | + "default": "" |
706 | + "package_status": |
707 | + "default": "install" |
708 | + "type": "string" |
709 | + "description": "The status of service-affecting packages will be set to this value\ |
710 | + \ in the dpkg database. Valid values are \"install\" and \"hold\".\n" |
711 | + "install_sources": |
712 | + "description": "List of extra apt sources, per charm-helpers standard format (a\ |
713 | + \ yaml list of strings encoded as a string). Each source may be either a line\ |
714 | + \ that can be added directly to sources.list(5), or in the form ppa:<user>/<ppa-name>\ |
715 | + \ for adding Personal Package Archives, or a distribution component to enable.\n" |
716 | + "type": "string" |
717 | + "default": "" |
718 | + "install_keys": |
719 | + "description": "List of signing keys for install_sources package sources, per\ |
720 | + \ charmhelpers standard format (a yaml list of strings encoded as a string).\ |
721 | + \ The keys should be the full ASCII armoured GPG public keys. While GPG key\ |
722 | + \ ids are also supported and looked up on a keyserver, operators should be aware\ |
723 | + \ that this mechanism is insecure. null can be used if a standard package signing\ |
724 | + \ key is used that will already be installed on the machine, and for PPA sources\ |
725 | + \ where the package signing key is securely retrieved from Launchpad.\n" |
726 | + "type": "string" |
727 | + "default": "" |
728 | + "dftdbpath": |
729 | + "type": "string" |
730 | + "default": "/tmp" |
731 | + "description": | |
732 | + This parameter contains the default file path used to create databases under |
733 | + the database manager. If no path is specified when a database is created, the |
734 | + database is created under the path specified by the dftdbpath parameter. |
735 | |
736 | === modified file 'copyright' |
737 | --- copyright 2015-07-14 11:32:09 +0000 |
738 | +++ copyright 2016-07-14 17:53:24 +0000 |
739 | @@ -1,4 +1,4 @@ |
740 | -Copyright 2015 IBM Corporation |
741 | +Copyright 2016 IBM Corporation |
742 | |
743 | This Charm is licensed under the Apache License, Version 2.0 (the "License"); |
744 | you may not use this file except in compliance with the License. |
745 | |
746 | === added file 'files/archives/db2inst1.INS' |
747 | --- files/archives/db2inst1.INS 1970-01-01 00:00:00 +0000 |
748 | +++ files/archives/db2inst1.INS 2016-07-14 17:53:24 +0000 |
749 | @@ -0,0 +1,119 @@ |
750 | +;Use BINARY file transfer |
751 | + |
752 | +[FILE_DESCRIPTION] |
753 | +APPLICATION=DB2/LINUXX8664 0.5.3 |
754 | +FILE_CONTENT=DB2 CCA Exported Data Sources |
755 | +FILE_TYPE=CommonServer |
756 | +FILE_FORMAT_VERSION=2.0 |
757 | +Platform=30 |
758 | +DB2SYSTEM=ISLRPBEIXV665 |
759 | +Instance=db2inst1 |
760 | + |
761 | +[REGISTRY_LOCAL] |
762 | +DB2COMM=TCPIP |
763 | +DB2AUTOSTART=NO |
764 | + |
765 | +[DBM_CONFIG] |
766 | +NODETYPE=4 |
767 | +RELEASE=0x1000 |
768 | +DIAGLEVEL=3 |
769 | +ALTERNATE_AUTH_ENC=255 |
770 | +RQRIOBLK=65535 |
771 | +AUTHENTICATION=0 |
772 | +DIR_CACHE=1 |
773 | +DISCOVER=2 |
774 | +TP_MON_NAME= |
775 | +SYSADM_GROUP=DB2GRP1 |
776 | +SYSCTRL_GROUP= |
777 | +SYSMAINT_GROUP= |
778 | +SYSMON_GROUP= |
779 | +TM_DATABASE=1ST_CONN |
780 | +DFT_ACCOUNT_STR= |
781 | +CATALOG_NOAUTH=0 |
782 | +NOTIFYLEVEL=3 |
783 | +JAVA_HEAP_SZ=2048 |
784 | +FEDERATED=0 |
785 | +FED_NOAUTH=0 |
786 | +UTIL_IMPACT_LIM=10 |
787 | +GROUP_PLUGIN= |
788 | +CLNT_PW_PLUGIN= |
789 | +CLNT_KRB_PLUGIN= |
790 | +LOCAL_GSSPLUGIN= |
791 | +MAX_QUERYDEGREE=-1 |
792 | +AUDIT_BUF_SZ=0 |
793 | +INTRA_PARALLEL=0 |
794 | +NUMDB=32 |
795 | +INITFENCED_JVM=0 |
796 | +INDEXREC=2 |
797 | +SHEAPTHRES=0 |
798 | +BACKBUFSZ=1024 |
799 | +RESTBUFSZ=1024 |
800 | +ASLHEAPSZ=15 |
801 | +FENCED_POOL=AUTOMATIC-1 |
802 | +KEEPFENCED=1 |
803 | +AGENTPRI=-1 |
804 | +SSL_SVR_KEYDB= |
805 | +SSL_SVR_STASH= |
806 | +SSL_SVR_LABEL= |
807 | +SSL_SVCENAME= |
808 | +SSL_CIPHERSPECS= |
809 | +SSL_VERSIONS= |
810 | +SSL_CLNT_KEYDB= |
811 | +SSL_CLNT_STASH= |
812 | +DFT_MON_UOW=OFF |
813 | +DFT_MON_STMT=OFF |
814 | +DFT_MON_TABLE=OFF |
815 | +DFT_MON_BUFPOOL=OFF |
816 | +DFT_MON_LOCK=OFF |
817 | +DFT_MON_SORT=OFF |
818 | +DFT_MON_TIMESTAMP=ON |
819 | +CPUSPEED=1.889377e-07 |
820 | +MAXTOTFILOP=0 |
821 | +AGENT_STACK_SZ=1024 |
822 | +MON_HEAP_SZ=AUTOMATIC90 |
823 | +RESYNC_INTERVAL=180 |
824 | +SPM_LOG_FILE_SZ=256 |
825 | +SPM_MAX_RESYNC=20 |
826 | +TRUST_ALLCLNTS=YES |
827 | +NUM_INITFENCED=0 |
828 | +SPM_NAME=islrpbei |
829 | +NUM_INITAGENTS=0 |
830 | +MAX_COORDAGENTS=AUTOMATIC200 |
831 | +NUM_POOLAGENTS=AUTOMATIC100 |
832 | +FCM_NUM_BUFFERS=4096 |
833 | +FCM_NUM_CHANNELS=AUTOMATIC2048 |
834 | +DISCOVER_INST=1 |
835 | +MAX_CONNECTIONS=AUTOMATIC-1 |
836 | +INSTANCE_MEMORY=AUTOMATIC1698252 |
837 | +HEALTH_MON=OFF |
838 | +SRV_PLUGIN_MODE=1 |
839 | +SRVCON_PW_PLUGIN= |
840 | +SRVCON_GSSPLUGIN_LIST= |
841 | +COMM_BANDWIDTH=1.000000e+02 |
842 | +CONN_ELAPSE=10 |
843 | +MAX_CONNRETRIES=5 |
844 | +MAX_TIME_DIFF=60 |
845 | +START_STOP_TIME=10 |
846 | +FEDERATED_ASYNC=0 |
847 | + |
848 | +[INST>db2inst1] |
849 | +instance_name=db2inst1 |
850 | +NodeType=4 |
851 | +ServerType=DB2LINUXX8664 |
852 | +Authentication=SERVER |
853 | +DB2COMM=TCPIP |
854 | + |
855 | +[DB>!LOCAL:APPCNTR] |
856 | +Dir_entry_type=INDIRECT |
857 | +Drive=/home/db2inst1 |
858 | +DBName=APPCNTR |
859 | + |
860 | +[DB>!LOCAL:WRKLGHT] |
861 | +Dir_entry_type=INDIRECT |
862 | +Drive=/home/db2inst1 |
863 | +DBName=WRKLGHT |
864 | + |
865 | +[DB>!LOCAL:TUT_DB] |
866 | +Dir_entry_type=INDIRECT |
867 | +Drive=/home/db2inst1 |
868 | +DBName=TUT_DB |
869 | |
870 | === removed directory 'files/archives/db2installresfile' |
871 | === removed file 'files/archives/db2installresfile/db2inst1.INS' |
872 | --- files/archives/db2installresfile/db2inst1.INS 2015-07-14 11:32:09 +0000 |
873 | +++ files/archives/db2installresfile/db2inst1.INS 1970-01-01 00:00:00 +0000 |
874 | @@ -1,119 +0,0 @@ |
875 | -;Use BINARY file transfer |
876 | - |
877 | -[FILE_DESCRIPTION] |
878 | -APPLICATION=DB2/LINUXX8664 0.5.3 |
879 | -FILE_CONTENT=DB2 CCA Exported Data Sources |
880 | -FILE_TYPE=CommonServer |
881 | -FILE_FORMAT_VERSION=2.0 |
882 | -Platform=30 |
883 | -DB2SYSTEM=ISLRPBEIXV665 |
884 | -Instance=db2inst1 |
885 | - |
886 | -[REGISTRY_LOCAL] |
887 | -DB2COMM=TCPIP |
888 | -DB2AUTOSTART=NO |
889 | - |
890 | -[DBM_CONFIG] |
891 | -NODETYPE=4 |
892 | -RELEASE=0x1000 |
893 | -DIAGLEVEL=3 |
894 | -ALTERNATE_AUTH_ENC=255 |
895 | -RQRIOBLK=65535 |
896 | -AUTHENTICATION=0 |
897 | -DIR_CACHE=1 |
898 | -DISCOVER=2 |
899 | -TP_MON_NAME= |
900 | -SYSADM_GROUP=DB2GRP1 |
901 | -SYSCTRL_GROUP= |
902 | -SYSMAINT_GROUP= |
903 | -SYSMON_GROUP= |
904 | -TM_DATABASE=1ST_CONN |
905 | -DFT_ACCOUNT_STR= |
906 | -CATALOG_NOAUTH=0 |
907 | -NOTIFYLEVEL=3 |
908 | -JAVA_HEAP_SZ=2048 |
909 | -FEDERATED=0 |
910 | -FED_NOAUTH=0 |
911 | -UTIL_IMPACT_LIM=10 |
912 | -GROUP_PLUGIN= |
913 | -CLNT_PW_PLUGIN= |
914 | -CLNT_KRB_PLUGIN= |
915 | -LOCAL_GSSPLUGIN= |
916 | -MAX_QUERYDEGREE=-1 |
917 | -AUDIT_BUF_SZ=0 |
918 | -INTRA_PARALLEL=0 |
919 | -NUMDB=32 |
920 | -INITFENCED_JVM=0 |
921 | -INDEXREC=2 |
922 | -SHEAPTHRES=0 |
923 | -BACKBUFSZ=1024 |
924 | -RESTBUFSZ=1024 |
925 | -ASLHEAPSZ=15 |
926 | -FENCED_POOL=AUTOMATIC-1 |
927 | -KEEPFENCED=1 |
928 | -AGENTPRI=-1 |
929 | -SSL_SVR_KEYDB= |
930 | -SSL_SVR_STASH= |
931 | -SSL_SVR_LABEL= |
932 | -SSL_SVCENAME= |
933 | -SSL_CIPHERSPECS= |
934 | -SSL_VERSIONS= |
935 | -SSL_CLNT_KEYDB= |
936 | -SSL_CLNT_STASH= |
937 | -DFT_MON_UOW=OFF |
938 | -DFT_MON_STMT=OFF |
939 | -DFT_MON_TABLE=OFF |
940 | -DFT_MON_BUFPOOL=OFF |
941 | -DFT_MON_LOCK=OFF |
942 | -DFT_MON_SORT=OFF |
943 | -DFT_MON_TIMESTAMP=ON |
944 | -CPUSPEED=1.889377e-07 |
945 | -MAXTOTFILOP=0 |
946 | -AGENT_STACK_SZ=1024 |
947 | -MON_HEAP_SZ=AUTOMATIC90 |
948 | -RESYNC_INTERVAL=180 |
949 | -SPM_LOG_FILE_SZ=256 |
950 | -SPM_MAX_RESYNC=20 |
951 | -TRUST_ALLCLNTS=YES |
952 | -NUM_INITFENCED=0 |
953 | -SPM_NAME=islrpbei |
954 | -NUM_INITAGENTS=0 |
955 | -MAX_COORDAGENTS=AUTOMATIC200 |
956 | -NUM_POOLAGENTS=AUTOMATIC100 |
957 | -FCM_NUM_BUFFERS=4096 |
958 | -FCM_NUM_CHANNELS=AUTOMATIC2048 |
959 | -DISCOVER_INST=1 |
960 | -MAX_CONNECTIONS=AUTOMATIC-1 |
961 | -INSTANCE_MEMORY=AUTOMATIC1698252 |
962 | -HEALTH_MON=OFF |
963 | -SRV_PLUGIN_MODE=1 |
964 | -SRVCON_PW_PLUGIN= |
965 | -SRVCON_GSSPLUGIN_LIST= |
966 | -COMM_BANDWIDTH=1.000000e+02 |
967 | -CONN_ELAPSE=10 |
968 | -MAX_CONNRETRIES=5 |
969 | -MAX_TIME_DIFF=60 |
970 | -START_STOP_TIME=10 |
971 | -FEDERATED_ASYNC=0 |
972 | - |
973 | -[INST>db2inst1] |
974 | -instance_name=db2inst1 |
975 | -NodeType=4 |
976 | -ServerType=DB2LINUXX8664 |
977 | -Authentication=SERVER |
978 | -DB2COMM=TCPIP |
979 | - |
980 | -[DB>!LOCAL:APPCNTR] |
981 | -Dir_entry_type=INDIRECT |
982 | -Drive=/home/db2inst1 |
983 | -DBName=APPCNTR |
984 | - |
985 | -[DB>!LOCAL:WRKLGHT] |
986 | -Dir_entry_type=INDIRECT |
987 | -Drive=/home/db2inst1 |
988 | -DBName=WRKLGHT |
989 | - |
990 | -[DB>!LOCAL:TUT_DB] |
991 | -Dir_entry_type=INDIRECT |
992 | -Drive=/home/db2inst1 |
993 | -DBName=TUT_DB |
994 | |
995 | === removed file 'files/archives/db2installresfile/db2server.rsp' |
996 | --- files/archives/db2installresfile/db2server.rsp 2015-07-14 11:32:09 +0000 |
997 | +++ files/archives/db2installresfile/db2server.rsp 1970-01-01 00:00:00 +0000 |
998 | @@ -1,64 +0,0 @@ |
999 | -*-------------------------------------------------------- |
1000 | -* The response file is generated by the db2rspgn command |
1001 | -*-------------------------------------------------------- |
1002 | -*-------------------------- |
1003 | -* Product Installation |
1004 | -*-------------------------- |
1005 | -PROD = DB2_SERVER_EDITION |
1006 | -FILE = /opt/ibm/db2/V10.5 |
1007 | -LIC_AGREEMENT = ACCEPT |
1008 | -INSTALL_TYPE = CUSTOM |
1009 | -COMP = BASE_CLIENT |
1010 | -COMP = JAVA_SUPPORT |
1011 | -COMP = SQL_PROCEDURES |
1012 | -COMP = BASE_DB2_ENGINE |
1013 | -COMP = CONNECT_SUPPORT |
1014 | -COMP = DB2_DATA_SOURCE_SUPPORT |
1015 | -COMP = SPATIAL_EXTENDER_SERVER_SUPPORT |
1016 | -COMP = JDK |
1017 | -COMP = LDAP_EXPLOITATION |
1018 | -COMP = INSTANCE_SETUP_SUPPORT |
1019 | -COMP = ACS |
1020 | -COMP = SPATIAL_EXTENDER_CLIENT_SUPPORT |
1021 | -COMP = COMMUNICATION_SUPPORT_TCPIP |
1022 | -COMP = APPLICATION_DEVELOPMENT_TOOLS |
1023 | -COMP = DB2_UPDATE_SERVICE |
1024 | -COMP = REPL_CLIENT |
1025 | -COMP = DB2_SAMPLE_DATABASE |
1026 | -COMP = TEXT_SEARCH |
1027 | -COMP = INFORMIX_DATA_SOURCE_SUPPORT |
1028 | -COMP = ORACLE_DATA_SOURCE_SUPPORT |
1029 | -COMP = FIRST_STEPS |
1030 | -COMP = GUARDIUM_INST_MNGR_CLIENT |
1031 | -*-------------------------- |
1032 | -* Installed Languages |
1033 | -*-------------------------- |
1034 | -LANG = EN |
1035 | -*-------------------------- |
1036 | -* Instance Properties |
1037 | -*-------------------------- |
1038 | -INSTANCE = db2inst1 |
1039 | -db2inst1.NAME = db2inst1 |
1040 | -db2inst1.UID = db2inst1_uid |
1041 | -db2inst1.GROUP_NAME = db2grp1 |
1042 | -db2inst1.GID = db2inst1_gid |
1043 | -db2inst1.HOME_DIRECTORY = /home/db2inst1_homedir |
1044 | -db2inst1.PASSWORD = db2inst1_password |
1045 | -db2inst1.CLIENT_IMPORT_PROFILE = db2inst1.INS |
1046 | -db2inst1.TYPE = ese |
1047 | -db2inst1.FENCED_USERNAME = db2fenc1 |
1048 | -db2inst1.FENCED_UID = db2fenc1_uid |
1049 | -db2inst1.FENCED_GROUP_NAME = db2fgrp1 |
1050 | -db2inst1.FENCED_GID = db2fenc1_gid |
1051 | -db2inst1.FENCED_HOME_DIRECTORY = /home/db2fenc1 |
1052 | -db2inst1.FENCED_PASSWORD = db2fenc1 |
1053 | -db2inst1.CONFIGURE_TEXT_SEARCH = NO |
1054 | -*-------------------------- |
1055 | -* DAS Properties |
1056 | -*__________________________ |
1057 | -DAS_USERNAME = dasusr1 |
1058 | -DAS_UID = das_uid |
1059 | -DAS_GROUP_NAME = dasadm1 |
1060 | -DAS_GID = das_gid |
1061 | -DAS_HOME_DIRECTORY = /home/dasusr1 |
1062 | -DAS_PASSWORD = dasusr1 |
1063 | |
1064 | === removed file 'files/archives/db2installresfile/db2server_ppcle.rsp' |
1065 | --- files/archives/db2installresfile/db2server_ppcle.rsp 2015-07-14 11:32:09 +0000 |
1066 | +++ files/archives/db2installresfile/db2server_ppcle.rsp 1970-01-01 00:00:00 +0000 |
1067 | @@ -1,64 +0,0 @@ |
1068 | -*-------------------------------------------------------- |
1069 | -* The response file is generated by the db2rspgn command |
1070 | -*-------------------------------------------------------- |
1071 | -*-------------------------- |
1072 | -* Product Installation |
1073 | -*-------------------------- |
1074 | -PROD = DB2_SERVER_EDITION |
1075 | -FILE = /opt/ibm/db2/V10.5 |
1076 | -LIC_AGREEMENT = ACCEPT |
1077 | -INSTALL_TYPE = CUSTOM |
1078 | -COMP = BASE_CLIENT |
1079 | -COMP = JAVA_SUPPORT |
1080 | -COMP = SQL_PROCEDURES |
1081 | -COMP = BASE_DB2_ENGINE |
1082 | -COMP = CONNECT_SUPPORT |
1083 | -COMP = DB2_DATA_SOURCE_SUPPORT |
1084 | -COMP = SPATIAL_EXTENDER_SERVER_SUPPORT |
1085 | -COMP = JDK |
1086 | -COMP = LDAP_EXPLOITATION |
1087 | -COMP = INSTANCE_SETUP_SUPPORT |
1088 | -*COMP = ACS |
1089 | -COMP = SPATIAL_EXTENDER_CLIENT_SUPPORT |
1090 | -COMP = COMMUNICATION_SUPPORT_TCPIP |
1091 | -COMP = APPLICATION_DEVELOPMENT_TOOLS |
1092 | -COMP = DB2_UPDATE_SERVICE |
1093 | -COMP = REPL_CLIENT |
1094 | -COMP = DB2_SAMPLE_DATABASE |
1095 | -COMP = TEXT_SEARCH |
1096 | -COMP = INFORMIX_DATA_SOURCE_SUPPORT |
1097 | -COMP = ORACLE_DATA_SOURCE_SUPPORT |
1098 | -COMP = FIRST_STEPS |
1099 | -COMP = GUARDIUM_INST_MNGR_CLIENT |
1100 | -*-------------------------- |
1101 | -* Installed Languages |
1102 | -*-------------------------- |
1103 | -LANG = EN |
1104 | -*-------------------------- |
1105 | -* Instance Properties |
1106 | -*-------------------------- |
1107 | -INSTANCE = db2inst1 |
1108 | -db2inst1.NAME = db2inst1 |
1109 | -db2inst1.UID = db2inst1_uid |
1110 | -db2inst1.GROUP_NAME = db2grp1 |
1111 | -db2inst1.GID = db2inst1_gid |
1112 | -db2inst1.HOME_DIRECTORY = /home/db2inst1_homedir |
1113 | -db2inst1.PASSWORD = db2inst1_password |
1114 | -db2inst1.CLIENT_IMPORT_PROFILE = db2inst1.INS |
1115 | -db2inst1.TYPE = ese |
1116 | -db2inst1.FENCED_USERNAME = db2fenc1 |
1117 | -db2inst1.FENCED_UID = db2fenc1_uid |
1118 | -db2inst1.FENCED_GROUP_NAME = db2fgrp1 |
1119 | -db2inst1.FENCED_GID = db2fenc1_gid |
1120 | -db2inst1.FENCED_HOME_DIRECTORY = /home/db2fenc1 |
1121 | -db2inst1.FENCED_PASSWORD = db2fenc1 |
1122 | -db2inst1.CONFIGURE_TEXT_SEARCH = NO |
1123 | -*-------------------------- |
1124 | -* DAS Properties |
1125 | -*__________________________ |
1126 | -DAS_USERNAME = dasusr1 |
1127 | -DAS_UID = das_uid |
1128 | -DAS_GROUP_NAME = dasadm1 |
1129 | -DAS_GID = das_gid |
1130 | -DAS_HOME_DIRECTORY = /home/dasusr1 |
1131 | -DAS_PASSWORD = dasusr1 |
1132 | |
1133 | === added file 'files/archives/db2server.rsp' |
1134 | --- files/archives/db2server.rsp 1970-01-01 00:00:00 +0000 |
1135 | +++ files/archives/db2server.rsp 2016-07-14 17:53:24 +0000 |
1136 | @@ -0,0 +1,64 @@ |
1137 | +*-------------------------------------------------------- |
1138 | +* The response file is generated by the db2rspgn command |
1139 | +*-------------------------------------------------------- |
1140 | +*-------------------------- |
1141 | +* Product Installation |
1142 | +*-------------------------- |
1143 | +PROD = DB2_SERVER_EDITION |
1144 | +FILE = /opt/ibm/db2/V10.5 |
1145 | +LIC_AGREEMENT = ACCEPT |
1146 | +INSTALL_TYPE = CUSTOM |
1147 | +COMP = BASE_CLIENT |
1148 | +COMP = JAVA_SUPPORT |
1149 | +COMP = SQL_PROCEDURES |
1150 | +COMP = BASE_DB2_ENGINE |
1151 | +COMP = CONNECT_SUPPORT |
1152 | +COMP = DB2_DATA_SOURCE_SUPPORT |
1153 | +COMP = SPATIAL_EXTENDER_SERVER_SUPPORT |
1154 | +COMP = JDK |
1155 | +COMP = LDAP_EXPLOITATION |
1156 | +COMP = INSTANCE_SETUP_SUPPORT |
1157 | +COMP = ACS |
1158 | +COMP = SPATIAL_EXTENDER_CLIENT_SUPPORT |
1159 | +COMP = COMMUNICATION_SUPPORT_TCPIP |
1160 | +COMP = APPLICATION_DEVELOPMENT_TOOLS |
1161 | +COMP = DB2_UPDATE_SERVICE |
1162 | +COMP = REPL_CLIENT |
1163 | +COMP = DB2_SAMPLE_DATABASE |
1164 | +COMP = TEXT_SEARCH |
1165 | +COMP = INFORMIX_DATA_SOURCE_SUPPORT |
1166 | +COMP = ORACLE_DATA_SOURCE_SUPPORT |
1167 | +COMP = FIRST_STEPS |
1168 | +COMP = GUARDIUM_INST_MNGR_CLIENT |
1169 | +*-------------------------- |
1170 | +* Installed Languages |
1171 | +*-------------------------- |
1172 | +LANG = EN |
1173 | +*-------------------------- |
1174 | +* Instance Properties |
1175 | +*-------------------------- |
1176 | +INSTANCE = db2inst1 |
1177 | +db2inst1.NAME = db2inst1 |
1178 | +db2inst1.UID = db2inst1_uid |
1179 | +db2inst1.GROUP_NAME = db2grp1 |
1180 | +db2inst1.GID = db2inst1_gid |
1181 | +db2inst1.HOME_DIRECTORY = /home/db2inst1_homedir |
1182 | +db2inst1.PASSWORD = db2inst1_password |
1183 | +db2inst1.CLIENT_IMPORT_PROFILE = db2inst1.INS |
1184 | +db2inst1.TYPE = ese |
1185 | +db2inst1.FENCED_USERNAME = db2fenc1 |
1186 | +db2inst1.FENCED_UID = db2fenc1_uid |
1187 | +db2inst1.FENCED_GROUP_NAME = db2fgrp1 |
1188 | +db2inst1.FENCED_GID = db2fenc1_gid |
1189 | +db2inst1.FENCED_HOME_DIRECTORY = /home/db2fenc1 |
1190 | +db2inst1.FENCED_PASSWORD = db2fenc1 |
1191 | +db2inst1.CONFIGURE_TEXT_SEARCH = NO |
1192 | +*-------------------------- |
1193 | +* DAS Properties |
1194 | +*__________________________ |
1195 | +DAS_USERNAME = dasusr1 |
1196 | +DAS_UID = das_uid |
1197 | +DAS_GROUP_NAME = dasadm1 |
1198 | +DAS_GID = das_gid |
1199 | +DAS_HOME_DIRECTORY = /home/dasusr1 |
1200 | +DAS_PASSWORD = dasusr1 |
1201 | |
1202 | === added file 'files/archives/db2server_ppcle.rsp' |
1203 | --- files/archives/db2server_ppcle.rsp 1970-01-01 00:00:00 +0000 |
1204 | +++ files/archives/db2server_ppcle.rsp 2016-07-14 17:53:24 +0000 |
1205 | @@ -0,0 +1,64 @@ |
1206 | +*-------------------------------------------------------- |
1207 | +* The response file is generated by the db2rspgn command |
1208 | +*-------------------------------------------------------- |
1209 | +*-------------------------- |
1210 | +* Product Installation |
1211 | +*-------------------------- |
1212 | +PROD = DB2_SERVER_EDITION |
1213 | +FILE = /opt/ibm/db2/V10.5 |
1214 | +LIC_AGREEMENT = ACCEPT |
1215 | +INSTALL_TYPE = CUSTOM |
1216 | +COMP = BASE_CLIENT |
1217 | +COMP = JAVA_SUPPORT |
1218 | +COMP = SQL_PROCEDURES |
1219 | +COMP = BASE_DB2_ENGINE |
1220 | +COMP = CONNECT_SUPPORT |
1221 | +COMP = DB2_DATA_SOURCE_SUPPORT |
1222 | +COMP = SPATIAL_EXTENDER_SERVER_SUPPORT |
1223 | +COMP = JDK |
1224 | +COMP = LDAP_EXPLOITATION |
1225 | +COMP = INSTANCE_SETUP_SUPPORT |
1226 | +*COMP = ACS |
1227 | +COMP = SPATIAL_EXTENDER_CLIENT_SUPPORT |
1228 | +COMP = COMMUNICATION_SUPPORT_TCPIP |
1229 | +COMP = APPLICATION_DEVELOPMENT_TOOLS |
1230 | +COMP = DB2_UPDATE_SERVICE |
1231 | +COMP = REPL_CLIENT |
1232 | +COMP = DB2_SAMPLE_DATABASE |
1233 | +COMP = TEXT_SEARCH |
1234 | +COMP = INFORMIX_DATA_SOURCE_SUPPORT |
1235 | +COMP = ORACLE_DATA_SOURCE_SUPPORT |
1236 | +COMP = FIRST_STEPS |
1237 | +COMP = GUARDIUM_INST_MNGR_CLIENT |
1238 | +*-------------------------- |
1239 | +* Installed Languages |
1240 | +*-------------------------- |
1241 | +LANG = EN |
1242 | +*-------------------------- |
1243 | +* Instance Properties |
1244 | +*-------------------------- |
1245 | +INSTANCE = db2inst1 |
1246 | +db2inst1.NAME = db2inst1 |
1247 | +db2inst1.UID = db2inst1_uid |
1248 | +db2inst1.GROUP_NAME = db2grp1 |
1249 | +db2inst1.GID = db2inst1_gid |
1250 | +db2inst1.HOME_DIRECTORY = /home/db2inst1_homedir |
1251 | +db2inst1.PASSWORD = db2inst1_password |
1252 | +db2inst1.CLIENT_IMPORT_PROFILE = db2inst1.INS |
1253 | +db2inst1.TYPE = ese |
1254 | +db2inst1.FENCED_USERNAME = db2fenc1 |
1255 | +db2inst1.FENCED_UID = db2fenc1_uid |
1256 | +db2inst1.FENCED_GROUP_NAME = db2fgrp1 |
1257 | +db2inst1.FENCED_GID = db2fenc1_gid |
1258 | +db2inst1.FENCED_HOME_DIRECTORY = /home/db2fenc1 |
1259 | +db2inst1.FENCED_PASSWORD = db2fenc1 |
1260 | +db2inst1.CONFIGURE_TEXT_SEARCH = NO |
1261 | +*-------------------------- |
1262 | +* DAS Properties |
1263 | +*__________________________ |
1264 | +DAS_USERNAME = dasusr1 |
1265 | +DAS_UID = das_uid |
1266 | +DAS_GROUP_NAME = dasadm1 |
1267 | +DAS_GID = das_gid |
1268 | +DAS_HOME_DIRECTORY = /home/dasusr1 |
1269 | +DAS_PASSWORD = dasusr1 |
1270 | |
1271 | === removed file 'files/sftp_get.sh' |
1272 | --- files/sftp_get.sh 2015-12-09 05:27:29 +0000 |
1273 | +++ files/sftp_get.sh 1970-01-01 00:00:00 +0000 |
1274 | @@ -1,19 +0,0 @@ |
1275 | -#!/usr/bin/expect |
1276 | -# Helper script to connect and download using sftp |
1277 | -# Usage: sftp_get.sh user password host remote_dir localpath |
1278 | - |
1279 | -set user [lindex $argv 0] |
1280 | -set password [lindex $argv 1] |
1281 | -set host [lindex $argv 2] |
1282 | -set r_dir [lindex $argv 3] |
1283 | -set localpath [lindex $argv 4] |
1284 | - |
1285 | -set timeout 90 |
1286 | -spawn sftp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $user@$host |
1287 | -expect "password:" |
1288 | -send "$password\n" |
1289 | -expect "sftp>" |
1290 | -set timeout 3000 |
1291 | -send "get -r $r_dir $localpath\n" |
1292 | -expect "sftp>" |
1293 | -send "exit\n" |
1294 | |
1295 | === modified file 'hooks/config-changed' |
1296 | --- hooks/config-changed 2016-01-12 08:17:38 +0000 |
1297 | +++ hooks/config-changed 2016-07-14 17:53:24 +0000 |
1298 | @@ -1,568 +1,19 @@ |
1299 | -#!/bin/bash |
1300 | - |
1301 | -set -e |
1302 | -DB2_INSTALL_PATH=/opt/ibm/db2/V10.5 |
1303 | -ARCHITECTURE=`uname -m` |
1304 | -ARCHIVE_DIR=$CHARM_DIR/files/archives |
1305 | -DB2_ARCHIVE_DIR=`pwd` |
1306 | -DB2_USER=db2inst1 |
1307 | -DB2_USER_PW=db2inst1 |
1308 | -# Check whether DB2 is installed |
1309 | -is_db2_installed() |
1310 | -{ |
1311 | - if [ -d $DB2_INSTALL_PATH/bin ]; then |
1312 | - echo "True" |
1313 | - else |
1314 | - echo "False" |
1315 | - fi |
1316 | -} |
1317 | -#Download DB2 package |
1318 | - |
1319 | -download_db2() |
1320 | -{ |
1321 | - HOST=`config-get host` |
1322 | - PACKAGE_DIR=`config-get package_dir` |
1323 | - USERNAME=`config-get username` |
1324 | - PASSWORD=`config-get password` |
1325 | - |
1326 | - #Exit if URL to download package is null |
1327 | - if [ "$USERNAME" == "" -o "$PASSWORD" == "" -o "$HOST" == "" -o "$PACKAGE_DIR" == "" ]; then |
1328 | - juju-log "IBM DB2: Failed to download files from repository. Please provide values for host,package_dir,username and password in config.yaml" |
1329 | - status-set blocked "please set db2_url" |
1330 | - exit 0 |
1331 | - fi |
1332 | - |
1333 | - # If an install was done, get the name of the package from which it was done |
1334 | - if [ -f $ARCHIVE_DIR/*.gz ]; then |
1335 | - pkg_name=`ls $ARCHIVE_DIR/*.gz` |
1336 | - if [ $? == 0 ]; then |
1337 | - pkg_name=`basename $pkg_name` |
1338 | - fi |
1339 | - fi |
1340 | - # Get the package name to check whether the user wants to install a different package$ |
1341 | - cfg_pkg_name=`config-get db2_package_name` |
1342 | - |
1343 | - # Set package name to a predefined value if the user has not provided a package name |
1344 | - if [ "$cfg_pkg_name" == "" ]; then |
1345 | - ARCHITECTURE=`uname -m` |
1346 | - if [ "$ARCHITECTURE" = "x86_64" ]; then |
1347 | - cfg_pkg_name="DB2_Svr_10.5.0.3_Linux_x86-64.tar.gz" |
1348 | - else |
1349 | - cfg_pkg_name="DB2_Svr_10.5.0.5_Linux_ppcle.tar.gz" |
1350 | - fi |
1351 | - fi |
1352 | - |
1353 | - #Check whether user has selected right package name from the package name string. If he selects wrong package name , install would fail. |
1354 | - |
1355 | - if [ "$ARCHITECTURE" = "x86_64" ]; then |
1356 | - juju-log "Checking the package name" |
1357 | - if echo "$cfg_pkg_name" | grep -q "x86"; then |
1358 | - juju-log "IBM DB2: Package name is matching for the platform" |
1359 | - else |
1360 | - juju-log "IBM DB2: Probably Not the right package. DB2 install will fail if its not the right package" |
1361 | - status-set blocked "Probably Not the right package. Please configure the correct package name" |
1362 | - exit 0 |
1363 | - fi |
1364 | - else |
1365 | - if echo "$cfg_pkg_name" | grep -q "ppcle"; then |
1366 | - juju-log "IBM DB2: Package name is matching for the platform" |
1367 | - else |
1368 | - juju-log "IBM DB2: Probably Not the right package. DB2 install will fail if its not the right package" |
1369 | - status-set blocked "Probably Not the right package. Please configure the correct package name" |
1370 | - exit 0 |
1371 | - fi |
1372 | - fi |
1373 | - |
1374 | - #The user has configured a different package name |
1375 | - if [ "$pkg_name" != "$cfg_pkg_name" ]; then |
1376 | - |
1377 | - #Download the new DB2 package |
1378 | - #set +e |
1379 | - juju-log "IBM DB2: Downloading DB2 package." |
1380 | - juju-log $cfg_pkg_name |
1381 | - status-set maintenance "Downloading IBM DB2 package" |
1382 | - set +e |
1383 | - $CHARM_DIR/files/sftp_get.sh $USERNAME $PASSWORD $HOST $PACKAGE_DIR/$cfg_pkg_name $ARCHIVE_DIR |
1384 | - |
1385 | - if [ $? == 0 ]; then |
1386 | - juju-log "IBM DB2: Downloaded DB2 package." |
1387 | - # Delete previously downloaded and installed DB2 package |
1388 | - if [ "$pkg_name" != "" ]; then |
1389 | - juju-log "IBM DB2: Deleting the older DB2 package." |
1390 | - rm $ARCHIVE_DIR/$pkg_name |
1391 | - rm -rf $ARCHIVE_DIR/server* |
1392 | - remove_software |
1393 | - juju-log "IBM DB2: Deleted the older DB2 package." |
1394 | - fi |
1395 | - |
1396 | - else |
1397 | - juju-log "IBM DB2: Download of DB2 package failed." |
1398 | - juju-log "IBM DB2: Ensure the download URL and package name are correctly set in the charm configuration." |
1399 | - exit 0 |
1400 | - fi |
1401 | - set -e |
1402 | - fi |
1403 | - |
1404 | - |
1405 | -} |
1406 | -# Remove DB2, if installed |
1407 | -remove_software() |
1408 | -{ |
1409 | - db2_inst=`is_db2_installed` |
1410 | - if [ $db2_inst == True ]; then |
1411 | - juju-log "IBM DB2: Removing IBM DB2 software......" |
1412 | - status-set maintenance "Removing IBM DB2" |
1413 | - |
1414 | - #finding the DB alias names to be dropped and dropping all Databases in that |
1415 | - for queue1 in `su - $DB2_USER -c 'db2ilist'`; |
1416 | - do |
1417 | - juju-log "IBM DB2: Dropping the Databases for the instance $queue1" |
1418 | - for queue in `su - $queue1 -c 'db2 list db directory | grep "Database alias" | cut -d"=" -f2'`; |
1419 | - do |
1420 | - queue=`echo $queue | xargs` |
1421 | - juju-log "IBM DB2: Dropping the DB $queue" |
1422 | - su - $queue1 -c 'db2 drop database '$queue |
1423 | - if [ $? == 0 ]; then |
1424 | - juju-log "IBM DB2: Dropped the DB $queue" |
1425 | - else |
1426 | - juju-log "IBM DB2: Dropping the DB $queue failed" |
1427 | - status-set blocked "Dropping the DB failed" |
1428 | - exit 0 |
1429 | - fi |
1430 | - done |
1431 | - juju-log "IBM DB2: Stopping the DB for $queue1" |
1432 | - |
1433 | - if su - $queue1 -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$queue1 |
1434 | - then |
1435 | - su - $queue1 -c 'db2 force application all' |
1436 | - su - $queue1 -c 'db2stop' |
1437 | - if [ $? == 0 ]; then |
1438 | - juju-log "IBM DB2: Stopped the DB for the instance $queue1" |
1439 | - else |
1440 | - juju-log "IBM DB2: Stopping the DB for $queue1 failed" |
1441 | - status-set blocked "Stopping the DB for $queue1 failed" |
1442 | - exit 0 |
1443 | - fi |
1444 | - |
1445 | - else |
1446 | - juju-log "IBM DB2: DB2 is already stopped" |
1447 | - fi |
1448 | - done |
1449 | - |
1450 | - #drop the das |
1451 | - cd $DB2_INSTALL_PATH/instance |
1452 | - juju-log "IBM DB2: Dropping the DAS" |
1453 | - ./dasdrop |
1454 | - if [ $? == 0 ]; then |
1455 | - juju-log "IBM DB2: Dropped the DAS" |
1456 | - else |
1457 | - juju-log "IBM DB2: Dropping the DAS failed" |
1458 | - status-set blocked "Dropping the DAS failed" |
1459 | - exit 0 |
1460 | - fi |
1461 | - |
1462 | - #delete the instances |
1463 | - su - $DB2_USER -c 'db2ilist' |
1464 | - |
1465 | - for queue1 in `su - $DB2_USER -c 'db2ilist'`; |
1466 | - do |
1467 | - juju-log "IBM DB2: Deleting the instance $queue1" |
1468 | - /opt/ibm/db2/V10.5/instance/db2idrop $queue1 |
1469 | - if [ $? == 0 ]; then |
1470 | - juju-log "IBM DB2: Deleted the instance $queue1" |
1471 | - else |
1472 | - juju-log "IBM DB2: Deleting the instance $queue1 failed" |
1473 | - status-set blocked "Deleting the instance $queue1 failed" |
1474 | - exit 0 |
1475 | - fi |
1476 | - |
1477 | - done |
1478 | - |
1479 | - #Delete the instance entries from /etc/services file |
1480 | - juju-log "IBM DB2: Deleting the entries from /etc/services" |
1481 | - sed -i '/db2c_/d' /etc/services |
1482 | - if [ $? == 0 ]; then |
1483 | - juju-log "IBM DB2: Deleted the entries from /etc/services" |
1484 | - else |
1485 | - juju-log "IBM DB2: Deletion of the entries from /etc/services failed" |
1486 | - status-set blocked "Deletion of the entries from /etc/services failed" |
1487 | - exit 0 |
1488 | - fi |
1489 | - |
1490 | - #uninstall |
1491 | - juju-log "IBM DB2: Uninstall " |
1492 | - cd /opt/ibm/db2/V10.5/install |
1493 | - set +e |
1494 | - ./db2_deinstall -a |
1495 | - if [ $? == 0 ]; then |
1496 | - juju-log "IBM DB2: Uninstall of db2 successful" |
1497 | - else |
1498 | - juju-log "IBM DB2: Uninstall of db2 failed" |
1499 | - status-set blocked "IBM DB2 Uninstallation failed" |
1500 | - exit 0 |
1501 | - fi |
1502 | - set -e |
1503 | - cd /opt/ibm |
1504 | - rm -rf db2 |
1505 | - juju-log "IBM DB2: Finished Uninstalling......." |
1506 | - status-set blocked "IBM DB2 Uninstalled" |
1507 | - |
1508 | - else |
1509 | - juju-log "IBM DB2: DB2 not installed" |
1510 | - fi |
1511 | - |
1512 | -} |
1513 | - |
1514 | -# Remove DB2 if license not accpeted |
1515 | -remove_unaccepted_software() |
1516 | -{ |
1517 | - |
1518 | - if [ $1 == False ]; then |
1519 | - juju-log "IBM DB2: Removing IBM DB2 (if installed) as the license agreement is not accepted." |
1520 | - remove_software |
1521 | - fi |
1522 | - |
1523 | -} |
1524 | -# Update system configuration after installing DB2 |
1525 | -configure_system() |
1526 | -{ |
1527 | - juju-log "IBM DB2: Updating system configuration." |
1528 | - cd $DB2_INSTALL_PATH/instance |
1529 | - su - $DB2_USER -c 'db2set DB2COMM=tcpip' |
1530 | - |
1531 | - #Start DB for the DB2_user |
1532 | - if su - $DB2_USER -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$DB2_USER; |
1533 | - then |
1534 | - juju-log "IBM DB2: DB2 already started for the user $DB2_USER" |
1535 | - else |
1536 | - su - $DB2_USER -c 'db2start' |
1537 | - juju-log "IBM DB2: DB2 is started" |
1538 | - fi |
1539 | - |
1540 | - service_name=`su - $DB2_USER -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'` |
1541 | - port_num=`grep $service_name /etc/services | cut -d"/" -f1 | cut -f2` |
1542 | - port_num=`echo $port_num | xargs` |
1543 | - if su - $DB2_USER -c 'netstat -an | grep '$port_num; |
1544 | - then |
1545 | - juju-log "DB2 started on port $port_num" |
1546 | - else |
1547 | - juju-log "DB2 not started on port $port_num" |
1548 | - exit 1 |
1549 | - fi |
1550 | - |
1551 | - juju-log "IBM DB2: Updated system configuration." |
1552 | - |
1553 | -} |
1554 | -#Configure dftdbpath |
1555 | -configure_dftdbpath() |
1556 | -{ |
1557 | - db2_inst=`is_db2_installed` |
1558 | - if [ $db2_inst == True ]; then |
1559 | - cfgdbpath=`config-get dftdbpath` |
1560 | - #If null, assign the default value |
1561 | - if [ "cfgdbpath" == "" ] |
1562 | - then |
1563 | - cfgdbpath="/tmp" |
1564 | - fi |
1565 | - for queue1 in `su - $DB2_USER -c 'db2ilist'`; |
1566 | - do |
1567 | - su - $queue1 -c 'db2 attach to '$queue1 |
1568 | - dbpath=`su - $queue1 -c 'db2 get dbm cfg|grep -i DFTDBPATH|cut -d"=" -f2'` |
1569 | - cfgdbpath=`echo $cfgdbpath | xargs` |
1570 | - dbpath=`echo $dbpath | xargs` |
1571 | - if [ "$cfgdbpath" != "$dbpath" ]; then |
1572 | - if [ -d "$cfgdbpath" ]; then |
1573 | - su - $queue1 -c 'db2 update dbm cfg using DFTDBPATH '$cfgdbpath |
1574 | - if [ $? == 0 ]; then |
1575 | - juju-log "DFTDBPATH changed to $cfgdbpath" |
1576 | - else |
1577 | - juju-log "Unable to set DFTDBPATH to $cfgdbpath" |
1578 | - exit 0 |
1579 | - fi |
1580 | - else |
1581 | - juju-log "Not a valid path. Please check the path and run the command again" |
1582 | - exit 0 |
1583 | - fi |
1584 | - fi |
1585 | - done |
1586 | - else |
1587 | - juju-log "IBM DB2: DB2 is not installed. Install DB2 to change the dbpath" |
1588 | - exit 0 |
1589 | - fi |
1590 | -} |
1591 | -# Edit the response file for UID |
1592 | -edit_responsefile() |
1593 | -{ |
1594 | - rsp_file=db2server_temp.rsp |
1595 | - if [ "$ARCHITECTURE" = "x86_64" ]; then |
1596 | - orgrsp_file=db2server.rsp |
1597 | - else |
1598 | - orgrsp_file=db2server_ppcle.rsp |
1599 | - fi |
1600 | - cp $CHARM_DIR/files/archives/db2installresfile/$orgrsp_file $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1601 | - |
1602 | - db2uid=`id $DB2_USER | cut -d"=" -f2 | cut -d"(" -f1` |
1603 | - sed -i s/db2inst1_uid/$db2uid/g $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1604 | - sed -i s/db2inst1_gid/$db2uid/g $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1605 | - sed -i s/db2inst1_homedir/$DB2_USER/g $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1606 | - sed -i s/db2inst1_password/$DB2_USER_PW/g $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1607 | - |
1608 | - db2fenid=`id db2fenc1 | cut -d"=" -f2 | cut -d"(" -f1` |
1609 | - sed -i s/db2fenc1_uid/$db2fenid/g $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1610 | - sed -i s/db2fenc1_gid/$db2fenid/g $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1611 | - dasuid=`id dasusr1 | cut -d"=" -f2 | cut -d"(" -f1` |
1612 | - sed -i s/das_uid/$dasuid/g $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1613 | - sed -i s/das_gid/$dasuid/g $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1614 | - |
1615 | -} |
1616 | -# Create the Required user for DB2 |
1617 | - |
1618 | -create_user() |
1619 | -{ |
1620 | - passwdchanged=0 |
1621 | - instance_exists=0 |
1622 | - db2_inst=`is_db2_installed` |
1623 | - if [ $db2_inst == True ]; then |
1624 | - status-set maintenance "Creating Users" |
1625 | - #Find the group id for db2inst1 user which is used to install db2 and find all |
1626 | - #all users belonging to this user |
1627 | - db2inst1grpid=`id $DB2_USER | cut -d" " -f2` |
1628 | - cfgusername=`config-get db2_user` |
1629 | - cfgpasswd=`config-get db2_pw` |
1630 | - |
1631 | - #If user is not set, make "db2usr1" as default user |
1632 | - if [ "cfgusername" == "" ]; then |
1633 | - cfgusername="db2usr1" |
1634 | - fi |
1635 | - |
1636 | - #If password is not set, make "password" as default password |
1637 | - if [ "cfgpasswd" == "" ]; then |
1638 | - cfgpasswd="db2usr123" |
1639 | - fi |
1640 | - |
1641 | - #If the user is already available, just change the password. |
1642 | - for queue2 in `awk -F':' '{ print $1}' /etc/passwd`; |
1643 | - do |
1644 | - gid=`id $queue2 | cut -d" " -f2` |
1645 | - if [ $gid == $db2inst1grpid ]; then |
1646 | - if [ $queue2 != "$DB2_USER" ]; then |
1647 | - if [ $cfgusername == $queue2 ]; then |
1648 | - juju-log "IBM DB2: Changing the password for the user $cfgusername to $cfgpasswd" |
1649 | - echo $cfgusername:$cfgpasswd | chpasswd |
1650 | - passwdchanged=1 |
1651 | - juju-log "IBM DB2: Changed the password for the user $cfgusername to $cfgpasswd" |
1652 | - fi |
1653 | - |
1654 | - fi |
1655 | - fi |
1656 | - done |
1657 | - #If not available, add a new user |
1658 | - if [ $passwdchanged != 1 ]; then |
1659 | - juju-log "IBM DB2: Creating New user" |
1660 | - create_newuser |
1661 | - juju-log "IBM DB2: Created New user" |
1662 | - juju-log $cfgusername |
1663 | - fi |
1664 | - #Creating a new instance for the new user if not existing |
1665 | - |
1666 | - for queue1 in `su - $DB2_USER -c 'db2ilist'`; |
1667 | - do |
1668 | - if [ $queue1 == $cfgusername ]; then |
1669 | - instance_exists=1 |
1670 | - fi |
1671 | - done |
1672 | - if [ $instance_exists != 1 ]; then |
1673 | - juju-log "IBM DB2: Creating new instance for the user" |
1674 | - /opt/ibm/db2/V10.5/instance/db2icrt -u $cfgusername $cfgusername |
1675 | - if [ $? == 0 ]; then |
1676 | - juju-log "IBM DB2: Created new instance for the user" |
1677 | - else |
1678 | - juju-log "Creation of new instance failed" |
1679 | - exit 0 |
1680 | - fi |
1681 | - fi |
1682 | - |
1683 | - #Do the configuration for the new instance created |
1684 | - new_port=50001 |
1685 | - free_port=0 |
1686 | - is_free=0 |
1687 | - #Check whether the port number is already in etc/services file, and then add it |
1688 | - cd /etc |
1689 | - if grep -q "db2c_$cfgusername" services |
1690 | - then |
1691 | - juju-log "IBM DB2: Services file already updated" |
1692 | - else |
1693 | - while [ $free_port == 0 ] |
1694 | - do |
1695 | - is_free=`netstat -lnp | grep $new_port | cut -d":" -f2 | cut -d" " -f1` |
1696 | - if [ "$is_free" != "$new_port" ]; then |
1697 | - free_port=1 |
1698 | - else |
1699 | - new_port=$((new_port+1)) |
1700 | - fi |
1701 | - done |
1702 | - juju-log "IBM DB2:Updating Services file" |
1703 | - echo "db2c_$cfgusername $new_port/tcp" >> /etc/services |
1704 | - su - $cfgusername -c 'set db2instance=$cfgusername' |
1705 | - su - $cfgusername -c 'db2set DB2COMM=tcpip' |
1706 | - new_port=`echo $new_port | xargs` |
1707 | - su - $cfgusername -c 'db2 update dbm cfg using svcename '$new_port |
1708 | - /opt/ibm/db2/V10.5/instance/db2iupdt $cfgusername |
1709 | - fi |
1710 | - cd - |
1711 | - |
1712 | - #Start DB for the new user |
1713 | - if su - $cfgusername -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$cfgusername; |
1714 | - then |
1715 | - juju-log "IBM DB2: Db2 already started for the user $cfgusername" |
1716 | - else |
1717 | - su - $cfgusername -c 'db2start' |
1718 | - juju-log "IBM DB2: DB2 is started" |
1719 | - fi |
1720 | - juju-log " After db2start" |
1721 | - |
1722 | - else |
1723 | - juju-log "IBM DB2: DB2 is not installed. Install DB2 before creating users" |
1724 | - exit 0 |
1725 | - |
1726 | - fi |
1727 | -} |
1728 | -create_newuser() |
1729 | -{ |
1730 | - cfgusername=`config-get db2_user` |
1731 | - cfgpasswd=`config-get db2_pw` |
1732 | - dbcreated="False" |
1733 | - #Add the new user |
1734 | - useradd -g db2grp1 -G dasadm1 -m $cfgusername |
1735 | - if [ $? != 0 ]; then |
1736 | - juju-log "IBM DB2: Addition of user $queue2 failed." |
1737 | - status-set blocked "Addition of new used failed, Try again" |
1738 | - exit 0 |
1739 | - fi |
1740 | - #Set the password for the new user |
1741 | - echo $cfgusername:$cfgpasswd | chpasswd |
1742 | - if [ $? != 0 ]; then |
1743 | - juju-log "IBM DB2: Setting password for user $queue2 failed." |
1744 | - status-set blocked "Setting the password for user failed, Try again" |
1745 | - exit 0 |
1746 | - fi |
1747 | - #Check whether test DB is already existing. If not create it |
1748 | - dbname=`su - $DB2_USER -c 'db2 list db directory' | grep "Database name" | grep -i "\bTEST\b" | cut -d"=" -f2` |
1749 | - dbname=`echo $dbname | xargs` |
1750 | - if [ "$dbname" != "TEST" ]; then |
1751 | - juju-log "IBM DB2: Creating DB Test" |
1752 | - su - $DB2_USER -c 'db2 create database test' |
1753 | - if [ $? != 0 ]; then |
1754 | - juju-log "IBM DB2: DB creation failed" |
1755 | - status-set blocked "DB creation failed, Try again" |
1756 | - exit 0 |
1757 | - fi |
1758 | - juju-log "IBM DB2: Created DB Test" |
1759 | - fi |
1760 | - #Connect to the DB and grant data access |
1761 | - su - $DB2_USER -c 'db2 connect to test;db2 grant dataaccess on database to user '$cfgusername |
1762 | - if [ $? != 0 ]; then |
1763 | - juju-log "IBM DB2: Grant access failed" |
1764 | - status-set blocked "Grant dataaccess on database failed, Try again" |
1765 | - exit 0 |
1766 | - fi |
1767 | - |
1768 | - su - $DB2_USER -c 'db2 connect to test;db2 disconnect test' |
1769 | - if [ $? != 0 ]; then |
1770 | - juju-log "IBM DB2: Disconnect DB failed" |
1771 | - status-set blocked "Disconnect DB failed" |
1772 | - exit 0 |
1773 | - fi |
1774 | - |
1775 | -} |
1776 | -#Check the package integrity after download |
1777 | -check_pkg_integrity() |
1778 | -{ |
1779 | - SHA=`config-get sha` |
1780 | - pkg_name=`ls $ARCHIVE_DIR/*.gz` |
1781 | - |
1782 | - if [ "$SHA" == "" ]; then |
1783 | - juju-log "IBM DB2: Please provide valid sha value for your package." |
1784 | - status-set blocked "Please provide valid sha value for your package" |
1785 | - exit 0 |
1786 | - elif [ "$SHA" != "`sha1sum $pkg_name | cut -d" " -f1`" ]; then |
1787 | - juju-log "IBM DB2: IBM DB2 package is corrupt." |
1788 | - status-set maintenance "IBM DB2 package is corrupt" |
1789 | - exit 1 |
1790 | - fi |
1791 | -} |
1792 | - |
1793 | -juju-log "IBM DB2: Begin config-change hook" |
1794 | -db2_license_accepted=`config-get accept-ibm-db2-license` |
1795 | - |
1796 | -# Remove DB2 if license not accepted and exit. Else install it |
1797 | -remove_unaccepted_software $db2_license_accepted |
1798 | -if [ $db2_license_accepted == False ]; then |
1799 | - juju-log "IBM DB2: IBM DB2 License not accepted." |
1800 | -elif [ $db2_license_accepted == True ]; then |
1801 | - juju-log "IBM DB2: License accepted" |
1802 | - db2_inst=`is_db2_installed` |
1803 | - #download db2 |
1804 | - status-set maintenance "Downloading the IBM DB2 package for deployment" |
1805 | - download_db2 |
1806 | - status-set maintenance "Checking whether download was successful" |
1807 | - #Install if download succeeded |
1808 | - if [ $db2_inst == False ]; then |
1809 | - if [ -f $ARCHIVE_DIR/*.gz ]; then |
1810 | - #Check the integrity of the downloaded package |
1811 | - check_pkg_integrity |
1812 | - |
1813 | - cd $CHARM_DIR/files/archives |
1814 | - tar -zxvf $ARCHIVE_DIR/*.gz |
1815 | - if [ $? != 0 ]; then |
1816 | - juju-log "IBM DB2: Unable to extract the DB2 package content. Verify whether the package is corrupt." |
1817 | - status-set maintenance " Unable to extract the DB2 package content" |
1818 | - #Remove corrupt archive file |
1819 | - rm -rf $ARCHIVE_DIR/*.gz |
1820 | - exit 0 |
1821 | - fi |
1822 | - if [ "$ARCHITECTURE" = "x86_64" ]; then |
1823 | - rsp_file=db2server.rsp |
1824 | - else |
1825 | - rsp_file=db2server_ppcle.rsp |
1826 | - fi |
1827 | - edit_responsefile |
1828 | - cd $CHARM_DIR/files/archives/server* |
1829 | - |
1830 | - juju-log "IBM DB2: Checking etc/hosts file." |
1831 | - private_address=`unit-get private-address` |
1832 | - juju-log "private_address : $private_address" |
1833 | - cd /etc |
1834 | - if grep -q "$private_address" hosts |
1835 | - then |
1836 | - juju-log "IBM DB2: Host file already updated" |
1837 | - else |
1838 | - juju-log "IBM DB2:Updating Host file" |
1839 | - echo "$private_address `hostname`" >> /etc/hosts |
1840 | - fi |
1841 | - juju-log "IBM DB2: Installing db2 package." |
1842 | - status-set maintenance "Installing IBM DB2" |
1843 | - cd - |
1844 | - ./db2setup -r $CHARM_DIR/files/archives/db2installresfile/$rsp_file |
1845 | - juju-log "IBM DB2: Installation of db2 complete." |
1846 | - # Configure system values for Db2 |
1847 | - #configure_system |
1848 | - fi |
1849 | - fi |
1850 | - # Configure system values for Db2 |
1851 | - configure_system |
1852 | - #Create the required user to connect to db2 |
1853 | - create_user |
1854 | - #Configure DFTDBPATH |
1855 | - configure_dftdbpath |
1856 | - juju-log "After Configure dftd" |
1857 | - status-set active "IBM DB2 Installed" |
1858 | - $CHARM_DIR/hooks/start |
1859 | - juju-log "After calling start" |
1860 | -else |
1861 | - juju-log "IBM DB2: Acceptable values for license is 'True' or 'False'" |
1862 | - |
1863 | -fi |
1864 | -juju-log "IBM DB2: End config-change hook" |
1865 | - |
1866 | - |
1867 | +#!/usr/bin/env python3 |
1868 | + |
1869 | +# Load modules from $CHARM_DIR/lib |
1870 | +import sys |
1871 | +sys.path.append('lib') |
1872 | + |
1873 | +from charms.layer import basic |
1874 | +basic.bootstrap_charm_deps() |
1875 | +basic.init_config_states() |
1876 | + |
1877 | + |
1878 | +# This will load and run the appropriate @hook and other decorated |
1879 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
1880 | +# and $CHARM_DIR/hooks/relations. |
1881 | +# |
1882 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
1883 | +# for more information on this pattern. |
1884 | +from charms.reactive import main |
1885 | +main() |
1886 | |
1887 | === added file 'hooks/db-relation-broken' |
1888 | --- hooks/db-relation-broken 1970-01-01 00:00:00 +0000 |
1889 | +++ hooks/db-relation-broken 2016-07-14 17:53:24 +0000 |
1890 | @@ -0,0 +1,19 @@ |
1891 | +#!/usr/bin/env python3 |
1892 | + |
1893 | +# Load modules from $CHARM_DIR/lib |
1894 | +import sys |
1895 | +sys.path.append('lib') |
1896 | + |
1897 | +from charms.layer import basic |
1898 | +basic.bootstrap_charm_deps() |
1899 | +basic.init_config_states() |
1900 | + |
1901 | + |
1902 | +# This will load and run the appropriate @hook and other decorated |
1903 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
1904 | +# and $CHARM_DIR/hooks/relations. |
1905 | +# |
1906 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
1907 | +# for more information on this pattern. |
1908 | +from charms.reactive import main |
1909 | +main() |
1910 | |
1911 | === added file 'hooks/db-relation-changed' |
1912 | --- hooks/db-relation-changed 1970-01-01 00:00:00 +0000 |
1913 | +++ hooks/db-relation-changed 2016-07-14 17:53:24 +0000 |
1914 | @@ -0,0 +1,19 @@ |
1915 | +#!/usr/bin/env python3 |
1916 | + |
1917 | +# Load modules from $CHARM_DIR/lib |
1918 | +import sys |
1919 | +sys.path.append('lib') |
1920 | + |
1921 | +from charms.layer import basic |
1922 | +basic.bootstrap_charm_deps() |
1923 | +basic.init_config_states() |
1924 | + |
1925 | + |
1926 | +# This will load and run the appropriate @hook and other decorated |
1927 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
1928 | +# and $CHARM_DIR/hooks/relations. |
1929 | +# |
1930 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
1931 | +# for more information on this pattern. |
1932 | +from charms.reactive import main |
1933 | +main() |
1934 | |
1935 | === added file 'hooks/db-relation-departed' |
1936 | --- hooks/db-relation-departed 1970-01-01 00:00:00 +0000 |
1937 | +++ hooks/db-relation-departed 2016-07-14 17:53:24 +0000 |
1938 | @@ -0,0 +1,19 @@ |
1939 | +#!/usr/bin/env python3 |
1940 | + |
1941 | +# Load modules from $CHARM_DIR/lib |
1942 | +import sys |
1943 | +sys.path.append('lib') |
1944 | + |
1945 | +from charms.layer import basic |
1946 | +basic.bootstrap_charm_deps() |
1947 | +basic.init_config_states() |
1948 | + |
1949 | + |
1950 | +# This will load and run the appropriate @hook and other decorated |
1951 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
1952 | +# and $CHARM_DIR/hooks/relations. |
1953 | +# |
1954 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
1955 | +# for more information on this pattern. |
1956 | +from charms.reactive import main |
1957 | +main() |
1958 | |
1959 | === modified file 'hooks/db-relation-joined' |
1960 | --- hooks/db-relation-joined 2016-01-12 08:17:38 +0000 |
1961 | +++ hooks/db-relation-joined 2016-07-14 17:53:24 +0000 |
1962 | @@ -1,14 +1,19 @@ |
1963 | -#!/bin/sh |
1964 | - |
1965 | -set -e |
1966 | -DB2_USER=db2inst1 |
1967 | -CFGUSERNAME=`config-get db2_user` |
1968 | -CFGPASSED=`config-get db2_pw` |
1969 | - |
1970 | -service_name=`su - $CFGUSERNAME -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'` |
1971 | -DB2_INSTALL_PATH=/opt/ibm/db2/V10.5 |
1972 | -PORT_NUM=`grep $service_name /etc/services | cut -d"/" -f1 | cut -f2` |
1973 | -#remove white space |
1974 | -PORT_NUM=`echo $PORT_NUM | xargs` |
1975 | - |
1976 | -relation-set hostname=`unit-get private-address` port=$PORT_NUM dbusername=$CFGUSERNAME dbuserpw=$CFGPASSED db2_instance_name=$CFGUSERNAME db2_install_path=$DB2_INSTALL_PATH |
1977 | +#!/usr/bin/env python3 |
1978 | + |
1979 | +# Load modules from $CHARM_DIR/lib |
1980 | +import sys |
1981 | +sys.path.append('lib') |
1982 | + |
1983 | +from charms.layer import basic |
1984 | +basic.bootstrap_charm_deps() |
1985 | +basic.init_config_states() |
1986 | + |
1987 | + |
1988 | +# This will load and run the appropriate @hook and other decorated |
1989 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
1990 | +# and $CHARM_DIR/hooks/relations. |
1991 | +# |
1992 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
1993 | +# for more information on this pattern. |
1994 | +from charms.reactive import main |
1995 | +main() |
1996 | |
1997 | === added file 'hooks/hook.template' |
1998 | --- hooks/hook.template 1970-01-01 00:00:00 +0000 |
1999 | +++ hooks/hook.template 2016-07-14 17:53:24 +0000 |
2000 | @@ -0,0 +1,19 @@ |
2001 | +#!/usr/bin/env python3 |
2002 | + |
2003 | +# Load modules from $CHARM_DIR/lib |
2004 | +import sys |
2005 | +sys.path.append('lib') |
2006 | + |
2007 | +from charms.layer import basic |
2008 | +basic.bootstrap_charm_deps() |
2009 | +basic.init_config_states() |
2010 | + |
2011 | + |
2012 | +# This will load and run the appropriate @hook and other decorated |
2013 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
2014 | +# and $CHARM_DIR/hooks/relations. |
2015 | +# |
2016 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
2017 | +# for more information on this pattern. |
2018 | +from charms.reactive import main |
2019 | +main() |
2020 | |
2021 | === modified file 'hooks/install' |
2022 | --- hooks/install 2016-01-12 08:17:38 +0000 |
2023 | +++ hooks/install 2016-07-14 17:53:24 +0000 |
2024 | @@ -1,62 +1,19 @@ |
2025 | -#!/bin/bash |
2026 | - |
2027 | -set -e |
2028 | -juju-log "IBM DB2: Begin Install." |
2029 | - |
2030 | -# Get the architecture from the uname command. |
2031 | -ARCHITECTURE=`uname -m` |
2032 | -apt-get update |
2033 | -status-set maintenance "Installing pre requisites for IBM DB2" |
2034 | - |
2035 | -juju-log "IBM DB2: Installing binutils" |
2036 | -apt-get install binutils |
2037 | -juju-log "IBM DB2: Installed binutils" |
2038 | - |
2039 | -ARCHITECTURE=`uname -m` |
2040 | -if [ "$ARCHITECTURE" != "x86_64" -a "$ARCHITECTURE" != "ppc64le" ]; then |
2041 | - juju-log "IBM DB2: Unsupported platform. IBM DB2 installed with this Charm supports only the x86_64 and POWER LE (ppc64le) platforms." |
2042 | - exit 1 |
2043 | -fi |
2044 | - |
2045 | -if [ "$ARCHITECTURE" == "x86_64" ]; then |
2046 | - juju-log "IBM DB2: Installing 32 bit libstdc++.so.6" |
2047 | - apt-get update |
2048 | - apt-get install lib32stdc++6 -y |
2049 | - juju-log "IBM DB2: Installed 32 bit libstdc++.so.6" |
2050 | -fi |
2051 | -if [ "$ARCHITECTURE" == "ppc64le" ]; then |
2052 | - juju-log "IBM DB2: Installing libnuma package for POWER LE (ppc64le) platforms." |
2053 | - apt-get install libnuma-dev -y |
2054 | - #Installing XL compiler runtime packages for Linux on Power as this is one of the prerequisite software/configuration requirements |
2055 | - echo "deb http://public.dhe.ibm.com/software/server/POWER/Linux/rte/xlcpp/le/ubuntu $(lsb_release -s -c) main" | tee -a /etc/apt/sources.list.d/ibm-xlcpp-rte.list |
2056 | - apt-get update |
2057 | - apt-get install libxlc -y --force-yes |
2058 | - juju-log "IBM DB2: Installed libnuma package for POWER LE (ppc64le) platforms." |
2059 | -fi |
2060 | - |
2061 | -# Install expect |
2062 | -juju-log "IBM DB2: Installng expect package" |
2063 | -apt-get install -y expect |
2064 | -juju-log "IBM DB2: Installed expect package" |
2065 | - |
2066 | -#create the userids required for db2 installation |
2067 | -DB2_USER=db2inst1 |
2068 | -DB2_USER_PW=db2inst1 |
2069 | - |
2070 | -juju-log "IBM DB2: Creating the user ids for db2 installation" |
2071 | -groupadd db2grp1 |
2072 | -groupadd dasadm1 |
2073 | -groupadd db2fgrp1 |
2074 | - |
2075 | -useradd -g db2grp1 -G dasadm1 -m $DB2_USER |
2076 | -echo $DB2_USER:$DB2_USER_PW | chpasswd |
2077 | - |
2078 | -useradd -g dasadm1 -G db2grp1 -m dasusr1 |
2079 | -echo dasusr1:dasusr1 | chpasswd |
2080 | - |
2081 | -useradd -g db2fgrp1 -m db2fenc1 |
2082 | -echo db2fenc1:db2fenc1 | chpasswd |
2083 | - |
2084 | -juju-log "IBM DB2: Created the user ids for db2 installation" |
2085 | -juju-log "IBM DB2: End Install hook" |
2086 | - |
2087 | +#!/usr/bin/env python3 |
2088 | + |
2089 | +# Load modules from $CHARM_DIR/lib |
2090 | +import sys |
2091 | +sys.path.append('lib') |
2092 | + |
2093 | +from charms.layer import basic |
2094 | +basic.bootstrap_charm_deps() |
2095 | +basic.init_config_states() |
2096 | + |
2097 | + |
2098 | +# This will load and run the appropriate @hook and other decorated |
2099 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
2100 | +# and $CHARM_DIR/hooks/relations. |
2101 | +# |
2102 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
2103 | +# for more information on this pattern. |
2104 | +from charms.reactive import main |
2105 | +main() |
2106 | |
2107 | === added file 'hooks/leader-elected' |
2108 | --- hooks/leader-elected 1970-01-01 00:00:00 +0000 |
2109 | +++ hooks/leader-elected 2016-07-14 17:53:24 +0000 |
2110 | @@ -0,0 +1,19 @@ |
2111 | +#!/usr/bin/env python3 |
2112 | + |
2113 | +# Load modules from $CHARM_DIR/lib |
2114 | +import sys |
2115 | +sys.path.append('lib') |
2116 | + |
2117 | +from charms.layer import basic |
2118 | +basic.bootstrap_charm_deps() |
2119 | +basic.init_config_states() |
2120 | + |
2121 | + |
2122 | +# This will load and run the appropriate @hook and other decorated |
2123 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
2124 | +# and $CHARM_DIR/hooks/relations. |
2125 | +# |
2126 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
2127 | +# for more information on this pattern. |
2128 | +from charms.reactive import main |
2129 | +main() |
2130 | |
2131 | === added file 'hooks/leader-settings-changed' |
2132 | --- hooks/leader-settings-changed 1970-01-01 00:00:00 +0000 |
2133 | +++ hooks/leader-settings-changed 2016-07-14 17:53:24 +0000 |
2134 | @@ -0,0 +1,19 @@ |
2135 | +#!/usr/bin/env python3 |
2136 | + |
2137 | +# Load modules from $CHARM_DIR/lib |
2138 | +import sys |
2139 | +sys.path.append('lib') |
2140 | + |
2141 | +from charms.layer import basic |
2142 | +basic.bootstrap_charm_deps() |
2143 | +basic.init_config_states() |
2144 | + |
2145 | + |
2146 | +# This will load and run the appropriate @hook and other decorated |
2147 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
2148 | +# and $CHARM_DIR/hooks/relations. |
2149 | +# |
2150 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
2151 | +# for more information on this pattern. |
2152 | +from charms.reactive import main |
2153 | +main() |
2154 | |
2155 | === added directory 'hooks/relations' |
2156 | === added directory 'hooks/relations/db2' |
2157 | === added file 'hooks/relations/db2/README.md' |
2158 | --- hooks/relations/db2/README.md 1970-01-01 00:00:00 +0000 |
2159 | +++ hooks/relations/db2/README.md 2016-07-14 17:53:24 +0000 |
2160 | @@ -0,0 +1,66 @@ |
2161 | +# Overview |
2162 | + |
2163 | +This interface layer handles the communication between IBM DB2 and Consumer |
2164 | +charms. The provider end of this interface provides the IBM DB2 service. The |
2165 | +consumer part requires the existence of a provider to function. |
2166 | + |
2167 | +## Usage |
2168 | + |
2169 | +### Provides |
2170 | + |
2171 | +This interface layer will set the following states, as appropriate: |
2172 | + |
2173 | +- `{relation_name}.connected`: The relation is established, but IBM DB2 may not |
2174 | +yet have provided any connection or service information. |
2175 | + |
2176 | +- `{relation_name}.sshconfigured`: A consumer ssh key has been added to the |
2177 | +IBM DB2 `authorized_keys` file. |
2178 | + |
2179 | +- `{relation_name}.ready`: IBM DB2 has established relation with the consumer |
2180 | +charm and the SSH key has been exchanged. DB2 has provided its connection |
2181 | +string information, and is ready to accept requests from the consumer. |
2182 | + |
2183 | +- `{relation_name}.departed`: The relation has been removed. Any cleanup |
2184 | +related to the consumer charm should happen now on the IBM DB2 charm since the |
2185 | +consumer is going away. |
2186 | + |
2187 | + |
2188 | +### Requires |
2189 | + |
2190 | +Consumers like WAS, Mobile First Server, etc require this interface to connect |
2191 | +to IBM DB2. This interface layer will set the following states, as appropriate: |
2192 | + |
2193 | +- `{relation_name}.connected`: The consumer charm has been related to IBM DB2. |
2194 | +At this point, the consumer charm sends the SSH key to IBM DB2 charm. |
2195 | + |
2196 | + For example, the consumer charm can send the ssh key to IBM DB2 charm as follows: |
2197 | + |
2198 | + ``` |
2199 | + @when 'db.connected' |
2200 | + @when_not 'db.sshconfigured' |
2201 | + function configure_sshkeys_dbs() { |
2202 | + SSH_PATH=/root/.ssh |
2203 | + if [ ! -f $SSH_PATH/id_rsa.pub ]; then |
2204 | + juju-log "Setting up SSH keys." |
2205 | + ssh-keygen -t rsa -f $SSH_PATH/id_rsa -N '' |
2206 | + fi |
2207 | + key="`cat $SSH_PATH/id_rsa.pub`" |
2208 | + relation_call --state=db.connected set_ssh_keys "$key" || true |
2209 | + } |
2210 | + ``` |
2211 | + |
2212 | +- `{relation_name}.ready`: IBM DB2 is ready to send connection information. |
2213 | +The consumer charm can access the IBM DB2 details from the interface using the |
2214 | +following methods: |
2215 | + |
2216 | + - get_db2_hostname() - host name of IBM DB2 |
2217 | + - get_db2_port() - port number of IBM DB2 |
2218 | + - get_db2_path() - the install location of IBM DB2 |
2219 | + - get_dbusername() - User name created for the consumer service to connect to DB2 |
2220 | + - get_dbuserpw() - Password for connecting to DB2 |
2221 | + - get_db2_instance_name() - Instance name created for the consumer service |
2222 | + |
2223 | + |
2224 | +- `{relation_name}.departed`: The relation has been removed. Any cleanup |
2225 | +related to IBM DB2 should happen now on the consumer charm since IBM DB2 is |
2226 | +going away. |
2227 | |
2228 | === added file 'hooks/relations/db2/__init__.py' |
2229 | === added file 'hooks/relations/db2/interface.yaml' |
2230 | --- hooks/relations/db2/interface.yaml 1970-01-01 00:00:00 +0000 |
2231 | +++ hooks/relations/db2/interface.yaml 2016-07-14 17:53:24 +0000 |
2232 | @@ -0,0 +1,4 @@ |
2233 | +name: db2 |
2234 | +summary: Facilitates communication between IBM DB2 and database consumers |
2235 | +version: 1 |
2236 | +maintainer: "IBM Juju Support Team <jujusupp@us.ibm.com>" |
2237 | |
2238 | === added file 'hooks/relations/db2/provides.py' |
2239 | --- hooks/relations/db2/provides.py 1970-01-01 00:00:00 +0000 |
2240 | +++ hooks/relations/db2/provides.py 2016-07-14 17:53:24 +0000 |
2241 | @@ -0,0 +1,80 @@ |
2242 | +from charms.reactive import hook |
2243 | +from charms.reactive import RelationBase |
2244 | +from charms.reactive import scopes |
2245 | + |
2246 | + |
2247 | +class db2Provides(RelationBase): |
2248 | + # Every unit connecting will get the same information |
2249 | + scope = scopes.SERVICE |
2250 | + # convenient way to provide accessor methods |
2251 | + auto_accessors = ['db2_path', 'db2_port'] |
2252 | + |
2253 | + @hook('{provides:db2}-relation-joined') |
2254 | + def joined(self): |
2255 | + conversation = self.conversation() |
2256 | + conversation.remove_state('{relation_name}.departed') |
2257 | + conversation.set_state('{relation_name}.connected') |
2258 | + |
2259 | + @hook('{provides:db2}-relation-changed') |
2260 | + def changed(self): |
2261 | + conversation = self.conversation() |
2262 | + conversation.remove_state('{relation_name}.departed') |
2263 | + conversation.set_state('{relation_name}.connected') |
2264 | + if str(conversation.get_remote('ssh_key')) != "None": |
2265 | + conversation.set_state('{relation_name}.ready') |
2266 | + |
2267 | + @hook('{provides:db2}-relation-departed') |
2268 | + def departed(self): |
2269 | + conversation = self.conversation() |
2270 | + conversation.remove_state('{relation_name}.connected') |
2271 | + conversation.remove_state('{relation_name}.ready') |
2272 | + conversation.set_state('{relation_name}.departed') |
2273 | + |
2274 | + def dismiss(self, service): |
2275 | + conversation = self.conversation(service) |
2276 | + conversation.remove_state('{relation_name}.departed') |
2277 | + |
2278 | + def reset_states(self, service): |
2279 | + conversation = self.conversation(service) |
2280 | + conversation.remove_state('{relation_name}.connected') |
2281 | + conversation.remove_state('{relation_name}.departed') |
2282 | + conversation.remove_state('{relation_name}.ready') |
2283 | + |
2284 | + def set_db_details(self, service, db2_path, db2_port, hostname, |
2285 | + dbusername, dbuserpw, db2_instance_name, dbs_created): |
2286 | + conversation = self.conversation(service) |
2287 | + conversation.set_remote(data={ |
2288 | + 'db2_ready': True, |
2289 | + 'db2_path': db2_path, |
2290 | + 'db2_port': db2_port, |
2291 | + 'hostname': hostname, |
2292 | + 'dbusername': dbusername, |
2293 | + 'dbuserpw': dbuserpw, |
2294 | + 'db2_instance_name': db2_instance_name, |
2295 | + 'dbs_created': dbs_created, |
2296 | + }) |
2297 | + |
2298 | + def set_sshconfigured(self, service): |
2299 | + conversation = self.conversation(service) |
2300 | + conversation.set_state('{relation_name}.sshconfigured') |
2301 | + |
2302 | + def dismiss_sshconfigured(self, service): |
2303 | + conversation = self.conversation(service) |
2304 | + conversation.remove_state('{relation_name}.sshconfigured') |
2305 | + |
2306 | + def get_sshkeys(self, service): |
2307 | + conversation = self.conversation(service) |
2308 | + return conversation.get_remote('ssh_key') |
2309 | + |
2310 | + def get_dbnames(self, service): |
2311 | + conversation = self.conversation(service) |
2312 | + return conversation.get_remote('db_names') |
2313 | + |
2314 | + def services(self): |
2315 | + """ |
2316 | + Return a list of services requesting databases. |
2317 | + """ |
2318 | + service = [] |
2319 | + for conversation in self.conversations(): |
2320 | + service.append(conversation.scope) |
2321 | + return service |
2322 | |
2323 | === added file 'hooks/relations/db2/requires.py' |
2324 | --- hooks/relations/db2/requires.py 1970-01-01 00:00:00 +0000 |
2325 | +++ hooks/relations/db2/requires.py 2016-07-14 17:53:24 +0000 |
2326 | @@ -0,0 +1,65 @@ |
2327 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
2328 | +# you may not use this file except in compliance with the License. |
2329 | +# You may obtain a copy of the License at |
2330 | +# |
2331 | +# http://www.apache.org/licenses/LICENSE-2.0 |
2332 | +# |
2333 | +# Unless required by applicable law or agreed to in writing, software |
2334 | +# distributed under the License is distributed on an "AS IS" BASIS, |
2335 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
2336 | +# See the License for the specific language governing permissions and |
2337 | +# limitations under the License. |
2338 | + |
2339 | +from charms.reactive import hook |
2340 | +from charms.reactive import RelationBase |
2341 | +from charms.reactive import scopes |
2342 | + |
2343 | + |
2344 | +class db2Requires(RelationBase): |
2345 | + scope = scopes.GLOBAL |
2346 | + auto_accessors = ['ssh_key'] |
2347 | + |
2348 | + @hook('{requires:db2}-relation-joined') |
2349 | + def joined(self): |
2350 | + self.remove_state('{relation_name}.departed') |
2351 | + self.set_state('{relation_name}.connected') |
2352 | + |
2353 | + @hook('{requires:db2}-relation-changed') |
2354 | + def changed(self): |
2355 | + self.remove_state('{relation_name}.departed') |
2356 | + self.set_state('{relation_name}.connected') |
2357 | + if str(self.get_remote('db2_port')) != "None": |
2358 | + self.set_state('{relation_name}.ready') |
2359 | + |
2360 | + @hook('{requires:db2}-relation-departed') |
2361 | + def departed(self): |
2362 | + self.remove_state('{relation_name}.connected') |
2363 | + self.remove_state('{relation_name}.ready') |
2364 | + self.set_state('{relation_name}.departed') |
2365 | + |
2366 | + def get_db2_port(self): |
2367 | + return self.get_remote('db2_port') |
2368 | + |
2369 | + def get_db2_path(self): |
2370 | + return self.get_remote('db2_path') |
2371 | + |
2372 | + def get_db2_hostname(self): |
2373 | + return self.get_remote('hostname') |
2374 | + |
2375 | + def get_dbusername(self): |
2376 | + return self.get_remote('dbusername') |
2377 | + |
2378 | + def get_dbuserpw(self): |
2379 | + return self.get_remote('dbuserpw') |
2380 | + |
2381 | + def get_db2_instance_name(self): |
2382 | + return self.get_remote('db2_instance_name') |
2383 | + |
2384 | + def get_db2_dbnames(self): |
2385 | + return self.get_remote('dbs_created') |
2386 | + |
2387 | + def set_ssh_keys(self, ssh_key): |
2388 | + self.set_remote('ssh_key', ssh_key) |
2389 | + |
2390 | + def set_dbs(self, db_names): |
2391 | + self.set_remote('db_names', db_names) |
2392 | |
2393 | === modified file 'hooks/start' |
2394 | --- hooks/start 2016-01-12 08:17:38 +0000 |
2395 | +++ hooks/start 2016-07-14 17:53:24 +0000 |
2396 | @@ -1,48 +1,19 @@ |
2397 | -#!/bin/bash |
2398 | - |
2399 | - |
2400 | -set -e |
2401 | -juju-log "IBM DB2: Begin Start hook" |
2402 | -DB2_USER=db2inst1 |
2403 | -DB2_INSTALL_PATH=/opt/ibm/db2/V10.5 |
2404 | -cfgusername=`config-get db2_user` |
2405 | -#If user is not set, make "db2usr1" as default user |
2406 | -if [ "cfgusername" == "" ]; then |
2407 | - cfgusername="db2usr1" |
2408 | -fi |
2409 | - |
2410 | -if [ -d $DB2_INSTALL_PATH/bin ]; then |
2411 | - service_name=`su - $DB2_USER -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'` |
2412 | - PORT_NUM=`grep $service_name /etc/services | cut -d"/" -f1 | cut -f2` |
2413 | - #remove white space |
2414 | - PORT_NUM=`echo $PORT_NUM | xargs` |
2415 | - if su - $DB2_USER -c 'netstat -an | grep '$PORT_NUM; |
2416 | - then |
2417 | - juju-log "IBM DB2: DB2 already running on port $PORT_NUM for the instance $DB2_USER" |
2418 | - else |
2419 | - su - db2inst1 -c 'db2start' |
2420 | - if su - $DB2_USER -c 'netstat -an | grep '$PORT_NUM; |
2421 | - then |
2422 | - juju-log "IBM DB2: DB2 started on port $PORT_NUM for the instance $DB2_USER" |
2423 | - else |
2424 | - juju-log "IBM DB2: DB2 not started on port $PORT_NUM for the instance $DB2_USER" |
2425 | - exit 1 |
2426 | - fi |
2427 | - fi |
2428 | - #Start the service for the db2 user configured |
2429 | - if su - $cfgusername -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$cfgusername |
2430 | - then |
2431 | - juju-log "IBM DB2: DB2 already running for the instance $cfgusername" |
2432 | - else |
2433 | - su - $cfgusername -c 'db2start' |
2434 | - if su - $cfgusername -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$cfgusername |
2435 | - then |
2436 | - juju-log "IBM DB2: DB2 started for the instance $cfgusername" |
2437 | - else |
2438 | - juju-log "IBM DB2: DB2 not started for the instance $cfgusername" |
2439 | - exit 1 |
2440 | - fi |
2441 | - fi |
2442 | -fi |
2443 | - |
2444 | -juju-log "IBM DB2: End Start hook" |
2445 | +#!/usr/bin/env python3 |
2446 | + |
2447 | +# Load modules from $CHARM_DIR/lib |
2448 | +import sys |
2449 | +sys.path.append('lib') |
2450 | + |
2451 | +from charms.layer import basic |
2452 | +basic.bootstrap_charm_deps() |
2453 | +basic.init_config_states() |
2454 | + |
2455 | + |
2456 | +# This will load and run the appropriate @hook and other decorated |
2457 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
2458 | +# and $CHARM_DIR/hooks/relations. |
2459 | +# |
2460 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
2461 | +# for more information on this pattern. |
2462 | +from charms.reactive import main |
2463 | +main() |
2464 | |
2465 | === modified file 'hooks/stop' |
2466 | --- hooks/stop 2016-01-12 08:17:38 +0000 |
2467 | +++ hooks/stop 2016-07-14 17:53:24 +0000 |
2468 | @@ -1,30 +1,19 @@ |
2469 | -#!/bin/bash |
2470 | - |
2471 | -set -e |
2472 | -juju-log "IBM DB2: Begin Stop hook" |
2473 | -DB2_USER=db2inst1 |
2474 | -DB2_INSTALL_PATH=/opt/ibm/db2/V10.5 |
2475 | -if [ -d $DB2_INSTALL_PATH/bin ]; then |
2476 | - service_name=`su - $DB2_USER -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'` |
2477 | - PORT_NUM=`grep $service_name /etc/services | cut -d"/" -f1 | cut -f2` |
2478 | - #remove white space |
2479 | - PORT_NUM=`echo $PORT_NUM | xargs` |
2480 | - if su - $DB2_USER -c 'netstat -an | grep '$PORT_NUM; |
2481 | - then |
2482 | - su - db2inst1 -c 'db2stop' |
2483 | - juju-log "IBM DB2: DB2 stopped for the instance $DB2_USER" |
2484 | - else |
2485 | - juju-log "IBM DB2: DB2 is already stopped for the instance $DB2_USER" |
2486 | - fi |
2487 | - |
2488 | - #Stopping for the db2 user configured |
2489 | - if su - $cfgusername -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$cfgusername |
2490 | - then |
2491 | - su - $cfgusername -c 'db2stop' |
2492 | - juju-log "IBM DB2: DB2 stopped for instance $cfgusername" |
2493 | - else |
2494 | - juju-log "IBM DB2: DB2 is already stopped for the instance $cfgusername" |
2495 | - fi |
2496 | - |
2497 | -fi |
2498 | -juju-log "IBM DB2: End Stop hook" |
2499 | +#!/usr/bin/env python3 |
2500 | + |
2501 | +# Load modules from $CHARM_DIR/lib |
2502 | +import sys |
2503 | +sys.path.append('lib') |
2504 | + |
2505 | +from charms.layer import basic |
2506 | +basic.bootstrap_charm_deps() |
2507 | +basic.init_config_states() |
2508 | + |
2509 | + |
2510 | +# This will load and run the appropriate @hook and other decorated |
2511 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
2512 | +# and $CHARM_DIR/hooks/relations. |
2513 | +# |
2514 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
2515 | +# for more information on this pattern. |
2516 | +from charms.reactive import main |
2517 | +main() |
2518 | |
2519 | === added file 'hooks/update-status' |
2520 | --- hooks/update-status 1970-01-01 00:00:00 +0000 |
2521 | +++ hooks/update-status 2016-07-14 17:53:24 +0000 |
2522 | @@ -0,0 +1,19 @@ |
2523 | +#!/usr/bin/env python3 |
2524 | + |
2525 | +# Load modules from $CHARM_DIR/lib |
2526 | +import sys |
2527 | +sys.path.append('lib') |
2528 | + |
2529 | +from charms.layer import basic |
2530 | +basic.bootstrap_charm_deps() |
2531 | +basic.init_config_states() |
2532 | + |
2533 | + |
2534 | +# This will load and run the appropriate @hook and other decorated |
2535 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
2536 | +# and $CHARM_DIR/hooks/relations. |
2537 | +# |
2538 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
2539 | +# for more information on this pattern. |
2540 | +from charms.reactive import main |
2541 | +main() |
2542 | |
2543 | === added file 'hooks/upgrade-charm' |
2544 | --- hooks/upgrade-charm 1970-01-01 00:00:00 +0000 |
2545 | +++ hooks/upgrade-charm 2016-07-14 17:53:24 +0000 |
2546 | @@ -0,0 +1,28 @@ |
2547 | +#!/usr/bin/env python3 |
2548 | + |
2549 | +# Load modules from $CHARM_DIR/lib |
2550 | +import os |
2551 | +import sys |
2552 | +sys.path.append('lib') |
2553 | + |
2554 | +# This is an upgrade-charm context, make sure we install latest deps |
2555 | +if not os.path.exists('wheelhouse/.upgrade'): |
2556 | + open('wheelhouse/.upgrade', 'w').close() |
2557 | + if os.path.exists('wheelhouse/.bootstrapped'): |
2558 | + os.unlink('wheelhouse/.bootstrapped') |
2559 | +else: |
2560 | + os.unlink('wheelhouse/.upgrade') |
2561 | + |
2562 | +from charms.layer import basic |
2563 | +basic.bootstrap_charm_deps() |
2564 | +basic.init_config_states() |
2565 | + |
2566 | + |
2567 | +# This will load and run the appropriate @hook and other decorated |
2568 | +# handlers from $CHARM_DIR/reactive, $CHARM_DIR/hooks/reactive, |
2569 | +# and $CHARM_DIR/hooks/relations. |
2570 | +# |
2571 | +# See https://jujucharms.com/docs/stable/authors-charm-building |
2572 | +# for more information on this pattern. |
2573 | +from charms.reactive import main |
2574 | +main() |
2575 | |
2576 | === added file 'layer.yaml' |
2577 | --- layer.yaml 1970-01-01 00:00:00 +0000 |
2578 | +++ layer.yaml 2016-07-14 17:53:24 +0000 |
2579 | @@ -0,0 +1,22 @@ |
2580 | +"includes": |
2581 | +- "layer:basic" |
2582 | +- "layer:apt" |
2583 | +- "layer:leadership" |
2584 | +- "layer:basic" |
2585 | +- "layer:ibm-base" |
2586 | +- "interface:db2" |
2587 | +"options": |
2588 | + "basic": |
2589 | + # Setting options for the basic layer. |
2590 | + "packages": |
2591 | + - "curl" |
2592 | + - "binutils" |
2593 | + - "pwgen" |
2594 | + - "tar" |
2595 | + "use_venv": !!bool "false" |
2596 | + "include_system_packages": !!bool "false" |
2597 | + "ibm-base": {} |
2598 | + "leadership": {} |
2599 | + "ibm-db2": {} |
2600 | +"repo": "bzr+ssh://bazaar.launchpad.net/~ibmcharmers/charms/trusty/layer-ibm-db2/trunk/" |
2601 | +"is": "ibm-db2" |
2602 | |
2603 | === added directory 'lib' |
2604 | === added directory 'lib/charms' |
2605 | === added file 'lib/charms/__init__.py' |
2606 | --- lib/charms/__init__.py 1970-01-01 00:00:00 +0000 |
2607 | +++ lib/charms/__init__.py 2016-07-14 17:53:24 +0000 |
2608 | @@ -0,0 +1,2 @@ |
2609 | +from pkgutil import extend_path |
2610 | +__path__ = extend_path(__path__, __name__) |
2611 | |
2612 | === added file 'lib/charms/apt.py' |
2613 | --- lib/charms/apt.py 1970-01-01 00:00:00 +0000 |
2614 | +++ lib/charms/apt.py 2016-07-14 17:53:24 +0000 |
2615 | @@ -0,0 +1,182 @@ |
2616 | +# Copyright 2015-2016 Canonical Ltd. |
2617 | +# |
2618 | +# This file is part of the Apt layer for Juju. |
2619 | +# |
2620 | +# This program is free software: you can redistribute it and/or modify |
2621 | +# it under the terms of the GNU General Public License version 3, as |
2622 | +# published by the Free Software Foundation. |
2623 | +# |
2624 | +# This program is distributed in the hope that it will be useful, but |
2625 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
2626 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2627 | +# PURPOSE. See the GNU General Public License for more details. |
2628 | +# |
2629 | +# You should have received a copy of the GNU General Public License |
2630 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2631 | + |
2632 | +''' |
2633 | +charms.reactive helpers for dealing with deb packages. |
2634 | + |
2635 | +Add apt package sources using add_source(). Queue deb packages for |
2636 | +installation with install(). Configure and work with your software |
2637 | +once the apt.installed.{packagename} state is set. |
2638 | +''' |
2639 | +import itertools |
2640 | +import subprocess |
2641 | + |
2642 | +from charmhelpers import fetch |
2643 | +from charmhelpers.core import hookenv, unitdata |
2644 | +from charms import reactive |
2645 | + |
2646 | + |
2647 | +__all__ = ['add_source', 'update', 'queue_install', 'install_queued', |
2648 | + 'installed', 'purge', 'ensure_package_status'] |
2649 | + |
2650 | + |
2651 | +def add_source(source, key=None): |
2652 | + '''Add an apt source. |
2653 | + |
2654 | + Sets the apt.needs_update state. |
2655 | + |
2656 | + A source may be either a line that can be added directly to |
2657 | + sources.list(5), or in the form ppa:<user>/<ppa-name> for adding |
2658 | + Personal Package Archives, or a distribution component to enable. |
2659 | + |
2660 | + The package signing key should be an ASCII armoured GPG key. While |
2661 | + GPG key ids are also supported, the retrieval mechanism is insecure. |
2662 | + There is no need to specify the package signing key for PPAs or for |
2663 | + the main Ubuntu archives. |
2664 | + ''' |
2665 | + # Maybe we should remember which sources have been added already |
2666 | + # so we don't waste time re-adding them. Is this time significant? |
2667 | + fetch.add_source(source, key) |
2668 | + reactive.set_state('apt.needs_update') |
2669 | + |
2670 | + |
2671 | +def queue_install(packages, options=None): |
2672 | + """Queue one or more deb packages for install. |
2673 | + |
2674 | + The `apt.installed.{name}` state is set once the package is installed. |
2675 | + |
2676 | + If a package has already been installed it will not be reinstalled. |
2677 | + |
2678 | + If a package has already been queued it will not be requeued, and |
2679 | + the install options will not be changed. |
2680 | + |
2681 | + Sets the apt.queued_installs state. |
2682 | + """ |
2683 | + if isinstance(packages, str): |
2684 | + packages = [packages] |
2685 | + # Filter installed packages. |
2686 | + store = unitdata.kv() |
2687 | + queued_packages = store.getrange('apt.install_queue.', strip=True) |
2688 | + packages = {package: options for package in packages |
2689 | + if not (package in queued_packages or |
2690 | + reactive.helpers.is_state('apt.installed.' + package))} |
2691 | + if packages: |
2692 | + unitdata.kv().update(packages, prefix='apt.install_queue.') |
2693 | + reactive.set_state('apt.queued_installs') |
2694 | + |
2695 | + |
2696 | +def installed(): |
2697 | + '''Return the set of deb packages completed install''' |
2698 | + return set(state.split('.', 2)[2] for state in reactive.bus.get_states() |
2699 | + if state.startswith('apt.installed.')) |
2700 | + |
2701 | + |
2702 | +def purge(packages): |
2703 | + """Purge one or more deb packages from the system""" |
2704 | + fetch.apt_purge(packages, fatal=True) |
2705 | + store = unitdata.kv() |
2706 | + store.unsetrange(packages, prefix='apt.install_queue.') |
2707 | + for package in packages: |
2708 | + reactive.remove_state('apt.installed.{}'.format(package)) |
2709 | + |
2710 | + |
2711 | +def update(): |
2712 | + """Update the apt cache. |
2713 | + |
2714 | + Removes the apt.needs_update state. |
2715 | + """ |
2716 | + status_set(None, 'Updating apt cache') |
2717 | + fetch.apt_update(fatal=True) # Friends don't let friends set fatal=False |
2718 | + reactive.remove_state('apt.needs_update') |
2719 | + |
2720 | + |
2721 | +def install_queued(): |
2722 | + '''Installs queued deb packages. |
2723 | + |
2724 | + Removes the apt.queued_installs state and sets the apt.installed state. |
2725 | + |
2726 | + On failure, sets the unit's workload state to 'blocked' and returns |
2727 | + False. Package installs remain queued. |
2728 | + |
2729 | + On success, sets the apt.installed.{packagename} state for each |
2730 | + installed package and returns True. |
2731 | + ''' |
2732 | + store = unitdata.kv() |
2733 | + queue = sorted((options, package) |
2734 | + for package, options in store.getrange('apt.install_queue.', |
2735 | + strip=True).items()) |
2736 | + |
2737 | + installed = set() |
2738 | + for options, batch in itertools.groupby(queue, lambda x: x[0]): |
2739 | + packages = [b[1] for b in batch] |
2740 | + try: |
2741 | + status_set(None, 'Installing {}'.format(','.join(packages))) |
2742 | + fetch.apt_install(packages, options, fatal=True) |
2743 | + store.unsetrange(packages, prefix='apt.install_queue.') |
2744 | + installed.update(packages) |
2745 | + except subprocess.CalledProcessError: |
2746 | + status_set('blocked', |
2747 | + 'Unable to install packages {}' |
2748 | + .format(','.join(packages))) |
2749 | + return False # Without setting reactive state. |
2750 | + |
2751 | + for package in installed: |
2752 | + reactive.set_state('apt.installed.{}'.format(package)) |
2753 | + |
2754 | + reactive.remove_state('apt.queued_installs') |
2755 | + return True |
2756 | + |
2757 | + |
2758 | +def ensure_package_status(): |
2759 | + '''Hold or unhold packages per the package_status configuration option. |
2760 | + |
2761 | + All packages installed using this module and handlers are affected. |
2762 | + |
2763 | + An mechanism may be added in the future to override this for a |
2764 | + subset of installed packages. |
2765 | + ''' |
2766 | + packages = installed() |
2767 | + if not packages: |
2768 | + return |
2769 | + config = hookenv.config() |
2770 | + package_status = config['package_status'] |
2771 | + changed = reactive.helpers.data_changed('apt.package_status', |
2772 | + (package_status, sorted(packages))) |
2773 | + if changed: |
2774 | + if package_status == 'hold': |
2775 | + hookenv.log('Holding packages {}'.format(','.join(packages))) |
2776 | + fetch.apt_hold(packages) |
2777 | + else: |
2778 | + hookenv.log('Unholding packages {}'.format(','.join(packages))) |
2779 | + fetch.apt_unhold(packages) |
2780 | + reactive.remove_state('apt.needs_hold') |
2781 | + |
2782 | + |
2783 | +def status_set(state, message): |
2784 | + """Set the unit's workload status. |
2785 | + |
2786 | + Set state == None to keep the same state and just change the message. |
2787 | + """ |
2788 | + if state is None: |
2789 | + state = hookenv.status_get()[0] |
2790 | + if state == 'unknown': |
2791 | + state = 'maintenance' # Guess |
2792 | + if state in ('error', 'blocked'): |
2793 | + lvl = hookenv.WARNING |
2794 | + else: |
2795 | + lvl = hookenv.INFO |
2796 | + hookenv.status_set(state, message) |
2797 | + hookenv.log('{}: {}'.format(state, message), lvl) |
2798 | |
2799 | === added directory 'lib/charms/layer' |
2800 | === added file 'lib/charms/layer/__init__.py' |
2801 | --- lib/charms/layer/__init__.py 1970-01-01 00:00:00 +0000 |
2802 | +++ lib/charms/layer/__init__.py 2016-07-14 17:53:24 +0000 |
2803 | @@ -0,0 +1,21 @@ |
2804 | +import os |
2805 | + |
2806 | + |
2807 | +class LayerOptions(dict): |
2808 | + def __init__(self, layer_file, section=None): |
2809 | + import yaml # defer, might not be available until bootstrap |
2810 | + with open(layer_file) as f: |
2811 | + layer = yaml.safe_load(f.read()) |
2812 | + opts = layer.get('options', {}) |
2813 | + if section and section in opts: |
2814 | + super(LayerOptions, self).__init__(opts.get(section)) |
2815 | + else: |
2816 | + super(LayerOptions, self).__init__(opts) |
2817 | + |
2818 | + |
2819 | +def options(section=None, layer_file=None): |
2820 | + if not layer_file: |
2821 | + base_dir = os.environ.get('CHARM_DIR', os.getcwd()) |
2822 | + layer_file = os.path.join(base_dir, 'layer.yaml') |
2823 | + |
2824 | + return LayerOptions(layer_file, section) |
2825 | |
2826 | === added file 'lib/charms/layer/basic.py' |
2827 | --- lib/charms/layer/basic.py 1970-01-01 00:00:00 +0000 |
2828 | +++ lib/charms/layer/basic.py 2016-07-14 17:53:24 +0000 |
2829 | @@ -0,0 +1,159 @@ |
2830 | +import os |
2831 | +import sys |
2832 | +import shutil |
2833 | +import platform |
2834 | +from glob import glob |
2835 | +from subprocess import check_call |
2836 | + |
2837 | +from charms.layer.execd import execd_preinstall |
2838 | + |
2839 | + |
2840 | +def bootstrap_charm_deps(): |
2841 | + """ |
2842 | + Set up the base charm dependencies so that the reactive system can run. |
2843 | + """ |
2844 | + # execd must happen first, before any attempt to install packages or |
2845 | + # access the network, because sites use this hook to do bespoke |
2846 | + # configuration and install secrets so the rest of this bootstrap |
2847 | + # and the charm itself can actually succeed. This call does nothing |
2848 | + # unless the operator has created and populated $CHARM_DIR/exec.d. |
2849 | + execd_preinstall() |
2850 | + # ensure that $CHARM_DIR/bin is on the path, for helper scripts |
2851 | + os.environ['PATH'] += ':%s' % os.path.join(os.environ['CHARM_DIR'], 'bin') |
2852 | + venv = os.path.abspath('../.venv') |
2853 | + vbin = os.path.join(venv, 'bin') |
2854 | + vpip = os.path.join(vbin, 'pip') |
2855 | + vpy = os.path.join(vbin, 'python') |
2856 | + if os.path.exists('wheelhouse/.bootstrapped'): |
2857 | + from charms import layer |
2858 | + cfg = layer.options('basic') |
2859 | + if cfg.get('use_venv') and '.venv' not in sys.executable: |
2860 | + # activate the venv |
2861 | + os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) |
2862 | + reload_interpreter(vpy) |
2863 | + return |
2864 | + # bootstrap wheelhouse |
2865 | + if os.path.exists('wheelhouse'): |
2866 | + with open('/root/.pydistutils.cfg', 'w') as fp: |
2867 | + # make sure that easy_install also only uses the wheelhouse |
2868 | + # (see https://github.com/pypa/pip/issues/410) |
2869 | + charm_dir = os.environ['CHARM_DIR'] |
2870 | + fp.writelines([ |
2871 | + "[easy_install]\n", |
2872 | + "allow_hosts = ''\n", |
2873 | + "find_links = file://{}/wheelhouse/\n".format(charm_dir), |
2874 | + ]) |
2875 | + apt_install(['python3-pip', 'python3-setuptools', 'python3-yaml']) |
2876 | + from charms import layer |
2877 | + cfg = layer.options('basic') |
2878 | + # include packages defined in layer.yaml |
2879 | + apt_install(cfg.get('packages', [])) |
2880 | + # if we're using a venv, set it up |
2881 | + if cfg.get('use_venv'): |
2882 | + if not os.path.exists(venv): |
2883 | + distname, version, series = platform.linux_distribution() |
2884 | + if series in ('precise', 'trusty'): |
2885 | + apt_install(['python-virtualenv']) |
2886 | + else: |
2887 | + apt_install(['virtualenv']) |
2888 | + cmd = ['virtualenv', '-ppython3', '--never-download', venv] |
2889 | + if cfg.get('include_system_packages'): |
2890 | + cmd.append('--system-site-packages') |
2891 | + check_call(cmd) |
2892 | + os.environ['PATH'] = ':'.join([vbin, os.environ['PATH']]) |
2893 | + pip = vpip |
2894 | + else: |
2895 | + pip = 'pip3' |
2896 | + # save a copy of system pip to prevent `pip3 install -U pip` |
2897 | + # from changing it |
2898 | + if os.path.exists('/usr/bin/pip'): |
2899 | + shutil.copy2('/usr/bin/pip', '/usr/bin/pip.save') |
2900 | + # need newer pip, to fix spurious Double Requirement error: |
2901 | + # https://github.com/pypa/pip/issues/56 |
2902 | + check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse', |
2903 | + 'pip']) |
2904 | + # install the rest of the wheelhouse deps |
2905 | + check_call([pip, 'install', '-U', '--no-index', '-f', 'wheelhouse'] + |
2906 | + glob('wheelhouse/*')) |
2907 | + if not cfg.get('use_venv'): |
2908 | + # restore system pip to prevent `pip3 install -U pip` |
2909 | + # from changing it |
2910 | + if os.path.exists('/usr/bin/pip.save'): |
2911 | + shutil.copy2('/usr/bin/pip.save', '/usr/bin/pip') |
2912 | + os.remove('/usr/bin/pip.save') |
2913 | + os.remove('/root/.pydistutils.cfg') |
2914 | + # flag us as having already bootstrapped so we don't do it again |
2915 | + open('wheelhouse/.bootstrapped', 'w').close() |
2916 | + # Ensure that the newly bootstrapped libs are available. |
2917 | + # Note: this only seems to be an issue with namespace packages. |
2918 | + # Non-namespace-package libs (e.g., charmhelpers) are available |
2919 | + # without having to reload the interpreter. :/ |
2920 | + reload_interpreter(vpy if cfg.get('use_venv') else sys.argv[0]) |
2921 | + |
2922 | + |
2923 | +def reload_interpreter(python): |
2924 | + """ |
2925 | + Reload the python interpreter to ensure that all deps are available. |
2926 | + |
2927 | + Newly installed modules in namespace packages sometimes seemt to |
2928 | + not be picked up by Python 3. |
2929 | + """ |
2930 | + os.execle(python, python, sys.argv[0], os.environ) |
2931 | + |
2932 | + |
2933 | +def apt_install(packages): |
2934 | + """ |
2935 | + Install apt packages. |
2936 | + |
2937 | + This ensures a consistent set of options that are often missed but |
2938 | + should really be set. |
2939 | + """ |
2940 | + if isinstance(packages, (str, bytes)): |
2941 | + packages = [packages] |
2942 | + |
2943 | + env = os.environ.copy() |
2944 | + |
2945 | + if 'DEBIAN_FRONTEND' not in env: |
2946 | + env['DEBIAN_FRONTEND'] = 'noninteractive' |
2947 | + |
2948 | + cmd = ['apt-get', |
2949 | + '--option=Dpkg::Options::=--force-confold', |
2950 | + '--assume-yes', |
2951 | + 'install'] |
2952 | + check_call(cmd + packages, env=env) |
2953 | + |
2954 | + |
2955 | +def init_config_states(): |
2956 | + import yaml |
2957 | + from charmhelpers.core import hookenv |
2958 | + from charms.reactive import set_state |
2959 | + from charms.reactive import toggle_state |
2960 | + config = hookenv.config() |
2961 | + config_defaults = {} |
2962 | + config_defs = {} |
2963 | + config_yaml = os.path.join(hookenv.charm_dir(), 'config.yaml') |
2964 | + if os.path.exists(config_yaml): |
2965 | + with open(config_yaml) as fp: |
2966 | + config_defs = yaml.load(fp).get('options', {}) |
2967 | + config_defaults = {key: value.get('default') |
2968 | + for key, value in config_defs.items()} |
2969 | + for opt in config_defs.keys(): |
2970 | + if config.changed(opt): |
2971 | + set_state('config.changed') |
2972 | + set_state('config.changed.{}'.format(opt)) |
2973 | + toggle_state('config.set.{}'.format(opt), config.get(opt)) |
2974 | + toggle_state('config.default.{}'.format(opt), |
2975 | + config.get(opt) == config_defaults[opt]) |
2976 | + hookenv.atexit(clear_config_states) |
2977 | + |
2978 | + |
2979 | +def clear_config_states(): |
2980 | + from charmhelpers.core import hookenv, unitdata |
2981 | + from charms.reactive import remove_state |
2982 | + config = hookenv.config() |
2983 | + remove_state('config.changed') |
2984 | + for opt in config.keys(): |
2985 | + remove_state('config.changed.{}'.format(opt)) |
2986 | + remove_state('config.set.{}'.format(opt)) |
2987 | + remove_state('config.default.{}'.format(opt)) |
2988 | + unitdata.kv().flush() |
2989 | |
2990 | === added file 'lib/charms/layer/execd.py' |
2991 | --- lib/charms/layer/execd.py 1970-01-01 00:00:00 +0000 |
2992 | +++ lib/charms/layer/execd.py 2016-07-14 17:53:24 +0000 |
2993 | @@ -0,0 +1,138 @@ |
2994 | +# Copyright 2014-2016 Canonical Limited. |
2995 | +# |
2996 | +# This file is part of layer-basic, the reactive base layer for Juju. |
2997 | +# |
2998 | +# charm-helpers is free software: you can redistribute it and/or modify |
2999 | +# it under the terms of the GNU Lesser General Public License version 3 as |
3000 | +# published by the Free Software Foundation. |
3001 | +# |
3002 | +# charm-helpers is distributed in the hope that it will be useful, |
3003 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3004 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3005 | +# GNU Lesser General Public License for more details. |
3006 | +# |
3007 | +# You should have received a copy of the GNU Lesser General Public License |
3008 | +# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. |
3009 | + |
3010 | +# This module may only import from the Python standard library. |
3011 | +import os |
3012 | +import sys |
3013 | +import subprocess |
3014 | +import time |
3015 | + |
3016 | +''' |
3017 | +execd/preinstall |
3018 | + |
3019 | +It is often necessary to configure and reconfigure machines |
3020 | +after provisioning, but before attempting to run the charm. |
3021 | +Common examples are specialized network configuration, enabling |
3022 | +of custom hardware, non-standard disk partitioning and filesystems, |
3023 | +adding secrets and keys required for using a secured network. |
3024 | + |
3025 | +The reactive framework's base layer invokes this mechanism as |
3026 | +early as possible, before any network access is made or dependencies |
3027 | +unpacked or non-standard modules imported (including the charms.reactive |
3028 | +framework itself). |
3029 | + |
3030 | +Operators needing to use this functionality may branch a charm and |
3031 | +create an exec.d directory in it. The exec.d directory in turn contains |
3032 | +one or more subdirectories, each of which contains an executable called |
3033 | +charm-pre-install and any other required resources. The charm-pre-install |
3034 | +executables are run, and if successful, state saved so they will not be |
3035 | +run again. |
3036 | + |
3037 | + $CHARM_DIR/exec.d/mynamespace/charm-pre-install |
3038 | + |
3039 | +An alternative to branching a charm is to compose a new charm that contains |
3040 | +the exec.d directory, using the original charm as a layer, |
3041 | + |
3042 | +A charm author could also abuse this mechanism to modify the charm |
3043 | +environment in unusual ways, but for most purposes it is saner to use |
3044 | +charmhelpers.core.hookenv.atstart(). |
3045 | +''' |
3046 | + |
3047 | + |
3048 | +def default_execd_dir(): |
3049 | + return os.path.join(os.environ['CHARM_DIR'], 'exec.d') |
3050 | + |
3051 | + |
3052 | +def execd_module_paths(execd_dir=None): |
3053 | + """Generate a list of full paths to modules within execd_dir.""" |
3054 | + if not execd_dir: |
3055 | + execd_dir = default_execd_dir() |
3056 | + |
3057 | + if not os.path.exists(execd_dir): |
3058 | + return |
3059 | + |
3060 | + for subpath in os.listdir(execd_dir): |
3061 | + module = os.path.join(execd_dir, subpath) |
3062 | + if os.path.isdir(module): |
3063 | + yield module |
3064 | + |
3065 | + |
3066 | +def execd_submodule_paths(command, execd_dir=None): |
3067 | + """Generate a list of full paths to the specified command within exec_dir. |
3068 | + """ |
3069 | + for module_path in execd_module_paths(execd_dir): |
3070 | + path = os.path.join(module_path, command) |
3071 | + if os.access(path, os.X_OK) and os.path.isfile(path): |
3072 | + yield path |
3073 | + |
3074 | + |
3075 | +def execd_sentinel_path(submodule_path): |
3076 | + module_path = os.path.dirname(submodule_path) |
3077 | + execd_path = os.path.dirname(module_path) |
3078 | + module_name = os.path.basename(module_path) |
3079 | + submodule_name = os.path.basename(submodule_path) |
3080 | + return os.path.join(execd_path, |
3081 | + '.{}_{}.done'.format(module_name, submodule_name)) |
3082 | + |
3083 | + |
3084 | +def execd_run(command, execd_dir=None, stop_on_error=True, stderr=None): |
3085 | + """Run command for each module within execd_dir which defines it.""" |
3086 | + if stderr is None: |
3087 | + stderr = sys.stdout |
3088 | + for submodule_path in execd_submodule_paths(command, execd_dir): |
3089 | + # Only run each execd once. We cannot simply run them in the |
3090 | + # install hook, as potentially storage hooks are run before that. |
3091 | + # We cannot rely on them being idempotent. |
3092 | + sentinel = execd_sentinel_path(submodule_path) |
3093 | + if os.path.exists(sentinel): |
3094 | + continue |
3095 | + |
3096 | + try: |
3097 | + subprocess.check_call([submodule_path], stderr=stderr, |
3098 | + universal_newlines=True) |
3099 | + with open(sentinel, 'w') as f: |
3100 | + f.write('{} ran successfully {}\n'.format(submodule_path, |
3101 | + time.ctime())) |
3102 | + f.write('Removing this file will cause it to be run again\n') |
3103 | + except subprocess.CalledProcessError as e: |
3104 | + # Logs get the details. We can't use juju-log, as the |
3105 | + # output may be substantial and exceed command line |
3106 | + # length limits. |
3107 | + print("ERROR ({}) running {}".format(e.returncode, e.cmd), |
3108 | + file=stderr) |
3109 | + print("STDOUT<<EOM", file=stderr) |
3110 | + print(e.output, file=stderr) |
3111 | + print("EOM", file=stderr) |
3112 | + |
3113 | + # Unit workload status gets a shorter fail message. |
3114 | + short_path = os.path.relpath(submodule_path) |
3115 | + block_msg = "Error ({}) running {}".format(e.returncode, |
3116 | + short_path) |
3117 | + try: |
3118 | + subprocess.check_call(['status-set', 'blocked', block_msg], |
3119 | + universal_newlines=True) |
3120 | + if stop_on_error: |
3121 | + sys.exit(0) # Leave unit in blocked state. |
3122 | + except Exception: |
3123 | + pass # We care about the exec.d/* failure, not status-set. |
3124 | + |
3125 | + if stop_on_error: |
3126 | + sys.exit(e.returncode or 1) # Error state for pre-1.24 Juju |
3127 | + |
3128 | + |
3129 | +def execd_preinstall(execd_dir=None): |
3130 | + """Run charm-pre-install for each module within execd_dir.""" |
3131 | + execd_run('charm-pre-install', execd_dir=execd_dir) |
3132 | |
3133 | === added file 'lib/charms/leadership.py' |
3134 | --- lib/charms/leadership.py 1970-01-01 00:00:00 +0000 |
3135 | +++ lib/charms/leadership.py 2016-07-14 17:53:24 +0000 |
3136 | @@ -0,0 +1,58 @@ |
3137 | +# Copyright 2015-2016 Canonical Ltd. |
3138 | +# |
3139 | +# This file is part of the Leadership Layer for Juju. |
3140 | +# |
3141 | +# This program is free software: you can redistribute it and/or modify |
3142 | +# it under the terms of the GNU General Public License version 3, as |
3143 | +# published by the Free Software Foundation. |
3144 | +# |
3145 | +# This program is distributed in the hope that it will be useful, but |
3146 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
3147 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
3148 | +# PURPOSE. See the GNU General Public License for more details. |
3149 | +# |
3150 | +# You should have received a copy of the GNU General Public License |
3151 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
3152 | + |
3153 | +from charmhelpers.core import hookenv |
3154 | +from charmhelpers.core import unitdata |
3155 | + |
3156 | +from charms import reactive |
3157 | +from charms.reactive import not_unless |
3158 | + |
3159 | + |
3160 | +__all__ = ['leader_get', 'leader_set'] |
3161 | + |
3162 | + |
3163 | +@not_unless('leadership.is_leader') |
3164 | +def leader_set(settings=None, **kw): |
3165 | + '''Change leadership settings, per charmhelpers.core.hookenv.leader_set. |
3166 | + |
3167 | + The leadership.set.{key} reactive state will be set while the |
3168 | + leadership hook environment setting remains set. |
3169 | + |
3170 | + Changed leadership settings will set the leadership.changed.{key} |
3171 | + and leadership.changed states. These states will remain set until |
3172 | + the following hook. |
3173 | + |
3174 | + These state changes take effect immediately on the leader, and |
3175 | + in future hooks run on non-leaders. In this way both leaders and |
3176 | + non-leaders can share handlers, waiting on these states. |
3177 | + ''' |
3178 | + settings = settings or {} |
3179 | + settings.update(kw) |
3180 | + previous = unitdata.kv().getrange('leadership.settings.', strip=True) |
3181 | + |
3182 | + for key, value in settings.items(): |
3183 | + if value != previous.get(key): |
3184 | + reactive.set_state('leadership.changed.{}'.format(key)) |
3185 | + reactive.set_state('leadership.changed') |
3186 | + reactive.helpers.toggle_state('leadership.set.{}'.format(key), |
3187 | + value is not None) |
3188 | + hookenv.leader_set(settings) |
3189 | + unitdata.kv().update(settings, prefix='leadership.settings.') |
3190 | + |
3191 | + |
3192 | +def leader_get(attribute=None): |
3193 | + '''Return leadership settings, per charmhelpers.core.hookenv.leader_get.''' |
3194 | + return hookenv.leader_get(attribute) |
3195 | |
3196 | === modified file 'metadata.yaml' |
3197 | --- metadata.yaml 2015-12-07 02:57:11 +0000 |
3198 | +++ metadata.yaml 2016-07-14 17:53:24 +0000 |
3199 | @@ -1,14 +1,21 @@ |
3200 | -name: ibm-db2 |
3201 | -summary: IBM DB2 |
3202 | -maintainer: IBM Juju Support Team <jujusupp@us.ibm.com> |
3203 | -description: | |
3204 | - IBM DB2 Enterprise Server Edition provides scalable database server software to handle the demanding workloads of large and midsize enterprise servers. |
3205 | -tags: |
3206 | - - misc |
3207 | - - database |
3208 | - - ibm |
3209 | -subordinate: false |
3210 | -provides: |
3211 | - db: |
3212 | - interface: db2 |
3213 | - |
3214 | +"name": "ibm-db2" |
3215 | +"summary": "IBM DB2 Product" |
3216 | +"maintainer": "IBM Juju Support Team <jujusupp@us.ibm.com>" |
3217 | +"description": | |
3218 | + IBM DB2 Enterprise Server Edition provides scalable database server software to handle the demanding workloads of large and midsize enterprise servers. |
3219 | +"tags": |
3220 | +- "ibm" |
3221 | +- "apt" |
3222 | +- "leadership" |
3223 | +- "ibm" |
3224 | +- "db2" |
3225 | +- "database" |
3226 | +- "misc" |
3227 | +"provides": |
3228 | + "db": |
3229 | + "interface": "db2" |
3230 | +"min-juju-version": "2.0-beta1" |
3231 | +"series": |
3232 | +- "trusty" |
3233 | +- "xenial" |
3234 | +"subordinate": !!bool "false" |
3235 | |
3236 | === added directory 'reactive' |
3237 | === added file 'reactive/__init__.py' |
3238 | === added file 'reactive/apt.py' |
3239 | --- reactive/apt.py 1970-01-01 00:00:00 +0000 |
3240 | +++ reactive/apt.py 2016-07-14 17:53:24 +0000 |
3241 | @@ -0,0 +1,112 @@ |
3242 | +# Copyright 2015-2016 Canonical Ltd. |
3243 | +# |
3244 | +# This file is part of the Apt layer for Juju. |
3245 | +# |
3246 | +# This program is free software: you can redistribute it and/or modify |
3247 | +# it under the terms of the GNU General Public License version 3, as |
3248 | +# published by the Free Software Foundation. |
3249 | +# |
3250 | +# This program is distributed in the hope that it will be useful, but |
3251 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
3252 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
3253 | +# PURPOSE. See the GNU General Public License for more details. |
3254 | +# |
3255 | +# You should have received a copy of the GNU General Public License |
3256 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
3257 | + |
3258 | +''' |
3259 | +charms.reactive helpers for dealing with deb packages. |
3260 | + |
3261 | +Add apt package sources using add_source(). Queue deb packages for |
3262 | +installation with install(). Configure and work with your software |
3263 | +once the apt.installed.{packagename} state is set. |
3264 | +''' |
3265 | +from charmhelpers import fetch |
3266 | +from charmhelpers.core import hookenv |
3267 | +from charms import layer |
3268 | +from charms import reactive |
3269 | +from charms.reactive import when, when_not |
3270 | + |
3271 | +import charms.apt |
3272 | +# Aliases for backwards compatibility |
3273 | +from charms.apt import add_source, queue_install, installed, purge |
3274 | + |
3275 | + |
3276 | +__all__ = ['add_source', 'update', 'queue_install', 'install_queued', |
3277 | + 'installed', 'purge', 'ensure_package_status'] |
3278 | + |
3279 | + |
3280 | +@when('apt.needs_update') |
3281 | +def update(): |
3282 | + charms.apt.update() |
3283 | + |
3284 | + |
3285 | +@when('apt.queued_installs') |
3286 | +@when_not('apt.needs_update') |
3287 | +def install_queued(): |
3288 | + charms.apt.install_queued() |
3289 | + |
3290 | + |
3291 | +@when_not('apt.queued_installs') |
3292 | +def ensure_package_status(): |
3293 | + charms.apt.ensure_package_status() |
3294 | + |
3295 | + |
3296 | +def configure_sources(): |
3297 | + """Add user specified package sources from the service configuration. |
3298 | + |
3299 | + See charmhelpers.fetch.configure_sources for details. |
3300 | + """ |
3301 | + hookenv.log('Initializing Apt Layer') |
3302 | + config = hookenv.config() |
3303 | + |
3304 | + # We don't have enums, so we need to validate this ourselves. |
3305 | + package_status = config.get('package_status') |
3306 | + if package_status not in ('hold', 'install'): |
3307 | + charms.apt.status_set('blocked', |
3308 | + 'Unknown package_status {}' |
3309 | + ''.format(package_status)) |
3310 | + # Die before further hooks are run. This isn't very nice, but |
3311 | + # there is no other way to inform the operator that they have |
3312 | + # invalid configuration. |
3313 | + raise SystemExit(0) |
3314 | + |
3315 | + sources = config.get('install_sources') |
3316 | + keys = config.get('install_keys') |
3317 | + if reactive.helpers.data_changed('apt.configure_sources', (sources, keys)): |
3318 | + fetch.configure_sources(update=False, |
3319 | + sources_var='install_sources', |
3320 | + keys_var='install_keys') |
3321 | + reactive.set_state('apt.needs_update') |
3322 | + |
3323 | + extra_packages = sorted(config.get('extra_packages', '').split()) |
3324 | + if extra_packages: |
3325 | + queue_install(extra_packages) |
3326 | + |
3327 | + |
3328 | +def queue_layer_packages(): |
3329 | + """Add packages listed in build-time layer options.""" |
3330 | + # Both basic and apt layer. basic layer will have already installed |
3331 | + # its defined packages, but rescheduling it here gets the apt layer |
3332 | + # state set and they will pinned as any other apt layer installed |
3333 | + # package. |
3334 | + opts = layer.options() |
3335 | + for section in ['basic', 'apt']: |
3336 | + if section in opts and 'packages' in opts[section]: |
3337 | + queue_install(opts[section]['packages']) |
3338 | + |
3339 | + |
3340 | +# Per https://github.com/juju-solutions/charms.reactive/issues/33, |
3341 | +# this module may be imported multiple times so ensure the |
3342 | +# initialization hook is only registered once. I have to piggy back |
3343 | +# onto the namespace of a module imported before reactive discovery |
3344 | +# to do this. |
3345 | +if not hasattr(reactive, '_apt_registered'): |
3346 | + # We need to register this to run every hook, not just during install |
3347 | + # and config-changed, to protect against race conditions. If we don't |
3348 | + # do this, then the config in the hook environment may show updates |
3349 | + # to running hooks well before the config-changed hook has been invoked |
3350 | + # and the intialization provided an opertunity to be run. |
3351 | + hookenv.atstart(configure_sources) |
3352 | + hookenv.atstart(queue_layer_packages) |
3353 | + reactive._apt_registered = True |
3354 | |
3355 | === added file 'reactive/ibm-base.sh' |
3356 | --- reactive/ibm-base.sh 1970-01-01 00:00:00 +0000 |
3357 | +++ reactive/ibm-base.sh 2016-07-14 17:53:24 +0000 |
3358 | @@ -0,0 +1,107 @@ |
3359 | +#!/bin/bash |
3360 | +source charms.reactive.sh |
3361 | +set -e |
3362 | + |
3363 | + |
3364 | +# Utility function to verify a downloaded resource |
3365 | +# :param: file name |
3366 | +# :param: checksum type |
3367 | +# :param: checksum value |
3368 | +function verify_curl_resource() { |
3369 | + local FILE=$1 |
3370 | + local TYPE=$2 |
3371 | + local EXPECTED_SUM=$3 |
3372 | + local CALCULATED_SUM="" |
3373 | + local PROG="" |
3374 | + |
3375 | + if [ ! -r ${FILE} ]; then |
3376 | + status-set blocked "ibm-base: could not read ${FILE}" |
3377 | + juju-log "Could not verify the downloaded resource. File could not be read: ${FILE}" |
3378 | + fi |
3379 | + |
3380 | + # Set our checksum utility based on the requested type |
3381 | + case "${TYPE}" in |
3382 | + md5) |
3383 | + PROG='md5sum' |
3384 | + ;; |
3385 | + sha256) |
3386 | + PROG='sha256sum' |
3387 | + ;; |
3388 | + sha512) |
3389 | + PROG='sha512sum' |
3390 | + ;; |
3391 | + *) |
3392 | + status-set blocked "ibm-base: checksum type must be md5, sha215, or sha512" |
3393 | + juju-log "Could not verify the downloaded resource ${FILE}. Unknown checksum type: ${TYPE}" |
3394 | + return 1 |
3395 | + esac |
3396 | + |
3397 | + CALCULATED_SUM=`${PROG} ${FILE} | awk '{print $1}'` |
3398 | + if [ "${CALCULATED_SUM}" = "${EXPECTED_SUM}" ]; then |
3399 | + juju-log "Checksum verified for ${FILE}." |
3400 | + return 0 |
3401 | + else |
3402 | + status-set blocked "ibm-base: checksums did not match" |
3403 | + juju-log "Checksum mismatch for ${FILE}. Expected ${EXPECTED_SUM}, got ${CALCULATED_SUM}" |
3404 | + return 1 |
3405 | + fi |
3406 | +} |
3407 | + |
3408 | + |
3409 | +# Fetch curl resources if a URL is configured |
3410 | +@when 'config.set.curl_url' |
3411 | +@when_any 'config.new.curl_url' 'config.changed.curl_url' 'config.new.curl_opts' 'config.changed.curl_opts' |
3412 | +function fetch_curl_resource() { |
3413 | + local ARCHIVE_DIR="${CHARM_DIR}/files/archives" |
3414 | + local CURL_URL=$(config-get 'curl_url') |
3415 | + local CURL_OPTS=$(config-get 'curl_opts') |
3416 | + |
3417 | + status-set maintenance "ibm-base: fetching resource(s)" |
3418 | + |
3419 | + mkdir -p ${ARCHIVE_DIR} |
3420 | + cd ${ARCHIVE_DIR} |
3421 | + # Multiple URLs may be separated by a space, so loop. |
3422 | + for URL_STRING in ${CURL_URL} |
3423 | + do |
3424 | + # For each URL_STRING, set the url, checksum type, and checksum value. |
3425 | + local URL=${URL_STRING%%\?*} # string before the first '?' |
3426 | + local FILE_NAME=${URL##*\/} # string after the last '/' |
3427 | + local SUM_STRING=${URL_STRING#*\?} # string after the first '?' |
3428 | + local SUM_TYPE=${SUM_STRING%%\=*} # string before the first '=' |
3429 | + local SUM_VALUE=${SUM_STRING#*\=} # string after the first '=' |
3430 | + |
3431 | + if [ -z ${FILE_NAME} ]; then |
3432 | + FILE_NAME="juju-${RANDOM}" |
3433 | + fi |
3434 | + curl --silent --show-error ${CURL_OPTS} -o ${FILE_NAME} ${URL} |
3435 | + |
3436 | + # Verify our resource checksum. If this fails, let verify_resource log |
3437 | + # the reason and exit successfully. Exiting non-zero would fail the hook, |
3438 | + # so return 0 and simply inform the user that verification failed. |
3439 | + verify_curl_resource ${FILE_NAME} ${SUM_TYPE} ${SUM_VALUE} || return 0 |
3440 | + done |
3441 | + cd - |
3442 | + |
3443 | + set_state 'ibm-base.curl.resource.fetched' |
3444 | + status-set active "ibm-base: curl resource(s) fetched" |
3445 | + juju-log 'Curl resource fetched' |
3446 | +} |
3447 | + |
3448 | + |
3449 | +# Handle license acceptance |
3450 | +@when 'config.changed.license_accepted' |
3451 | +function check_license_acceptance() { |
3452 | + local LIC_ACCEPTED=$(config-get 'license_accepted') |
3453 | + |
3454 | + # compare lowercase LIC_ACCEPTED (requires bash > 4) |
3455 | + if [ "${LIC_ACCEPTED,,}" = "true" ]; then |
3456 | + set_state 'ibm-base.license.accepted' |
3457 | + juju-log 'License accepted' |
3458 | + else |
3459 | + remove_state 'ibm-base.license.accepted' |
3460 | + juju-log 'License NOT accepted' |
3461 | + fi |
3462 | +} |
3463 | + |
3464 | +# Main reactive entry point |
3465 | +reactive_handler_main |
3466 | |
3467 | === added file 'reactive/ibm-db2.sh' |
3468 | --- reactive/ibm-db2.sh 1970-01-01 00:00:00 +0000 |
3469 | +++ reactive/ibm-db2.sh 2016-07-14 17:53:24 +0000 |
3470 | @@ -0,0 +1,799 @@ |
3471 | +#!/bin/bash |
3472 | +set -e |
3473 | + |
3474 | +source charms.reactive.sh |
3475 | + |
3476 | +ARCHITECTURE=`uname -m` |
3477 | +ARCHIVE_DIR=$CHARM_DIR/files/archives |
3478 | +DB2_ARCHIVE_DIR=`pwd` |
3479 | +DB2_USER=db2inst1 |
3480 | +DB2_USER_PW=`pwgen -N 1 15` |
3481 | +DB2_DAS_USER=dasusr1 |
3482 | +DB2_DAS_USER_PW=`pwgen -N 1 15` |
3483 | +DB2_FENCE_USER=db2fenc1 |
3484 | +DB2_FENCE_USER_PW=`pwgen -N 1 15` |
3485 | +DB2_INSTALL_PATH=/opt/ibm/db2/V10.5 |
3486 | +AUTH_KEY_FILE=/root/.ssh/authorized_keys |
3487 | +TEMP_KEY_FILE=key.txt |
3488 | + |
3489 | +cfgusername="" |
3490 | + |
3491 | +remoteunit=$cfgusername |
3492 | +cfgpasswd="" |
3493 | +dbs_created="" |
3494 | + |
3495 | +isdbcreated=0 |
3496 | +#Get the cfguser name based on the remote unit name |
3497 | +get_cfgusername() |
3498 | +{ |
3499 | + usr="usr" |
3500 | + passwd=`pwgen -N 1 15` |
3501 | + db="db" |
3502 | + cfgusername=$1 |
3503 | + cfgusername=`echo $cfgusername | cut -d"/" -f1` |
3504 | + cfgusername=`echo "$cfgusername" | sed -r 's/-//g' | sed -r 's/ibm//g'` |
3505 | + cfgusername=`echo "$cfgusername" | awk '{print substr($0,0,5)}'` |
3506 | + remoteunit=$cfgusername |
3507 | + cfgusername="$cfgusername$usr" |
3508 | + cfgpasswd="$cfgusername$passwd" |
3509 | + remoteunitdbname="$remoteunit$db" |
3510 | + |
3511 | +} |
3512 | +# Check whether DB2 is installed |
3513 | +is_db2_installed() |
3514 | +{ |
3515 | + if [ -d $DB2_INSTALL_PATH/bin ]; then |
3516 | + echo "True" |
3517 | + else |
3518 | + echo "False" |
3519 | + fi |
3520 | +} |
3521 | + |
3522 | + |
3523 | +# Remove DB2, if installed |
3524 | +remove_software() |
3525 | +{ |
3526 | + db2_inst=`is_db2_installed` |
3527 | + if [ $db2_inst == "True" ]; then |
3528 | + juju-log "IBM DB2: Removing IBM DB2 software." |
3529 | + status-set maintenance "Removing IBM DB2" |
3530 | + |
3531 | + #finding the DB alias names to be dropped and dropping all Databases in that |
3532 | + for queue1 in `su - $DB2_USER -c 'db2ilist'`; |
3533 | + do |
3534 | + juju-log "IBM DB2: Dropping the Databases for the instance $queue1" |
3535 | + #if db2 is not running, we need to start it first, otherwise db2 drop command will fail |
3536 | + if su - $queue1 -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$queue1; |
3537 | + then |
3538 | + juju-log "IBM DB2: DB2 already started for the user $queue1" |
3539 | + else |
3540 | + su - $queue1 -c 'db2start' |
3541 | + juju-log "IBM DB2: DB2 is started" |
3542 | + fi |
3543 | + |
3544 | + for queue in `su - $queue1 -c 'db2 list db directory | grep "Database alias" | cut -d"=" -f2'`; |
3545 | + do |
3546 | + queue=`echo $queue | xargs` |
3547 | + juju-log "IBM DB2: Dropping the DB $queue" |
3548 | + su - $queue1 -c 'db2 drop database '$queue |
3549 | + if [ $? -eq 0 ]; then |
3550 | + juju-log "IBM DB2: Dropped the DB $queue" |
3551 | + else |
3552 | + juju-log "IBM DB2: Dropping the DB $queue failed" |
3553 | + status-set blocked "Dropping the DB failed" |
3554 | + exit 0 |
3555 | + fi |
3556 | + done |
3557 | + juju-log "IBM DB2: Stopping the DB for $queue1" |
3558 | + |
3559 | + if su - $queue1 -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$queue1 |
3560 | + then |
3561 | + su - $queue1 -c 'db2 force application all' |
3562 | + su - $queue1 -c 'db2stop' |
3563 | + if [ $? -eq 0 ]; then |
3564 | + juju-log "IBM DB2: Stopped the DB for the instance $queue1" |
3565 | + else |
3566 | + juju-log "IBM DB2: Stopping the DB for $queue1 failed" |
3567 | + status-set blocked "Stopping the DB for $queue1 failed" |
3568 | + exit 0 |
3569 | + fi |
3570 | + |
3571 | + else |
3572 | + juju-log "IBM DB2: DB2 is already stopped" |
3573 | + fi |
3574 | + done |
3575 | + |
3576 | + #drop the das |
3577 | + cd $DB2_INSTALL_PATH/instance |
3578 | + juju-log "IBM DB2: Dropping the DAS" |
3579 | + ./dasdrop |
3580 | + if [ $? -eq 0 ]; then |
3581 | + juju-log "IBM DB2: Dropped the DAS" |
3582 | + else |
3583 | + juju-log "IBM DB2: Dropping the DAS failed" |
3584 | + status-set blocked "Dropping the DAS failed" |
3585 | + exit 0 |
3586 | + fi |
3587 | + |
3588 | + #delete the instances |
3589 | + su - $DB2_USER -c 'db2ilist' |
3590 | + for queue1 in `su - $DB2_USER -c 'db2ilist'`; |
3591 | + do |
3592 | + juju-log "IBM DB2: Deleting the instance $queue1" |
3593 | + $DB2_INSTALL_PATH/instance/db2idrop $queue1 |
3594 | + if [ $? -eq 0 ]; then |
3595 | + juju-log "IBM DB2: Deleted the instance $queue1" |
3596 | + else |
3597 | + juju-log "IBM DB2: Deleting the instance $queue1 failed" |
3598 | + status-set blocked "Deleting the instance $queue1 failed" |
3599 | + exit 0 |
3600 | + fi |
3601 | + |
3602 | + done |
3603 | + |
3604 | + #Delete the instance entries from /etc/services file |
3605 | + juju-log "IBM DB2: Deleting the entries from /etc/services" |
3606 | + sed -i '/db2c_/d' /etc/services |
3607 | + if [ $? -eq 0 ]; then |
3608 | + juju-log "IBM DB2: Deleted the entries from /etc/services" |
3609 | + else |
3610 | + juju-log "IBM DB2: Deletion of the entries from /etc/services failed" |
3611 | + status-set blocked "Deletion of the entries from /etc/services failed" |
3612 | + exit 0 |
3613 | + fi |
3614 | + |
3615 | + #uninstall |
3616 | + juju-log "IBM DB2: Uninstall " |
3617 | + cd $DB2_INSTALL_PATH/install |
3618 | + set +e |
3619 | + ./db2_deinstall -a |
3620 | + if [ $? -eq 0 ]; then |
3621 | + juju-log "IBM DB2: Uninstall of db2 successful" |
3622 | + else |
3623 | + juju-log "IBM DB2: Uninstall of db2 failed" |
3624 | + status-set blocked "IBM DB2 Uninstallation failed" |
3625 | + exit 0 |
3626 | + fi |
3627 | + set -e |
3628 | + cd /opt/ibm |
3629 | + rm -rf db2 |
3630 | + juju-log "IBM DB2: Finished Uninstalling......." |
3631 | + status-set blocked "IBM DB2 Uninstalled" |
3632 | + |
3633 | + else |
3634 | + juju-log "IBM DB2: DB2 not installed" |
3635 | + fi |
3636 | + |
3637 | +} |
3638 | + |
3639 | +# Update system configuration after installing DB2 |
3640 | +configure_system() |
3641 | +{ |
3642 | + juju-log "IBM DB2: Updating system configuration." |
3643 | + cd $DB2_INSTALL_PATH/instance |
3644 | + su - $DB2_USER -c 'db2set DB2COMM=tcpip' |
3645 | + |
3646 | + #Start DB for the DB2_user |
3647 | + if su - $DB2_USER -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$DB2_USER; |
3648 | + then |
3649 | + juju-log "IBM DB2: DB2 already started for the user $DB2_USER" |
3650 | + else |
3651 | + su - $DB2_USER -c 'db2start' |
3652 | + juju-log "IBM DB2: DB2 is started" |
3653 | + fi |
3654 | + |
3655 | + service_name=`su - $DB2_USER -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'` |
3656 | + port_num=`grep $service_name /etc/services | cut -d"/" -f1 | cut -f2` |
3657 | + port_num=`echo $port_num | xargs` |
3658 | + if su - $DB2_USER -c 'netstat -an | grep '$port_num; |
3659 | + then |
3660 | + juju-log "IBM DB2: DB2 started on port $port_num" |
3661 | + else |
3662 | + juju-log "IBM DB2: DB2 not started on port $port_num" |
3663 | + exit 1 |
3664 | + fi |
3665 | + |
3666 | + juju-log "IBM DB2: Updated system configuration." |
3667 | + |
3668 | +} |
3669 | + |
3670 | +#Configure dftdbpath |
3671 | +configure_dftdbpath() |
3672 | +{ |
3673 | + db2_inst=`is_db2_installed` |
3674 | + if [ $db2_inst == "True" ]; then |
3675 | + cfgdbpath=`config-get dftdbpath` |
3676 | + #If null, assign the default value |
3677 | + if [ "cfgdbpath" == "" ] |
3678 | + then |
3679 | + cfgdbpath="/tmp" |
3680 | + fi |
3681 | + |
3682 | + for queue1 in `su - $DB2_USER -c 'db2ilist'`; |
3683 | + do |
3684 | + #if db2 is not running don't do anything |
3685 | + if su - $queue1 -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$queue1; |
3686 | + then |
3687 | + su - $queue1 -c 'db2 attach to '$queue1 |
3688 | + dbpath=`su - $queue1 -c 'db2 get dbm cfg|grep -i DFTDBPATH|cut -d"=" -f2'` |
3689 | + cfgdbpath=`echo $cfgdbpath | xargs` |
3690 | + dbpath=`echo $dbpath | xargs` |
3691 | + if [ "$cfgdbpath" != "$dbpath" ]; then |
3692 | + if [ -d "$cfgdbpath" ]; then |
3693 | + su - $queue1 -c 'db2 update dbm cfg using DFTDBPATH '$cfgdbpath |
3694 | + if [ $? -eq 0 ]; then |
3695 | + juju-log "IBM DB2: DFTDBPATH changed to $cfgdbpath" |
3696 | + else |
3697 | + juju-log "IBM DB2: Unable to set DFTDBPATH to $cfgdbpath" |
3698 | + exit 0 |
3699 | + fi |
3700 | + else |
3701 | + juju-log "IBM DB2: Not a valid path. Please check the path and run the command again" |
3702 | + exit 0 |
3703 | + fi |
3704 | + fi |
3705 | + fi |
3706 | + done |
3707 | + else |
3708 | + juju-log "IBM DB2: DB2 is not installed. Install DB2 to change the dbpath" |
3709 | + exit 0 |
3710 | + fi |
3711 | +} |
3712 | + |
3713 | +# Edit the response file for UID |
3714 | +edit_responsefile() |
3715 | +{ |
3716 | + rsp_file=db2server_temp.rsp |
3717 | + if [ "$ARCHITECTURE" = "x86_64" ]; then |
3718 | + orgrsp_file=db2server.rsp |
3719 | + else |
3720 | + orgrsp_file=db2server_ppcle.rsp |
3721 | + fi |
3722 | + cp $CHARM_DIR/files/archives/$orgrsp_file $CHARM_DIR/files/archives/$rsp_file |
3723 | + |
3724 | + db2uid=`id $DB2_USER | cut -d"=" -f2 | cut -d"(" -f1` |
3725 | + sed -i s/db2inst1_uid/$db2uid/g $CHARM_DIR/files/archives/$rsp_file |
3726 | + sed -i s/db2inst1_gid/$db2uid/g $CHARM_DIR/files/archives/$rsp_file |
3727 | + sed -i s/db2inst1_homedir/$DB2_USER/g $CHARM_DIR/files/archives/$rsp_file |
3728 | + sed -i s/db2inst1_password/$DB2_USER_PW/g $CHARM_DIR/files/archives/$rsp_file |
3729 | + |
3730 | + db2fenid=`id $DB2_FENCE_USER | cut -d"=" -f2 | cut -d"(" -f1` |
3731 | + sed -i s/db2fenc1_uid/$db2fenid/g $CHARM_DIR/files/archives/$rsp_file |
3732 | + sed -i s/db2fenc1_gid/$db2fenid/g $CHARM_DIR/files/archives/$rsp_file |
3733 | + |
3734 | + dasuid=`id $DB2_DAS_USER | cut -d"=" -f2 | cut -d"(" -f1` |
3735 | + sed -i s/das_uid/$dasuid/g $CHARM_DIR/files/archives/$rsp_file |
3736 | + sed -i s/das_gid/$dasuid/g $CHARM_DIR/files/archives/$rsp_file |
3737 | + |
3738 | +} |
3739 | + |
3740 | +create_user() |
3741 | +{ |
3742 | + servicename=$1 |
3743 | + user_exists=0 |
3744 | + instance_exists=0 |
3745 | + db2_inst=`is_db2_installed` |
3746 | + get_cfgusername $servicename |
3747 | + if [ $db2_inst == "True" ]; then |
3748 | + status-set maintenance "Creating DB user and instance" |
3749 | + #Find the group id for db2inst1 user which is used to install db2 and find all |
3750 | + #users belonging to this user |
3751 | + db2inst1grpid=`id $DB2_USER | cut -d" " -f2` |
3752 | + |
3753 | + #If the user is already available, just log the information. |
3754 | + for queue2 in `awk -F':' '{ print $1}' /etc/passwd`; |
3755 | + do |
3756 | + gid=`id $queue2 | cut -d" " -f2` |
3757 | + if [ $gid == $db2inst1grpid ]; then |
3758 | + if [ $queue2 != "$DB2_USER" ]; then |
3759 | + if [ $cfgusername == $queue2 ]; then |
3760 | + juju-log "IBM DB2: User $cfgusername already exists" |
3761 | + user_exists=1 |
3762 | + fi |
3763 | + fi |
3764 | + fi |
3765 | + done |
3766 | + |
3767 | + #If not available, add a new user |
3768 | + if [ $user_exists -ne 1 ]; then |
3769 | + juju-log "IBM DB2: Creating New user" |
3770 | + create_newuser $servicename |
3771 | + juju-log "IBM DB2: Created New user" |
3772 | + juju-log $cfgusername |
3773 | + fi |
3774 | + |
3775 | + #Creating a new instance for the new user if not existing |
3776 | + for queue1 in `su - $DB2_USER -c 'db2ilist'`; |
3777 | + do |
3778 | + if [ $queue1 == $cfgusername ]; then |
3779 | + juju-log "IBM DB2: Instance $cfgusername already exists" |
3780 | + instance_exists=1 |
3781 | + fi |
3782 | + done |
3783 | + if [ $instance_exists -ne 1 ]; then |
3784 | + juju-log "IBM DB2: Creating new instance for the user" |
3785 | + $DB2_INSTALL_PATH/instance/db2icrt -u $cfgusername $cfgusername |
3786 | + if [ $? = 0 ]; then |
3787 | + juju-log "IBM DB2: Created new instance for the user" |
3788 | + else |
3789 | + juju-log "IBM DB2: Creation of new instance failed" |
3790 | + exit 0 |
3791 | + fi |
3792 | + fi |
3793 | + |
3794 | + #Do the configuration for the new instance created |
3795 | + new_port=50001 |
3796 | + free_port=0 |
3797 | + is_free=0 |
3798 | + #Check whether the port number is already in etc/services file, and then add it |
3799 | + cd /etc |
3800 | + if grep -q "db2c_$cfgusername" services |
3801 | + then |
3802 | + juju-log "IBM DB2: Services file already updated" |
3803 | + else |
3804 | + while [ $free_port -eq 0 ] |
3805 | + do |
3806 | + is_free=`netstat -lnp | grep $new_port | cut -d":" -f2 | cut -d" " -f1` |
3807 | + if [ "$is_free" != "$new_port" ]; then |
3808 | + free_port=1 |
3809 | + else |
3810 | + new_port=$((new_port+1)) |
3811 | + fi |
3812 | + done |
3813 | + juju-log "IBM DB2:Updating Services file" |
3814 | + echo -e "db2c_$cfgusername $new_port/tcp" >> /etc/services |
3815 | + su - $cfgusername -c 'set db2instance=$cfgusername' |
3816 | + su - $cfgusername -c 'db2set DB2COMM=tcpip' |
3817 | + new_port=`echo $new_port | xargs` |
3818 | + #port_num_consumer=$new_port |
3819 | + su - $cfgusername -c 'db2 update dbm cfg using svcename '$new_port |
3820 | + $DB2_INSTALL_PATH/instance/db2iupdt $cfgusername |
3821 | + fi |
3822 | + cd - |
3823 | + |
3824 | + #Start DB for the new user |
3825 | + if su - $cfgusername -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$cfgusername; |
3826 | + then |
3827 | + juju-log "IBM DB2: DB2 already started for the user $cfgusername" |
3828 | + else |
3829 | + su - $cfgusername -c 'db2start' |
3830 | + juju-log "IBM DB2: DB2 is started" |
3831 | + fi |
3832 | + #set_state 'db.dbstarted' |
3833 | + |
3834 | + else |
3835 | + juju-log "IBM DB2: DB2 is not installed. Install DB2 before creating users" |
3836 | + exit 0 |
3837 | + |
3838 | + fi |
3839 | + status-set active "Completed DB user and instance creation" |
3840 | +} |
3841 | + |
3842 | +create_newuser() |
3843 | +{ |
3844 | + servicename=$1 |
3845 | + dbcreated="False" |
3846 | + #Add the new user |
3847 | + get_cfgusername $servicename |
3848 | + useradd -g db2grp1 -G dasadm1 -m $cfgusername |
3849 | + if [ $? -ne 0 ]; then |
3850 | + juju-log "IBM DB2: Addition of user $queue2 failed." |
3851 | + status-set blocked "Addition of new used failed, Try again" |
3852 | + exit 0 |
3853 | + fi |
3854 | + #Set the password for the new user |
3855 | + echo $cfgusername:$cfgpasswd | chpasswd |
3856 | + if [ $? -ne 0 ]; then |
3857 | + juju-log "IBM DB2: Setting password for user $queue2 failed." |
3858 | + status-set blocked "Setting the password for user failed, Try again" |
3859 | + exit 0 |
3860 | + fi |
3861 | + #Check whether test DB already exists. If not create it |
3862 | + |
3863 | + dbname=`su - $DB2_USER -c 'db2 list db directory' | grep "Database name" | grep -i "\bTEST\b" | cut -d"=" -f2` |
3864 | + dbname=`echo $dbname | xargs` |
3865 | + if [ "$dbname" != "TEST" ]; then |
3866 | + juju-log "IBM DB2: Creating DB Test" |
3867 | + su - $DB2_USER -c 'db2 create database test' |
3868 | + if [ $? -ne 0 ]; then |
3869 | + juju-log "IBM DB2: DB creation failed" |
3870 | + status-set blocked "DB creation failed, Try again" |
3871 | + exit 0 |
3872 | + fi |
3873 | + juju-log "IBM DB2: Created DB Test" |
3874 | + fi |
3875 | + #Connect to the DB and grant data access |
3876 | + su - $DB2_USER -c 'db2 connect to test;db2 grant dataaccess on database to user '$cfgusername |
3877 | + if [ $? -ne 0 ]; then |
3878 | + juju-log "IBM DB2: Grant access failed" |
3879 | + status-set blocked "Grant dataaccess on database failed, Try again" |
3880 | + exit 0 |
3881 | + fi |
3882 | + su - $DB2_USER -c 'db2 connect to test;db2 disconnect test' |
3883 | + if [ $? -ne 0 ]; then |
3884 | + juju-log "IBM DB2: Disconnect DB failed" |
3885 | + status-set blocked "Disconnect DB failed" |
3886 | + exit 0 |
3887 | + fi |
3888 | + |
3889 | +} |
3890 | + |
3891 | +create_database() |
3892 | +{ |
3893 | + isdbcreated=0 |
3894 | + dbtocreate=$1 |
3895 | + servicename=$2 |
3896 | + get_cfgusername $servicename |
3897 | + #create the db for $dbnametocreate if it doesn't exist |
3898 | + dbname=`su - $cfgusername -c 'db2 list db directory' | grep "Database name" | grep -i "\b$dbtocreate\b" | cut -d"=" -f2` |
3899 | + dbname=`echo $dbname | xargs` |
3900 | + dbname=`echo "$dbname" | awk '{ print tolower($1) }'` |
3901 | + dbtocreate=`echo "$dbtocreate" | awk '{ print tolower($1) }'` |
3902 | + #check whether dbname is more than 8 chars |
3903 | + if [ ${#dbtocreate} -gt 8 ]; then |
3904 | + juju-log "IBM DB2: Failed to create DB $dbtocreate. DB name should be <= 8 chars" |
3905 | + #status-set blocked "DB creation for $dbtocreate failed as it contains more than 8 chars" |
3906 | + else |
3907 | + if [ "$dbname" != "$dbtocreate" ]; then |
3908 | + juju-log "IBM DB2: Creating DB $dbtocreate" |
3909 | + su - $cfgusername -c 'db2 create database '$dbtocreate |
3910 | + if [ $? -ne 0 ]; then |
3911 | + juju-log "IBM DB2: DB creation failed" |
3912 | + status-set blocked "DB creation failed, Try again" |
3913 | + exit 0 |
3914 | + fi |
3915 | + juju-log "IBM DB2: Created DB $dbtocreate" |
3916 | + isdbcreated=1 |
3917 | + else |
3918 | + juju-log "IBM DB2: DB $dbtocreate already exists" |
3919 | + fi |
3920 | + fi |
3921 | +} |
3922 | + |
3923 | +# Must be called from a 'db.ready' state handler |
3924 | +create_dbs() |
3925 | +{ |
3926 | +dbs_created="" |
3927 | +servicename=$1 |
3928 | +dbnames=$(relation_call --state=db.ready get_dbnames $servicename) || true |
3929 | + |
3930 | +#If dbnames is null, create a default DB as per service name. Else create the DBs requested by the related charm |
3931 | +if [ -z "$dbnames" -o "$dbnames" == "None" ] ; then |
3932 | + juju-log "IBM DB2: Creating a default DB $remoteunitdbname based on remote service name" |
3933 | + create_database $remoteunitdbname $servicename |
3934 | + if [ $isdbcreated -eq 1 ] ; then |
3935 | + dbs_created+=$remoteunitdbname |
3936 | + dbs_created+="." |
3937 | + fi |
3938 | +else |
3939 | + juju-log "IBM DB2: Creating the DB names as passed by consumer" |
3940 | + if [ `echo $dbnames | grep -c "," ` -gt 0 ] |
3941 | + then |
3942 | + #parse the $dbnames string to get the names of dbs to be created |
3943 | + count=1 |
3944 | + db_to_create="test" |
3945 | + while [ "$db_to_create" != "" ] |
3946 | + do |
3947 | + db_to_create=`echo $dbnames | cut -d"," -f$count` |
3948 | + juju-log "IBM DB2:db_to_create is $db_to_create" |
3949 | + if [ "$db_to_create" != "" ] ; then |
3950 | + create_database $db_to_create $servicename |
3951 | + juju-log "Created DB $db_to_create" |
3952 | + if [ $isdbcreated -eq 1 ] ; then |
3953 | + dbs_created+=$db_to_create |
3954 | + dbs_created+="." |
3955 | + fi |
3956 | + fi |
3957 | + ((count=count+1)) |
3958 | + done |
3959 | + else |
3960 | + create_database $dbnames $servicename |
3961 | + juju-log "Created DB $dbnames" |
3962 | + dbs_created+=$dbnames |
3963 | + dbs_created+="." |
3964 | + fi |
3965 | +fi |
3966 | +} |
3967 | + |
3968 | +remove_sshkeys() |
3969 | +{ |
3970 | + servicename=$1 |
3971 | + #Read the key from the key.txt file and see whether it exists |
3972 | + if grep -q "$servicename" $TEMP_KEY_FILE |
3973 | + then |
3974 | + key=`cat $TEMP_KEY_FILE | grep $servicename | cut -d":" -f2` |
3975 | + grep -v "$key" $AUTH_KEY_FILE > tempfile.txt || touch tempfile.txt |
3976 | + mv tempfile.txt $AUTH_KEY_FILE |
3977 | + if grep -q "$key" $AUTH_KEY_FILE |
3978 | + then |
3979 | + juju-log "IBM DB2: SSH Key not deleted from $AUTH_KEY_FILE" |
3980 | + else |
3981 | + juju-log "IBM DB2: SSH Key deleted from $AUTH_KEY_FILE" |
3982 | + fi |
3983 | + #Remove from the temporary file as well |
3984 | + grep -v "$servicename:$key" $TEMP_KEY_FILE > tempfile1.txt |
3985 | + mv tempfile1.txt $TEMP_KEY_FILE |
3986 | + if grep -q "$key" $TEMP_KEY_FILE |
3987 | + then |
3988 | + juju-log "IBM DB2: SSH Key not deleted from $TEMP_KEY_FILE" |
3989 | + else |
3990 | + juju-log "IBM DB2: SSH Key deleted from $TEMP_KEY_FILE" |
3991 | + fi |
3992 | + |
3993 | +fi |
3994 | + |
3995 | +} |
3996 | + |
3997 | + |
3998 | +@when_not 'config.set.license_accepted' |
3999 | +function report_missing_license(){ |
4000 | + juju-log "IBM DB2: license_accepted is not set." |
4001 | + status-set blocked "license_accepted must be set" |
4002 | +} |
4003 | + |
4004 | + |
4005 | +@when_not 'config.set.curl_url' |
4006 | +function report_missing_curl(){ |
4007 | + juju-log "IBM DB2: curl config options are not set." |
4008 | + status-set blocked "curl options must be set" |
4009 | +} |
4010 | + |
4011 | + |
4012 | +@when 'ibm-db2.installed' |
4013 | +@when_not 'ibm-base.license.accepted' |
4014 | +function uninstall(){ |
4015 | + juju-log "IBM DB2: Removing IBM DB2 (if installed) as the license agreement is not accepted." |
4016 | + status-set maintenance "IBM DB2 is getting uninstalled" |
4017 | + remove_software |
4018 | + remove_state 'ibm-db2.installed' |
4019 | + status-set maintenance "IBM DB2 is uninstalled" |
4020 | + rm -rf $TEMP_KEY_FILE |
4021 | + |
4022 | +} |
4023 | + |
4024 | +#Setting the interface states after uninstall |
4025 | +@when 'db.connected' |
4026 | +@when_not 'ibm-db2.installed' |
4027 | +function reset_interface_states(){ |
4028 | + services=$(relation_call --state=db.connected services) || true |
4029 | + for service in $services; do |
4030 | + juju-log "IBM DB2: Resetting states for the service $service" |
4031 | + relation_call --state=db.connected dismiss_sshconfigured $service || true |
4032 | + relation_call --state=db.connected reset_states $service || true |
4033 | + done |
4034 | + |
4035 | +} |
4036 | + |
4037 | + |
4038 | +@when_not 'ibm-db2.prereqsinstalled' |
4039 | +function init() { |
4040 | + if [ "$ARCHITECTURE" != "x86_64" -a "$ARCHITECTURE" != "ppc64le" ]; then |
4041 | + juju-log "IBM DB2: Unsupported platform. IBM DB2 installed with this Charm supports only the x86_64 and POWER LE (ppc64le) platforms." |
4042 | + exit 1 |
4043 | + fi |
4044 | + set -e |
4045 | + juju-log "IBM DB2: Begin Install." |
4046 | + status-set maintenance "Installing pre requisites for IBM DB2" |
4047 | + apt-get update |
4048 | + |
4049 | + if [ "$ARCHITECTURE" == "x86_64" ]; then |
4050 | + juju-log "IBM DB2: Installing 32 bit libstdc++.so.6" |
4051 | + apt-get install lib32stdc++6 -y |
4052 | + juju-log "IBM DB2: Installed 32 bit libstdc++.so.6" |
4053 | + fi |
4054 | + if [ "$ARCHITECTURE" == "ppc64le" ]; then |
4055 | + juju-log "IBM DB2: Installing libnuma package for POWER LE (ppc64le) platforms." |
4056 | + apt-get install libnuma-dev -y |
4057 | + #Installing XL compiler runtime packages for Linux on Power as this is one of the prerequisite software/configuration requirements |
4058 | + echo "deb http://public.dhe.ibm.com/software/server/POWER/Linux/rte/xlcpp/le/ubuntu $(lsb_release -s -c) main" | tee -a /etc/apt/sources.list.d/ibm-xlcpp-rte.list |
4059 | + apt-get update |
4060 | + apt-get install libxlc -y --force-yes |
4061 | + juju-log "IBM DB2: Installed libnuma package for POWER LE (ppc64le) platforms." |
4062 | + fi |
4063 | + |
4064 | + juju-log "IBM DB2: Creating the user ids for db2 installation" |
4065 | + groupadd db2grp1 |
4066 | + groupadd dasadm1 |
4067 | + groupadd db2fgrp1 |
4068 | + |
4069 | + useradd -g db2grp1 -G dasadm1 -m $DB2_USER |
4070 | + echo $DB2_USER:$DB2_USER_PW | chpasswd |
4071 | + useradd -g dasadm1 -G db2grp1 -m $DB2_DAS_USER |
4072 | + echo $DB2_DAS_USER:$DB2_DAS_USER_PW | chpasswd |
4073 | + useradd -g db2fgrp1 -m $DB2_FENCE_USER |
4074 | + echo $DB2_FENCE_USER:$DB2_FENCE_USER_PW | chpasswd |
4075 | + |
4076 | + juju-log "IBM DB2: Created the user ids for db2 installation" |
4077 | + status-set maintenance "Installed pre requisites for IBM DB2" |
4078 | + set_state 'ibm-db2.prereqsinstalled' |
4079 | + |
4080 | +} |
4081 | + |
4082 | + |
4083 | +@when 'ibm-db2.prereqsinstalled' 'ibm-base.license.accepted' 'ibm-base.curl.resource.fetched' |
4084 | +@when_not 'ibm-db2.installed' |
4085 | +function install() { |
4086 | + juju-log "IBM DB2: License accepted" |
4087 | + db2_inst=`is_db2_installed` |
4088 | + if [[ ! -d $ARCHIVE_DIR ]]; then |
4089 | + mkdir $ARCHIVE_DIR |
4090 | + fi |
4091 | + #Install if download succeeded |
4092 | + if [ $db2_inst == "False" ]; then |
4093 | + if [ -f $ARCHIVE_DIR/*.gz ]; then |
4094 | + |
4095 | + cd $CHARM_DIR/files/archives |
4096 | + tar -zxvf $ARCHIVE_DIR/*.gz |
4097 | + if [ $? -ne 0 ]; then |
4098 | + juju-log "IBM DB2: Unable to extract the DB2 package content. Verify whether the package is corrupt." |
4099 | + status-set maintenance "Unable to extract the DB2 package content" |
4100 | + #Remove corrupt archive file |
4101 | + rm -rf $ARCHIVE_DIR/*.gz |
4102 | + exit 0 |
4103 | + fi |
4104 | + if [ "$ARCHITECTURE" = "x86_64" ]; then |
4105 | + rsp_file=db2server.rsp |
4106 | + else |
4107 | + rsp_file=db2server_ppcle.rsp |
4108 | + fi |
4109 | + edit_responsefile |
4110 | + cd $CHARM_DIR/files/archives/server* |
4111 | + juju-log "IBM DB2: Edited the response file" |
4112 | + |
4113 | + juju-log "IBM DB2: Checking etc/hosts file." |
4114 | + private_address=`unit-get private-address` |
4115 | + if grep -q "$private_address" /etc/hosts; then |
4116 | + juju-log "IBM DB2: Host file already updated" |
4117 | + else |
4118 | + juju-log "IBM DB2: Updating Host file" |
4119 | + echo "$private_address `hostname`" >> /etc/hosts |
4120 | + fi |
4121 | + |
4122 | + juju-log "IBM DB2: Installing db2 package." |
4123 | + status-set maintenance "Installing IBM DB2" |
4124 | + ./db2setup -r $CHARM_DIR/files/archives/$rsp_file |
4125 | + juju-log "IBM DB2: Installation of db2 complete." |
4126 | + fi |
4127 | + fi |
4128 | + # Configure system values for Db2 |
4129 | + configure_system |
4130 | + #Configure DFTDBPATH |
4131 | + configure_dftdbpath |
4132 | + echo "Tempory Key File" > $TEMP_KEY_FILE |
4133 | + set_state 'ibm-db2.installed' |
4134 | + status-set active "IBM DB2 Installed" |
4135 | +} |
4136 | + |
4137 | +@when 'config.changed.dftdbpath' |
4138 | +function configurevalues(){ |
4139 | + configure_dftdbpath |
4140 | +} |
4141 | + |
4142 | +@when 'ibm-db2.installed' |
4143 | +@when_not 'db.connected' |
4144 | +function report_waiting_on_consumers(){ |
4145 | + status-set active "IBM DB2 Ready (waiting for consumers)" |
4146 | +} |
4147 | + |
4148 | +@when 'ibm-db2.installed' |
4149 | +@when 'db.connected' |
4150 | +function configure_sshkeys(){ |
4151 | + services=$(relation_call --state=db.connected services) |
4152 | + for service in $services; do |
4153 | + key=$(relation_call --state=db.connected get_sshkeys $service) || true |
4154 | + juju-log "IBM DB2: Received the ssh key $key from the service $service" |
4155 | + |
4156 | + if [ "$key" == "None" ]; then |
4157 | + juju-log "IBM DB2: No data sent yet" |
4158 | + continue |
4159 | + fi |
4160 | + |
4161 | + # Add the key to the authorized_keys file, if it exists |
4162 | + set +e |
4163 | + #Create a temp key file if it doesn't exist |
4164 | + if [ -f $TEMP_KEY_FILE ]; then |
4165 | + juju-log "IBM DB2: Temp file already exists" |
4166 | + else |
4167 | + echo "Temp Key File" > $TEMP_KEY_FILE |
4168 | + fi |
4169 | + if [ -f $AUTH_KEY_FILE ]; then |
4170 | + # Append only if the key is not present |
4171 | + juju-log "IBM DB2: Updating the key file" |
4172 | + grep "$key" $AUTH_KEY_FILE > /dev/null |
4173 | + if [ $? -ne 0 ]; then |
4174 | + juju-log "IBM DB2: Updating authorized keys file" |
4175 | + echo "$key" >> $AUTH_KEY_FILE |
4176 | + echo "$service:$key" >> $TEMP_KEY_FILE |
4177 | + else |
4178 | + juju-log "IBM DB2: Key already present" |
4179 | + fi |
4180 | + else |
4181 | + juju-log "IBM DB2: Creating authorized keys file" |
4182 | + echo "$key" > $AUTH_KEY_FILE |
4183 | + echo "$service:$key" > $TEMP_KEY_FILE |
4184 | + fi |
4185 | + relation_call --state=db.connected set_sshconfigured $service || true |
4186 | + juju-log "IBM DB2: Completed updating the authorized key" |
4187 | + set -e |
4188 | + done |
4189 | +} |
4190 | + |
4191 | +@when 'ibm-db2.installed' |
4192 | +@when 'db.ready' |
4193 | +@when 'db.sshconfigured' |
4194 | +function create_consumer_dbs(){ |
4195 | + services=$(relation_call --state=db.ready services) |
4196 | + for service in $services; do |
4197 | + |
4198 | + key=$(relation_call --state=db.ready get_sshkeys $service) || true |
4199 | + juju-log "IBM DB2: In create_consumer_dbs function, Received the ssh key $key from the service $service" |
4200 | + |
4201 | + if [ "$key" == "None" ]; then |
4202 | + juju-log "IBM DB2: No data sent yet" |
4203 | + continue |
4204 | + fi |
4205 | + |
4206 | + |
4207 | + #Create the user for the remote unit connected |
4208 | + juju-log "IBM DB2: Creating the users for the consumer $service" |
4209 | + create_user $service |
4210 | + juju-log "IBM DB2: Create users completed" |
4211 | + |
4212 | + #Create the DBs after parsing |
4213 | + juju-log "IBM DB2: Creating DBs for the consumer $service" |
4214 | + create_dbs $service |
4215 | + juju-log "IBM DB2: Create DBs completed" |
4216 | + |
4217 | + # If we created a new db, send relation data. Otherwise, the db already |
4218 | + # existed, so there is no need to send the data. |
4219 | + if [ $isdbcreated -eq 1 ] ; then |
4220 | + get_cfgusername $service |
4221 | + service_name=`su - $cfgusername -c 'db2 get dbm cfg|grep -i svce|cut -d"=" -f2'` |
4222 | + db2_port=`grep $service_name /etc/services | cut -d"/" -f1 | grep "db2c_$cfgusername" | cut -f2` |
4223 | + db2_path="/opt/ibm/db2" |
4224 | + hostname=`unit-get private-address` |
4225 | + dbusername=$cfgusername |
4226 | + dbuserpw=$cfgpasswd |
4227 | + db2_instance_name=$cfgusername |
4228 | + |
4229 | + |
4230 | + juju-log "IBM DB2: Sending the DB details to the consumer $service" |
4231 | + juju-log "Port number: $db2_port" |
4232 | + juju-log "Hostname: $hostname" |
4233 | + juju-log "DBusername: $dbusername DBuserpw: $dbuserpw" |
4234 | + juju-log "DB Instance name: $db2_instance_name" |
4235 | + juju-log "Service: $service_name" |
4236 | + juju-log "DBname: $dbs_created" |
4237 | + |
4238 | + relation_call --state=db.ready set_db_details $service $db2_path $db2_port $hostname $dbusername $dbuserpw $db2_instance_name $dbs_created || true |
4239 | + fi |
4240 | + |
4241 | + status-set active "IBM DB2 Ready" |
4242 | + done |
4243 | +} |
4244 | + |
4245 | +@when 'ibm-db2.installed' |
4246 | +@when 'db.departed' |
4247 | +function stop_db2(){ |
4248 | + juju-log "IBM DB2: Stopping the DB when relation is broken" |
4249 | + services=$(relation_call --state=db.departed services) || true |
4250 | + for service in $services; do |
4251 | + juju-log "IBM DB2: Service name is $service" |
4252 | + get_cfgusername $service |
4253 | + if su - $cfgusername -c 'ps -eaf|grep -i "\bdb2sysc 0\b" |grep -i '$cfgusername |
4254 | + then |
4255 | + su - $cfgusername -c 'db2 force applications all' |
4256 | + su - $cfgusername -c 'db2stop' |
4257 | + juju-log "IBM DB2: DB2 stopped for instance $cfgusername" |
4258 | + else |
4259 | + juju-log "IBM DB2: DB2 is already stopped for the instance $cfgusername" |
4260 | + fi |
4261 | + #Remove the ssh key entry from ssh keys file |
4262 | + remove_sshkeys $service |
4263 | + relation_call --state=db.departed dismiss_sshconfigured $service || true |
4264 | + relation_call --state=db.departed dismiss $service || true |
4265 | + done |
4266 | +} |
4267 | + |
4268 | + |
4269 | +reactive_handler_main |
4270 | |
4271 | === added file 'reactive/leadership.py' |
4272 | --- reactive/leadership.py 1970-01-01 00:00:00 +0000 |
4273 | +++ reactive/leadership.py 2016-07-14 17:53:24 +0000 |
4274 | @@ -0,0 +1,68 @@ |
4275 | +# Copyright 2015-2016 Canonical Ltd. |
4276 | +# |
4277 | +# This file is part of the Leadership Layer for Juju. |
4278 | +# |
4279 | +# This program is free software: you can redistribute it and/or modify |
4280 | +# it under the terms of the GNU General Public License version 3, as |
4281 | +# published by the Free Software Foundation. |
4282 | +# |
4283 | +# This program is distributed in the hope that it will be useful, but |
4284 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
4285 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
4286 | +# PURPOSE. See the GNU General Public License for more details. |
4287 | +# |
4288 | +# You should have received a copy of the GNU General Public License |
4289 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
4290 | + |
4291 | +from charmhelpers.core import hookenv |
4292 | +from charmhelpers.core import unitdata |
4293 | + |
4294 | +from charms import reactive |
4295 | +from charms.leadership import leader_get, leader_set |
4296 | + |
4297 | + |
4298 | +__all__ = ['leader_get', 'leader_set'] # Backwards compatibility |
4299 | + |
4300 | + |
4301 | +def initialize_leadership_state(): |
4302 | + '''Initialize leadership.* states from the hook environment. |
4303 | + |
4304 | + Invoked by hookenv.atstart() so states are available in |
4305 | + @hook decorated handlers. |
4306 | + ''' |
4307 | + is_leader = hookenv.is_leader() |
4308 | + if is_leader: |
4309 | + hookenv.log('Initializing Leadership Layer (is leader)') |
4310 | + else: |
4311 | + hookenv.log('Initializing Leadership Layer (is follower)') |
4312 | + |
4313 | + reactive.helpers.toggle_state('leadership.is_leader', is_leader) |
4314 | + |
4315 | + previous = unitdata.kv().getrange('leadership.settings.', strip=True) |
4316 | + current = hookenv.leader_get() |
4317 | + |
4318 | + # Handle deletions. |
4319 | + for key in set(previous.keys()) - set(current.keys()): |
4320 | + current[key] = None |
4321 | + |
4322 | + any_changed = False |
4323 | + for key, value in current.items(): |
4324 | + reactive.helpers.toggle_state('leadership.changed.{}'.format(key), |
4325 | + value != previous.get(key)) |
4326 | + if value != previous.get(key): |
4327 | + any_changed = True |
4328 | + reactive.helpers.toggle_state('leadership.set.{}'.format(key), |
4329 | + value is not None) |
4330 | + reactive.helpers.toggle_state('leadership.changed', any_changed) |
4331 | + |
4332 | + unitdata.kv().update(current, prefix='leadership.settings.') |
4333 | + |
4334 | + |
4335 | +# Per https://github.com/juju-solutions/charms.reactive/issues/33, |
4336 | +# this module may be imported multiple times so ensure the |
4337 | +# initialization hook is only registered once. I have to piggy back |
4338 | +# onto the namespace of a module imported before reactive discovery |
4339 | +# to do this. |
4340 | +if not hasattr(reactive, '_leadership_registered'): |
4341 | + hookenv.atstart(initialize_leadership_state) |
4342 | + reactive._leadership_registered = True |
4343 | |
4344 | === added file 'requirements.txt' |
4345 | --- requirements.txt 1970-01-01 00:00:00 +0000 |
4346 | +++ requirements.txt 2016-07-14 17:53:24 +0000 |
4347 | @@ -0,0 +1,2 @@ |
4348 | +flake8 |
4349 | +pytest |
4350 | |
4351 | === modified file 'tests/00-setup' |
4352 | --- tests/00-setup 2015-12-07 02:57:11 +0000 |
4353 | +++ tests/00-setup 2016-07-14 17:53:24 +0000 |
4354 | @@ -1,31 +1,17 @@ |
4355 | #!/bin/bash |
4356 | |
4357 | |
4358 | -SFTP_USER_NAME=${SFTP_USER_NAME?Error: Need SFTP user name for logging into to sftp server} |
4359 | -SFTP_PASSWORD=${SFTP_PASSWORD?Error: Need SFTP password for logging into to sftp server} |
4360 | -PACKAGE_NAME=${DIR_NAME?Error: The path on sftp server for the packages for $CHARM_NAME} |
4361 | -SFTP_HOST=${SFTP_HOST?Error: Need SFTP server Domain name} |
4362 | -PACKAGE_DIR=${PACKAGE_DIR?Error: Need Package Directory name} |
4363 | +DB2_CURL_URL=${DB2_CURL_URL?Error: IBM IM curl_url be defined in tests/00-setup} |
4364 | +DB2_CURL_OPTS=${DB2_CURL_OPTS?Error: IBM IM curl_OPTS be defined in tests/00-setup} |
4365 | + |
4366 | |
4367 | # Add a local configuration file |
4368 | cat << EOF > local.yaml |
4369 | ibm-repo: |
4370 | - sftp_user_name: "$SFTP_USER_NAME" |
4371 | - sftp_password: "$SFTP_PASSWORD" |
4372 | - package_name: "$PACKAGE_NAME" |
4373 | - sftp_host: "$SFTP_HOST" |
4374 | - package_dir: "$PACKAGE_DIR" |
4375 | -EOF |
4376 | - |
4377 | -DB2_SHA_DISTRIBUTION_PKG=${DB2_SHA_DISTRIBUTION_PKG?Error: Checksum value for Distribution package must be defined in tests/00-setup} |
4378 | - |
4379 | -# Add a local configuration file |
4380 | -cat << EOF >> local.yaml |
4381 | -ibm-db2: |
4382 | - db2distribution_pkg_sha: "$DB2_SHA_DISTRIBUTION_PKG" |
4383 | - |
4384 | -EOF |
4385 | - |
4386 | -add-apt-repository ppa:juju/stable -y |
4387 | -apt-get update |
4388 | -apt-get install amulet -y |
4389 | + db2_curl_url: "$DB2_CURL_URL" |
4390 | + db2_curl_opts: "$DB2_CURL_OPTS" |
4391 | +EOF |
4392 | + |
4393 | +sudo add-apt-repository ppa:juju/stable -y |
4394 | +sudo apt-get update |
4395 | +sudo apt-get install amulet python3 -y |
4396 | |
4397 | === modified file 'tests/10-bundles-test.py' |
4398 | --- tests/10-bundles-test.py 2015-12-07 03:38:45 +0000 |
4399 | +++ tests/10-bundles-test.py 2016-07-14 17:53:24 +0000 |
4400 | @@ -8,8 +8,9 @@ |
4401 | import amulet |
4402 | import sys |
4403 | import time |
4404 | +import requests |
4405 | |
4406 | -seconds_to_wait = 1000 |
4407 | +seconds_to_wait = 20000 |
4408 | |
4409 | |
4410 | class BundleTest(unittest.TestCase): |
4411 | @@ -17,7 +18,7 @@ |
4412 | @classmethod |
4413 | def setUpClass(cls): |
4414 | """ Set up an amulet deployment using the bundle. """ |
4415 | - d = amulet.Deployment() |
4416 | + d = amulet.Deployment(juju_env='local', series='trusty') |
4417 | # We have a contextual test, if no config is present, initialze the |
4418 | # test with an empty configuration set |
4419 | config = {} |
4420 | @@ -25,61 +26,28 @@ |
4421 | with open(local_path, "r") as fd: |
4422 | config = yaml.safe_load(fd) |
4423 | |
4424 | - sftphost = config.get('ibm-repo').get('sftp_host') |
4425 | - if not sftphost: |
4426 | - message = 'Please provide the host name from where the package can be downloaded.' |
4427 | + curl_url = config.get('ibm-repo').get('db2_curl_url') |
4428 | + if not curl_url: |
4429 | + message = 'Please provide the curl url from where the package can be downloaded.' |
4430 | amulet.raise_status(amulet.FAIL, msg=message) |
4431 | sys.exit(1) |
4432 | |
4433 | - packagedir = config.get('ibm-repo').get('package_dir') |
4434 | - if not packagedir: |
4435 | - message = 'Please provide the directory from where the package can be downloaded.' |
4436 | - amulet.raise_status(amulet.FAIL, msg=message) |
4437 | - sys.exit(1) |
4438 | - |
4439 | - packagename = config.get('ibm-repo').get('package_name') |
4440 | - if not packagename: |
4441 | - message = 'Please provide the package name to download.' |
4442 | - amulet.raise_status(amulet.FAIL, msg=message) |
4443 | - sys.exit(1) |
4444 | - |
4445 | - sftpusername = config.get('ibm-repo').get('sftp_user_name') |
4446 | - if not sftpusername: |
4447 | - message = 'Please provide the user name to log into the sftp server for downloading the package.' |
4448 | - amulet.raise_status(amulet.FAIL, msg=message) |
4449 | - sys.exit(1) |
4450 | - |
4451 | - sftppasswd = config.get('ibm-repo').get('sftp_password') |
4452 | - if not sftppasswd: |
4453 | - message = 'Please provide the password to log into the sftp server for downloading the package.' |
4454 | - amulet.raise_status(amulet.FAIL, msg=message) |
4455 | - sys.exit(1) |
4456 | - |
4457 | - db2distributionpkgsha = config.get('ibm-db2').get('db2distribution_pkg_sha') |
4458 | - print('Using SHA sum for distribution package %s' % db2distributionpkgsha) |
4459 | - |
4460 | - if not db2distributionpkgsha: |
4461 | - message = 'Please provide the sha value to proceed further. Exiting before completing rest of the verification tests.' |
4462 | - amulet.raise_status(amulet.FAIL, msg=message) |
4463 | - |
4464 | - bundle_path = os.path.join(os.path.dirname(__file__), 'bundles.yaml') |
4465 | - with open(bundle_path, 'r') as bundle_file: |
4466 | - contents = yaml.safe_load(bundle_file) |
4467 | - d.load(contents) |
4468 | - |
4469 | - |
4470 | + curl_opts = config.get('ibm-repo').get('db2_curl_opts') |
4471 | + if not curl_opts: |
4472 | + message = 'Please provide the curl_opts to specify the credentials to download the packages.' |
4473 | + amulet.raise_status(amulet.FAIL, msg=message) |
4474 | + sys.exit(1) |
4475 | + |
4476 | + |
4477 | + d.add('ibm-db2') |
4478 | + |
4479 | + d.configure('ibm-db2', { 'license_accepted': True, |
4480 | + 'curl_url': curl_url, |
4481 | + 'curl_opts': curl_opts }) |
4482 | d.setup(seconds_to_wait) |
4483 | d.sentry.wait(seconds_to_wait) |
4484 | cls.d = d |
4485 | |
4486 | - d.configure('ibm-db2', { 'accept-ibm-db2-license': True, |
4487 | - 'host': sftphost, |
4488 | - 'package_dir': packagedir, |
4489 | - 'username': sftpusername, |
4490 | - 'password': sftppasswd, |
4491 | - 'db2_package_name': packagename, |
4492 | - 'sha': db2distributionpkgsha }) |
4493 | - time.sleep(300) |
4494 | |
4495 | |
4496 | def test_deployed(self): |
4497 | |
4498 | === added file 'tox.ini' |
4499 | --- tox.ini 1970-01-01 00:00:00 +0000 |
4500 | +++ tox.ini 2016-07-14 17:53:24 +0000 |
4501 | @@ -0,0 +1,12 @@ |
4502 | +[tox] |
4503 | +skipsdist=True |
4504 | +envlist = py34, py35 |
4505 | +skip_missing_interpreters = True |
4506 | + |
4507 | +[testenv] |
4508 | +commands = py.test -v |
4509 | +deps = |
4510 | + -r{toxinidir}/requirements.txt |
4511 | + |
4512 | +[flake8] |
4513 | +exclude=docs |
4514 | |
4515 | === added directory 'wheelhouse' |
4516 | === added file 'wheelhouse/Jinja2-2.8.tar.gz' |
4517 | Binary files wheelhouse/Jinja2-2.8.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/Jinja2-2.8.tar.gz 2016-07-14 17:53:24 +0000 differ |
4518 | === added file 'wheelhouse/MarkupSafe-0.23.tar.gz' |
4519 | Binary files wheelhouse/MarkupSafe-0.23.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/MarkupSafe-0.23.tar.gz 2016-07-14 17:53:24 +0000 differ |
4520 | === added file 'wheelhouse/PyYAML-3.11.zip' |
4521 | Binary files wheelhouse/PyYAML-3.11.zip 1970-01-01 00:00:00 +0000 and wheelhouse/PyYAML-3.11.zip 2016-07-14 17:53:24 +0000 differ |
4522 | === added file 'wheelhouse/Tempita-0.5.2.tar.gz' |
4523 | Binary files wheelhouse/Tempita-0.5.2.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/Tempita-0.5.2.tar.gz 2016-07-14 17:53:24 +0000 differ |
4524 | === added file 'wheelhouse/charmhelpers-0.8.0.tar.gz' |
4525 | Binary files wheelhouse/charmhelpers-0.8.0.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/charmhelpers-0.8.0.tar.gz 2016-07-14 17:53:24 +0000 differ |
4526 | === added file 'wheelhouse/charms.reactive-0.4.4.tar.gz' |
4527 | Binary files wheelhouse/charms.reactive-0.4.4.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/charms.reactive-0.4.4.tar.gz 2016-07-14 17:53:24 +0000 differ |
4528 | === added file 'wheelhouse/netaddr-0.7.18.tar.gz' |
4529 | Binary files wheelhouse/netaddr-0.7.18.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/netaddr-0.7.18.tar.gz 2016-07-14 17:53:24 +0000 differ |
4530 | === added file 'wheelhouse/pip-8.1.2.tar.gz' |
4531 | Binary files wheelhouse/pip-8.1.2.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/pip-8.1.2.tar.gz 2016-07-14 17:53:24 +0000 differ |
4532 | === added file 'wheelhouse/pyaml-15.8.2.tar.gz' |
4533 | Binary files wheelhouse/pyaml-15.8.2.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/pyaml-15.8.2.tar.gz 2016-07-14 17:53:24 +0000 differ |
4534 | === added file 'wheelhouse/six-1.10.0.tar.gz' |
4535 | Binary files wheelhouse/six-1.10.0.tar.gz 1970-01-01 00:00:00 +0000 and wheelhouse/six-1.10.0.tar.gz 2016-07-14 17:53:24 +0000 differ |
This item has failed automated testing! Results available here http:// juju-ci. vapour. ws:8080/ job/charm- bundle- test-lxc/ 4102/