Ubuntu Pastebin

Paste from root at Fri, 8 Jul 2016 19:13:06 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
#!/bin/bash
set -ex

source charms.reactive.sh

charms.reactive -y get_states

WAS_BASE_INSTALL_PATH=/root/IBM/WebSphere/AppServer/V85/BASE
IM_INSTALL_PATH=/opt/IBM/InstallationManager
ARCHITECTURE=`uname -m`
profile_name=`config-get profile_name`
was_admin_name=`config-get was_admin_user`
was_admin_pw=`config-get was_admin_pw`
profilepath=`config-get profile_path`
profile_template_path="$WAS_BASE_INSTALL_PATH/profileTemplates/default"
ihsadminuser="usr"
ihsadminpw="123"
ihsadmingrp="grp"

if [ "$ARCHITECTURE" != "x86_64" -a  "$ARCHITECTURE" != "ppc64le" ]; then
	juju-log "IBM WAS Base: Unsupported platform. IBM WAS Base installed with this Charm supports only the x86_64 and ppc64le platforms."
	status-set blocked "IBM WAS Base: Unsupported architecture"
	exit 1
fi

#Get the cfguser name based on the remote unit name
get_cfgusername()
{
        cfgusername=$1
        cfgusername=`echo $cfgusername | cut -d"/" -f1`
        cfgusername=`echo "$cfgusername" | sed -r 's/-//g' | sed -r 's/ibm//g'`
        cfgusername=`echo "$cfgusername" | awk '{print substr($0,0,5)}'`
        ihsadminuser="$cfgusername$ihsadminuser"
        ihsadminpw="$cfgusername$ihsadminpw"
        ihsadmingrp="$cfgusername$ihsadmingrp"

}

stop_was_base_server() {
	if [ "$1" != "" -a "$1" != $was_admin_name ]; then
		was_admin_name=$1
	fi
	if [ "$2" != "" -a "$2" != $was_admin_pw ]; then
		was_admin_pw=$2
	fi
	if [ "$3" != "" -a "$3" != "$profilepath" ]; then
		profilepath=$3
	fi
	profile_name=`ls $profilepath`
	profile_name=`basename $profile_name`
	juju-log "profile_nmae===="$profile_name"==was_admin_name==="$was_admin_name"====was_admin_pw=="$was_admin_pw"profilepath====$profilepath"
	if [ -d "$profilepath/$profile_name/bin" ]; then
		cd $profilepath/$profile_name/bin/
		if ! ./stopServer.sh server1 -username $was_admin_name -password $was_admin_pw
		then
			status-set blocked "Error while stoping the server"
		else
			status-set active "Server stopped successfully"
			close-port 9060
			close-port 9043
			remove_state 'ibm-was-base.server.started'
		fi
	else
		juju-log "IBM WAS Base: No server to stop, exiting."
	fi
}

install_was_base_fixpack() {
	if [ "$ARCHITECTURE" == "x86_64" ];then
		if $IM_INSTALL_PATH/eclipse/tools/imcl install com.ibm.websphere.BASE.v85 -acceptLicense -repositories $CHARM_DIR/../resources/WAS_BASE/FP -installationDirectory $WAS_BASE_INSTALL_PATH  -showProgress
		then
			set_state 'ibm-was-base.updated'
			status-set active "IBM WAS Base: WAS Base installation upgraded successfully!"
		else
			status-set blocked "IBM WAS Base: Error while upgrading WAS Base!"
			exit 1
		fi
                          
	elif [ "$ARCHITECTURE" == "ppc64le" ];then
		if $IM_INSTALL_PATH/eclipse/tools/imcl install com.ibm.websphere.BASE.le.v85 -acceptLicense -repositories $CHARM_DIR/../resources/WAS_BASE/FP -installationDirectory $WAS_BASE_INSTALL_PATH  -showProgress
		then
			set_state 'ibm-was-base.updated'
			status-set active "IBM WAS Base: WAS Base installation upgraded successfully!"
		else
			status-set blocked "IBM WAS Base: Error while upgrading WAS Base!"
			exit 1
		fi
	fi
}

@when 'ibm-im.installed'
@when_not 'ibm-was-base.installed'
function install_was_base() {
	juju-log "IBM WAS Base: Checking etc/hosts file."
	private_address=`unit-get private-address`
	juju-log "private_address : $private_address"
	cd /etc
	if grep -q "$private_address" hosts
	then
		juju-log "IBM WAS Base: Host file already updated"
	else
		juju-log "IBM WAS Base: Updating Host file"
		echo "$private_address `hostname`" >> /etc/hosts
	fi

	# Get the installable WAS Base resources
	juju-log "IBM WAS Base: fetching the ibm_was_base_installer1 resource"
	status-set maintenance "fetching the ibm_was_base_installer1 resource"
	cfg_was_base_pkg1_name=`resource-get 'ibm_was_base_installer1' || echo unavailable`
	
	juju-log "IBM WAS Base: fetching the ibm_was_base_installer2 resource"
	status-set maintenance "fetching the ibm_was_base_installer2 resource"
	cfg_was_base_pkg2_name=`resource-get 'ibm_was_base_installer2' || echo unavailable`
	
	juju-log "IBM WAS Base: fetching the ibm_was_base_installer3 resource"
	status-set maintenance "fetching the ibm_was_base_installer3 resource"
	cfg_was_base_pkg3_name=`resource-get 'ibm_was_base_installer3' || echo unavailable`
	  
	# If we don't have a package, report blocked status; we can't proceed.
	if [ "$cfg_was_base_pkg1_name" = "unavailable" -o "$cfg_was_base_pkg2_name" = "unavailable" -o "$cfg_was_base_pkg3_name" = "unavailable" ]; then
		juju-log "IBM WAS Base: missing required ibm_was_base_installer resource"
		status-set blocked "missing required ibm_was_base_installer resource"
		exit 0
	fi
	
	juju-log "IBM WAS Base: using $cfg_was_base_pkg1_name $cfg_was_base_pkg2_name $cfg_was_base_pkg3_name as the ibm_was_base_installer resources"
	was_base_installers="$cfg_was_base_pkg1_name $cfg_was_base_pkg2_name $cfg_was_base_pkg3_name"
	juju-log "was_base_installers===$was_base_installers"
	
	for was_pkg in $was_base_installers; do
		juju-log "was_pkg====="$was_pkg
		if [ -f $was_pkg ]; then
			ARCHIVE_DIR=`dirname $was_pkg`
			juju-log "IBM WAS Base: extracting the ibm_was_base_installer resources"
			status-set maintenance "extracting the ibm_was_base_installer resource"
			if [ -d $ARCHIVE_DIR/../WAS_BASE/disk1 -a -d $ARCHIVE_DIR/../WAS_BASE/disk2 -a -d $ARCHIVE_DIR/../WAS_BASE/disk3 ];then
				juju-log "IBM WAS Base: ibm_was_base_installer resources already extracted"
			else
				if [ ! -d $ARCHIVE_DIR/../WAS_BASE ]; then
					mkdir $ARCHIVE_DIR/../WAS_BASE
				fi				
				if ! unzip $was_pkg -d $ARCHIVE_DIR/../WAS_BASE
				then
					juju-log "IBM WAS Base: Unable to extract the WAS Base packages content. Verify whether the package is corrupt."
					# Remove corrupt archive file
					status-set blocked "IBM WAS Base packages are corrupt"
					rm -f $ARCHIVE_DIR
					exit 0
				else
					juju-log "IBM WAS Base: $was_pkg extracted successfully"
				fi
			fi
		fi
	done
	
	juju-log "IBM WAS Base: starting was base installation."
	status-set maintenance "IBM WAS Base: Installing WAS BASE"
	#sh does not work in ubuntu so linking to bash
	juju-log "IBM WAS Base: Unlink /bin/sh"
	unlink /bin/sh
	ln -s /bin/bash /bin/sh
	if [ "$ARCHITECTURE" == "x86_64" ];then
		if $IM_INSTALL_PATH/eclipse/tools/imcl install com.ibm.websphere.BASE.v85 -acceptLicense -repositories $ARCHIVE_DIR/../WAS_BASE -installationDirectory $WAS_BASE_INSTALL_PATH  -showProgress
		then
			set_state 'ibm-was-base.installed'
			status-set active "IBM WAS Base: WAS Base is installed successfully!"
		else
			status-set blocked "IBM WAS Base: WAS Base Installation failed!"
			exit 1
		fi
                          
	elif [ "$ARCHITECTURE" == "ppc64le" ];then
		if $IM_INSTALL_PATH/eclipse/tools/imcl install com.ibm.websphere.BASE.le.v85 -acceptLicense -repositories $ARCHIVE_DIR/../WAS_BASE -installationDirectory $WAS_BASE_INSTALL_PATH  -showProgress
		then
			set_state 'ibm-was-base.installed'
			status-set active "IBM WAS Base: WAS Base is installed successfully!"
		else
			status-set blocked "IBM WAS Base: WAS Base Installation failed!"
			exit 1
		fi
	fi
              
}

@when 'ibm-was-base.installed'
@when_not 'ibm-was-base.updated'
function install_was_base_fixpack(){
	
	# Get the WAS Base fixpack resources
	juju-log "IBM WAS Base: fetching the ibm_was_base_fp1 resource"
	status-set maintenance "fetching the ibm_was_base_fp1 resource"
	if [ ! -f $CHARM_DIR/../resources/ibm_was_base_fp1/ibm_was_base_fp1.zip ]; then
		was_base_fp1=`resource-get 'ibm_was_base_fp1' || echo unavailable`
	fi
	
	juju-log "IBM WAS Base: fetching the ibm_was_base_fp2 resource"
	status-set maintenance "fetching the ibm_was_base_fp2 resource"
	if [ ! -f $CHARM_DIR/../resources/ibm_was_base_fp2/ibm_was_base_fp2.zip ]; then
		was_base_fp2=`resource-get 'ibm_was_base_fp2' || echo unavailable`
	fi
	
	#If we don't have a fixpack, just exit successfully; there's nothing to do.
	if [ "$was_base_fp1" = "unavailable" -a "$was_base_fp2" = "unavailable" ]; then
		juju-log "IBM WAS Base: no ibm_was_base_fixpack packages to install"
		status-set active "IBM WAS Base is ready"
		exit 0
	fi
	
	#If we detect the fixpack is just a placeholder in charm store, just exit successfully; there's nothing to do.
	ibm_was_fp1_isempty=`file $was_base_fp1 | { grep -q empty && echo "True"; } || echo "False"`
	ibm_was_fp2_isempty=`file $was_base_fp2 | { grep -q empty && echo "True"; } || echo "False"`
	if [ "$ibm_was_fp1_isempty" = "True" -a "$ibm_was_fp1_isempty" = "True" ]; then
		juju-log "IBM WAS Base: no ibm_was_base_fixpack packages to install"
		status-set active "IBM WAS Base is ready"
		exit 0
	fi
	was_fixpack_packages="was_base_fp1 was_base_fp2"
	juju-log "IBM WAS Base: Fixpacks provided for upgrade $was_fixpack_packages"
	
	ARCHIVE_DIR=`dirname $was_base_fp1`
	
	if [ ! -d $CHARM_DIR/../resources/WAS_BASE/FP ]; then
		mkdir $CHARM_DIR/../resources/WAS_BASE/FP
	fi
	
	for was_fp_pkg in $was_fixpack_packages; do
		juju-log "was_fp_pkg====="$was_fp_pkg
		if [ -f $was_fp_pkg ]; then
			ARCHIVE_DIR=`dirname $was_fp_pkg`
			juju-log "IBM WAS Base: extracting the ibm_was_base_fp resources"
			status-set maintenance "extracting the ibm_was_base_fp resources"
			if ! unzip $was_fp_pkg -d $ARCHIVE_DIR/../WAS_BASE/FP
				then
					juju-log "IBM WAS Base: Unable to extract the WAS Base fixpack content. Verify whether the package is corrupt."
					# Remove corrupt archive file
					status-set blocked "IBM WAS Base packages are corrupt"
					rm -f $ARCHIVE_DIR
					exit 0
			else
				juju-log "IBM WAS Base: $was_fp_pkg extracted successfully"
			fi
		fi
	done
	if ! charms.reactive is_state 'ibm-was-base.server.started'; then
		stop_was_base_server $was_admin_name $was_admin_pw
	fi		
	install_was_base_fixpack
}

@when 'ibm-was-base.installed'
@when_not 'ibm-was-base.profile.available'
function create_profile(){
	$WAS_BASE_INSTALL_PATH/bin/manageprofiles.sh -create -profileName $profile_name -profilePath $profilepath/$profile_name -templatePath $profile_template_path -enableAdminSecurity true -serverName "server1" -adminUserName $was_admin_name -adminPassword $was_admin_pw
	set_state 'ibm-was-base.profile.available'
}

@when 'ibm-was-base.installed' 'ibm-was-base.profile.available'
@when_not 'ibm-was-base.server.started'
function start_was_base_server() {
	if [ -d $profilepath/$profile_name/bin ]; then
		cd $profilepath/$profile_name/bin/
		if ! ./startServer.sh server1
		then
			status-set blocked "IBM WAS Base: Error while starting the server"
		else
			status-set active "IBM WAS Base: Server started successfully"
			open-port 9060
			open-port 9043
			set_state 'ibm-was-base.server.started'
		fi
	else
		status-set blocked "IBM WAS Base: No server to start, exiting."
		exit 0
	fi
}

@when_not_all 'config.default.profile_name' 'config.default.was_admin_user' 'config.default.was_admin_pw' 'config.default.profile_path'
@when_any 'config.changed.profile_name' 'config.changed.was_admin_user' 'config.changed.was_admin_pw' 'config.changed.profile_path'
function create_new_profile() {
	if [ -f $CHARM_DIR/files/was_users.txt ]; then
		source $CHARM_DIR/files/was_users.txt
		old_user_name=$user_name
		old_password=$password
		old_profile_path=$profile_path
	else
		touch $CHARM_DIR/files/was_users.txt
	fi
	if [ "$was_admin_pw" == "" ]; then
		status-set blocked "IBM WAS Base: Please set the was admin password through was_admin_pw config option."
		exit 0
	fi
cat > $CHARM_DIR/files/was_users.txt <<EOF
user_name=$was_admin_name
password=$was_admin_pw
profile_path=$profilepath
EOF
	chmod 600 $CHARM_DIR/files/was_users.txt
	juju-log "was_admin_user=$was_admin_name, was_admin_password=$was_admin_pw"
	if [ -d $profilepath -o "$old_profile_path" != "" -a "$old_profile_path" != "$profilepath" ]; then
		if [ "$old_profile_path" != "" -a "$old_profile_path" != "$profilepath" ]; then
			juju-log "old_profile_path===$old_profile_path profilepath=$profilepath"
			old_profile_name=`ls $old_profile_path`
		else
			juju-log "old_profile_path===$old_profile_path profilepath=$profilepath"
			old_profile_name=`ls $profilepath`
		fi
		old_profile_name=`basename $old_profile_name`
		stop_was_base_server $old_user_name $old_password $old_profile_path
		cd /
		$WAS_BASE_INSTALL_PATH/bin/manageprofiles.sh -delete -profileName $old_profile_name
		if [ -d "$old_profile_path" ]; then
			rm -rf $old_profile_path
		else
			juju-log "IBM WAS BASE: profilepath to be deleted $profilepath"
			rm -rf $profilepath
		fi
		remove_state 'ibm-was-base.profile.available'
		juju-log "IBM WAS Base: Removed old profile."
	fi
					
}

@hook 'upgrade-charm'
function check_fixpack(){
	# The upgrade-charm hook will fire when a new resource is pushed for this
	# charm. This is a good time to determine if we need to deal with a new
	# fixpack.
	if ! charms.reactive is_state 'ibm-was-base.updated'; then
		# If there is no prior fixpack installed (because ibm-was-base.updated is not
		# set), do nothing since install_was_base_fixpack will handle that case.
		juju-log "IBM WAS Base: no fixpack has been installed; nothing to upgrade."
		exit 0
	else
		# If we have a fixpack packges already (because ibm-was-base.updated is set),
		# we should fetch the latest fixpack packages and determine if it is new.
		#  - If it is new, set our states so install_was_base_fixpack is called again
		#  - If it is not new, do nothing
		juju-log "IBM WAS Base: scanning for new fixpacks to install"
		WAS_FP1_DIR="$CHARM_DIR/../resources/ibm_was_base_fp1"
		WAS_FP2_DIR="$CHARM_DIR/../resources/ibm_was_base_fp2"
		CUR_FP1="$WAS_FP1_DIR/ibm_was_base_fp1.zip"
		CUR_FP2="$WAS_FP2_DIR/ibm_was_base_fp2.zip"
		if [ -f $CUR_FP1 -a -f  $CUR_FP2 ]; then
			CUR_FP1_MD5=`md5sum "$CUR_FP1" | awk '{print $1}'`
			CUR_FP2_MD5=`md5sum "$CUR_FP2" | awk '{print $1}'`
		fi
		NEW_FP1=`resource-get 'ibm_was_base_fp1' || echo unavailable`
		NEW_FP2=`resource-get 'ibm_was_base_fp2' || echo unavailable`
		
		if [ "$NEW_FP1" = "unavailable" -a "$NEW_FP2" = "unavailable" ]; then
			juju-log "IBM WAS Base: no fixpacks to install"
		elif [ -f $NEW_FP1 -a -f  $NEW_FP2 ]; then
			NEW_FP1_MD5=`md5sum "$NEW_FP1" | awk '{print $1}'`
			NEW_FP2_MD5=`md5sum "$NEW_FP2" | awk '{print $1}'`
		fi
		
		if [ "$CUR_FP1_MD5" != "$NEW_FP1_MD5" -a "$CUR_FP2_MD5" != "$NEW_FP2_MD5" ]; then
			juju-log "IBM WAS Base: new fixpack detected ($CUR_FP1 with $CUR_FP1_MD5 versus $NEW_FP1 with $NEW_FP1_MD5 and $CUR_FP2 with $CUR_FP2_MD5 versus $NEW_FP2 with $NEW_FP2_MD5)"
			rm -rf $CHARM_DIR/../resources/WAS_BASE/FP
			remove_state 'ibm-was-base.updated'
		else
			juju-log "IBM WAS Base: no new fixpack to install"
		fi
	fi
}

@when 'wasbase.available'
function expose_was_base_details(){
	juju-log "************************In expose_was_base_details function ***********"
	was_path=$WAS_BASE_INSTALL_PATH
	was_port='9060'
	host_name=`unit-get private-address`
	services=$(relation_call --state=wasbase.available services)
	for service in $services; do
		juju-log "Creating users for $service"
		juju-log "IBM WAS Base: Creating the users for the IHS Admin Server"
		get_cfgusername $service
		juju-log "Created IHS Admin Server Credentials."
		juju-log "Sending the port number $was_port"
                juju-log "Other vals are was_path = $was_path hostname = $host_name service = $service ihsadminuser = $ihsadminuser ihsadminpw = $ihsadminpw ihsadmingrp = $ihsadmingrp profilename = $profile_name"
                juju-log "***************In expose_was_base_details function**********"
                juju-log "Setting was base details for $service"

                relation_call --state=wasbase.available set_was_details $service $was_path $was_port $host_name $ihsadminuser $ihsadmingrp $ihsadminpw $profile_name || true

	done
}

@when 'wasbase.departed'
function remove_relation(){
	juju-log "Removing relation from IHS."
        for service in $services; do
		juju-log "Calling dismiss for $service"
		 relation_call --state=wasbase.departed dismiss $service || true
	done
	juju-log "Removed relation from IHS"
}

#to pass ssh keys
@when 'wasdb.connected'
@when_not 'ibm-was-base.sshconfigured'
function configure_sshkeys_dbs(){
        SSH_PATH=/root/.ssh
        if [ ! -f  $SSH_PATH/id_rsa.pub ]; then
                juju-log "IBM WAS BASE: Setting up SSH keys."
                ssh-keygen -t rsa -f $SSH_PATH/id_rsa -N ''
        fi
        key="`cat $SSH_PATH/id_rsa.pub`"
        #finger_print="`ssh-keygen -l -f $SSH_PATH/id_rsa.pub`"
        #Pass the DB names to be created to DB2 charm
        dbnames="WASDB"
        juju-log "Key is $key"
        #juju-log "Finger print is $finger_print"
        juju-log "DB names is $dbnames"
        juju-log "******* In pass_ssh_keys function in WAS Base charm ***"
        #to set ssh from the interface
        #relation_call --state=db.connected capture_sskkey $key || true
        # To pass the SSH key and DB names to DB2 charm
        relation_call --state=wasdb.connected set_ssh_keys "$key" || true
        relation_call --state=wasdb.connected set_dbs $dbnames || true
        set_state 'ibm-was-base.sshconfigured'

}

@when 'wasdb.ready'
@when 'ibm-was-base.sshconfigured'
@when_not 'ibm-was-base.db2.available'
function configure_db(){
        juju-log "*******In configure_db reactive function of WAS Base charm*******"
        port=$(relation_call --state=wasdb.connected get_db2_port) || true
        juju-log "I got the port as $port"
        if [ -z "$port" ]; then
                juju-log "No data sent yet"
                exit 0
        fi
        db2_instance=$(relation_call --state=wasdb.connected get_db2_instance_name) || true
        juju-log "I got the db2_instance as $db2_instance"
        db2_path=$(relation_call --state=wasdb.available get_db2_path) || true
        hostname=$(relation_call --state=wasdb.available get_db2_hostname) || true
        dbusername=$(relation_call --state=wasdb.available get_dbusername) || true
        dbuserpw=$(relation_call --state=wasdb.available get_dbuserpw) || true
        juju-log "I got the db2 values $db2_path $hostname $dbusername $dbuserpw"
        juju-log "IBM WAS Base: Copying files from remote - Directory: $db2_path Host:$hostname"
        status-set maintenance "Copying db2 jar files from remote DB2 machine"
        scp  -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$hostname:$db2_path/V10.5/java/db2jcc.jar $CHARM_DIR/files || true
        scp  -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$hostname:$db2_path/V10.5/java/db2jcc4.jar $CHARM_DIR/files || true
        scp  -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$hostname:$db2_path/V10.5/java/db2jcc_license_*.jar $CHARM_DIR/files || true
        juju-log "Copied the files to $CHARM_DIR/files"
        status-set maintenance "db2 jar files copied from remote DB2 machine"
        set_state 'ibm-was-base.db2.available'
        #take the code from db-relation-changed of mobile firset server
        #creation of DB done here
}

@when 'ibm-was-base.db2.available'
@when_not 'wasdb.ready'
function reset_all_states(){

        juju-log " Resetting all states for WAS Base charm"
        remove_state 'ibm-was-base.sshconfigured'
        remove_state 'ibm-was-base.db2.available'
}

@when 'wasdb.departed'
function departed_from_db2(){
        status-set maintenance "Relatin broken from db2"
        juju-log "WAS Base cahrm and db2 departed"
}

@when 'wasmessaging.ready'
@when_not 'ibm-was-base.mq.available'
function get_mq_instance_details(){
	juju-log "IBM WAS BASE: Inside get_mq_instance_details function."
	juju-log "*******In get_mq_instance_details reactive function of WAS Base charm*******"
        port=$(relation_call --state=wasmessaging.connected get_mq_port) || true
        juju-log "I got the port as $port"
        if [ -z "$port" ]; then
                juju-log "No data sent yet"
                exit 0
        fi
	QM_Name=$(relation_call --state=wasmessaging.available get_qm_name) || true
        hostname=$(relation_call --state=wasmessaging.available get_mq_hostname) || true
        Qname=$(relation_call --state=wasmessaging.available get_qname) || true

	#MQvalues=$(relation_call --state=messaging.connected get_mq_values) || true
	status-set active "IBM WAS Base: Got MQ instance details."
        juju-log "values of MQ in WAS Charm port=$port QM_Name=$QM_Name hostname=$hostname Qname=$Qname"
	set_state 'ibm-was-base.mq.available'
}

@when 'ibm-was-base.mq.available'
@when_not 'wasmessaging.ready'
function reset_all_mq_relation_states(){
	juju-log " Resetting all MQ states for WAS Base charm"
	remove_state 'ibm-was-base.mq.available'
}

@when 'wasmessaging.departed'
function departed_from_mq(){
	status-set maintenance "Relatin broken from mq"
	juju-log "WAS Base cahrm and mq departed"
}

reactive_handler_main
Download as text