You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@fineract.apache.org by GitBox <gi...@apache.org> on 2019/09/19 17:20:22 UTC

[GitHub] [fineract-cn-docker-compose] aasaru commented on a change in pull request #6: FINCN-165: Implement bash scripts to provisioner fineract cn services

aasaru commented on a change in pull request #6: FINCN-165: Implement bash scripts to provisioner fineract cn services
URL: https://github.com/apache/fineract-cn-docker-compose/pull/6#discussion_r326284063
 
 

 ##########
 File path: bash_scripts/provision.sh
 ##########
 @@ -0,0 +1,318 @@
+#!/bin/bash
+set -e
+
+function init-variables {
+    local file="../env_variables"
+
+    CASSANDRA_REPLICATION_TYPE="Simple"
+    CASSANDRA_CONTACT_POINTS='172.16.238.68:9042' #initialized by the start-up script
+    CASSANDRA_REPLICAS="1"
+    POSTGRES_DRIVER_CLASS="org.postgresql.Driver"
+    POSTGRES_HOST='172.16.238.66' #initialized by the start-up script
+    POSTGRES_PWD="postgres"
+
+    MS_VENDOR="Apache Fineract"
+    IDENTITY_MS_NAME="identity-v1"
+    RHYTHM_MS_NAME="rhythm-v1"
+    OFFICE_MS_NAME="office-v1"
+    CUSTOMER_MS_NAME="customer-v1"
+    ACCOUNTING_MS_NAME="accounting-v1"
+    PORTFOLIO_MS_NAME="portfolio-v1"
+    DEPOSIT_MS_NAME="deposit-v1"
+    TELLER_MS_NAME="teller-v1"
+    REPORT_MS_NAME="report-v1"
+    CHEQUES_MS_NAME="cheques-v1"
+    PAYROLL_MS_NAME="payroll-v1"
+    GROUP_MS_NAME="group-v1"
+    NOTIFICATIONS_MS_NAME="notification-v1"
+
+    while IFS="=" read -r key value; do
+        case "$key" in
+            '#'*) ;;
+            "CASSANDRA_CLUSTER_NAME") CASSANDRA_CLUSTER_NAME="$value" ;;
+            "POSTGRESQL_PORT") POSTGRESQL_PORT="$value" ;;
+            "POSTGRESQL_USER") POSTGRESQL_USER="$value" ;;
+            "PROVISIONER_IP") PROVISIONER_IP="$value"; PROVISIONER_URL="http://${PROVISIONER_IP}:2020/provisioner/v1" ;;
+            "IDENTITY_IP") IDENTITY_IP="$value"; IDENTITY_URL="http://${IDENTITY_IP}:2021/identity/v1";;
+            "RHYTHM_IP") RHYTHM_IP="$value"; RHYTHM_URL="http://${RHYTHM_IP}:2022/rhythm/v1";;
+            "OFFICE_IP") OFFICE_IP="$value"; OFFICE_URL="http://${OFFICE_IP}:2023/office/v1";;
+            "CUSTOMER_IP") CUSTOMER_IP="$value"; CUSTOMER_URL="http://${CUSTOMER_IP}:2024/customer/v1";;
+            "ACCOUNTING_IP") ACCOUNTING_IP="$value"; ACCOUNTING_URL="http://${ACCOUNTING_IP}:2025/accounting/v1";;
+            "PORTFOLIO_IP") PORTFOLIO_IP="$value"; PORTFOLIO_URL="http://${PORTFOLIO_IP}:2026/portfolio/v1";;
+            "DEPOSIT_ACCOUNT_MANAGEMENT_IP") DEPOSIT_IP="$value"; DEPOSIT_URL="http://${DEPOSIT_IP}:2027/deposit/v1";;
+            "TELLER_IP") TELLER_IP="$value"; TELLER_URL="http://${TELLER_IP}:2028/teller/v1";;
+            "REPORTING_IP") REPORT_IP="$value"; REPORT_URL="http://${REPORT_IP}:2029/report/v1";;
+            "CHEQUES_IP") CHEQUES_IP="$value"; CHEQUES_URL="http://${CHEQUES_IP}:2030/cheques/v1";;
+            "PAYROLL_IP") PAYROLL_IP="$value"; PAYROLL_URL="http://${PAYROLL_IP}:2031/payroll/v1";;
+            "GROUP_IP") GROUP_IP="$value"; GROUP_URL="http://${GROUP_IP}:2032/group/v1";;
+            "NOTIFICATIONS_IP") NOTIFICATIONS_IP="$value"; NOTIFICATIONS_URL="http://${NOTIFICATIONS_IP}:2033/notification/v1";;
+            *) ;;
+        esac
+    done < "$file"
+}
+
+function auto-seshat {
+    TOKEN=$( curl -s -X POST -H "Content-Type: application/json" \
+        "$PROVISIONER_URL"'/auth/token?grant_type=password&client_id=service-runner&username=wepemnefret&password=oS/0IiAME/2unkN1momDrhAdNKOhGykYFH/mJN20' \
+         | jq --raw-output '.token' )
+}
+
+function login {
+    local tenant="$1"
+    local username="$2"
+    local password="$3"
+
+    ACCESS_TOKEN=$( curl -s -X POST -H "Content-Type: application/json" -H "User: guest" -H "X-Tenant-Identifier: $tenant" \
+       "${IDENTITY_URL}/token?grant_type=password&username=${username}&password=${password}" \
+        | jq --raw-output '.accessToken' )
+}
+
+function create-application {
+    local name="$1"
+    local description="$2"
+    local vendor="$3"
+    local homepage="$4"
+
+    curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${TOKEN}" \
+    --data '{ "name": "'"$name"'", "description": "'"$description"'", "vendor": "'"$vendor"'", "homepage": "'"$homepage"'" }' \
+     ${PROVISIONER_URL}/applications
+    echo "Created microservice: $name"
+}
+
+function get-application {
+    echo ""
+    echo "Microservices: "
+    curl -s -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${TOKEN}" ${PROVISIONER_URL}/applications | jq '.'
+}
+
+function delete-application {
+    local service_name="$1"
+
+    curl -X delete -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${TOKEN}" ${PROVISIONER_URL}/applications/${service_name}
+    echo "Deleted microservice: $name"
+}
+
+function create-tenant {
+    local identifier="$1"
+    local name="$2"
+    local description="$3"
+    local database_name="$4"
+
+    curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${TOKEN}" \
+    --data '{
+	"identifier": "'"$identifier"'",
+	"name": "'"$name"'",
+	"description": "'"$description"'",
+	"cassandraConnectionInfo": {
+		"clusterName": "'"$CASSANDRA_CLUSTER_NAME"'",
+		"contactPoints": "'"$CASSANDRA_CONTACT_POINTS"'",
+		"keyspace": "'"$database_name"'",
+		"replicationType": "'"$CASSANDRA_REPLICATION_TYPE"'",
+		"replicas": "'"$CASSANDRA_REPLICAS"'"
+	},
+	"databaseConnectionInfo": {
+		"driverClass": "'"$POSTGRES_DRIVER_CLASS"'",
+		"databaseName": "'"$database_name"'",
+		"host": "'"$POSTGRES_HOST"'",
+		"port": "'"$POSTGRES_PORT"'",
+		"user": "'"$POSTGRES_USER"'",
+		"password": "'"$POSTGRES_PWD"'"
+	}}' \
+    ${PROVISIONER_URL}/tenants
+    echo "Created tenant: $database_name"
+}
+
+function get-tenants {
+    echo ""
+    echo "Tenants: "
+    curl -s -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${TOKEN}" ${PROVISIONER_URL}/tenants | jq '.'
+}
+
+function assign-identity-ms {
+    local tenant="$1"
+
+    ADMIN_PASSWORD=$( curl -s -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${TOKEN}" \
 
 Review comment:
   shouldn't you add:
   
   -H "X-Tenant-Identifier: $tenant" 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services