-
Notifications
You must be signed in to change notification settings - Fork 9
/
provisioner.sh
142 lines (128 loc) · 8.06 KB
/
provisioner.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
echo "Authenticating super user account"
token=$( curl -X POST -H "Content-Type: application/json" \
'http://172.16.238.6:2020/provisioner-v1/auth/token?grant_type=password&client_id=service-runner&username=wepemnefret&password=oS/0IiAME/2unkN1momDrhAdNKOhGykYFH/mJN20' \
| jq --raw-output '.token' )
echo ""
echo ""
echo "Creating Microservice application via Provision MS"
curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
--data '{ "name": "identity-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://172.16.238.7:2021/identity-v1" }' \
http://172.16.238.6:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "rhythm-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2022/rhythm-v1" }' \
# http://172.16.238.6:2020/provisioner-v1/applications
# # curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "office-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2023/office-v1" }' \
# http://172.16.238.6:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "customer-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2024/customer-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "ledger-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2025/ledger-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "portfolio-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2025/portfolio-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "deposit-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2026/deposit-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "teller-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2027/teller-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "report-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2028/report-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "cheque-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2020/cheque-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "payroll-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2029/payroll-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
# --data '{ "name": "group-v1", "description": "", "vendor": "Apache Fineract", "homepage": "http://35.231.130.203:2020/group-v1" }' \
# http://35.229.63.46:2020/provisioner-v1/applications
# echo ""
# echo ""
# echo "Deleting microservice"
# curl -X delete -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" http://172.16.238.6:2020/provisioner-v1/applications/identity-v1
echo "List of existing microservice applications"
curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" http://172.16.238.6:2020/provisioner-v1/applications | jq '.'
echo ""
echo ""
echo "Creating Tenants via Provision MS"
curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
--data '{
"identifier": "playground",
"name": "A place to mess around and have fun",
"description": "All in one Demo Server",
"cassandraConnectionInfo": {
"clusterName": "Test Cluster",
"contactPoints": "172.16.238.5:9042",
"keyspace": "playground",
"replicationType": "Simple",
"replicas": "3"
},
"databaseConnectionInfo": {
"driverClass": "org.mariadb.jdbc.Driver",
"databaseName": "playground",
"host": "172.16.238.4",
"port": "3306",
"user": "root",
"password": "mysql"
}}' \
http://172.16.238.6:2020/provisioner-v1/tenants
echo "List of existing tenants"
curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" http://172.16.238.6:2020/provisioner-v1/tenants | jq '.'
echo ""
echo ""
echo "Assign identity microservice for tenant"
adminPassword=$( curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" \
--data '{ "name": "identity-v1" }' \
http://172.16.238.6:2020/provisioner-v1/tenants/playground/identityservice | jq --raw-output '.adminPassword')
# Dont see the use of the below statement
# curl -H "Content-Type: application/json" -H "User: wepemnefret" -H "Authorization: ${token}" -H "X-Tenant-Identifier: playground" http://172.16.238.6:2020/provisioner-v1/tenants/playground/applications | jq '.'
echo ""
echo ""
echo "Authenticate as an administrator"
accessToken=$( curl -X POST -H "Content-Type: application/json" -H "User: guest" -H "X-Tenant-Identifier: playground" \
"http://172.16.238.7:2021/identity-v1/token?grant_type=password&username=antony&password=${adminPassword}" \
| jq --raw-output '.accessToken' )
echo ""
echo "Create scheduler permission"
curl -H "Content-Type: application/json" -H "User: antony" -H "Authorization: ${accessToken}" -H "X-Tenant-Identifier: playground" \
--data '{
"identifier": "scheduler",
"permissions": [
{
"permittableEndpointGroupIdentifier": "identity__v1__app_self",
"allowedOperations": ["CHANGE"]
},
{
"permittableEndpointGroupIdentifier": "portfolio__v1__khepri",
"allowedOperations": ["CHANGE"]
}
]
}' \
http://172.16.238.7:2021/identity-v1/roles
echo ""
echo "Create scheduler user"
curl -H "Content-Type: application/json" -H "User: antony" -H "Authorization: ${accessToken}" -H "X-Tenant-Identifier: playground" \
--data '{
"identifier": "imhotep",
"password": "p4ssw0rd",
"role": "scheduler"
}' \
http://172.16.238.7:2021/identity-v1/users | jq '.'
echo ""
echo ""
echo "Authenticate as the newly created scheduler user so as to enable the user's account"
tempAccessToken=$( curl -X POST -H "Content-Type: application/json" -H "User: guest" -H "X-Tenant-Identifier: playground" \
'http://172.16.238.7:2021/identity-v1/token?grant_type=password&username=imhotep&password=p4ssw0rd' \
| jq --raw-output '.accessToken' )
curl -X PUT -H "Content-Type: application/json" -H "User: imhotep" -H "Authorization: ${tempAccessToken}" -H "X-Tenant-Identifier: playground" \
--data '{
"password": "p4ssw0rd"
}' \
http://172.16.238.7:2021/identity-v1/users/imhotep/password | jq '.'
echo ""
curl -H "Content-Type: application/json" -H "User: antony" -H "Authorization: ${accessToken}" -H "X-Tenant-Identifier: playground" http://172.16.238.7:2021/identity-v1/users | jq '.'