aboutsummaryrefslogtreecommitdiffstats
path: root/postgresql-prep/src/stage/opt/app/postgresql-prep/bin/iDNS-responder.py
diff options
context:
space:
mode:
authorTony Hansen <TonyLHansen@gerrit.onap.com>2017-05-05 15:08:05 +0000
committerTony Hansen <tony@att.com>2017-05-05 21:57:32 +0000
commit48feaffcb16e1fd5eb3ce453b99797de1bd15d7a (patch)
tree54f60886e301fe999cff8a33a58bef1c0bf9fb4d /postgresql-prep/src/stage/opt/app/postgresql-prep/bin/iDNS-responder.py
parenta936f09820b61df6d27c0d788c3b185597d1470c (diff)
rebase DCAE Storage Components from OpenECOMP
[145075] Build 1707 DCAE Storage Components from OpenECOMP source Change-Id: Ie395395ad59afb658b46ecda31a079c050e2dd2e Signed-off-by: Tony Hansen <th1395@att.com> Signed-off-by: Tony Hansen <tony@att.com>
Diffstat (limited to 'postgresql-prep/src/stage/opt/app/postgresql-prep/bin/iDNS-responder.py')
-rwxr-xr-xpostgresql-prep/src/stage/opt/app/postgresql-prep/bin/iDNS-responder.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/postgresql-prep/src/stage/opt/app/postgresql-prep/bin/iDNS-responder.py b/postgresql-prep/src/stage/opt/app/postgresql-prep/bin/iDNS-responder.py
index b6c5174..14c16b3 100755
--- a/postgresql-prep/src/stage/opt/app/postgresql-prep/bin/iDNS-responder.py
+++ b/postgresql-prep/src/stage/opt/app/postgresql-prep/bin/iDNS-responder.py
@@ -445,10 +445,16 @@ class MyHandler(http.server.BaseHTTPRequestHandler):
elif self.path == '/isrw':
isrw = readFile("/var/run/postgresql/isrw", "n/a")
- debugTrace("/rw: isrw returns %s" % isrw)
+ debugTrace("/isrw: returns %s" % isrw)
resp = 200
msg = isrw
+ elif self.path == '/healthcheck/status':
+ hs = readFile("/var/run/postgresql/check_cluster", "n/a")
+ debugTrace("/healthcheck/status: returns %s" % hs)
+ resp = 429 if hs == "n/a" else 200
+ msg = '{ "output": "' + re.sub('"', "'", re.sub("\n", " ", hs)) + '" }'
+
elif not self.checkAuth():
resp = 401
msg = "not authenticated"
@@ -471,10 +477,18 @@ class MyHandler(http.server.BaseHTTPRequestHandler):
else:
msg = "non-secondary server"
+ elif self.path == '/ismaintenance':
+ msg = ""
+ if os.path.exists("/var/run/postgresql/inmaintenance"):
+ resp = 200
+ msg = "in maintenance mode"
+ else:
+ msg = "not in maintenance mode"
+
elif self.path == '/getpubkey':
try:
resp = 200
- msg = readFile("/home/postgres/.ssh/id_rsa.pub")
+ msg = readFile(os.path.expanduser("~postgres/.ssh/id_rsa.pub"))
except:
traceback.print_exc()
resp = 404
@@ -487,7 +501,7 @@ class MyHandler(http.server.BaseHTTPRequestHandler):
host = re.sub("[^a-zA-Z0-9_.-]", "", host)
debugTrace("#2: /getssh/ host='%s'" % host)
if self.isValidPgHost(host):
- p = readPipe("scp -o StrictHostKeyChecking=no ~postgres/.ssh/id_rsa* " + host + ":.ssh/ 2>&1")
+ p = readPipe("scp -o StrictHostKeyChecking=no -i ~postgres/.ssh/id_rsa ~postgres/.ssh/id_rsa* postgres@" + host + ":.ssh/ 2>&1")
debugTrace("#3: /getssh/ to '%s' returns '%s'" % (host, p))
msg = "OK " + p
resp = 200
@@ -505,7 +519,7 @@ class MyHandler(http.server.BaseHTTPRequestHandler):
host = re.sub("[^a-zA-Z0-9_.-]", "", host)
debugTrace("#2: /getcdf/ host='%s'" % host)
if self.isValidPgHost(host):
- p = readPipe("scp -o StrictHostKeyChecking=no " + fi + " " + host + ":/opt/app/cdf/lib/cdf.cfg 2>&1")
+ p = readPipe("scp -o StrictHostKeyChecking=no -i ~postgres/.ssh/id_rsa " + fi + " postgres@" + host + ":/opt/app/cdf/lib/cdf.cfg 2>&1")
debugTrace("#3: /getcdf/ to '%s' returns '%s'" % (host, p))
msg = "OK " + p
resp = 200
@@ -842,6 +856,7 @@ class MyHandler(http.server.BaseHTTPRequestHandler):
<a href='/isrw'>isrw</a> == /var/run/postgresql/isrw
<a href='/ismaster'>ismaster</a> == is master
<a href='/issecondary'>issecondary</a> == is secondary
+ <a href='/ismaintenance'>ismaintenance</a> == is in maintenance mode
<a href='/getpubkey'>getpubkey</a> == retrieve public key
<a href='/hasrepmgr'>hasrepmgr</a> == repmgr id and database are set up
<a href='/status'>status</a> == lots of info