diff -ur install_scripts.orig/deployMultipleTomcats.py install_scripts/deployMultipleTomcats.py
old
|
new
|
|
38 | 38 | import sys |
39 | 39 | import os |
40 | 40 | import xml.dom.minidom |
41 | | import urlparse |
| 41 | #import urlparse |
| 42 | from urllib.parse import urlparse |
42 | 43 | import shutil |
43 | 44 | |
44 | 45 | def deployMultipleTomcats(destFolder): |
45 | 46 | tomcatHome = os.getenv("TOMCAT_HOME") |
46 | 47 | if tomcatHome == None: |
47 | | print "We determine the source Tomcat distribution using the environment variable TOMCAT_HOME which does not seem to be set." |
| 48 | print("We determine the source Tomcat distribution using the environment variable TOMCAT_HOME which does not seem to be set.") |
48 | 49 | sys.exit(1) |
49 | 50 | thisAppliance = os.getenv("ARCHAPPL_MYIDENTITY") |
50 | 51 | if thisAppliance == None: |
51 | | print "We determine the identity of this appliance using the environment variable ARCHAPPL_MYIDENTITY which does not seem to be set." |
| 52 | print("We determine the identity of this appliance using the environment variable ARCHAPPL_MYIDENTITY which does not seem to be set.") |
52 | 53 | sys.exit(1) |
53 | 54 | appliancesXML = os.getenv("ARCHAPPL_APPLIANCES") |
54 | 55 | if appliancesXML == None: |
55 | | print "We determine the location of the appliances.xml file using the environment variable ARCHAPPL_APPLIANCES which does not seem to be set." |
| 56 | print("We determine the location of the appliances.xml file using the environment variable ARCHAPPL_APPLIANCES which does not seem to be set.") |
56 | 57 | sys.exit(1) |
57 | 58 | |
58 | | print "Using\n\ttomcat installation at", tomcatHome, "\n\tto generate deployments for appliance", thisAppliance, "\n\tusing configuration info from", appliancesXML, "\n\tinto folder", destFolder |
| 59 | print("Using\n\ttomcat installation at", tomcatHome, "\n\tto generate deployments for appliance", thisAppliance, "\n\tusing configuration info from", appliancesXML, "\n\tinto folder", destFolder) |
59 | 60 | |
60 | 61 | # Parse the tomcat/conf/server.xml file and determine the stop start port |
61 | 62 | # We start incrementing and use this port+1 for each of the new webapps |
… |
… |
|
63 | 64 | serverdom = xml.dom.minidom.parse(tomcatServerConfSrc); |
64 | 65 | serverStopStartPort = serverdom.getElementsByTagName('Server').item(0).getAttribute('port') |
65 | 66 | if int(serverStopStartPort) == 8005: |
66 | | print "The start/stop port is the standard Tomcat start/stop port. Changing it to something else random - 16000" |
| 67 | print("The start/stop port is the standard Tomcat start/stop port. Changing it to something else random - 16000") |
67 | 68 | serverStopStartPort='16000' |
68 | 69 | newServerStopStartPort = int(serverStopStartPort)+1 |
69 | | print 'The stop/start ports for the new instance will being at ', newServerStopStartPort |
| 70 | print('The stop/start ports for the new instance will being at ', newServerStopStartPort) |
70 | 71 | |
71 | 72 | # Parse the appliances.xml and determine the ports for the HTTP listeners |
72 | 73 | appliancesXMLDOM = xml.dom.minidom.parse(appliancesXML) |
… |
… |
|
81 | 82 | engineUrl = appliance.getElementsByTagName('engine_url').item(0).firstChild.data |
82 | 83 | etlUrl = appliance.getElementsByTagName('etl_url').item(0).firstChild.data |
83 | 84 | retrievalUrl = appliance.getElementsByTagName('retrieval_url').item(0).firstChild.data |
84 | | httplistenerports['mgmt'] = urlparse.urlparse(mgmtUrl).port |
85 | | httplistenerports['engine'] = urlparse.urlparse(engineUrl).port |
86 | | httplistenerports['etl'] = urlparse.urlparse(etlUrl).port |
87 | | httplistenerports['retrieval'] = urlparse.urlparse(retrievalUrl).port |
| 85 | |
| 86 | httplistenerports['mgmt'] = urlparse(mgmtUrl).port |
| 87 | httplistenerports['engine'] = urlparse(engineUrl).port |
| 88 | httplistenerports['etl'] = urlparse(etlUrl).port |
| 89 | httplistenerports['retrieval'] = urlparse(retrievalUrl).port |
88 | 90 | |
89 | 91 | for app in ['mgmt', 'engine', 'etl', 'retrieval']: |
90 | 92 | # Delete any existing subfolders if any and make new ones. |
91 | 93 | subFolder = destFolder + '/' + app |
92 | 94 | if os.access(subFolder, os.W_OK): |
93 | | print "Removing ", subFolder |
| 95 | print("Removing ", subFolder) |
94 | 96 | shutil.rmtree(subFolder) |
95 | | print "Generating tomcat folder for ", app, " in location", subFolder |
| 97 | print("Generating tomcat folder for ", app, " in location", subFolder) |
96 | 98 | os.makedirs(subFolder) |
97 | 99 | # See http://kief.com/running-multiple-tomcat-instances-on-one-server.html for the steps we are using here. |
98 | 100 | shutil.copytree(tomcatHome + '/conf', subFolder + '/conf') |
… |
… |
|
111 | 113 | httplistenerNode.setAttribute('port', str(httplistenerports[app])) |
112 | 114 | haveSetConnector = True |
113 | 115 | else: |
114 | | print "Commenting connector with protocol ", httplistenerNode.getAttribute('protocol'), ". If you do need this connector, you should un-comment this." |
| 116 | print("Commenting connector with protocol ", httplistenerNode.getAttribute('protocol'), ". If you do need this connector, you should un-comment this.") |
115 | 117 | comment = httplistenerNode.ownerDocument.createComment(httplistenerNode.toxml()) |
116 | 118 | httplistenerNode.parentNode.replaceChild(comment, httplistenerNode) |
117 | 119 | if haveSetConnector == False: |
… |
… |
|
124 | 126 | |
125 | 127 | if __name__ == "__main__": |
126 | 128 | if len(sys.argv) < 2: |
127 | | print "Usage: ", sys.argv[0], "<DeploymentFolder>" |
| 129 | print("Usage: ", sys.argv[0], "<DeploymentFolder>") |
128 | 130 | sys.exit(1) |
129 | 131 | deployMultipleTomcats(sys.argv[1]) |
130 | 132 | |