Merge lp:~kwmonroe/charms/trusty/layer-ibm-im/switch-to-resources into lp:~ibmcharmers/charms/trusty/layer-ibm-im/trunk

Proposed by Kevin W Monroe
Status: Merged
Approved by: Shruthima
Approved revision: 21
Merged at revision: 6
Proposed branch: lp:~kwmonroe/charms/trusty/layer-ibm-im/switch-to-resources
Merge into: lp:~ibmcharmers/charms/trusty/layer-ibm-im/trunk
Diff against target: 866 lines (+323/-463)
9 files modified
README.md (+115/-210)
config.yaml (+0/-6)
layer.yaml (+1/-0)
metadata.yaml (+13/-2)
reactive/ibm-im.sh (+161/-140)
tests/00-setup (+0/-21)
tests/01-deploy.py (+29/-0)
tests/10-bundles-test.py (+0/-84)
tests/tests.yaml (+4/-0)
To merge this branch: bzr merge lp:~kwmonroe/charms/trusty/layer-ibm-im/switch-to-resources
Reviewer Review Type Date Requested Status
Shruthima Approve
Review via email: mp+296630@code.launchpad.net

Description of the change

Switch to Juju Resources and Terms instead of requiring curl and license config options.

To post a comment you must log in.
13. By Kevin W Monroe

update fixpack placeholder description

14. By Kevin W Monroe

update tests since we can test charm deployment with a placeholder resource

15. By Kevin W Monroe

be more explicity with log/status messages

16. By Kevin W Monroe

never let the grep fail when detecting an empty fixpack (set -e will make the hook fail on subshell failures); make check-fixpack only run during upgrade-charm (otherwise it ran on update-status, every 5 minutes)

17. By Kevin W Monroe

use underscores instead of hyphens in function names

18. By Kevin W Monroe

fixup last commit (missed an extra ibm_im_fp_empty assignment)

19. By Kevin W Monroe

update sentry message for placeholder resource test

20. By Kevin W Monroe

tweak sentry status message in amulet test

21. By Kevin W Monroe

change upgrade-charm hook logic

The first time a fixpack resource was uploaded, the upgrade-charm hook would
fetch it, md5sum it, and compare that sum to a bogus previous value (because
there was no previous valid fixpack). This sum mismatch triggered the install
of a new fixpack, which goes out to re-fetch it. The double-fetch on initial
fixpack (first in upgrade-charm, then in install_ibm_im_fixpack) is
inefficient.

Instead, upgrade-charm now checks for the ibm-im.updated state, which is only
set when a fixpack gets installed. On initial fixpack upload, this state will
not be set, so we avoid the double fetch.

Revision history for this message
Shruthima (salmavar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2016-05-05 10:58:11 +0000
3+++ README.md 2016-06-23 19:40:22 +0000
4@@ -1,210 +1,115 @@
5-## Charm for IBM Installation Manager(IM) 1.8
6-
7-### Overview
8-
9-IBM Installation Manager
10-
11-IBM Installation Manager is a single installation program that uses remote or local software repositories to install, modify, or update certain IBM products.
12-
13-User guides and security guides to support this release are available for
14-online viewing [User Guide](http://www.ibm.com/support/knowledgecenter/SSDV2W/im_family_welcome.html)
15-
16-
17-### Download of Product Binaries
18-
19-Download your licensed IBM IM 1.8 software for Ubuntu.
20-
21-You can download product binaries from
22-[Product Page](http://www-01.ibm.com/support/docview.wss?uid=swg27025142)
23-
24-
25-### Usage
26-Download your licensed IBM Installation Manager software and host it in a way that can be downloaded using curl.
27-
28-Curl-url and Curl-opts are two main options we are using from ibm-base-layer to download the ibm product as IBM-IM is built on top of the ibm-base layer [More Info](http://interfaces.juju.solutions/layer/ibm-base/)
29-
30-To download and install the code contained in this charm you must agree to the IBM license.
31-
32-You can view the full license for `IBM Installation Manager`by visiting the [license-info](http://www-03.ibm.com/software/sla/sladb.nsf/displaylis/39AFC1C1D485C4E085257E7300548B05?OpenDocument).
33-
34-Search for "IBM Installation Manager" and choose the license that applies to the version you are using.
35-
36-###### For (x86_64) Ubuntu , The packages are:
37-
38-IBM Installation Manager 1.8 (agent.installer.linux.gtk.x86_64_1.8.3000.20150606_0047.zip)
39-
40-###### For Power (ppcle) Ubuntu, The packages are:
41-
42-IBM Installation Manager 1.8(agent.installer.linux.gtk.ppc64le_1.8.1000.20141126_2002.zip)
43-
44-Creating Repositories
45---------------------
46-For deploying IBM IM charm the user needs to download the correct packages as mentioned in the 'Usage' section above and host it in a way which can be downloaded using curl.
47-
48-For eg:
49-
50-Using python simple HTTP Server as follows,If the user downloads the IM package agent.installer.linux.gtk.x86_64_1.8.3000.20150606_0047.zip in /home/Downloads then the below commands will start a simple HTTP Server and host the packages in the /home/Downloads folder
51-
52- cd /home/Downloads
53- python -m SimpleHTTPServer
54-
55-And the curl-url would be
56-
57- http://localhost:8000/package/agent.installer.linux.gtk.x86_64_1.8.3000.20150606_0047.zip?md5=<md5 of agent.installer.linux.gtk.x86_64_1.8.3000.20150606_0047.zip>
58-
59-### Deploy
60-
61-1.Run the following commands to deploy this charm:
62-
63- juju deploy ibm-im
64-
65-2.Here the charm will wait until the user accepts the license. If you agree to the license, run the following command.
66-
67- juju set ibm-im license_accepted="True"
68-
69-
70-3.IBM IM charm also needs an host from where the packages can be downloaded (the user has to keep the Installation Manager packages on this host server),from the directory where the package is kept, user name and password to connect to the host server(as mentioned in the creating repositories section).
71-
72-We have to provide values for curl-url and curl-opt to download the product.
73-
74-curl-url with host name,package_dir,package name,checksum value, curl-opts with user name and password,to proceed with the installation.
75- To provide these run the following command:
76-
77- juju set ibm-im curl_url="<hostname>/<package_dir><package_name>?<sha512=value>"
78- juju set ibm-im curl_opts="-u <username>:<password>"
79-
80-For eg:
81-
82- juju set ibm-im curl_url="http://1.2.3.4/debs/agent.installer.linux.gtk.x86_64_1.8.3000.20150606_0047.zip?sha512=d58483957f56c20492f174b5a112b93a35cb7e45d5009c5c5fc4a3d34f91d2fcbefff770cad578287056ca1af01cacd700eb349937530e6f44780075f7dbaaab"
83- juju set ibm-im curl_opts="-u root:root123"
84-
85-
86-
87- The command to find the sha512 value is
88-
89- sha512sum <IM Package Name>
90-
91-For eg:
92-
93- sha512sum agent.installer.linux.gtk.x86_64_1.8.3000.20150606_0047.zip
94-
95-
96-4.Setting the license-accepted to False will uninstall the product:
97-
98- juju set ibm-im license_accepted="False"
99-
100-**Note** : If user wants to install any other packages other then the packages mentioned in usage section, user needs to download IBM-IM charm folder from charm store to local machine and edit the layer.yaml i.e provide the default package name under ibm-im-package option.
101-
102-Next user needs to deploy locally with the command
103-
104- juju deploy --repository=<path_to_charms_folder> local:trusty/ibm-im
105-
106-Next he need to follow the below deploy section from step 2
107-### Upgrade of ibm-im
108-Once deployed and if the user wants to upgrade to the newer version, setting the ibm-im-fp-package will upgrade the product.
109-
110- juju set ibm-im ibm_im_fp_package="<fix pack-name>"
111-
112-For eg:
113-
114- juju set ibm-im ibm_im_fp_package="agent.installer.linux.gtk.x86_64_1.8.4001.20160217_1716.zip"
115-
116-**Note** Before setting the ibm-im-fp-package value user must host the package and provide curl-url and curl-opt options for Downloading fix pack package.
117-
118- For eg:
119-
120- juju set ibm-im curl_url="http://1.2.3.4/debs/agent.installer.linux.gtk.x86_64_1.8.4001.20160217_1716.zip?sha512=0a2e72e40530c2fe39edf76c45ea068a296d1670f8e4e75111c8efeede8e845087b4d5b850f5a570ffb0d5422b5f4b24121812ca754739989a9b160261d40d15"
121- juju set ibm-im curl_opts="-u root:root123"
122-
123-
124-
125-### Installation Verification
126-
127-Once deployed, you can use IBM IM to install any IBM products. To verify IM is installed or not
128-get into the container and check whether the below path is exist.
129-
130- /opt/IBM/InstallationManager
131-
132-To get into the container run the below command.
133-
134- juju ssh <machine-id where IBM IM is installed>
135-
136-
137-### Uninstallation of ibm-im
138-
139-Setting the license-accepted to False will uninstall the product.
140-
141- juju set ibm-im license_accepted=False
142-
143-
144-### Configuration
145-
146-- **license_accepted** Before you can use or install IBM IM,
147- you must accept the terms of International License
148- Agreement for Non-Warranted Programs and additional license information.
149- Please read the license agreement carefully
150- [IBM IM License](http://www-03.ibm.com/software/sla/sladb.nsf/displaylis/39AFC1C1D485C4E085257E7300548B05?OpenDocument). Set the value of license-accepted to True if you agree to IBM IM license.
151-
152-**The IBM IM software cannot be installed until the terms and
153-conditions are accepted. The charm will not function correctly until the configuration option is set to True.**
154-
155-- **curl_url** For downloading package we need to set curl_url with following options.
156-
157- - *hostname* - The web server host name from which IBM IM installation packages can be downloaded.
158- - *package_dir* - The package directory path in the web server.
159- - *package name* - The IBM IM Package name.
160- - *checksum value* - Checksum value to check integrity of IBM IM package. The Charm
161- uses sha512sum to check the integrity. If empty, it does not carry out the
162- integrity check. Use `sha512sum <Package Location/Package Name>`
163- to find out Checksum value for downloaded package.
164-
165-- **curl_opts** We need to set curl_opts with following options.
166- - *username* - User name of the webserver host.
167- - *password* - Password of the webserver host.
168-
169-- **ibm-im-fp-package** The IBM IM Fix pack Package name. These must be provided when user wants to upgrade the charm.
170-
171-### Additional Information
172-This layer is intended to be extended by other charms that would benefit from having IBM Installation Manager (IBM IM) preinstalled. For example, a WebSphere layered charm could include this layer so it could use IBM IM to install WebSphere.
173-
174-To use this layer, include the following in your `layer.yaml`:
175-
176-```yaml
177-includes: ['layer:ibm-installation-manager']
178-```
179-
180-Then, in your charm, watch for the `im.installed` state, at which point you will know the IBM IM tools are available:
181-
182- IM_PATH=/opt/IBM/InstallationManager
183-
184- @when 'im.installed'
185- install_was() {
186- WAS_REPO=`config-get was_repo`
187- ${IM_PATH}/tools/imutilsc saveCredential -url $WAS_REPO -userName $IBM_ID_NAME -userPassword $IBM_ID_PASS -secureStorageFile "secure.store"
188- ${IM_PATH}/installc -input silent-install.xml -acceptlicense -secureStorageFile "secure.store"
189- ${IM_PATH}/imcl install $IM_ARGS
190- }
191-
192-
193-
194-### IBM IM Information
195-
196-### General Information
197-
198-Details about IBM IM available [Here](http://www.ibm.com/support/knowledgecenter/SSDV2W/im_family_welcome.html)
199-
200-### Download Information
201-
202-Information on procuring IBM IM product is available at the [Product Page](http://www-01.ibm.com/support/docview.wss?uid=swg27025142)
203-
204-### License Information
205-
206-License information for IBM IM can be viewed [Here](http://www-03.ibm.com/software/sla/sladb.nsf/searchlis/?searchview&searchorder=4&searchmax=0&query=%28Installation+Manager+1.8.3%29)
207-
208-### Known Limitations
209-
210-This charm makes use of juju status commands, and requires juju 1.24 or greater
211-
212-### Contact Information
213-
214-For issues with this charm, please contact [IBM Juju Support Team](mailto:jujusupp@us.ibm.com)
215+# IBM Installation Manager (IM)
216+
217+IBM Installation Manager (IM) is a single installation program that uses remote
218+or local software repositories to install, modify, or update certain IBM
219+products.
220+
221+User guides and security guides to support this release are available for
222+online viewing
223+[User Guide](http://www.ibm.com/support/knowledgecenter/SSDV2W/im_family_welcome.html).
224+
225+
226+## Prerequisites
227+
228+This charm makes use of resources, a feature only available in Juju 2.0. During
229+deploy or upgrade, you will need to specify the installable package(s)
230+required by this charm. Download your licensed IBM Installation Manager
231+packages from the [Product Page](http://www-01.ibm.com/support/docview.wss?uid=swg27025142).
232+
233+### Package for Ubuntu on AMD64 (x86_64):
234+
235+IBM Installation Manager 1.8 (`agent.installer.linux.gtk.x86_64_1.8.3000.20150606_0047.zip`)
236+
237+### Package for Ubuntu on Power (ppc64le):
238+
239+IBM Installation Manager 1.8 (`agent.installer.linux.gtk.ppc64le_1.8.1000.20141126_2002.zip`)
240+
241+## Usage
242+
243+To use this charm, you must agree to the Terms of Use. You can view the full license
244+for `IBM Installation Manager` by visiting the
245+[license-info](http://www-03.ibm.com/software/sla/sladb.nsf/displaylis/39AFC1C1D485C4E085257E7300548B05?OpenDocument)
246+page.
247+
248+Search for "IBM Installation Manager" and choose the license that applies to
249+the version you are using.
250+
251+### Deploy
252+
253+Run the following commands to deploy this charm:
254+
255+ juju deploy ibm-im --resource ibm_im_installer=</path/to/installer.zip>
256+
257+**Note**: This charm requires acceptance of Terms of Use. When deploying from
258+the Charm Store, these terms will be presented to you for your consideration.
259+To accept the terms:
260+
261+ juju agree somePlan/1
262+
263+### Upgrade
264+
265+Once deployed, users can install fixpacks by upgrading the charm:
266+
267+ juju upgrade-charm ibm-im --resource ibm_im_fixpack=</path/to/fixpack.zip>
268+
269+### Verification
270+
271+Once deployed, you can use IBM IM to install any IBM products. To verify IM is
272+installed, list the contents of the installation directory:
273+
274+ juju run --service ibm-im 'ls /opt/IBM/InstallationManager'
275+
276+
277+## Additional information
278+
279+### General
280+
281+Details about IBM Installation Manager are available
282+[here](http://www.ibm.com/support/knowledgecenter/SSDV2W/im_family_welcome.html).
283+
284+### Download
285+
286+Information on procuring IBM IM product is available at the
287+[Product Page](http://www-01.ibm.com/support/docview.wss?uid=swg27025142).
288+
289+### License
290+
291+License information for IBM IM can be viewed
292+[here](http://www-03.ibm.com/software/sla/sladb.nsf/searchlis/?searchview&searchorder=4&searchmax=0&query=%28Installation+Manager+1.8.3%29).
293+
294+### Developers
295+
296+This layer is intended to be extended by other charms that would benefit from
297+having IBM Installation Manager (IBM IM) preinstalled. For example, a WebSphere
298+layered charm could include this layer so it could use IBM IM to install
299+WebSphere.
300+
301+To use this layer, include the following in your `layer.yaml`:
302+
303+```yaml
304+includes: ['layer:ibm-im']
305+```
306+
307+Then in your charm, watch for the `ibm-im.installed` state, at which point you
308+will know the IBM IM tools are available:
309+
310+```sh
311+IM_PATH=/opt/IBM/InstallationManager
312+
313+@when 'ibm-im.installed'
314+install_was() {
315+ WAS_REPO=`config-get was_repo`
316+ ${IM_PATH}/tools/imutilsc saveCredential -url $WAS_REPO -userName $IBM_ID_NAME -userPassword $IBM_ID_PASS -secureStorageFile "secure.store"
317+ ${IM_PATH}/installc -input silent-install.xml -acceptlicense -secureStorageFile "secure.store"
318+ ${IM_PATH}/imcl install $IM_ARGS
319+}
320+```
321+
322+## Known Limitations
323+
324+This charm makes use of Juju features that are only available in version 2.0 or
325+greater.
326+
327+## Contact Information
328+
329+For issues with this charm, please contact [IBM Juju Support Team](mailto:jujusupp@us.ibm.com)
330
331=== removed file 'config.yaml'
332--- config.yaml 2016-04-25 07:15:10 +0000
333+++ config.yaml 1970-01-01 00:00:00 +0000
334@@ -1,6 +0,0 @@
335-options:
336- ibm_im_fp_package:
337- type: string
338- default: ""
339- description: |
340- Name of the IBM IM Fixpack package.
341
342=== modified file 'layer.yaml'
343--- layer.yaml 2016-04-25 07:15:10 +0000
344+++ layer.yaml 2016-06-23 19:40:22 +0000
345@@ -1,3 +1,4 @@
346+repo: bzr+ssh://bazaar.launchpad.net/~ibmcharmers/charms/trusty/layer-ibm-im/trunk/
347 includes: ['layer:ibm-base']
348 options:
349 basic:
350
351=== modified file 'metadata.yaml'
352--- metadata.yaml 2016-04-25 07:15:10 +0000
353+++ metadata.yaml 2016-06-23 19:40:22 +0000
354@@ -1,9 +1,20 @@
355 name: ibm-im
356-summary: IBM Java IM Product
357+summary: IBM Installation Manager
358 maintainer: IBM Juju Support Team <jujusupp@us.ibm.com>
359 description: |
360- IBM IM is an installation tool, which helps you to install many IBM products.
361+ IBM IM is an installation tool that helps install many IBM products.
362 tags:
363 - ibm
364 - im
365 subordinate: false
366+resources:
367+ ibm_im_installer:
368+ type: file
369+ filename: ibm_im_installer.zip
370+ description: Installation Manager installer archive
371+ ibm_im_fixpack:
372+ type: file
373+ filename: ibm_im_fixpack.zip
374+ description: Installation Manager fix pack archive
375+terms:
376+ - lorem-ipsum/1
377
378=== modified file 'reactive/ibm-im.sh'
379--- reactive/ibm-im.sh 2016-05-05 10:58:11 +0000
380+++ reactive/ibm-im.sh 2016-06-23 19:40:22 +0000
381@@ -1,166 +1,187 @@
382 #!/bin/bash
383-set -ex
384+set -e
385
386 source charms.reactive.sh
387-ARCHIVE_DIR=files/archives
388 ARCHITECTURE=`uname -m`
389
390 # Installation Manager install path
391 IM_INSTALL_PATH="/opt/IBM/InstallationManager"
392
393-
394-@when 'ibm-base.license.accepted' 'ibm-base.curl.resource.fetched'
395 @when_not 'ibm-im.installed'
396-function install-ibm-im(){
397-# Get the package name to check whether the user wants to install a different package
398- im_file_name="$(layer_option ibm-im ibm_im_package)"
399- cfg_im_pkg_name=$im_file_name
400-
401- #Check whether user has selected right package name from the package name string. If he selects wrong package name , install would fail.
402- # Set package name to a predefined value if user have not set the layer option
403- if [ "$cfg_im_pkg_name" == "" ]; then
404- if [ "$ARCHITECTURE" = "x86_64" ]; then
405- DEFAULT_INSTALLER_FILE_IM="agent.installer.linux.gtk.x86_64_1.8.3000.20150606_0047.zip"
406- elif [ "$ARCHITECTURE" = "ppc64le" ]; then
407- DEFAULT_INSTALLER_FILE_IM="agent.installer.linux.gtk.ppc64le_1.8.1000.20141126_2002.zip"
408- else
409- status-set blocked "IBM IM: Platform not supported"
410- fi
411- cfg_im_pkg_name=${DEFAULT_INSTALLER_FILE_IM}
412- else
413- if [ "$ARCHITECTURE" = "x86_64" ]; then
414- juju-log "Checking the package name"
415- if echo "$cfg_im_pkg_name" | grep -q "x86"; then
416- juju-log "IBM IM: Package name is matching for the platform"
417- else
418- juju-log "IBM IM: Probably Not the right package. IM install will fail if its not the right package"
419- status-set blocked "Probably Not the right package. Please configure the correct package name"
420- exit 0
421- fi
422- else
423- if echo "$cfg_im_pkg_name" | grep -q "ppcle"; then
424- juju-log "IBM IM: Package name is matching for the platform"
425- else
426- juju-log "IBM IM: Probably Not the right package. IM install will fail if its not the right package"
427- status-set blocked "Probably Not the right package. Please configure the correct package name"
428- exit 0
429- fi
430- fi
431- fi
432-
433- # Do the actual IBM IM install
434- if [ -f $CHARM_DIR/$ARCHIVE_DIR/$cfg_im_pkg_name ]; then
435- juju-log "IBM IM: downloading and extracting IM packages"
436- if [ -f $CHARM_DIR/$ARCHIVE_DIR/userinstc ]; then
437- juju-log "IBM IM: IBM IM package contents extracted already."
438+function install_ibm_im(){
439+ # Fail fast if we're on an unsupported arch
440+ if [ "$ARCHITECTURE" != "x86_64" -a "$ARCHITECTURE" != "ppc64le" ]; then
441+ juju-log "IBM IM: only supported on x86_64 or ppc64le platforms"
442+ status-set blocked "unsupported architecture"
443+ exit 1
444+ fi
445+
446+ # Get the installable resource
447+ juju-log "IBM IM: fetching the ibm_im_installer resource"
448+ status-set maintenance "fetching the ibm_im_installer resource"
449+ cfg_im_pkg_name=`resource-get 'ibm_im_installer' || echo unavailable`
450+
451+ # If we don't have a package, report blocked status; we can't proceed.
452+ if [ "$cfg_im_pkg_name" = "unavailable" ]; then
453+ juju-log "IBM IM: missing required ibm_im_installer resource"
454+ status-set blocked "missing required ibm_im_installer resource"
455+ exit 0
456+ fi
457+
458+ juju-log "IBM IM: using $cfg_im_pkg_name as the ibm_im_installer resource"
459+ ARCHIVE_DIR=`dirname $cfg_im_pkg_name`
460+
461+ # Extract the installer contents
462+ if [ -f $cfg_im_pkg_name ]; then
463+ juju-log "IBM IM: extracting the ibm_im_installer resource"
464+ status-set maintenance "extracting the ibm_im_installer resource"
465+ if [ -f $ARCHIVE_DIR/userinstc ]; then
466+ juju-log "IBM IM: ibm_im_installer resource already extracted"
467 else
468- cd $CHARM_DIR/$ARCHIVE_DIR
469-
470- if ! unzip $cfg_im_pkg_name -d $CHARM_DIR/$ARCHIVE_DIR
471- then
472- juju-log "IBM IM: Unable to extract the IM package content. Verify whether the package is corrupt."
473+ cd $ARCHIVE_DIR
474+ if ! unzip $cfg_im_pkg_name; then
475+ juju-log "IBM IM: Unable to extract the ibm_im_installer resource"
476 # Remove corrupt archive file
477- status-set blocked "IBM Installation Manager package is corrupt"
478- rm -f $CHARM_DIR/$ARCHIVE_DIR/$im_pkg_name
479+ status-set blocked "ibm_im_installer resource is corrupt"
480+ rm -rf $ARCHIVE_DIR
481 exit 0
482 else
483- juju-log "IBM IM: Installation Manager extracted successfully."
484+ juju-log "IBM IM: ibm_im_installer resource extracted successfully"
485 fi
486 fi
487- fi
488- juju-log "IBM IM: IM installation start"
489- # Check IM package availability
490- juju-log $CHARM_DIR/$ARCHIVE_DIR
491- if [ -f $CHARM_DIR/$ARCHIVE_DIR/userinstc ];
492- then
493+ fi
494
495- juju-log "IBM IM: IM Packages available for installation."
496- cp $CHARM_DIR/$ARCHIVE_DIR/install.xml $CHARM_DIR/$ARCHIVE_DIR/silent_install.xml
497- sed -i "2 a \<profile kind='self' installLocation='$IM_INSTALL_PATH' id='IBM Installation Manager'>\n <data key='eclipseLocation' value='$IM_INSTALL_PATH' />\n</profile>" $CHARM_DIR/$ARCHIVE_DIR/silent_install.xml
498- if $CHARM_DIR/$ARCHIVE_DIR/userinstc -input $CHARM_DIR/$ARCHIVE_DIR/silent_install.xml -acceptlicense
499- then
500- set_state 'ibm-im.installed'
501-
502- status-set active "IBM IM: IM Is installed successfully"
503+ # Do the actual IBM IM install
504+ if [ -f $ARCHIVE_DIR/userinstc ]; then
505+ juju-log "IBM IM: starting installation."
506+ status-set maintenance "installing ibm-im"
507+ cp $ARCHIVE_DIR/install.xml $ARCHIVE_DIR/silent_install.xml
508+ sed -i "2 a \<profile kind='self' installLocation='$IM_INSTALL_PATH' id='IBM Installation Manager'>\n <data key='eclipseLocation' value='$IM_INSTALL_PATH' />\n</profile>" $ARCHIVE_DIR/silent_install.xml
509+ if $ARCHIVE_DIR/userinstc -input $ARCHIVE_DIR/silent_install.xml -acceptlicense; then
510+ set_state 'ibm-im.installed'
511+ status-set active "ready"
512+ else
513+ juju-log "IBM IM: error while installing"
514+ exit 1
515+ fi
516 else
517- juju-log "IBM IM: Error while installing IM"
518+ juju-log "IBM IM: installer was not found."
519+ status-set blocked "installation failed"
520 exit 1
521 fi
522-
523- else
524- juju-log "IBM IM: IM Packages missing. Please check README file"
525- status-set maintenance "IBM IM install failed"
526- exit 1
527- fi
528- }
529-
530-
531-@when 'ibm-im.installed' 'config.set.ibm_im_fp_package'
532+}
533+
534+@when 'ibm-im.installed'
535 @when_not 'ibm-im.updated'
536-function install-ibm-im-fixpack(){
537-ibm_im_fp_package=`config-get ibm_im_fp_package`
538-
539- if [ -f $CHARM_DIR/$ARCHIVE_DIR/$ibm_im_fp_package ]; then
540- juju-log "IBM-IM: ibm_im_fp_package is available"
541- if [ -f $CHARM_DIR/$ARCHIVE_DIR/FP/userinstc ]; then
542- juju-log "IBM IM: IBM IM package contents extracted already."
543- else
544- mkdir $CHARM_DIR/$ARCHIVE_DIR/FP
545- cd $CHARM_DIR/$ARCHIVE_DIR
546- if ! unzip $ibm_im_fp_package -d $CHARM_DIR/$ARCHIVE_DIR/FP
547- then
548- juju-log "IBM IM: Unable to extract the IM FP package content. Verify whether the package is corrupt."
549+function install_ibm_im_fixpack(){
550+ # Get the fixpack resource
551+ juju-log "IBM IM: fetching the ibm_im_fixpack resource"
552+ status-set maintenance "fetching the ibm_im_fixpack resource"
553+ ibm_im_fp_package=`resource-get 'ibm_im_fixpack' || echo unavailable`
554+
555+ # If we don't have a fixpack, just exit successfully; there's nothing to do.
556+ if [ "$ibm_im_fp_package" = "unavailable" ]; then
557+ juju-log "IBM IM: no ibm_im_fixpack to install"
558+ status-set active "ready"
559+ exit 0
560+ fi
561+
562+ # Currently, there is no way to make a resource optional, so something
563+ # must be uploaded to the charm store, even if it's a dummy archive.
564+ # If we detect the fixpack is just a placeholder (because we created an
565+ # empty placeholder in the store), exit just like we do with a missing
566+ # fixpack resource.
567+ ibm_im_fp_empty=`file $ibm_im_fp_package | { grep -q empty && echo "True"; } || echo "False"`
568+ if [ "$ibm_im_fp_empty" = "True" ]; then
569+ juju-log "IBM IM: no ibm_im_fixpack to install"
570+ status-set active "ready"
571+ exit 0
572+ fi
573+
574+ juju-log "IBM IM: using $ibm_im_fp_package as the ibm_im_fixpack resource"
575+ ARCHIVE_DIR=`dirname $ibm_im_fp_package`
576+
577+ # Extract the fixpack contents
578+ if [ -f $ibm_im_fp_package ]; then
579+ juju-log "IBM IM: extracting the ibm_im_fixpack resource"
580+ status-set maintenance "extracting the ibm_im_fixpack resource"
581+ if [ -f $ARCHIVE_DIR/userinstc ]; then
582+ juju-log "IBM IM: ibm_im_fixpack resource already extracted"
583+ else
584+ cd $ARCHIVE_DIR
585+ if ! unzip $ibm_im_fp_package; then
586+ juju-log "IBM IM: Unable to extract the ibm_im_fixpack resource"
587 # Remove corrupt archive file
588- status-set blocked "IBM Installation Manager fixpack package is corrupt"
589- rm -f $CHARM_DIR/$ARCHIVE_DIR/$ibm_im_fp_package
590+ status-set blocked "ibm_im_fixpack resource is corrupt"
591+ rm -rf $ARCHIVE_DIR
592 exit 0
593- else
594- juju-log "IBM IM: Installation Manager Fix pack extracted successfully."
595- fi
596- fi
597- juju-log "IBM IM: IM upgrading start"
598- # Check IM package availability
599- juju-log $CHARM_DIR/$ARCHIVE_DIR
600- if [ -f $CHARM_DIR/$ARCHIVE_DIR/FP/userinstc ];
601- then
602-
603- juju-log "IBM IM: IM FP Packages available for installation."
604- cp $CHARM_DIR/$ARCHIVE_DIR/FP/install.xml $CHARM_DIR/$ARCHIVE_DIR/FP/silent_install.xml
605- sed -i "2 a \<profile kind='self' installLocation='$IM_INSTALL_PATH' id='IBM Installation Manager'>\n <data key='eclipseLocation' value='$IM_INSTALL_PATH' />\n</profile>" $CHARM_DIR/$ARCHIVE_DIR/FP/silent_install.xml
606- if $CHARM_DIR/$ARCHIVE_DIR/FP/userinstc -input $CHARM_DIR/$ARCHIVE_DIR/FP/silent_install.xml -acceptlicense
607- then
608- set_state 'ibm-im.updated'
609-
610- status-set active "IBM IM: IM Is updated successfully"
611- else
612- juju-log "IBM IM: Error while updating IM"
613- exit 1
614- fi
615- fi
616-
617- else
618- juju-log "IBM_IM: Fix pack is not available to install, please provide the correct package"
619- status-set maintenance "IBM IM updating failed"
620+ else
621+ juju-log "IBM IM: ibm_im_fixpack resource extracted successfully"
622+ fi
623+ fi
624+ fi
625+
626+ # Do the actual IBM IM fixpack install
627+ if [ -f $ARCHIVE_DIR/userinstc ]; then
628+ juju-log "IBM IM: starting fixpack installation."
629+ status-set maintenance "installing fixpack"
630+ cp $ARCHIVE_DIR/install.xml $ARCHIVE_DIR/silent_install.xml
631+ sed -i "2 a \<profile kind='self' installLocation='$IM_INSTALL_PATH' id='IBM Installation Manager'>\n <data key='eclipseLocation' value='$IM_INSTALL_PATH' />\n</profile>" $ARCHIVE_DIR/silent_install.xml
632+ if $ARCHIVE_DIR/userinstc -input $ARCHIVE_DIR/silent_install.xml -acceptlicense; then
633+ set_state 'ibm-im.updated'
634+ status-set active "ready"
635+ else
636+ juju-log "IBM IM: error while installing the fixpack."
637+ exit 1
638+ fi
639+ else
640+ juju-log "IBM_IM: Fix pack installer was not found."
641+ status-set blocked "fixpack installation failed"
642 exit 1
643 fi
644-
645-}
646-
647-@when 'config.changed.ibm_im_fp_package'
648-function config-changed-ibm-im-fp(){
649- rm -rf $CHARM_DIR/$ARCHIVE_DIR/FP
650- remove_state 'ibm-im.updated'
651-
652-}
653-
654-@when 'ibm-im.installed'
655-@when_not 'ibm-base.license.accepted'
656-function uninstall() {
657- juju-log "IBM IM: Removing IBM IM software."
658- /root/var/ibm/InstallationManager/uninstall/uninstallc
659- juju-log "IBM IM: Removed IBM IM software"
660- remove_state "ibm-im.installed"
661- status-set blocked "IBM IM uninstalled"
662-}
663+}
664+
665+@hook 'upgrade-charm'
666+function check_fixpack(){
667+ # The upgrade-charm hook will fire when a new resource is pushed for this
668+ # charm. This is a good time to determine if we need to deal with a new
669+ # fixpack.
670+ if ! charms.reactive is_state 'ibm-im.updated'; then
671+ # If there is no prior fixpack installed (because ibm-im.updated is not
672+ # set), do nothing since install-ibm-im-fixpack will handle that case.
673+ juju-log "IBM IM: no fixpack has been installed; nothing to upgrade."
674+ exit 0
675+ else
676+ # If we have a fixpack already (because ibm-im.updated is set),
677+ # we should fetch the latest fixpack and determine if it is new.
678+ # - If it is new, set our states so install-ibm-im-fixpack is called again
679+ # - If it is not new, do nothing
680+ juju-log "IBM IM: scanning for new fixpacks to install"
681+ ARCHIVE_DIR="$CHARM_DIR/../resources/ibm_im_fixpack"
682+ CUR_FIXPACK="$ARCHIVE_DIR/ibm_im_fixpack.zip"
683+
684+ # Sum any existing fixpack to determine if we have a new one
685+ if [ -f $CUR_FIXPACK ]; then
686+ CUR_MD5=`md5sum "$CUR_FIXPACK" | awk '{print $1}'`
687+ # Calling resource-get here will fetch the fixpack resource.
688+ NEW_FIXPACK=`resource-get 'ibm_im_fixpack' || echo unavailable`
689+ if [ "$NEW_FIXPACK" = "unavailable" ]; then
690+ juju-log "IBM IM: no fixpack to install"
691+ else
692+ NEW_MD5=`md5sum "$NEW_FIXPACK" | awk '{print $1}'`
693+ # If sums don't match, we have a new fp. Configure states so
694+ # we re-run install-ibm-im-fixpack().
695+ if [ "$CUR_MD5" != "$NEW_MD5" ]; then
696+ juju-log "IBM IM: new fixpack detected ($CUR_FIXPACK with $CUR_MD5 versus $NEW_FIXPACK with $NEW_MD5)"
697+ rm -rf $ARCHIVE_DIR
698+ remove_state 'ibm-im.updated'
699+ else
700+ juju-log "IBM IM: no new fixpack to install"
701+ fi
702+ fi
703+ fi
704+ fi
705+}
706+
707
708 reactive_handler_main
709
710=== removed file 'tests/00-setup'
711--- tests/00-setup 2016-04-25 07:15:10 +0000
712+++ tests/00-setup 1970-01-01 00:00:00 +0000
713@@ -1,21 +0,0 @@
714-#!/bin/bash
715-
716-
717-IM_CURL_URL=${IM_CURL_URL?Error: IBM IM curl_url be defined in tests/00-setup}
718-IM_CURL_OPTS=${IM_CURL_OPTS?Error: IBM IM curl_OPTS be defined in tests/00-setup}
719-IM_LICENSE=${IM_LICENSE?Error: IBM IM License accepted value must be defined in tests/00-setup}
720-IM_FP_PACKAGE=${IM_FP_PACKAGE?Error: IBM IM FP Package value must be defined in tests/00-setup}
721-
722-# Add a local configuration file
723-cat << EOF > local.yaml
724-im:
725- im_curl_url: "$IM_CURL_URL"
726- im_curl_opts: "$IM_CURL_OPTS"
727- im_license_accepted: "$IM_LICENSE"
728- im_ibm_im_fp_package: "$IM_FP_PACKAGE"
729-EOF
730-
731-sudo add-apt-repository ppa:juju/stable -y
732-sudo apt-get update
733-sudo apt-get -y install unzip
734-sudo apt-get install amulet python3 -y
735
736=== added file 'tests/01-deploy.py'
737--- tests/01-deploy.py 1970-01-01 00:00:00 +0000
738+++ tests/01-deploy.py 2016-06-23 19:40:22 +0000
739@@ -0,0 +1,29 @@
740+#!/usr/bin/env python3
741+
742+import amulet
743+import re
744+import unittest
745+
746+
747+class TestDeploy(unittest.TestCase):
748+ """
749+ Deployment test for the IBM IM charm.
750+
751+ This charm doesn't do much by itself, so we expect functional
752+ tests to happen in the charms that use this layer (for example, websphere).
753+ """
754+ def setUp(self):
755+ self.d = amulet.Deployment(series='trusty')
756+ self.d.add('ibm-im', 'cs:~ibmcharmers/trusty/ibm-im')
757+ self.d.setup(timeout=900)
758+ self.d.sentry.wait(timeout=1800)
759+
760+ def test_deploy_with_placeholder_resource(self):
761+ # The status message when using placeholder resources will include the
762+ # string "ibm_im_installer resource". If we see that, the test is
763+ # successful.
764+ sentry_re = re.compile('ibm_im_installer resource')
765+ self.d.sentry.wait_for_messages({"ibm-im": sentry_re})
766+
767+if __name__ == '__main__':
768+ unittest.main()
769
770=== removed file 'tests/10-bundles-test.py'
771--- tests/10-bundles-test.py 2016-04-25 07:15:10 +0000
772+++ tests/10-bundles-test.py 1970-01-01 00:00:00 +0000
773@@ -1,84 +0,0 @@
774-#!/usr/bin/env python3
775-
776-# This amulet test deploys the bundles.yaml file in this directory.
777-
778-import os
779-import unittest
780-import yaml
781-import amulet
782-import sys
783-import time
784-import requests
785-
786-# Lots of prereqs on this charm so give it a large timeout accordingly
787-seconds_to_wait = 20000
788-
789-
790-class BundleTest(unittest.TestCase):
791- """ Create a class for testing the charm in the unit test framework. """
792- @classmethod
793- def setUpClass(cls):
794- """ Set up an amulet deployment using the bundle. """
795- d = amulet.Deployment(juju_env='local', series='trusty')
796- local_path = os.path.join(os.path.dirname(__file__), 'local.yaml')
797- with open(local_path, "r") as fd:
798- config = yaml.safe_load(fd)
799-
800- curl_url = config.get('im').get('im_curl_url')
801- print('Using im_curl_url %s' % curl_url)
802- # Test if a IBM im curl url is defined
803- if not curl_url:
804- print("You need to define a im_curl_url.\n"
805- "Edit local.yaml or tests/00-setup and run it again.")
806- sys.exit(1)
807-
808- curl_opts = config.get('im').get('im_curl_opts')
809- print('Using im_curl_opts %s' % curl_opts)
810- # Test if IBM curl_opts is defined
811- if not curl_opts:
812- print("You need to define a curl_opts."
813- " repository.\n Edit local.yaml or tests/00-setup"
814- " and run it again.")
815- sys.exit(1)
816-
817- license_accepted = config.get('im').get('im_license_accepted')
818- print('Using license_accepted %s' % license_accepted)
819- # Test if a license_accepted is defined
820- if not license_accepted:
821- print("You need to define a license_accepted for the IBM IM product"
822- " repository.\n Edit local.yaml or tests/00-setup"
823- " and run it again.")
824- sys.exit(1)
825-
826- ibm_im_fp_package = config.get('im').get('im_ibm_im_fp_package')
827- print('Using ibm_im_fp_package %s' % ibm_im_fp_package)
828- # Test if a password for the repository is defined
829- if not ibm_im_fp_package:
830- print("You need to define a ibm_im_fp_package for the IBM IM updation"
831- " repository.\n Edit local.yaml or tests/00-setup"
832- " and run it again.")
833- sys.exit(1)
834-
835- d.add('ibm-im')
836-
837- # Software doesn't actually install until you accept the license
838- d.configure('ibm-im', {'license_accepted': license_accepted,
839- 'curl_url': curl_url,
840- 'curl_opts': curl_opts,
841- 'ibm_im_fp_package': ibm_im_fp_package})
842-
843- d.setup(seconds_to_wait)
844- d.sentry.wait(seconds_to_wait)
845- cls.d = d
846-
847- def test_deployed(self):
848- self.assertTrue(self.d.deployed)
849- unit = self.d.sentry['ibm-im'][0]
850- cmd = "cd /opt/IBM/InstallationManager"
851- output, code = unit.run(cmd)
852- if code != 0:
853- message = 'IM is not installed as im path doesnt exist'
854- amulet.raise_status(amulet.FAIL, msg=message)
855-
856-if __name__ == '__main__':
857- unittest.main()
858
859=== added file 'tests/tests.yaml'
860--- tests/tests.yaml 1970-01-01 00:00:00 +0000
861+++ tests/tests.yaml 2016-06-23 19:40:22 +0000
862@@ -0,0 +1,4 @@
863+packages:
864+ - amulet
865+ - python3
866+ - unzip

Subscribers

People subscribed via source and target branches