aboutsummaryrefslogtreecommitdiffstats
path: root/pgaas-post/src
diff options
context:
space:
mode:
authorlj1412 <lji@research.att.com>2017-02-14 15:10:09 +0000
committerlj1412 <lji@research.att.com>2017-02-14 15:10:11 +0000
commit7927ff179242b796330d17869c83fa07751abf95 (patch)
treeba2b93e26ec71bff863bc7be9fb5dbd0b5d9c928 /pgaas-post/src
parentd1bf35c127a238238b573103edf7dbcb1ebd48ed (diff)
Init dcae.pgaas
Change-Id: Ieef6b600f4cbb0bf4ee3910c1bfc6b36773cd2d2 Signed-off-by: lj1412 <lji@research.att.com>
Diffstat (limited to 'pgaas-post/src')
-rwxr-xr-xpgaas-post/src/common/postinst41
-rwxr-xr-xpgaas-post/src/common/postrm1
-rw-r--r--pgaas-post/src/makefile38
-rw-r--r--pgaas-post/src/repackage.json23
-rw-r--r--pgaas-post/src/stage/opt/app/pgaas-post/bin/pgaas-verify-install227
5 files changed, 330 insertions, 0 deletions
diff --git a/pgaas-post/src/common/postinst b/pgaas-post/src/common/postinst
new file mode 100755
index 0000000..47b1add
--- /dev/null
+++ b/pgaas-post/src/common/postinst
@@ -0,0 +1,41 @@
+#!/bin/bash
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this code except in compliance
+# with the License. You may obtain a copy of the License
+# at http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+
+exec 1> /tmp/pgaas-post.out 2>&1
+set -x
+if [ -d /opt/app/postgresql-9.5.2 ]
+then export OPENECOMP=false NOTOPENECOMP=true
+else export OPENECOMP=true NOTOPENECOMP=false
+fi
+
+if $OPENECOMP
+then INSTALL_ROOT=
+fi
+
+echo STARTING $0 $(date)
+umask 0
+echo STARTING $0 $(date) >> /tmp/pgaas.inst.report
+
+if [ -d /opt/app/postgresql-9.5.2 ]
+then chmod 751 /opt/app/postgresql-9.5.2 /opt/app/postgresql-9.5.2/bin /opt/app/postgresql-9.5.2/lib
+fi
+
+/opt/app/pgaas-post/bin/pgaas-verify-install
+
+echo ENDING $0 $(date)
+echo ENDING $0 $(date) >> /tmp/pgaas.inst.report
+if $NOTOPENECOMP
+then sed -n '/^STARTING/,/^ENDING/p' `dirname $0`/../../proc_out >> /tmp/pgaas.inst.report
+fi
diff --git a/pgaas-post/src/common/postrm b/pgaas-post/src/common/postrm
new file mode 100755
index 0000000..42d2529
--- /dev/null
+++ b/pgaas-post/src/common/postrm
@@ -0,0 +1 @@
+echo STARTING $0 $(date)
diff --git a/pgaas-post/src/makefile b/pgaas-post/src/makefile
new file mode 100644
index 0000000..d66d74b
--- /dev/null
+++ b/pgaas-post/src/makefile
@@ -0,0 +1,38 @@
+
+DEVBIN=../../bin
+PKG=pgaas-post
+REPACKAGESWMOPTS=
+REPACKAGEDEBIANOPTS=
+
+INS= ../install
+INSSTG= $(INS)/stage
+INSCOM= $(INS)/common
+
+all:
+
+clean-stage:
+ rm -rf $(INSSTG)
+
+clean-common:
+ rm -rf $(INSCOM)
+
+clean:
+ rm -rf $(INS)
+
+build:
+
+stage: clean-stage clean-common
+ find common ! -name makefile ! -name '*~' | cpio -pudmv $(INS)
+ find stage ! -name makefile ! -name '*~' | cpio -pudmv $(INS)
+ chmod a+x $(INSSTG)/opt/app/pgaas-post/bin/*
+ cp -p repackage.* $(INS)
+
+
+debian: stage
+ repackage -y repackage.json -b debian -d $(INS) -u
+ repackage -y repackage.json -b debian -d $(INS) -u -B LATEST
+ @echo debian built
+
+upload-javadocs:
+ @echo nothing to do here
+
diff --git a/pgaas-post/src/repackage.json b/pgaas-post/src/repackage.json
new file mode 100644
index 0000000..134c00c
--- /dev/null
+++ b/pgaas-post/src/repackage.json
@@ -0,0 +1,23 @@
+{
+ "version": "1.0.0",
+ "executionUser": "root",
+ "description": " PostgreSQL as a Service main scripts ",
+ "maintainer": "OpenECOMP <dcae@lists.openecomp.org>",
+ "debian": {
+ "replaces": [],
+ "groupId": "org.openecomp.dcae.storage.pgaas",
+ "externalDependencies": [],
+ "conflicts": []
+ },
+ "internalDependencies": [],
+ "fileUser": "root",
+ "docker": {
+ "tag": "latest",
+ "externalDependencies": []
+ },
+ "directoryTreeTops": {},
+ "groupId": "org.openecomp.dcae.storage.pgaas",
+ "fileGroup": "root",
+ "applicationName": "pgaas-post",
+ "executionGroup": "root"
+} \ No newline at end of file
diff --git a/pgaas-post/src/stage/opt/app/pgaas-post/bin/pgaas-verify-install b/pgaas-post/src/stage/opt/app/pgaas-post/bin/pgaas-verify-install
new file mode 100644
index 0000000..5bf3962
--- /dev/null
+++ b/pgaas-post/src/stage/opt/app/pgaas-post/bin/pgaas-verify-install
@@ -0,0 +1,227 @@
+#!/bin/bash
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this code except in compliance
+# with the License. You may obtain a copy of the License
+# at http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+
+
+die()
+{
+ exec 1>&2
+ echo "$@"
+ logger --stderr --priority local1.error --tag "DCAE" "$@"
+ exit 1
+}
+
+usage()
+{
+ exec 1>&2
+ [ $# -gt 0 ] && echo "$@"
+ b=$(basename $0)
+ echo "Usage: $b [-v]"
+ echo "$b runs a variety of tests on the PG VM and database"
+ echo "It must be run as root or postgres."
+ echo "If run as root, it will do additional tests that are"
+ echo "not possible as a normal user."
+ echo " -v verbose"
+ echo " -P do not print VERIFIED"
+ exit 1
+}
+
+PRINTVERIFIED=:
+while getopts Pv c
+do
+ case $c in
+ P ) PRINTVERIFIED=false ;;
+ v ) set -x ;;
+ '?' ) usage ;;
+ esac
+done
+shift `expr $OPTIND - 1`
+
+# this can be run as root
+ROOT=false
+case `id` in
+ *"(root)"* ) ROOT=true ;;
+ *"(postgres)"* ) ;;
+ * ) echo "$0 must be run as either root or postgres" ;;
+esac
+
+VERIFIEDCOUNT=0
+FAILEDCOUNT=0
+TOTALCOUNT=0
+
+verified()
+{
+ (( VERIFIEDCOUNT = VERIFIEDCOUNT + 1 ))
+ (( TOTALCOUNT = TOTALCOUNT + 1 ))
+ $PRINTVERIFIED && echo "VERIFIED: $@"
+}
+
+failed()
+{
+ (( FAILEDCOUNT = FAILEDCOUNT + 1 ))
+ (( TOTALCOUNT = TOTALCOUNT + 1 ))
+ echo "FAILED: $@"
+}
+
+tabtext()
+{
+ echo "$@" | sed 's/^/ /'
+}
+
+HOSTNAME=$(hostname -f)
+
+################################################################
+################ things set up by ################
+################ openstack ################
+################################################################
+
+case $HOSTNAME in
+ *.*.* ) verified "hostname has a FQDN" ;;
+ * ) failed "hostname does not have a FQDN" ;;
+esac
+
+################################################################
+################ things set up by ################
+################ controller dcae_install ################
+################################################################
+
+if grep '^dcae:' /etc/passwd > /dev/null
+then verified "dcae user exists"
+else failed "dcae user does not exist"
+fi
+if $ROOT
+then
+ if [ -s /etc/sudoers.d/dcae-postgres ]
+ then verified "dcae can sudo to postgres"
+ else failed "dcae cannot sudo to postgres"
+ fi
+fi
+
+SHOWDF=false
+for i in /opt/tools /dbroot/pgdata /dbroot/pglogs
+do
+ if df -h 2>&1 | grep " $i"'$' > /dev/null
+ then verified "$i has its own filesystem"
+ else failed "$i does not have its own filesystem"; SHOWDF=true
+ fi
+done
+$SHOWDF && tabtext "$(df -h 2>&1)"
+
+if grep '^postgres:' /etc/passwd > /dev/null
+then verified "postgres user exists"
+else failed "postgres user does not exist"
+fi
+
+################################################################
+################ things set up by ################
+################ cdf package ################
+################################################################
+
+if [ -d /opt/app/cdf ]
+then verified "/opt/app/cdf is present"
+else failed "/opt/app/cdf is present"
+fi
+
+cdfcall=$(/opt/app/cdf/bin/getpropvalue -n foo 2>&1)
+case "$cdfcall" in
+ *Configuration?property*must?be?defined* ) verified "CDF is installed and working" ;;
+ * ) failed "CDF is not installed and working"; tabtext "$cdfcall" ;;
+esac
+
+################################################################
+################ things set up by ################
+################ postgresql-prep package ################
+################################################################
+
+if grep "^pgnodes=.*$HOSTNAME" /opt/app/cdf/lib/cdf.cfg > /dev/null
+then verified "HOSTNAME is part of cluster (cdf.cfg pgnodes)"
+else failed "HOSTNAME is not part of cluster (cdf.cfg pgnodes)"
+fi
+
+# check for certificate presence goes here
+
+if [ -s /lib/systemd/system/pgaas-idns.service ]
+then verified "found pgaas-idns service properly installed for Ubuntu 16"
+elif [ -s /etc/init/pgaas-init.conf ]
+then verified "found pgaas-idns service properly installed for Ubuntu 14"
+else failed "pgaas-idns service has not bee installed properly"
+fi
+
+if [ -d /var/run/postgresql ]
+then verified "/var/run/postgresql exists"
+else failed "/var/run/postgresql does not exist"
+fi
+
+if [ -s /etc/logrotate.d/pgaas ]
+then verified "/etc/logrotate.d/pgaas has been installed"
+else failed "/etc/logrotate.d/pgaas has not been installed"
+fi
+
+
+################################################################
+################ things set up by ################
+################ postgresql-config ################
+################################################################
+
+if ps -fu postgres | grep "postgres: logger process" > /dev/null
+then verified "postgres is running"
+else failed "postgres does not have a logger process running"
+fi
+
+if pgrep repmgrd > /dev/null
+then verified "repmgrd is running"
+else failed "repmgrd is not running"
+fi
+
+if [ -f /opt/app/pgaas/bin/runpsqll ]
+then
+ verified "/opt/app/pgaas/bin/runpsqll is installed"
+ roles=$( /opt/app/pgaas/bin/runpsqll "select rolname from pg_roles" )
+ case "$roles" in
+ *repmgr* ) verified "postgres repmgr role name is present" ;;
+ * ) failed "postgres repmgr role name was not added"; tabtext "$roles" ;;
+ esac
+ rolcount=$( /opt/app/pgaas/bin/runpsqll "select count(rolname) from pg_roles" | awk 'NF > 0 {print $1}' )
+ case $rolcount in
+ 1 | 2 ) failed "no additional postgresql role names have been added"; tabtext "$roles" ;;
+ * ) verified "additional postgresql role names have been added" ;;
+ esac
+ dxpgtemporal=$( /opt/app/pgaas/bin/runpsqll "select count(extname) from pg_extension where extname = 'temporal_tables'" | awk 'NF > 0 {print $1}' )
+ case $dxpgtemporal in
+ 1 ) verified "temporal_tables extension has been added" ;;
+ * ) failed "temporal_tables extension has not been added" ;;
+ esac
+else
+ failed "/opt/app/pgaas/bin/runpsqll is not installed"
+fi
+
+if ps -ef | grep python3 | grep iDNS-responder.py > /dev/null
+then verified "iDNS-responder.py is running"
+else failed "iDNS-responder.py is not running"
+fi
+
+if [ -f /opt/app/pgaas/bin/check_cluster ]
+then
+ verified "/opt/app/pgaas/bin/check_cluster is installed"
+ ckcl=$( /opt/app/pgaas/bin/check_cluster 2>&1 )
+ case $ckcl in
+ *No?such?file?or?directory* ) failed "check_cluster not found"; tabtext "$ckcl" ;;
+ *ERROR* ) failed "check_cluster returned error:"; tabtext "$ckcl" ;;
+ *WARNING* ) failed "check_cluster returned a warning:"; tabtext "$ckcl" ;;
+ * ) verified "check_cluster succeeded" ;;
+ esac
+else
+ failed "/opt/app/pgaas/bin/check_cluster is not installed"
+fi
+
+echo "$VERIFIEDCOUNT tests passed, $FAILEDCOUNT tests failed, $TOTALCOUNT total tests run"