Skip to content

Commit 5142558

Browse files
committed
remove fixed port numbers for HTTP/HTTPS connections
1 parent efcdc0d commit 5142558

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

source/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ COPY ./gpfsConfig/mmsdrfs* /var/mmfs/gen/
1919
COPY ./gpfsConfig/ZIMon* /opt/IBM/zimon/
2020

2121

22+
ARG HTTPPROTOCOL=http
23+
ENV PROTOCOL=$HTTPPROTOCOL
24+
RUN echo "the HTTP/S protocol is set to $PROTOCOL"
25+
2226
ARG HTTPPORT=4242
2327
ENV PORT=$HTTPPORT
2428
RUN echo "the HTTP/S port is set to $PORT"
@@ -32,7 +36,7 @@ ENV TLSKEYFILE=$KEYFILE
3236
ARG CERTFILE=None
3337
ENV TLSCERTFILE=$CERTFILE
3438

35-
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
39+
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
3640
RUN echo "the ssl certificates path is set to $TLSKEYPATH"
3741

3842
ARG PMCOLLECTORIP=0.0.0.0
@@ -42,7 +46,7 @@ RUN echo "the pmcollector server ip is set to $SERVER"
4246

4347
WORKDIR /opt/IBM/bridge
4448

45-
ARG DEFAULTLOGPATH='/var/log/ibm_bridge_for_grafanalogs/install.log'
49+
ARG DEFAULTLOGPATH='/var/log/ibm_bridge_for_grafana/install.log'
4650
ENV LOGPATH=$DEFAULTLOGPATH
4751
RUN mkdir -p $(dirname $LOGPATH)
4852
RUN echo "the log will use $(dirname $LOGPATH)"
@@ -54,7 +58,7 @@ RUN echo "pmcollector_server: $SERVER" >> $LOGPATH
5458
RUN echo "ssl certificates location: $TLSKEYPATH" >> $LOGPATH
5559
RUN echo "HTTP/S port: $PORT" >> $LOGPATH
5660

57-
CMD ["sh", "-c", "python3 zimonGrafanaIntf.py -c 10 -s $SERVER -p $PORT -t $TLSKEYPATH --tlsKeyFile $TLSKEYFILE --tlsCertFile $TLSCERTFILE"]
61+
CMD ["sh", "-c", "python3 zimonGrafanaIntf.py -c 10 -s $SERVER -r $PROTOCOL -p $PORT -t $TLSKEYPATH --tlsKeyFile $TLSKEYFILE --tlsCertFile $TLSCERTFILE"]
5862

5963
EXPOSE 4242 8443
6064

source/confParser.py

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

3535

3636
def checkTLSsettings(args):
37-
if args.get('port') == 8443 and (not args.get('tlsKeyPath') or not args.get('tlsKeyFile') or not args.get('tlsCertFile')):
37+
if args.get('protocol') == "https" and (not args.get('tlsKeyPath') or not args.get('tlsKeyFile') or not args.get('tlsCertFile')):
3838
return False, MSG['MissingParm']
39-
elif args.get('port') == 8443 and not os.path.exists(args.get('tlsKeyPath')):
39+
elif args.get('protocol') == "https" and not os.path.exists(args.get('tlsKeyPath')):
4040
return False, MSG['KeyPathError']
41-
elif args.get('port') == 8443:
41+
elif args.get('protocol') == "https":
4242
if (not checkFileExists(args.get('tlsKeyPath'), args.get('tlsCertFile'))) or (not checkFileExists(args.get('tlsKeyPath'), args.get('tlsKeyFile'))):
4343
return False, MSG['CertError']
4444
return True, ''
@@ -160,7 +160,8 @@ def parse_cmd_args(argv):
160160
parser.add_argument('-f', '--logFile', action="store", default=None, help='Name of the log file (Default from config.ini: zserver.log')
161161
parser.add_argument('-c', '--logLevel', action="store", type=int, default=None,
162162
help='log level. Available levels: 10 (DEBUG), 15 (MOREINFO), 20 (INFO), 30 (WARN), 40 (ERROR) (Default from config.ini: 15)')
163-
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)')
163+
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)')
164+
parser.add_argument('-r', '--protocol', action="store", choices=["http", "https"], default=None, help='Connection protocol HTTP/HTTPS (Default from config.ini: "http")')
164165
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)')
165166
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)')
166167
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
@@ -600,7 +600,7 @@ def main(argv):
600600

601601
# prepare cherrypy server configuration
602602
updateCherrypyConf(args)
603-
if args.get('port') == 8443:
603+
if args.get('protocol') == "https":
604604
updateCherrypySslConf(args)
605605

606606
# prepare metadata

0 commit comments

Comments
 (0)