Skip to content

Commit 458e965

Browse files
committed
remove fixed port numbers for HTTP/HTTPS connections
1 parent 37ae236 commit 458e965

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

source/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ COPY ./gpfsConfig/mmsdrfs* /var/mmfs/gen/
2121
COPY ./gpfsConfig/ZIMon* /opt/IBM/zimon/
2222

2323

24+
ARG HTTPPROTOCOL=http
25+
ENV PROTOCOL=$HTTPPROTOCOL
26+
RUN echo "the HTTP/S protocol is set to $PROTOCOL"
27+
2428
ARG HTTPPORT=4242
2529
ENV PORT=$HTTPPORT
2630
RUN echo "the HTTP/S port is set to $PORT"
@@ -44,7 +48,7 @@ ENV APIKEYNAME=$KEYNAME
4448
ARG KEYVALUE=None
4549
ENV APIKEYVALUE=$KEYVALUE
4650

47-
RUN if [ -z "$TLSKEYPATH" ] || [ -z "$TLSCERTFILE" ] || [ -z "$TLSKEYFILE" ] && [ "$PORT" -eq 8443 ]; then echo "TLSKEYPATH FOR SSL CONNECTION NOT SET - ERROR"; exit 1; else echo "PASS"; fi
51+
RUN if [ -z "$TLSKEYPATH" ] || [ -z "$TLSCERTFILE" ] || [ -z "$TLSKEYFILE" ] && [ "$PROTOCOL" = "https" ]; then echo "TLSKEYPATH FOR SSL CONNECTION NOT SET - ERROR"; exit 1; else echo "PASS"; fi
4852
RUN echo "the ssl certificates path is set to $TLSKEYPATH"
4953

5054
ARG PMCOLLECTORIP=0.0.0.0
@@ -66,7 +70,8 @@ RUN echo "pmcollector_server: $SERVER" >> $LOGPATH
6670
RUN echo "ssl certificates location: $TLSKEYPATH" >> $LOGPATH
6771
RUN echo "HTTP/S port: $PORT" >> $LOGPATH
6872

69-
CMD ["sh", "-c", "python3 zimonGrafanaIntf.py -c 10 -s $SERVER -p $PORT -P $SERVERPORT -t $TLSKEYPATH --tlsKeyFile $TLSKEYFILE --tlsCertFile $TLSCERTFILE --apiKeyName $APIKEYNAME --apiKeyValue $APIKEYVALUE"]
73+
74+
CMD ["sh", "-c", "python3 zimonGrafanaIntf.py -c 10 -s $SERVER -r $PROTOCOL -p $PORT -P $SERVERPORT -t $TLSKEYPATH --tlsKeyFile $TLSKEYFILE --tlsCertFile $TLSCERTFILE --apiKeyName $APIKEYNAME --apiKeyValue $APIKEYVALUE"]
7075

7176
EXPOSE 4242 8443
7277

source/confParser.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ def checkFileExists(path, filename):
3535

3636

3737
def checkTLSsettings(args):
38-
if args.get('port') == 8443 and (not args.get('tlsKeyPath') or not args.get('tlsKeyFile') or not args.get('tlsCertFile')):
38+
if args.get('protocol') == "https" and (not args.get('tlsKeyPath') or not args.get('tlsKeyFile') or not args.get('tlsCertFile')):
3939
return False, MSG['MissingParm']
40-
elif args.get('port') == 8443 and not os.path.exists(args.get('tlsKeyPath')):
40+
elif args.get('protocol') == "https" and not os.path.exists(args.get('tlsKeyPath')):
4141
return False, MSG['KeyPathError']
42-
elif args.get('port') == 8443:
42+
elif args.get('protocol') == "https":
4343
if (not checkFileExists(args.get('tlsKeyPath'), args.get('tlsCertFile'))) or (not checkFileExists(args.get('tlsKeyPath'), args.get('tlsKeyFile'))):
4444
return False, MSG['CertError']
4545
return True, ''
@@ -181,7 +181,8 @@ def parse_cmd_args(argv):
181181
all traces will be printed out directly on the command line')
182182
parser.add_argument('-c', '--logLevel', action="store", type=int, default=None,
183183
help='log level. Available levels: 10 (DEBUG), 15 (MOREINFO), 20 (INFO), 30 (WARN), 40 (ERROR) (Default from config.ini: 15)')
184-
parser.add_argument('-p', '--port', action="store", type=int, choices=[4242, 8443], default=None, help='port number listening on for HTTP(S) connections (Default from config.ini: 4242)')
184+
parser.add_argument('-p', '--port', action="store", type=int, default=None, help='port number listening on HTTP(S) client connections (Default from config.ini: 4242)')
185+
parser.add_argument('-r', '--protocol', action="store", choices=["http", "https"], default=None, help='Connection protocol HTTP/HTTPS (Default from config.ini: "http")')
185186
parser.add_argument('-t', '--tlsKeyPath', action="store", default=None, help='Directory path of tls privkey.pem and cert.pem file location (Required only for HTTPS port 8443)')
186187
parser.add_argument('-k', '--tlsKeyFile', action="store", default=None, help='Name of TLS key file, f.e.: privkey.pem (Required only for HTTPS port 8443)')
187188
parser.add_argument('-m', '--tlsCertFile', action="store", default=None, help='Name of TLS certificate file, f.e.: cert.pem (Required only for HTTPS port 8443)')

source/config.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
# (Default: 4242)
77
port = 4242
88

9+
# Protocol (http, https)
10+
protocol = http
11+
912
#################################### Grafana Generic OAuth ####################
1013
[tls]
1114
# Directory path of tls key and cert file location

source/zimonGrafanaIntf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ def main(argv):
592592

593593
# prepare cherrypy server configuration
594594
updateCherrypyConf(args)
595-
if args.get('port') == 8443:
595+
if args.get('protocol') == "https":
596596
updateCherrypySslConf(args)
597597

598598
# prepare metadata

0 commit comments

Comments
 (0)