81
82
http_server_installers = (http_installer1, http_installer2, http_installer3)
82
83
CHARM_DIR = os.getcwd()
83
os.makedirs(CHARM_DIR+"/../resources/HTTP")
84
if os.path.exists(CHARM_DIR+"/../resources/HTTP"):
85
hookenv.log("IBM HTTP: dir exist already.")
87
os.makedirs(CHARM_DIR+"/../resources/HTTP")
84
88
if os.path.exists(CHARM_DIR+"/../resources/HTTP/disk1") and os.path.exists(CHARM_DIR+"/../resources/HTTP/disk2") and os.path.exists(CHARM_DIR+"/../resources/HTTP/disk3"):
85
hookenv.log("HTTP package contents extracted already.")
87
for i in http_server_installers:
89
hookenv.log("Extracting HTTP package contents.")
90
with zipfile.ZipFile(filename) as z:
91
z.extractall(CHARM_DIR+"/../resources/HTTP")
92
hookenv.log("extracted")
93
#checking whether zip files extracted properly
94
if not os.path.exists(CHARM_DIR+"/../resources/HTTP/disk1") :
95
hookenv.log("IBM HTTP: Unable to extract the HTTP package content. Verify whether the package is corrupt")
96
hookenv.status_set('blocked', 'IBM HTTP Server package is corrupt')
97
shutil.rmtree(CHARM_DIR+"/../resources/HTTP")
100
hookenv.log("IBM HTTP: HTTP Server packages extracted successfully and available for installation")
101
http_repo = str(CHARM_DIR)+"/../resources/HTTP"
103
hookenv.status_set('active', "IBM HTTP Server: Installing HTTP Server")
89
hookenv.log("IBM HTTP: Package contents extracted already.")
91
hookenv.log("IBM HTTP: Extracting HTTP package contents.")
92
#checking whether zip files extracted properly
105
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.IHS.v85', '-repositories', http_repo, '-acceptLicense', '-properties', 'user.ihs.httpPort=80'])
106
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.PLG.v85', '-repositories', http_repo, '-acceptLicense'])
107
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.WCT.v85', '-repositories', http_repo, '-acceptLicense'])
108
hookenv.status_set('active', "IBM HTTP: HTTP Server is installed successfully")
109
set_state('ibm-http-server.installed')
94
for i in http_server_installers:
96
with zipfile.ZipFile(filename) as z:
97
z.extractall(CHARM_DIR+"/../resources/HTTP")
98
hookenv.log("IBM HTTP: HTTP Server packages extracted successfully and available for installation")
110
99
except subprocess.CalledProcessError as e:
112
hookenv.status_set('maintenance', "IBM HTTP Server: Error while installing HTTP")
101
hookenv.log("IBM HTTP: Unable to extract the HTTP package content. Verify whether the package is corrupt")
102
hookenv.status_set('blocked', 'IBM HTTP Server package is corrupt')
103
shutil.rmtree(CHARM_DIR+"/../resources/HTTP")
106
http_repo = str(CHARM_DIR)+"/../resources/HTTP"
107
hookenv.status_set('active', "IBM HTTP: Installing HTTP Server")
109
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.IHS.v85', '-installationDirectory', IHS_install_path, '-repositories', http_repo, '-acceptLicense', '-properties', 'user.ihs.httpPort=80'])
110
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.PLG.v85', '-installationDirectory', PLG_install_path, '-repositories', http_repo, '-acceptLicense'])
111
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.WCT.v85', '-installationDirectory', WCT_install_path, '-repositories', http_repo, '-acceptLicense'])
112
hookenv.status_set('active', "IBM HTTP: HTTP Server is installed successfully")
113
set_state('ibm-http-server.installed')
114
except subprocess.CalledProcessError as e:
116
hookenv.status_set('maintenance', "IBM HTTP: Error while installing HTTP")
115
119
elif "ppc64le" in ARCHITECTURE:
116
120
print ("architecture is ppc64le")
118
122
hookenv.log('IBM HTTP: fetching the ibm__http_power_installer resource', 'INFO')
119
123
hookenv.status_set('active', 'fetching the ibm_http_power_installer resource')
120
124
http_power_installer = hookenv.resource_get('ibm_http_power_installer')
121
hookenv.status_set('active', 'fetched ibm_http_power_installer resource')
126
# If we don't have a package, report blocked status; we can't proceed.
127
if (http_power_installer == False):
128
hookenv.log('IBM HTTP: missing the required ibm_http resources', 'INFO')
129
hookenv.status_set('blocked', 'IBM HTTP Server required packages are missing')
123
132
command = ["file", http_power_installer]
124
133
p1 = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
125
134
output, err = p1.communicate()
126
135
http_power_installer_msg = str(output)
128
# If we don't have a package, report blocked status; we can't proceed.
129
if (http_power_installer == False):
130
hookenv.log('IBM HTTP: missing the required ibm_http resources', 'INFO')
131
hookenv.status_set('blocked', 'IBM HTTP Server required packages are missing')
133
137
if "empty" in http_power_installer_msg:
134
138
hookenv.log('IBM HTTP: missing the required ibm_http resources,empty packages are found', 'INFO')
135
139
hookenv.status_set('blocked', 'IBM HTTP Server required packages are missing.Please provide actual packages to install')
138
142
CHARM_DIR = os.getcwd()
139
os.makedirs(CHARM_DIR+"/../resources/HTTP")
140
print ("HTTP created")
143
if os.path.exists(CHARM_DIR+"/../resources/HTTP"):
144
hookenv.log("IBM HTTP: dir exist already.")
146
os.makedirs(CHARM_DIR+"/../resources/HTTP")
141
147
if os.path.exists(CHARM_DIR+"/../resources/HTTP/disk1"):
142
hookenv.log("HTTP package contents extracted already.")
144
zip_ref = zipfile.ZipFile(http_power_installer, 'r')
145
zip_ref.extractall(CHARM_DIR+"/../resources/HTTP")
147
hookenv.log("extracted")
149
#checking whether zip files extracted properly
150
if not os.path.exists(CHARM_DIR+"/../resources/HTTP/disk1") :
151
hookenv.log("IBM HTTP: Unable to extract the HTTP package content. Verify whether the package is corrupt")
152
hookenv.status_set('blocked', 'IBM HTTP Server package is corrupt')
153
shutil.rmtree(CHARM_DIR+"/../resources/HTTP")
156
hookenv.log("IBM HTTP: HTTP Server packages extracted successfully and available for installation")
157
http_repo = str(CHARM_DIR)+"/../resources/HTTP"
159
hookenv.status_set('active', "IBM HTTP Server: Installing HTTP Server")
148
hookenv.log("IBM HTTP: package contents extracted already.")
150
hookenv.log("IBM HTTP: Extracting HTTP package contents.")
151
#checking whether zip files extracted properly
161
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.IHS.le.v85', '-repositories', http_repo, '-acceptLicense', '-properties', 'user.ihs.httpPort=80'])
162
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.PLG.le.v85', '-repositories', http_repo, '-acceptLicense'])
163
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.WCT.le.v85', '-repositories', http_repo, '-acceptLicense'])
164
hookenv.status_set('active', "IBM HTTP: HTTP Server is installed successfully")
165
set_state('ibm-http-server.installed')
153
zip_ref = zipfile.ZipFile(http_power_installer, 'r')
154
zip_ref.extractall(CHARM_DIR+"/../resources/HTTP")
156
hookenv.log("IBM HTTP: HTTP Server packages extracted successfully and available for installation")
166
157
except subprocess.CalledProcessError as e:
168
hookenv.status_set('maintenance', "IBM HTTP Server: Error while installing HTTP")
159
hookenv.log("IBM HTTP: Unable to extract the HTTP package content. Verify whether the package is corrupt")
160
hookenv.status_set('blocked', 'IBM HTTP Server package is corrupt')
161
shutil.rmtree(CHARM_DIR+"/../resources/HTTP")
164
http_repo = str(CHARM_DIR)+"/../resources/HTTP"
165
hookenv.status_set('active', "IBM HTTP: Installing HTTP Server")
167
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.IHS.le.v85', '-installationDirectory', IHS_install_path, '-repositories', http_repo, '-acceptLicense', '-properties', 'user.ihs.httpPort=80'])
168
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.PLG.le.v85', '-installationDirectory', PLG_install_path, '-repositories', http_repo, '-acceptLicense'])
169
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.WCT.le.v85', '-installationDirectory', WCT_install_path, '-repositories', http_repo, '-acceptLicense'])
170
hookenv.status_set('active', "IBM HTTP: HTTP Server is installed successfully")
171
set_state('ibm-http-server.installed')
172
except subprocess.CalledProcessError as e:
174
hookenv.status_set('maintenance', "IBM HTTP: Error while installing HTTP")
171
177
@when ('ibm-http-server.installed')
172
178
@when_not ('ibm-http-server.updated')
223
227
http_fixpack_msg4 = str(output4)
225
229
if (("empty" in http_fixpack_msg1) or ("empty" in http_fixpack_msg2) or ("empty" in http_fixpack_msg3) or ("empty" in http_fixpack_msg4)):
226
hookenv.log('IBM HTTP: no ibm_http_server_fixpack to install', 'INFO')
230
hookenv.log('IBM HTTP: no ibm_http_server_fixpack to install,empty packages found', 'INFO')
227
231
hookenv.status_set('active', 'IBM HTTP is ready')
230
234
http_fixpack_installers = (http_fixpack1, http_fixpack2)
231
235
http_WCT_fixpack_installers = (http_WCT_fixpack1, http_WCT_fixpack2)
232
236
CHARM_DIR = os.getcwd()
233
os.makedirs(CHARM_DIR+"/../resources/HTTP_FP")
234
os.makedirs(CHARM_DIR+"/../resources/HTTP_WCT_FP")
235
print ("HTTP_FP and HTTP_WCT_FP created")
236
if os.path.exists(CHARM_DIR+"/../resources/HTTP_FP/disk1"):
237
hookenv.log("HTTP fixpack_package contents extracted already.")
237
if os.path.exists(CHARM_DIR+"/../resources/HTTP_FP"):
238
hookenv.log("HTTP_FP dir exist already.")
240
os.makedirs(CHARM_DIR+"/../resources/HTTP_FP")
241
if os.path.exists(CHARM_DIR+"/../resources/HTTP_WCT_FP"):
242
hookenv.log("HTTP_WCT_FP dir exist already.")
244
os.makedirs(CHARM_DIR+"/../resources/HTTP_WCT_FP")
245
hookenv.log("Extracting HTTP fixpack package contents.")
246
#checking whether zip files extracted properly
239
248
for i in http_fixpack_installers:
242
hookenv.log("Extracting HTTP fixpack package contents.")
250
hookenv.log("IBM HTTP: Extracting HTTP fixpack package contents.")
243
251
with zipfile.ZipFile(filename) as z:
244
252
z.extractall(CHARM_DIR+"/../resources/HTTP_FP")
245
hookenv.log("extracted")
246
if os.path.exists(CHARM_DIR+"/../resources/HTTP_WCT_FP/Offerings"):
247
hookenv.log("HTTP fixpack_WCT_package contents extracted already.")
253
hookenv.log("IBM HTTP: HTTP_FP Server packages extracted successfully")
254
except subprocess.CalledProcessError as e:
256
hookenv.log("IBM HTTP: Unable to extract the HTTP_FP package content. Verify whether the package is corrupt")
257
hookenv.status_set('blocked', 'IBM HTTP_FP Server package is corrupt')
258
shutil.rmtree(CHARM_DIR+"/../resources/HTTP_FP")
260
hookenv.log("IBM HTTP: Extracting HTTP WCT fixpack package contents.")
249
262
for i in http_WCT_fixpack_installers:
252
hookenv.log("Extracting HTTP WCT fixpack package contents.")
264
hookenv.log("IBM HTTP: Extracting HTTP WCT fixpack package contents.")
253
265
with zipfile.ZipFile(filename) as z:
254
266
z.extractall(CHARM_DIR+"/../resources/HTTP_WCT_FP")
255
hookenv.log("extracted")
257
#checking whether zip files extracted properly
258
if not os.path.exists(CHARM_DIR+"/../resources/HTTP_WCT_FP"):
259
hookenv.log("IBM HTTP: Unable to extract the HTTP_FP package content. Verify whether the package is corrupt")
260
hookenv.status_set('blocked', 'IBM HTTP_FP Server package is corrupt')
263
hookenv.log("IBM HTTP: HTTP_FP Server packages extracted successfully and available for installation")
264
http_FP_repo = str(CHARM_DIR)+"/../resources/HTTP_FP"
265
http_WCT_FP_repo = str(CHARM_DIR)+"/../resources/HTTP_WCT_FP"
267
hookenv.status_set('active', "IBM HTTP Server: Updating HTTP Server")
268
if "x86_64" in ARCHITECTURE:
270
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.IHS.v85', '-repositories', http_FP_repo, '-acceptLicense', '-properties', 'user.ihs.httpPort=80'])
271
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.PLG.v85', '-repositories', http_FP_repo, '-acceptLicense'])
272
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.WCT.v85', '-repositories', http_WCT_FP_repo, '-acceptLicense'])
273
hookenv.status_set('active', "IBM HTTP: HTTP Server is updated successfully")
274
set_state('ibm-http-server.updated')
275
except subprocess.CalledProcessError as e:
277
hookenv.status_set('maintenance', "IBM HTTP Server: Error while updating HTTP")
279
elif "ppc64le" in ARCHITECTURE:
281
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.IHS.le.v85', '-repositories', http_FP_repo, '-acceptLicense', '-properties', 'user.ihs.httpPort=80'])
282
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.PLG.le.v85', '-repositories', http_FP_repo, '-acceptLicense'])
283
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.WCT.le.v85', '-repositories', http_WCT_FP_repo, '-acceptLicense'])
284
hookenv.status_set('active', "IBM HTTP: HTTP Server is updated successfully")
285
set_state('ibm-http-server.updated')
286
except subprocess.CalledProcessError as e:
288
hookenv.status_set('maintenance', "IBM HTTP Server: Error while updating HTTP")
267
hookenv.log("IBM HTTP: HTTP_WCT_FP Server packages extracted successfully")
268
except subprocess.CalledProcessError as e:
270
hookenv.log("IBM HTTP: Unable to extract the HTTP_WCT_FP package content. Verify whether the package is corrupt")
271
hookenv.status_set('blocked', 'IBM HTTP_WCT_FP Server package is corrupt')
272
shutil.rmtree(CHARM_DIR+"/../resources/HTTP_WCT_FP")
275
http_FP_repo = str(CHARM_DIR)+"/../resources/HTTP_FP"
276
http_WCT_FP_repo = str(CHARM_DIR)+"/../resources/HTTP_WCT_FP"
277
hookenv.status_set('active', "IBM HTTP: Updating HTTP Server")
278
if "x86_64" in ARCHITECTURE:
280
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.IHS.v85', '-installationDirectory', IHS_install_path, '-repositories', http_FP_repo, '-acceptLicense', '-properties', 'user.ihs.httpPort=80'])
281
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.PLG.v85', '-installationDirectory', PLG_install_path, '-repositories', http_FP_repo, '-acceptLicense'])
282
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.WCT.v85', '-installationDirectory', WCT_install_path, '-repositories', http_WCT_FP_repo, '-acceptLicense'])
283
hookenv.status_set('active', "IBM HTTP: HTTP Server is updated successfully")
284
set_state('ibm-http-server.updated')
285
except subprocess.CalledProcessError as e:
287
hookenv.status_set('maintenance', "IBM HTTP: Error while updating HTTP")
289
elif "ppc64le" in ARCHITECTURE:
291
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.IHS.le.v85', '-installationDirectory', IHS_install_path, '-repositories', http_FP_repo, '-acceptLicense', '-properties', 'user.ihs.httpPort=80'])
292
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.PLG.le.v85', '-installationDirectory', PLG_install_path, '-repositories', http_FP_repo, '-acceptLicense'])
293
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'install', 'com.ibm.websphere.WCT.le.v85', '-installationDirectory', WCT_install_path, '-repositories', http_WCT_FP_repo, '-acceptLicense'])
294
hookenv.status_set('active', "IBM HTTP: HTTP Server is updated successfully")
295
set_state('ibm-http-server.updated')
296
except subprocess.CalledProcessError as e:
298
hookenv.status_set('maintenance', "IBM HTTP: Error while updating HTTP")
291
301
@hook('upgrade-charm')
292
302
def check_fixpack():
299
309
CHARM_DIR = os.getcwd()
300
310
ARCHIVE_DIR1 = str(CHARM_DIR)+"/../resources/ibm_http_server_fixpack1"
301
311
ARCHIVE_DIR2 = str(CHARM_DIR)+"/../resources/ibm_http_server_fixpack2"
312
ARCHIVE_DIR3 = str(CHARM_DIR)+"/../resources/ibm_http_server_WCT_fixpack1"
313
ARCHIVE_DIR4 = str(CHARM_DIR)+"/../resources/ibm_http_server_WCT_fixpack2"
302
314
CUR_FIXPACK1 = str(ARCHIVE_DIR1)+"/ibm_http_server_fixpack1.zip"
303
315
CUR_FIXPACK2 = str(ARCHIVE_DIR2)+"/ibm_http_server_fixpack2.zip"
316
CUR_FIXPACK3 = str(ARCHIVE_DIR3)+"/ibm_http_server_WCT_fixpack1.zip"
317
CUR_FIXPACK4 = str(ARCHIVE_DIR4)+"/ibm_http_server_WCT_fixpack2.zip"
305
319
# Sum any existing fixpack to determine if we have a new one
306
if os.path.exists(ARCHIVE_DIR1+"/ibm_http_server_fixpack1.zip") and os.path.exists(ARCHIVE_DIR2+"/ibm_http_server_fixpack2.zip"):
320
if (os.path.exists(ARCHIVE_DIR1+"/ibm_http_server_fixpack1.zip") and os.path.exists(ARCHIVE_DIR2+"/ibm_http_server_fixpack2.zip") and os.path.exists(ARCHIVE_DIR3+"/ibm_http_server_WCT_fixpack1.zip") and os.path.exists(ARCHIVE_DIR4+"/ibm_http_server_WCT_fixpack2.zip")):
321
hookenv.log("IBM HTTP: Checking checksum values of CUR_Fixpacks")
307
322
command1 = ["md5sum", CUR_FIXPACK1]
308
323
p1 = subprocess.Popen(command1, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
309
324
output1, err = p1.communicate()
310
CUR_FP1_MD5 = str(output1)
325
value1 = output1.split()
326
CUR_FP1_MD5 = str(value1[0])
313
328
command2 = ["md5sum", CUR_FIXPACK2]
314
329
p2 = subprocess.Popen(command2, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
315
330
output2, err = p2.communicate()
316
CUR_FP2_MD5 = str(output2)
331
value2 = output2.split()
332
CUR_FP2_MD5 = str(value2[0])
334
command3 = ["md5sum", CUR_FIXPACK3]
335
p3 = subprocess.Popen(command3, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
336
output3, err = p3.communicate()
337
value3 = output3.split()
338
CUR_FP3_MD5 = str(value3[0])
340
command4 = ["md5sum", CUR_FIXPACK4]
341
p4 = subprocess.Popen(command4, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
342
output4, err = p4.communicate()
343
value4 = output4.split()
344
CUR_FP4_MD5 = str(value4[0])
319
346
# Calling resource-get here will fetch the fixpack resource.
320
347
NEW_FIXPACK1 = hookenv.resource_get('ibm_http_server_fixpack1')
321
348
NEW_FIXPACK2 = hookenv.resource_get('ibm_http_server_fixpack2')
322
if (NEW_FIXPACK1 == False or NEW_FIXPACK2 == False):
323
hookenv.log("IBM Http: no fixpack to install")
349
NEW_FIXPACK3 = hookenv.resource_get('ibm_http_server_WCT_fixpack1')
350
NEW_FIXPACK4 = hookenv.resource_get('ibm_http_server_WCT_fixpack2')
351
if (NEW_FIXPACK1 == False or NEW_FIXPACK2 == False or NEW_FIXPACK3 == False or NEW_FIXPACK4 == False):
352
hookenv.log("IBM HTTP: no fixpack to install")
325
command3 = ["md5sum", NEW_FIXPACK1]
326
p3 = subprocess.Popen(command3, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
327
output3, err = p3.communicate()
328
NEW_FP1_MD5 = str(output3)
331
command4 = ["md5sum", NEW_FIXPACK2]
332
p4 = subprocess.Popen(command4, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
333
output4, err = p4.communicate()
334
NEW_FP2_MD5 = str(output4)
354
hookenv.log("IBM HTTP: Checking checksum of NEW_FIXPACKS")
355
command5 = ["md5sum", NEW_FIXPACK1]
356
p5 = subprocess.Popen(command5, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
357
output5, err = p5.communicate()
358
value5 = output5.split()
359
NEW_FP1_MD5 = str(value5[0])
361
command6 = ["md5sum", NEW_FIXPACK2]
362
p6 = subprocess.Popen(command6, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
363
output6, err = p6.communicate()
364
value6 = output6.split()
365
NEW_FP2_MD5 = str(value6[0])
367
command7 = ["md5sum", NEW_FIXPACK3]
368
p7 = subprocess.Popen(command7, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
369
output7, err = p7.communicate()
370
value7 = output7.split()
371
NEW_FP3_MD5 = str(value7[0])
373
command8 = ["md5sum", NEW_FIXPACK4]
374
p8 = subprocess.Popen(command8, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
375
output8, err = p8.communicate()
376
value8 = output8.split()
377
NEW_FP4_MD5 = str(value8[0])
336
379
# If sums don't match, we have a new fp. Configure states so
337
# we re-run install-ibm-im-fixpack().
338
if not ((CUR_FP1_MD5 == NEW_FP1_MD5) or (CUR_FP2_MD5 == NEW_FP2_MD5)):
339
hookenv.log("IBM HTTP: new fixpack detected")
380
# we re-run install-ibm-http-server-fixpack().
381
if (CUR_FP1_MD5 != NEW_FP1_MD5 or CUR_FP2_MD5 != NEW_FP2_MD5 or CUR_FP3_MD5 != NEW_FP3_MD5 or CUR_FP4_MD5 != NEW_FP4_MD5):
382
hookenv.log("IBM HTTP: new fixpack detected "+CUR_FP1_MD5+"versus"+NEW_FP1_MD5+""+CUR_FP2_MD5+"versus"+NEW_FP2_MD5+""+CUR_FP3_MD5+"versus"+NEW_FP3_MD5+""+CUR_FP4_MD5+"versus"+NEW_FP4_MD5 )
340
383
remove_state ('ibm-http-server.updated')
341
384
shutil.rmtree(CHARM_DIR+"/../resources/HTTP_FP")
385
shutil.rmtree(CHARM_DIR+"/../resources/HTTP_WCT_FP")
343
hookenv.log("IBM HTTP: no new fixpack to install")
387
hookenv.log("IBM HTTP: no new fixpacks to install")
345
389
hookenv.log("IBM HTTP: no new fixpack to install")
383
427
text_file.writelines(lines)
384
428
text_file.close()
386
subprocess.check_call(['/root/IBM/WebSphere/Toolbox/WCT/wctcmd.sh', '-tool', 'pct', '-defLocPathname', '/root/IBM/WebSphere/Plugins', '-defLocName', 'wasplg', '-createDefinition', '-response', '/root/IBM/WebSphere/Toolbox/WCT/res.txt'])
387
http_path = '/root/IBM/HTTPServer/bin'
430
subprocess.check_call(['/opt/IBM/WebSphere/Toolbox/WCT/wctcmd.sh', '-tool', 'pct', '-defLocPathname', '/opt/IBM/WebSphere/Plugins', '-defLocName', 'wasplg', '-createDefinition', '-response', '/opt/IBM/WebSphere/Toolbox/WCT/res.txt'])
431
http_path = '/opt/IBM/HTTPServer/bin'
388
432
subprocess.check_call([http_path +'/apachectl','start'])
389
subprocess.call(['chmod', '-R', '755', '/root/IBM/HTTPServer/'])
433
subprocess.check_call([http_path +'/adminctl','start'])
434
subprocess.call(['chmod', '-R', '755', '/opt/IBM/HTTPServer/'])
390
435
hookenv.status_set('active', "IBM HTTP: HTTP Server started successfully")
391
436
ihs.set_isihsstarted('started')
392
437
except subprocess.CalledProcessError as e:
394
hookenv.status_set('maintenance', "IBM HTTP Server: Error while installing HTTP Server")
439
hookenv.status_set('maintenance', "IBM HTTP: Error while starting HTTP Server")
395
442
@when('test.configured')
396
443
@when_not('ihs.ready')
397
444
def reset_all_states():
398
445
hookenv.log("Resetting all states for test charm")
399
446
remove_state('test.configured')
401
449
@when('ihs.departed')
402
450
def departed_from_was(self):
403
451
hookenv.status_set("maintenance","Relation broken from WAS Base")
404
http_path = '/root/IBM/HTTPServer/bin'
405
subprocess.check_call([http_path +'/apachectl','stop'])
406
hookenv.log("Stopped apachectl server.......")
452
http_path = '/opt/IBM/HTTPServer/bin'
453
if os.path.exists(http_path):
454
subprocess.check_call([http_path +'/apachectl','stop'])
455
subprocess.check_call([http_path +'/adminctl','stop'])
456
hookenv.log("Stopped adminctl and apachectl server")
458
hookenv.log("Stopped adminctl and apachectl server")
459
if os.path.exists(WCT_install_path):
460
subprocess.check_call(['/opt/IBM/WebSphere/Toolbox/WCT/wctcmd.sh', '-tool', 'pct', ' -removeDefinitionLocation', 'wasplg', '-defLocPathname', '/opt/IBM/WebSphere/Plugins'])
461
hookenv.log("Removed webserver definition")
463
hookenv.log("Removed webserver definition")
407
464
hookenv.log("Test charm and WAS Base departed")
408
465
hookenv.log("IBM HTTP: Removing HTTP-Server")
409
466
if "x86_64" in ARCHITECTURE:
411
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.IHS.v85'])
412
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.PLG.v85'])
413
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.WCT.v85'])
468
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.IHS.v85', '-installationDirectory', IHS_install_path])
469
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.PLG.v85', '-installationDirectory', PLG_install_path])
470
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.WCT.v85', '-installationDirectory', WCT_install_path])
414
471
hookenv.status_set('active', "IBM HTTP: HTTP Server is uninstalled successfully")
415
shutil.rmtree('/root/IBM/HTTPServer')
416
shutil.rmtree('/root/IBM/WebSphere/Plugins')
417
shutil.rmtree('/root/IBM/WebSphere/Toolbox')
472
shutil.rmtree('/opt/IBM/HTTPServer')
473
shutil.rmtree('/opt/IBM/WebSphere/Plugins')
474
shutil.rmtree('/opt/IBM/WebSphere/Toolbox')
418
475
remove_state ('test.configured')
419
476
except subprocess.CalledProcessError as e:
421
hookenv.status_set('maintenance', "IBM HTTP Server: Error while uninstalling HTTP")
478
hookenv.status_set('maintenance', "IBM HTTP: Error while uninstalling HTTP")
422
479
elif "ppc64le" in ARCHITECTURE:
424
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.IHS.le.v85'])
425
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.PLG.le.v85'])
426
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.WCT.le.v85'])
481
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.IHS.le.v85', '-installationDirectory', IHS_install_path])
482
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.PLG.le.v85', '-installationDirectory', PLG_install_path])
483
subprocess.check_call([IM_INSTALL_PATH +'/eclipse/tools/imcl', 'uninstall', 'com.ibm.websphere.WCT.le.v85', '-installationDirectory', WCT_install_path])
427
484
hookenv.status_set('active', "IBM HTTP: HTTP Server is uninstalled successfully")
428
shutil.rmtree('/root/IBM/HTTPServer')
429
shutil.rmtree('/root/IBM/WebSphere/Plugins')
430
shutil.rmtree('/root/IBM/WebSphere/Toolbox')
485
shutil.rmtree('/opt/IBM/HTTPServer')
486
shutil.rmtree('/opt/IBM/WebSphere/Plugins')
487
shutil.rmtree('/opt/IBM/WebSphere/Toolbox')
431
488
remove_state ('test.configured')
432
489
except subprocess.CalledProcessError as e:
434
hookenv.status_set('maintenance', "IBM HTTP Server: Error while uninstalling HTTP")
491
hookenv.status_set('maintenance', "IBM HTTP: Error while uninstalling HTTP")