k2hr3-api 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog +24 -0
- package/app.js +7 -4
- package/bin/run.sh +218 -172
- package/bin/watcher +7 -4
- package/bin/www +7 -4
- package/config/default.json +7 -4
- package/config/development.json +7 -4
- package/config/dummyuser.json +8 -5
- package/config/extdata-dummy.sh.templ +12 -9
- package/config/k2hr3-cloud-config.txt.templ +7 -4
- package/config/k2hr3-init-error.sh.templ +8 -5
- package/config/k2hr3-init.sh.templ +127 -207
- package/config/keystone_v2.json +7 -4
- package/config/keystone_v3.json +7 -4
- package/lib/basicipcheck.js +7 -4
- package/lib/cacerts.js +7 -4
- package/lib/dbglogging.js +7 -4
- package/lib/dummyuserapi.js +7 -4
- package/lib/ipwatch.js +7 -4
- package/lib/k2hr3acrutil.js +7 -5
- package/lib/k2hr3apiutil.js +7 -4
- package/lib/k2hr3cliutil.js +7 -4
- package/lib/k2hr3config.js +7 -4
- package/lib/k2hr3cryptutil.js +7 -4
- package/lib/k2hr3dkc.js +7 -4
- package/lib/k2hr3extdata.js +7 -4
- package/lib/k2hr3keys.js +7 -4
- package/lib/k2hr3resutil.js +7 -4
- package/lib/k2hr3template.js +7 -4
- package/lib/k2hr3tokens.js +7 -4
- package/lib/k2hr3userdata.js +8 -5
- package/lib/k8soidc.js +1 -1
- package/lib/openstackapiv2.js +7 -4
- package/lib/openstackapiv3.js +7 -4
- package/lib/openstackep.js +7 -4
- package/package.json +73 -72
- package/routes/acr.js +7 -4
- package/routes/debugVerify.js +7 -4
- package/routes/extdata.js +7 -4
- package/routes/list.js +7 -4
- package/routes/policy.js +7 -4
- package/routes/resource.js +7 -4
- package/routes/role.js +7 -4
- package/routes/service.js +7 -4
- package/routes/userTokens.js +7 -4
- package/routes/userdata.js +7 -4
- package/routes/version.js +7 -4
- package/templ/Dockerfile.templ +35 -52
- package/{test → tests}/auto_acr.js +7 -4
- package/{test → tests}/auto_acr_spec.js +7 -4
- package/{test → tests}/auto_all_spec.js +7 -4
- package/{test → tests}/auto_common.js +7 -4
- package/tests/auto_control_subprocess.sh +239 -0
- package/{test → tests}/auto_extdata.js +7 -4
- package/{test → tests}/auto_extdata_spec.js +7 -4
- package/tests/auto_init_config_json.sh +275 -0
- package/{test → tests}/auto_k2hdkc_server.ini +7 -4
- package/{test → tests}/auto_k2hdkc_slave.ini +7 -4
- package/{test → tests}/auto_list.js +7 -4
- package/{test → tests}/auto_list_spec.js +7 -4
- package/{test → tests}/auto_policy.js +7 -4
- package/{test → tests}/auto_policy_spec.js +7 -4
- package/{test → tests}/auto_resource.js +7 -4
- package/{test → tests}/auto_resource_spec.js +7 -4
- package/{test → tests}/auto_role.js +7 -4
- package/{test → tests}/auto_role_spec.js +7 -4
- package/{test → tests}/auto_service.js +7 -4
- package/{test → tests}/auto_service_spec.js +7 -4
- package/{test → tests}/auto_subprocesses.js +14 -11
- package/tests/auto_template.sh +126 -0
- package/{test → tests}/auto_token_util.js +7 -4
- package/{test → tests}/auto_userdata.js +7 -4
- package/{test → tests}/auto_userdata_spec.js +7 -4
- package/{test → tests}/auto_usertokens.js +7 -4
- package/{test → tests}/auto_usertokens_spec.js +7 -4
- package/{test → tests}/auto_version.js +7 -4
- package/{test → tests}/auto_version_spec.js +7 -4
- package/{test → tests}/auto_watcher.js +7 -4
- package/{test → tests}/auto_watcher_spec.js +7 -4
- package/{test → tests}/k2hdkc_test.data +7 -4
- package/tests/k2hdkc_test_load.sh +255 -0
- package/{test → tests}/k2hr3template_test.js +7 -4
- package/tests/k2hr3template_test.sh +339 -0
- package/{test → tests}/k2hr3template_test_async.js +7 -4
- package/{test → tests}/k2hr3template_test_template.result +14 -8
- package/{test → tests}/k2hr3template_test_template.txt +7 -4
- package/{test → tests}/k2hr3template_test_vars.js +7 -4
- package/{test → tests}/manual_acr_delete.js +7 -4
- package/{test → tests}/manual_acr_get.js +7 -4
- package/{test → tests}/manual_acr_postput.js +7 -4
- package/{test → tests}/manual_allusertenant_get.js +7 -4
- package/{test → tests}/manual_extdata_get.js +7 -4
- package/{test → tests}/manual_k2hr3keys_get.js +7 -4
- package/{test → tests}/manual_list_gethead.js +7 -4
- package/{test → tests}/manual_policy_delete.js +7 -4
- package/{test → tests}/manual_policy_gethead.js +7 -4
- package/{test → tests}/manual_policy_postput.js +7 -4
- package/{test → tests}/manual_resource_delete.js +7 -4
- package/{test → tests}/manual_resource_gethead.js +7 -4
- package/{test → tests}/manual_resource_postput.js +7 -4
- package/{test → tests}/manual_role_delete.js +7 -4
- package/{test → tests}/manual_role_gethead.js +7 -4
- package/{test → tests}/manual_role_postput.js +7 -4
- package/{test → tests}/manual_service_delete.js +7 -4
- package/{test → tests}/manual_service_gethead.js +7 -4
- package/{test → tests}/manual_service_postput.js +7 -4
- package/tests/manual_test.sh +338 -0
- package/{test → tests}/manual_userdata_get.js +7 -4
- package/{test → tests}/manual_usertoken_gethead.js +7 -4
- package/{test → tests}/manual_usertoken_postput.js +7 -4
- package/{test → tests}/manual_version_get.js +7 -4
- package/tests/run_local_test_k2hdkc.sh +174 -0
- package/tests/test.sh +331 -0
- package/test/auto_control_subprocess.sh +0 -170
- package/test/auto_init_config_json.sh +0 -246
- package/test/auto_template.sh +0 -127
- package/test/auto_test.sh +0 -321
- package/test/k2hdkc_test_load.sh +0 -198
- package/test/k2hr3template_test.sh +0 -296
- package/test/manual_test.sh +0 -321
- package/test/run_local_test_k2hdkc.sh +0 -154
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# K2HR3 REST API
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2017 Yahoo Japan Corporation.
|
|
6
|
+
#
|
|
7
|
+
# K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
8
|
+
# common management information for the cloud.
|
|
9
|
+
# K2HR3 can dynamically manage information as "who", "what", "operate".
|
|
10
|
+
# These are stored as roles, resources, policies in K2hdkc, and the
|
|
11
|
+
# client system can dynamically read and modify these information.
|
|
12
|
+
#
|
|
13
|
+
# For the full copyright and license information, please view
|
|
14
|
+
# the license file that was distributed with this source code.
|
|
15
|
+
#
|
|
16
|
+
# AUTHOR: Takeshi Nakatani
|
|
17
|
+
# CREATE: Wed Jun 8 2017
|
|
18
|
+
# REVISION:
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
#==========================================================
|
|
22
|
+
# Common Variables
|
|
23
|
+
#==========================================================
|
|
24
|
+
PRGNAME=$(basename "$0")
|
|
25
|
+
SCRIPTDIR=$(dirname "$0")
|
|
26
|
+
SCRIPTDIR=$(cd "${SCRIPTDIR}" || exit 1; pwd)
|
|
27
|
+
SRCTOP=$(cd "${SCRIPTDIR}/.." || exit 1; pwd)
|
|
28
|
+
|
|
29
|
+
#
|
|
30
|
+
# Variables
|
|
31
|
+
#
|
|
32
|
+
COMMAND=""
|
|
33
|
+
CMD_PREFIX="manual_"
|
|
34
|
+
CMD_SUFFIX=".js"
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Commands
|
|
38
|
+
#
|
|
39
|
+
COMMANDS="
|
|
40
|
+
version_get
|
|
41
|
+
usertoken_gethead
|
|
42
|
+
usertoken_postput
|
|
43
|
+
policy_delete
|
|
44
|
+
policy_gethead
|
|
45
|
+
policy_postput
|
|
46
|
+
resource_delete
|
|
47
|
+
resource_gethead
|
|
48
|
+
resource_postput
|
|
49
|
+
role_delete
|
|
50
|
+
role_gethead
|
|
51
|
+
role_postput
|
|
52
|
+
service_postput
|
|
53
|
+
service_gethead
|
|
54
|
+
service_delete
|
|
55
|
+
acr_postput
|
|
56
|
+
acr_get
|
|
57
|
+
acr_delete
|
|
58
|
+
list_gethead
|
|
59
|
+
userdata_get
|
|
60
|
+
extdata_get
|
|
61
|
+
allusertenant_get
|
|
62
|
+
k2hr3keys_get
|
|
63
|
+
"
|
|
64
|
+
|
|
65
|
+
#==============================================================
|
|
66
|
+
# Utility functions
|
|
67
|
+
#==============================================================
|
|
68
|
+
#
|
|
69
|
+
# Usage
|
|
70
|
+
#
|
|
71
|
+
PrintUsage()
|
|
72
|
+
{
|
|
73
|
+
echo "Usage: $1 [--apihost(-a) hostname]"
|
|
74
|
+
echo " [--apiport(-p) port]"
|
|
75
|
+
echo " [--sec(-s) | --https]"
|
|
76
|
+
echo " [--debuglevel(-d) DBG/MSG/WARN/ERR/(custom debug level)]"
|
|
77
|
+
echo " <Command>"
|
|
78
|
+
echo ""
|
|
79
|
+
echo "Option:"
|
|
80
|
+
echo " --apihost(-a) : Specify k2hr3 API hostname used by this test"
|
|
81
|
+
echo " --apiport(-p) : Specify k2hr3 API port used by this test"
|
|
82
|
+
echo " --sec(-s) : Use HTTPS to access k2hr3 API server"
|
|
83
|
+
echo " --https : Same as '--sec' option"
|
|
84
|
+
echo " --debuglevel(-d) : Specify the level of debug output."
|
|
85
|
+
echo " (DBG/MSG/WARN/ERR/custom debug level)"
|
|
86
|
+
echo ""
|
|
87
|
+
echo "Command:"
|
|
88
|
+
echo " version_get : Get version information"
|
|
89
|
+
echo ""
|
|
90
|
+
echo " usertoken_postput : Get User Token(v1)"
|
|
91
|
+
echo " usertoken_gethead : Get User Token Information(v1)"
|
|
92
|
+
echo ""
|
|
93
|
+
echo " resource_postput : Post(Put) resource(v1)"
|
|
94
|
+
echo " resource_gethead : Get(Head) resource(v1)"
|
|
95
|
+
echo " resource_delete : Delete resource(v1)"
|
|
96
|
+
echo ""
|
|
97
|
+
echo " policy_postput : Post(Put) policy(v1)"
|
|
98
|
+
echo " policy_gethead : Get(Head) policy(v1)"
|
|
99
|
+
echo " policy_delete : Delete policy(v1)"
|
|
100
|
+
echo ""
|
|
101
|
+
echo " role_postput : Post(Put) role(v1)"
|
|
102
|
+
echo " role_gethead : Get(Head) role(v1)"
|
|
103
|
+
echo " role_delete : Delete role(v1)"
|
|
104
|
+
echo ""
|
|
105
|
+
echo " service_postput : Post(Put) service(v1)"
|
|
106
|
+
echo " service_gethead : Get(head) service(v1)"
|
|
107
|
+
echo " service_delete : Delete service(v1)"
|
|
108
|
+
echo ""
|
|
109
|
+
echo " acr_postput : Post(Put) ACR(v1)"
|
|
110
|
+
echo " acr_get : Get ACR(v1)"
|
|
111
|
+
echo " acr_delete : Delete ACR(v1)"
|
|
112
|
+
echo ""
|
|
113
|
+
echo " list_gethead : Get(Head) children list for path(v1)"
|
|
114
|
+
echo ""
|
|
115
|
+
echo " userdata_get : Get userdata for openstack instance(v1)"
|
|
116
|
+
echo ""
|
|
117
|
+
echo " extdata_get : Get extdata for user defined data(v1)"
|
|
118
|
+
echo ""
|
|
119
|
+
echo " allusertenant_get : Get all user and tenant list in k2hr3"
|
|
120
|
+
echo " k2hr3keys_get : Get common key name object for debug"
|
|
121
|
+
echo ""
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#
|
|
125
|
+
# Check Commands
|
|
126
|
+
#
|
|
127
|
+
CheckCommands()
|
|
128
|
+
{
|
|
129
|
+
if [ -n "$1" ]; then
|
|
130
|
+
for command in ${COMMANDS}; do
|
|
131
|
+
if [ "$1" = "${command}" ]; then
|
|
132
|
+
echo "${command}"
|
|
133
|
+
return 0
|
|
134
|
+
fi
|
|
135
|
+
done
|
|
136
|
+
fi
|
|
137
|
+
echo ""
|
|
138
|
+
return 1
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#==========================================================
|
|
142
|
+
# Parse options
|
|
143
|
+
#==========================================================
|
|
144
|
+
APIPORT=0
|
|
145
|
+
APIHOST=""
|
|
146
|
+
HTTPS_ENV=""
|
|
147
|
+
DEBUG_ENV_LEVEL=0
|
|
148
|
+
DEBUG_ENV_CUSTOM=""
|
|
149
|
+
|
|
150
|
+
while [ $# -ne 0 ]; do
|
|
151
|
+
if [ -z "$1" ]; then
|
|
152
|
+
break
|
|
153
|
+
|
|
154
|
+
elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then
|
|
155
|
+
PrintUsage "${PRGNAME}"
|
|
156
|
+
exit 0
|
|
157
|
+
|
|
158
|
+
elif [ "$1" = "-a" ] || [ "$1" = "-A" ] || [ "$1" = "--apihost" ] || [ "$1" = "--APIHOST" ]; then
|
|
159
|
+
#
|
|
160
|
+
# API HOST
|
|
161
|
+
#
|
|
162
|
+
if [ -n "${APIHOST}" ]; then
|
|
163
|
+
echo "[ERROR] already specified --apihost option"
|
|
164
|
+
exit 1
|
|
165
|
+
fi
|
|
166
|
+
shift
|
|
167
|
+
if [ $# -eq 0 ]; then
|
|
168
|
+
echo "[ERROR] --apihost(-h) option needs parameter(hostname)"
|
|
169
|
+
exit 1
|
|
170
|
+
fi
|
|
171
|
+
APIHOST="$1"
|
|
172
|
+
|
|
173
|
+
elif [ "$1" = "-p" ] || [ "$1" = "-P" ] || [ "$1" = "--apiport" ] || [ "$1" = "--APIPORT" ]; then
|
|
174
|
+
#
|
|
175
|
+
# API PORT
|
|
176
|
+
#
|
|
177
|
+
if [ -n "${APIPORT}" ]; then
|
|
178
|
+
echo "[ERROR] already specified --apiport option"
|
|
179
|
+
exit 1
|
|
180
|
+
fi
|
|
181
|
+
shift
|
|
182
|
+
if [ $# -eq 0 ]; then
|
|
183
|
+
echo "[ERROR] --apiport(-p) option needs parameter(port number)"
|
|
184
|
+
exit 1
|
|
185
|
+
fi
|
|
186
|
+
if echo "$1" | grep -q '[^0-9]'; then
|
|
187
|
+
echo "[ERROR] --apiport(-p) option parameter must be number"
|
|
188
|
+
exit 1
|
|
189
|
+
elif [ "$1" -eq 0 ]; then
|
|
190
|
+
echo "[ERROR] --apiport(-p) option parameter must be positive number"
|
|
191
|
+
exit 1
|
|
192
|
+
fi
|
|
193
|
+
APIPORT="$1"
|
|
194
|
+
|
|
195
|
+
elif [ "$1" = "-s" ] || [ "$1" = "-S" ] || [ "$1" = "--sec" ] || [ "$1" = "--SEC" ] || [ "$1" = "--https" ] || [ "$1" = "--HTTPS" ]; then
|
|
196
|
+
if [ -n "${HTTPS_ENV}" ]; then
|
|
197
|
+
echo "[ERROR] already specified --sec(-s) or --https option"
|
|
198
|
+
exit 1
|
|
199
|
+
fi
|
|
200
|
+
HTTPS_ENV="yes"
|
|
201
|
+
|
|
202
|
+
elif [ "$1" = "-d" ] || [ "$1" = "-D" ] || [ "$1" = "--debuglevel" ] || [ "$1" = "--DEBUGLEVEL" ]; then
|
|
203
|
+
#
|
|
204
|
+
# DEBUG option
|
|
205
|
+
#
|
|
206
|
+
shift
|
|
207
|
+
if [ $# -eq 0 ]; then
|
|
208
|
+
echo "[ERROR] --debuglevel(-d) option needs parameter(dbg/msg/warn/err)"
|
|
209
|
+
exit 1
|
|
210
|
+
fi
|
|
211
|
+
if [ "$1" = "dbg" ] || [ "$1" = "DBG" ] || [ "$1" = "debug" ] || [ "$1" = "DEBUG" ]; then
|
|
212
|
+
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
213
|
+
echo "[ERROR] --debuglevel(-d) option already is set"
|
|
214
|
+
exit 1
|
|
215
|
+
fi
|
|
216
|
+
DEBUG_ENV_LEVEL=4
|
|
217
|
+
elif [ "$1" = "msg" ] || [ "$1" = "MSG" ] || [ "$1" = "message" ] || [ "$1" = "MESSAGE" ] || [ "$1" = "info" ] || [ "$1" = "INFO" ]; then
|
|
218
|
+
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
219
|
+
echo "[ERROR] --debuglevel(-d) option already is set"
|
|
220
|
+
exit 1
|
|
221
|
+
fi
|
|
222
|
+
DEBUG_ENV_LEVEL=3
|
|
223
|
+
elif [ "$1" = "warn" ] || [ "$1" = "WARN" ] || [ "$1" = "warning" ] || [ "$1" = "WARNING" ]; then
|
|
224
|
+
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
225
|
+
echo "[ERROR] --debuglevel(-d) option already is set"
|
|
226
|
+
exit 1
|
|
227
|
+
fi
|
|
228
|
+
DEBUG_ENV_LEVEL=2
|
|
229
|
+
elif [ "$1" = "err" ] || [ "$1" = "ERR" ] || [ "$1" = "error" ] || [ "$1" = "ERROR" ]; then
|
|
230
|
+
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
231
|
+
echo "[ERROR] --debuglevel(-d) option already is set"
|
|
232
|
+
exit 1
|
|
233
|
+
fi
|
|
234
|
+
DEBUG_ENV_LEVEL=1
|
|
235
|
+
else
|
|
236
|
+
#
|
|
237
|
+
# Custom debug level value
|
|
238
|
+
#
|
|
239
|
+
if [ -n "${DEBUG_ENV_CUSTOM}" ]; then
|
|
240
|
+
DEBUG_ENV_CUSTOM="${DEBUG_ENV_CUSTOM},"
|
|
241
|
+
fi
|
|
242
|
+
DEBUG_ENV_CUSTOM="${DEBUG_ENV_CUSTOM}$1"
|
|
243
|
+
fi
|
|
244
|
+
|
|
245
|
+
else
|
|
246
|
+
#
|
|
247
|
+
# Run test command
|
|
248
|
+
#
|
|
249
|
+
if [ -n "${COMMAND}" ]; then
|
|
250
|
+
echo "[ERROR] Already specified command name(${COMMAND}), could not specify multi command $1"
|
|
251
|
+
exit 1
|
|
252
|
+
fi
|
|
253
|
+
if ! COMMAND=$(CheckCommands "$1"); then
|
|
254
|
+
echo "[ERROR] $1 is not command name"
|
|
255
|
+
exit 1
|
|
256
|
+
fi
|
|
257
|
+
fi
|
|
258
|
+
shift
|
|
259
|
+
done
|
|
260
|
+
|
|
261
|
+
#
|
|
262
|
+
# Check Command
|
|
263
|
+
#
|
|
264
|
+
if [ -z "${COMMAND}" ]; then
|
|
265
|
+
echo "[ERROR] Command name is not specified"
|
|
266
|
+
exit 1
|
|
267
|
+
fi
|
|
268
|
+
|
|
269
|
+
#
|
|
270
|
+
# Make NODE_DEBUG environment
|
|
271
|
+
#
|
|
272
|
+
DEBUG_ENV_PARAM=""
|
|
273
|
+
if [ "${DEBUG_ENV_LEVEL}" -ge 4 ]; then
|
|
274
|
+
DEBUG_ENV_PARAM="LOGLEVEL_DBG"
|
|
275
|
+
elif [ "${DEBUG_ENV_LEVEL}" -ge 3 ]; then
|
|
276
|
+
DEBUG_ENV_PARAM="LOGLEVEL_MSG"
|
|
277
|
+
elif [ "${DEBUG_ENV_LEVEL}" -ge 2 ]; then
|
|
278
|
+
DEBUG_ENV_PARAM="LOGLEVEL_WAN"
|
|
279
|
+
elif [ "${DEBUG_ENV_LEVEL}" -ge 1 ]; then
|
|
280
|
+
DEBUG_ENV_PARAM="LOGLEVEL_ERR"
|
|
281
|
+
else
|
|
282
|
+
DEBUG_ENV_PARAM="LOGLEVEL_SILENT"
|
|
283
|
+
fi
|
|
284
|
+
if [ -n "${DEBUG_ENV_CUSTOM}" ]; then
|
|
285
|
+
if [ -n "${DEBUG_ENV_PARAM}" ]; then
|
|
286
|
+
DEBUG_ENV_PARAM="${DEBUG_ENV_PARAM},"
|
|
287
|
+
fi
|
|
288
|
+
DEBUG_ENV_PARAM="${DEBUG_ENV_PARAM}${DEBUG_ENV_CUSTOM}"
|
|
289
|
+
fi
|
|
290
|
+
|
|
291
|
+
#
|
|
292
|
+
# Check HTTPS
|
|
293
|
+
#
|
|
294
|
+
if [ -n "${HTTPS_ENV}" ]; then
|
|
295
|
+
HTTPS_ENV="yes"
|
|
296
|
+
fi
|
|
297
|
+
|
|
298
|
+
#
|
|
299
|
+
# Check K2HR3 API HOST/PORT
|
|
300
|
+
#
|
|
301
|
+
if [ -z "${APIHOST}" ]; then
|
|
302
|
+
APIHOST="$(hostname | tr -d '\n')"
|
|
303
|
+
fi
|
|
304
|
+
if [ "${APIPORT}" -eq 0 ]; then
|
|
305
|
+
if [ -n "${HTTPS_ENV}" ]; then
|
|
306
|
+
APIPORT=443
|
|
307
|
+
else
|
|
308
|
+
APIPORT=3000
|
|
309
|
+
fi
|
|
310
|
+
fi
|
|
311
|
+
|
|
312
|
+
#==========================================================
|
|
313
|
+
# Do work
|
|
314
|
+
#==========================================================
|
|
315
|
+
cd "${SRCTOP}" || exit 1
|
|
316
|
+
|
|
317
|
+
if [ "${DEBUG_ENV_LEVEL}" -ge 4 ]; then
|
|
318
|
+
echo "***** RUN *****"
|
|
319
|
+
echo "NODE_PATH=${NODE_PATH} NODE_DEBUG=${DEBUG_ENV_PARAM} APIHOST=${APIHOST} APIPORT=${APIPORT} HTTPS_ENV=${HTTPS_ENV} node ${DEBUG_OPTION} tests/${CMD_PREFIX}${COMMAND}${CMD_SUFFIX}"
|
|
320
|
+
echo "***************"
|
|
321
|
+
fi
|
|
322
|
+
|
|
323
|
+
if ! NODE_PATH="${NODE_PATH}" NODE_DEBUG="${DEBUG_ENV_PARAM}" APIHOST="${APIHOST}" APIPORT="${APIPORT}" HTTPS_ENV="${HTTPS_ENV}" node "${DEBUG_OPTION}" "tests/${CMD_PREFIX}${COMMAND}${CMD_SUFFIX}"; then
|
|
324
|
+
EXIT_CODE="$?"
|
|
325
|
+
echo "[ERROR] Failed to run command with exit code : ${EXIT_CODE}"
|
|
326
|
+
exit "${EXIT_CODE}"
|
|
327
|
+
fi
|
|
328
|
+
|
|
329
|
+
exit 0
|
|
330
|
+
|
|
331
|
+
#
|
|
332
|
+
# Local variables:
|
|
333
|
+
# tab-width: 4
|
|
334
|
+
# c-basic-offset: 4
|
|
335
|
+
# End:
|
|
336
|
+
# vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
337
|
+
# vim<600: noexpandtab sw=4 ts=4
|
|
338
|
+
#
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* K2HR3 REST API
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2017 Yahoo
|
|
4
|
+
* Copyright 2017 Yahoo Japan Corporation.
|
|
5
5
|
*
|
|
6
6
|
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
7
7
|
* common management information for the cloud.
|
|
@@ -164,7 +164,10 @@ cliutil.getConsoleInput('Response Type (gzip or text(default)) : ', true, false,
|
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
/*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
167
|
+
* Local variables:
|
|
168
|
+
* tab-width: 4
|
|
169
|
+
* c-basic-offset: 4
|
|
170
|
+
* End:
|
|
171
|
+
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
172
|
+
* vim<600: noexpandtab sw=4 ts=4
|
|
170
173
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* K2HR3 REST API
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2017 Yahoo
|
|
4
|
+
* Copyright 2017 Yahoo Japan Corporation.
|
|
5
5
|
*
|
|
6
6
|
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
7
7
|
* common management information for the cloud.
|
|
@@ -128,7 +128,10 @@ cliutil.getConsoleInput('Method(GET/HEAD) : ', true, false, function(isbreak, me
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
/*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
131
|
+
* Local variables:
|
|
132
|
+
* tab-width: 4
|
|
133
|
+
* c-basic-offset: 4
|
|
134
|
+
* End:
|
|
135
|
+
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
136
|
+
* vim<600: noexpandtab sw=4 ts=4
|
|
134
137
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* K2HR3 REST API
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2017 Yahoo
|
|
4
|
+
* Copyright 2017 Yahoo Japan Corporation.
|
|
5
5
|
*
|
|
6
6
|
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
7
7
|
* common management information for the cloud.
|
|
@@ -303,7 +303,10 @@ cliutil.getConsoleInput('Method(POST/PUT) : ', true, false, functi
|
|
|
303
303
|
});
|
|
304
304
|
|
|
305
305
|
/*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
306
|
+
* Local variables:
|
|
307
|
+
* tab-width: 4
|
|
308
|
+
* c-basic-offset: 4
|
|
309
|
+
* End:
|
|
310
|
+
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
311
|
+
* vim<600: noexpandtab sw=4 ts=4
|
|
309
312
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* K2HR3 REST API
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2017 Yahoo
|
|
4
|
+
* Copyright 2017 Yahoo Japan Corporation.
|
|
5
5
|
*
|
|
6
6
|
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
7
7
|
* common management information for the cloud.
|
|
@@ -118,7 +118,10 @@ cliutil.getConsoleInput('path(\'/\' or \'/v1\') : ', true, false, function(isbre
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
/*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
121
|
+
* Local variables:
|
|
122
|
+
* tab-width: 4
|
|
123
|
+
* c-basic-offset: 4
|
|
124
|
+
* End:
|
|
125
|
+
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
126
|
+
* vim<600: noexpandtab sw=4 ts=4
|
|
124
127
|
*/
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# K2HR3 REST API
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2017 Yahoo Japan Corporation.
|
|
6
|
+
#
|
|
7
|
+
# K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
8
|
+
# common management information for the cloud.
|
|
9
|
+
# K2HR3 can dynamically manage information as "who", "what", "operate".
|
|
10
|
+
# These are stored as roles, resources, policies in K2hdkc, and the
|
|
11
|
+
# client system can dynamically read and modify these information.
|
|
12
|
+
#
|
|
13
|
+
# For the full copyright and license information, please view
|
|
14
|
+
# the license file that was distributed with this source code.
|
|
15
|
+
#
|
|
16
|
+
# AUTHOR: Takeshi Nakatani
|
|
17
|
+
# CREATE: Wed Dec 27 2017
|
|
18
|
+
# REVISION:
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
#==========================================================
|
|
22
|
+
# Common Variables
|
|
23
|
+
#==========================================================
|
|
24
|
+
PRGNAME=$(basename "$0")
|
|
25
|
+
SCRIPTDIR=$(dirname "$0")
|
|
26
|
+
SCRIPTDIR=$(cd "${SCRIPTDIR}" || exit 1; pwd)
|
|
27
|
+
SRCTOP=$(cd "${SCRIPTDIR}/.." || exit 1; pwd)
|
|
28
|
+
TESTDIR=$(cd "${SRCTOP}/tests" || exit 1; pwd)
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# Variables
|
|
32
|
+
#
|
|
33
|
+
AUTO_CTRL_SH="${TESTDIR}/auto_control_subprocess.sh"
|
|
34
|
+
TEST_LOAD_SH="${TESTDIR}/k2hdkc_test_load.sh"
|
|
35
|
+
|
|
36
|
+
#==============================================================
|
|
37
|
+
# Utility functions
|
|
38
|
+
#==============================================================
|
|
39
|
+
#
|
|
40
|
+
# Usage
|
|
41
|
+
#
|
|
42
|
+
PrintUsage()
|
|
43
|
+
{
|
|
44
|
+
echo ""
|
|
45
|
+
echo "Usage: $1 [--key(-k) keyword(group name for control)] [start | stop]"
|
|
46
|
+
echo ""
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#==========================================================
|
|
50
|
+
# Parse options
|
|
51
|
+
#==========================================================
|
|
52
|
+
SCRIPT_MODE=""
|
|
53
|
+
KEY_SUFFIX=""
|
|
54
|
+
|
|
55
|
+
while [ $# -ne 0 ]; do
|
|
56
|
+
if [ -z "$1" ]; then
|
|
57
|
+
break
|
|
58
|
+
|
|
59
|
+
elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then
|
|
60
|
+
PrintUsage "${PRGNAME}"
|
|
61
|
+
exit 0
|
|
62
|
+
|
|
63
|
+
elif [ "$1" = "-k" ] || [ "$1" = "-K" ] || [ "$1" = "--key" ] || [ "$1" = "--KEY" ]; then
|
|
64
|
+
if [ -n "${KEY_SUFFIX}" ]; then
|
|
65
|
+
echo "[ERROR] already set --key(-k) option"
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
shift
|
|
69
|
+
if [ $# -eq 0 ]; then
|
|
70
|
+
echo "[ERROR] --key(-k) option needs parameter"
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
KEY_SUFFIX="_$1"
|
|
74
|
+
|
|
75
|
+
elif [ "$1" = "start" ] || [ "$1" = "START" ]; then
|
|
76
|
+
if [ -n "${SCRIPT_MODE}" ]; then
|
|
77
|
+
echo "[ERROR] already specified start or stop"
|
|
78
|
+
exit 1
|
|
79
|
+
fi
|
|
80
|
+
SCRIPT_MODE="start"
|
|
81
|
+
|
|
82
|
+
elif [ "$1" = "stop" ] || [ "$1" = "STOP" ]; then
|
|
83
|
+
if [ -n "${SCRIPT_MODE}" ]; then
|
|
84
|
+
echo "[ERROR] already specified start or stop"
|
|
85
|
+
exit 1
|
|
86
|
+
fi
|
|
87
|
+
SCRIPT_MODE="stop"
|
|
88
|
+
|
|
89
|
+
else
|
|
90
|
+
echo "[ERROR] Unknown option $1"
|
|
91
|
+
exit 1
|
|
92
|
+
fi
|
|
93
|
+
shift
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Check option
|
|
98
|
+
#
|
|
99
|
+
if [ -z "${SCRIPT_MODE}" ]; then
|
|
100
|
+
echo "[ERROR] You must specify start or stop"
|
|
101
|
+
exit 1
|
|
102
|
+
fi
|
|
103
|
+
|
|
104
|
+
#==========================================================
|
|
105
|
+
# Do work
|
|
106
|
+
#==========================================================
|
|
107
|
+
if [ "${SCRIPT_MODE}" = "start" ]; then
|
|
108
|
+
#
|
|
109
|
+
# Start
|
|
110
|
+
#
|
|
111
|
+
echo "*** Start : chmpx server node for k2hdkc"
|
|
112
|
+
printf " "
|
|
113
|
+
if ! "${AUTO_CTRL_SH}" --start --key "server${KEY_SUFFIX}" --interval 3 -- chmpx -conf "${TESTDIR}"/auto_k2hdkc_server.ini -ctlport 18021 -d msg; then
|
|
114
|
+
echo "[ERROR] could not run chmpx server node for k2hdkc"
|
|
115
|
+
exit 1
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
echo "*** Start : one k2hdkc process"
|
|
119
|
+
printf " "
|
|
120
|
+
if ! "${AUTO_CTRL_SH}" --start --key "server${KEY_SUFFIX}" --interval 3 -- k2hdkc -conf "${TESTDIR}"/auto_k2hdkc_server.ini -ctlport 18021 -d msg; then
|
|
121
|
+
echo "[ERROR] one k2hdkc process"
|
|
122
|
+
exit 1
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
echo "*** Start : chmpx slave node for k2hdkc"
|
|
126
|
+
printf " "
|
|
127
|
+
if ! "${AUTO_CTRL_SH}" --start --key "slave${KEY_SUFFIX}" --interval 3 -- chmpx -conf "${TESTDIR}"/auto_k2hdkc_slave.ini -ctlport 18031 -d msg; then
|
|
128
|
+
echo "[ERROR] chmpx slave node for k2hdkc"
|
|
129
|
+
exit 1
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
echo "*** Start : load default test data to k2hdkc"
|
|
133
|
+
printf " "
|
|
134
|
+
if ! "${TEST_LOAD_SH}" --for_auto_test; then
|
|
135
|
+
echo "[ERROR] load default test data to k2hdkc"
|
|
136
|
+
exit 1
|
|
137
|
+
fi
|
|
138
|
+
else
|
|
139
|
+
#
|
|
140
|
+
# Stop
|
|
141
|
+
#
|
|
142
|
+
echo "*** Stop : chmpx slave node for k2hdkc"
|
|
143
|
+
printf " "
|
|
144
|
+
if ! "${AUTO_CTRL_SH}" --stop --key "slave${KEY_SUFFIX}" --interval 3 -- chmpx; then
|
|
145
|
+
echo "[ERROR] chmpx slave node for k2hdkc"
|
|
146
|
+
exit 1
|
|
147
|
+
fi
|
|
148
|
+
|
|
149
|
+
echo "*** Stop : one k2hdkc process"
|
|
150
|
+
printf " "
|
|
151
|
+
if ! "${AUTO_CTRL_SH}" --stop --key "server${KEY_SUFFIX}" --interval 3 -- k2hdkc; then
|
|
152
|
+
echo "[ERROR] one k2hdkc process"
|
|
153
|
+
exit 1
|
|
154
|
+
fi
|
|
155
|
+
|
|
156
|
+
echo "*** Stop : chmpx server node for k2hdkc"
|
|
157
|
+
printf " "
|
|
158
|
+
if ! "${AUTO_CTRL_SH}" --stop --key "server${KEY_SUFFIX}" --interval 3 -- chmpx; then
|
|
159
|
+
echo "[ERROR] could not run chmpx server node for k2hdkc"
|
|
160
|
+
exit 1
|
|
161
|
+
fi
|
|
162
|
+
fi
|
|
163
|
+
echo "[SUCCEED] Finished"
|
|
164
|
+
|
|
165
|
+
exit 0
|
|
166
|
+
|
|
167
|
+
#
|
|
168
|
+
# Local variables:
|
|
169
|
+
# tab-width: 4
|
|
170
|
+
# c-basic-offset: 4
|
|
171
|
+
# End:
|
|
172
|
+
# vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
173
|
+
# vim<600: noexpandtab sw=4 ts=4
|
|
174
|
+
#
|