k2hr3-api 1.0.11 → 1.0.12

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.
Files changed (121) hide show
  1. package/ChangeLog +18 -0
  2. package/app.js +7 -4
  3. package/bin/run.sh +218 -172
  4. package/bin/watcher +7 -4
  5. package/bin/www +7 -4
  6. package/config/default.json +7 -4
  7. package/config/development.json +7 -4
  8. package/config/dummyuser.json +8 -5
  9. package/config/extdata-dummy.sh.templ +12 -9
  10. package/config/k2hr3-cloud-config.txt.templ +7 -4
  11. package/config/k2hr3-init-error.sh.templ +8 -5
  12. package/config/k2hr3-init.sh.templ +127 -207
  13. package/config/keystone_v2.json +7 -4
  14. package/config/keystone_v3.json +7 -4
  15. package/lib/basicipcheck.js +7 -4
  16. package/lib/cacerts.js +7 -4
  17. package/lib/dbglogging.js +7 -4
  18. package/lib/dummyuserapi.js +7 -4
  19. package/lib/ipwatch.js +7 -4
  20. package/lib/k2hr3acrutil.js +7 -5
  21. package/lib/k2hr3apiutil.js +7 -4
  22. package/lib/k2hr3cliutil.js +7 -4
  23. package/lib/k2hr3config.js +7 -4
  24. package/lib/k2hr3cryptutil.js +7 -4
  25. package/lib/k2hr3dkc.js +7 -4
  26. package/lib/k2hr3extdata.js +7 -4
  27. package/lib/k2hr3keys.js +7 -4
  28. package/lib/k2hr3resutil.js +7 -4
  29. package/lib/k2hr3template.js +7 -4
  30. package/lib/k2hr3tokens.js +7 -4
  31. package/lib/k2hr3userdata.js +8 -5
  32. package/lib/k8soidc.js +1 -1
  33. package/lib/openstackapiv2.js +7 -4
  34. package/lib/openstackapiv3.js +7 -4
  35. package/lib/openstackep.js +7 -4
  36. package/package.json +73 -72
  37. package/routes/acr.js +7 -4
  38. package/routes/debugVerify.js +7 -4
  39. package/routes/extdata.js +7 -4
  40. package/routes/list.js +7 -4
  41. package/routes/policy.js +7 -4
  42. package/routes/resource.js +7 -4
  43. package/routes/role.js +7 -4
  44. package/routes/service.js +7 -4
  45. package/routes/userTokens.js +7 -4
  46. package/routes/userdata.js +7 -4
  47. package/routes/version.js +7 -4
  48. package/templ/Dockerfile.templ +35 -52
  49. package/{test → tests}/auto_acr.js +7 -4
  50. package/{test → tests}/auto_acr_spec.js +7 -4
  51. package/{test → tests}/auto_all_spec.js +7 -4
  52. package/{test → tests}/auto_common.js +7 -4
  53. package/tests/auto_control_subprocess.sh +239 -0
  54. package/{test → tests}/auto_extdata.js +7 -4
  55. package/{test → tests}/auto_extdata_spec.js +7 -4
  56. package/tests/auto_init_config_json.sh +275 -0
  57. package/{test → tests}/auto_k2hdkc_server.ini +7 -4
  58. package/{test → tests}/auto_k2hdkc_slave.ini +7 -4
  59. package/{test → tests}/auto_list.js +7 -4
  60. package/{test → tests}/auto_list_spec.js +7 -4
  61. package/{test → tests}/auto_policy.js +7 -4
  62. package/{test → tests}/auto_policy_spec.js +7 -4
  63. package/{test → tests}/auto_resource.js +7 -4
  64. package/{test → tests}/auto_resource_spec.js +7 -4
  65. package/{test → tests}/auto_role.js +7 -4
  66. package/{test → tests}/auto_role_spec.js +7 -4
  67. package/{test → tests}/auto_service.js +7 -4
  68. package/{test → tests}/auto_service_spec.js +7 -4
  69. package/{test → tests}/auto_subprocesses.js +14 -11
  70. package/tests/auto_template.sh +126 -0
  71. package/{test → tests}/auto_token_util.js +7 -4
  72. package/{test → tests}/auto_userdata.js +7 -4
  73. package/{test → tests}/auto_userdata_spec.js +7 -4
  74. package/{test → tests}/auto_usertokens.js +7 -4
  75. package/{test → tests}/auto_usertokens_spec.js +7 -4
  76. package/{test → tests}/auto_version.js +7 -4
  77. package/{test → tests}/auto_version_spec.js +7 -4
  78. package/{test → tests}/auto_watcher.js +7 -4
  79. package/{test → tests}/auto_watcher_spec.js +7 -4
  80. package/{test → tests}/k2hdkc_test.data +7 -4
  81. package/tests/k2hdkc_test_load.sh +255 -0
  82. package/{test → tests}/k2hr3template_test.js +7 -4
  83. package/tests/k2hr3template_test.sh +339 -0
  84. package/{test → tests}/k2hr3template_test_async.js +7 -4
  85. package/{test → tests}/k2hr3template_test_template.result +14 -8
  86. package/{test → tests}/k2hr3template_test_template.txt +7 -4
  87. package/{test → tests}/k2hr3template_test_vars.js +7 -4
  88. package/{test → tests}/manual_acr_delete.js +7 -4
  89. package/{test → tests}/manual_acr_get.js +7 -4
  90. package/{test → tests}/manual_acr_postput.js +7 -4
  91. package/{test → tests}/manual_allusertenant_get.js +7 -4
  92. package/{test → tests}/manual_extdata_get.js +7 -4
  93. package/{test → tests}/manual_k2hr3keys_get.js +7 -4
  94. package/{test → tests}/manual_list_gethead.js +7 -4
  95. package/{test → tests}/manual_policy_delete.js +7 -4
  96. package/{test → tests}/manual_policy_gethead.js +7 -4
  97. package/{test → tests}/manual_policy_postput.js +7 -4
  98. package/{test → tests}/manual_resource_delete.js +7 -4
  99. package/{test → tests}/manual_resource_gethead.js +7 -4
  100. package/{test → tests}/manual_resource_postput.js +7 -4
  101. package/{test → tests}/manual_role_delete.js +7 -4
  102. package/{test → tests}/manual_role_gethead.js +7 -4
  103. package/{test → tests}/manual_role_postput.js +7 -4
  104. package/{test → tests}/manual_service_delete.js +7 -4
  105. package/{test → tests}/manual_service_gethead.js +7 -4
  106. package/{test → tests}/manual_service_postput.js +7 -4
  107. package/tests/manual_test.sh +338 -0
  108. package/{test → tests}/manual_userdata_get.js +7 -4
  109. package/{test → tests}/manual_usertoken_gethead.js +7 -4
  110. package/{test → tests}/manual_usertoken_postput.js +7 -4
  111. package/{test → tests}/manual_version_get.js +7 -4
  112. package/tests/run_local_test_k2hdkc.sh +174 -0
  113. package/tests/test.sh +331 -0
  114. package/test/auto_control_subprocess.sh +0 -170
  115. package/test/auto_init_config_json.sh +0 -246
  116. package/test/auto_template.sh +0 -127
  117. package/test/auto_test.sh +0 -321
  118. package/test/k2hdkc_test_load.sh +0 -198
  119. package/test/k2hr3template_test.sh +0 -296
  120. package/test/manual_test.sh +0 -321
  121. package/test/run_local_test_k2hdkc.sh +0 -154
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * K2HR3 REST API
3
3
  *
4
- * Copyright 2017 Yahoo! Japan Corporation.
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.
@@ -129,7 +129,10 @@ describe('ALL K2HR3 API TEST', function(){ // eslint-disable-line no-undef
129
129
  });
130
130
 
131
131
  /*
132
- * VIM modelines
133
- *
134
- * vim:set ts=4 fenc=utf-8:
132
+ * Local variables:
133
+ * tab-width: 4
134
+ * c-basic-offset: 4
135
+ * End:
136
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
137
+ * vim<600: noexpandtab sw=4 ts=4
135
138
  */
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * K2HR3 REST API
3
3
  *
4
- * Copyright 2017 Yahoo! Japan Corporation.
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.
@@ -54,7 +54,10 @@ exports.json2url = function json2url(json){
54
54
  };
55
55
 
56
56
  /*
57
- * VIM modelines
58
- *
59
- * vim:set ts=4 fenc=utf-8:
57
+ * Local variables:
58
+ * tab-width: 4
59
+ * c-basic-offset: 4
60
+ * End:
61
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
62
+ * vim<600: noexpandtab sw=4 ts=4
60
63
  */
@@ -0,0 +1,239 @@
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: Tue Dec 19 2017
18
+ # REVISION:
19
+ #
20
+
21
+ #----------------------------------------------------------
22
+ # This script starts/stops k2hdkc cluster/chmpx server/
23
+ # chmpx slave processes, and initializes data on k2hdkc for
24
+ # testing.
25
+ #----------------------------------------------------------
26
+
27
+ #==========================================================
28
+ # Common Variables
29
+ #==========================================================
30
+ PRGNAME=$(basename "$0")
31
+ SCRIPTDIR=$(dirname "$0")
32
+ SCRIPTDIR=$(cd "${SCRIPTDIR}" || exit 1; pwd)
33
+ #SRCTOP=$(cd "${SCRIPTDIR}/.." || exit 1; pwd)
34
+
35
+ #==============================================================
36
+ # Utility functions
37
+ #==============================================================
38
+ #
39
+ # Usage
40
+ #
41
+ PrintUsage()
42
+ {
43
+ echo ""
44
+ echo "Usage: $1 [ --help(-h) ] [ --start(-str) | --stop(-stp) ] [--key(-k) <key>] [--interval(-i) <sec>] -- <process> <arg>..."
45
+ echo ""
46
+ echo "Option:"
47
+ echo " --start(-str) : start process"
48
+ echo " --stop(-stp) : stop process"
49
+ echo " --key(-k) <key> : key name for controling process(a part of pid file name)"
50
+ echo " --interval(-i) <sec> : interval second time"
51
+ echo ""
52
+ }
53
+
54
+ #==========================================================
55
+ # Parse options
56
+ #==========================================================
57
+ EXEC_MODE=""
58
+ RUN_INTERVAL=0
59
+ PID_FILENAME_EXT_PART=""
60
+ CHILD_PROCESS_NAME=""
61
+ CHILD_PROCESS_CMD=""
62
+
63
+ while [ $# -ne 0 ]; do
64
+ if [ -z "$1" ]; then
65
+ break
66
+
67
+ elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then
68
+ PrintUsage "${PRGNAME}"
69
+ exit 0
70
+
71
+ elif [ "$1" = "-str" ] || [ "$1" = "-STR" ] || [ "$1" = "--start" ] || [ "$1" = "--START" ]; then
72
+ if [ -n "${EXEC_MODE}" ]; then
73
+ echo "[ERROR] Already run mode(--start(-str) or --stop(-stp) option) is specified."
74
+ exit 1
75
+ fi
76
+ EXEC_MODE="start"
77
+
78
+ elif [ "$1" = "-stp" ] || [ "$1" = "-STP" ] || [ "$1" = "--stop" ] || [ "$1" = "--STOP" ]; then
79
+ if [ -n "${EXEC_MODE}" ]; then
80
+ echo "[ERROR] Already run mode(--start(-str) or --stop(-stp) option) is specified."
81
+ exit 1
82
+ fi
83
+ EXEC_MODE="stop"
84
+
85
+ elif [ "$1" = "-k" ] || [ "$1" = "-K" ] || [ "$1" = "--key" ] || [ "$1" = "--KEY" ]; then
86
+ if [ -n "${PID_FILENAME_EXT_PART}" ]; then
87
+ echo "[ERROR] Already --key(-k) option is specified."
88
+ exit 1
89
+ fi
90
+ shift
91
+ if [ $# -eq 0 ]; then
92
+ echo "[ERROR] --key(-k) option needs parameter"
93
+ exit 1
94
+ fi
95
+ PID_FILENAME_EXT_PART="_$1"
96
+
97
+ elif [ "$1" = "-i" ] || [ "$1" = "-I" ] || [ "$1" = "-int" ] || [ "$1" = "-INT" ] || [ "$1" = "--interval" ] || [ "$1" = "--INTERVAL" ]; then
98
+ if [ "${RUN_INTERVAL}" -ne 0 ]; then
99
+ echo "[ERROR] Already --interval(-i) option is specified."
100
+ exit 1
101
+ fi
102
+ shift
103
+ if [ $# -eq 0 ]; then
104
+ echo "[ERROR] --interval(-i) option needs parameter"
105
+ exit 1
106
+ fi
107
+ if echo "$1" | grep -q '[^0-9]'; then
108
+ echo "[ERROR] --interval(-i) option parameter must be number(second)"
109
+ exit 1
110
+ elif [ "$1" -eq 0 ]; then
111
+ echo "[ERROR] --interval(-i) option parameter must be positive number(second)"
112
+ exit 1
113
+ fi
114
+ RUN_INTERVAL="$1"
115
+
116
+ elif [ "$1" = "--" ]; then
117
+ #
118
+ # Finish to parse option, rest arguments are command and it's args
119
+ #
120
+ if [ -n "${CHILD_PROCESS_NAME}" ]; then
121
+ echo "[ERROR] Already \"-- <process> <arg>...\" option is specified(${CHILD_PROCESS_CMD})"
122
+ exit 1
123
+ fi
124
+ shift
125
+ if [ -z "$1" ]; then
126
+ echo "[ERROR] \"-- <process> <arg>...\" option need parameter"
127
+ exit 1
128
+ fi
129
+ CHILD_PROCESS_NAME="$1"
130
+ CHILD_PROCESS_CMD="$*"
131
+ break
132
+
133
+ else
134
+ echo "[ERROR] Unknown option $1."
135
+ exit 1
136
+ fi
137
+ shift
138
+ done
139
+
140
+ #
141
+ # Check execute mode
142
+ #
143
+ if [ -z "${EXEC_MODE}" ]; then
144
+ echo "[ERROR] You must specify --start(-str) or --stop(-stp) option."
145
+ exit 1
146
+ fi
147
+
148
+ #
149
+ # Check sub process options
150
+ #
151
+ if [ -z "${CHILD_PROCESS_NAME}" ] || [ -z "${CHILD_PROCESS_CMD}" ]; then
152
+ echo "[ERROR] No sub process and arguments are specified."
153
+ exit 1
154
+ fi
155
+
156
+ #
157
+ # Process pid/log
158
+ #
159
+ CHILD_PROCESS_PIDFILE="/tmp/${PRGNAME}_${CHILD_PROCESS_NAME}${PID_FILENAME_EXT_PART}.pid"
160
+ CHILD_PROCESS_LOGFILE="/tmp/${PRGNAME}_${CHILD_PROCESS_NAME}${PID_FILENAME_EXT_PART}.log"
161
+
162
+ #==========================================================
163
+ # Execute
164
+ #==========================================================
165
+ if [ "${EXEC_MODE}" = "start" ]; then
166
+ #
167
+ # Start Process
168
+ #
169
+ ${CHILD_PROCESS_CMD} >"${CHILD_PROCESS_LOGFILE}" 2>&1 &
170
+ CHILD_PROCESS_PID=$!
171
+
172
+ if [ "${RUN_INTERVAL}" -gt 0 ]; then
173
+ sleep "${RUN_INTERVAL}"
174
+ fi
175
+
176
+ if ! ps -p "${CHILD_PROCESS_PID}" >/dev/null 2>&1; then
177
+ echo "[ERROR] Could not start child process : ${CHILD_PROCESS_CMD}"
178
+ exit 1
179
+ fi
180
+ echo "${CHILD_PROCESS_PID}" >"${CHILD_PROCESS_PIDFILE}"
181
+
182
+ echo "[SUCCEED] Start process(${CHILD_PROCESS_PID}) : ${CHILD_PROCESS_CMD}"
183
+
184
+ else
185
+ #
186
+ # Stop Process
187
+ #
188
+ if [ -n "${CHILD_PROCESS_PIDFILE}" ] && [ -f "${CHILD_PROCESS_PIDFILE}" ]; then
189
+
190
+ CHILD_PROCESS_PID="$(tr -d '\n' < "${CHILD_PROCESS_PIDFILE}")"
191
+
192
+ if ps -p "${CHILD_PROCESS_PID}" >/dev/null 2>&1; then
193
+ #
194
+ # Try stop
195
+ #
196
+ if ! kill -HUP "${CHILD_PROCESS_PID}"; then
197
+ echo "[WARNING] Failed to stop(HUP) process : ${CHILD_PROCESS_NAME}"
198
+ fi
199
+ if [ "${RUN_INTERVAL}" -gt 0 ]; then
200
+ sleep "${RUN_INTERVAL}"
201
+ fi
202
+
203
+ if ps -p "${CHILD_PROCESS_PID}" >/dev/null 2>&1; then
204
+ #
205
+ # Retry stop
206
+ #
207
+ if ! kill -KILL "${CHILD_PROCESS_PID}"; then
208
+ echo "[WARNING] Failed to stop(KILL) process : ${CHILD_PROCESS_NAME}"
209
+ fi
210
+ if [ "${RUN_INTERVAL}" -gt 0 ]; then
211
+ sleep "${RUN_INTERVAL}"
212
+ fi
213
+
214
+ if ps -p "${CHILD_PROCESS_PID}" >/dev/null 2>&1; then
215
+ echo "[ERROR] Could not stop process : ${CHILD_PROCESS_NAME}"
216
+ exit 1
217
+ fi
218
+ fi
219
+
220
+ echo "[SUCCEED] Stop process : ${CHILD_PROCESS_NAME}(${CHILD_PROCESS_PID})"
221
+ else
222
+ echo "[SUCCEED] Already stop process : ${CHILD_PROCESS_NAME}(${CHILD_PROCESS_PID})"
223
+ fi
224
+ rm -f "${CHILD_PROCESS_PIDFILE}"
225
+ else
226
+ echo "[SUCCEED] Already stop process, because not found child process pid file : ${CHILD_PROCESS_PIDFILE}"
227
+ fi
228
+ fi
229
+
230
+ exit 0
231
+
232
+ #
233
+ # Local variables:
234
+ # tab-width: 4
235
+ # c-basic-offset: 4
236
+ # End:
237
+ # vim600: noexpandtab sw=4 ts=4 fdm=marker
238
+ # vim<600: noexpandtab sw=4 ts=4
239
+ #
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * K2HR3 REST API
3
3
  *
4
- * Copyright 2017 Yahoo! Japan Corporation.
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.
@@ -209,7 +209,10 @@ describe('API : EXTDATA', function(){ // eslint-disable-line no-undef
209
209
  });
210
210
 
211
211
  /*
212
- * VIM modelines
213
- *
214
- * vim:set ts=4 fenc=utf-8:
212
+ * Local variables:
213
+ * tab-width: 4
214
+ * c-basic-offset: 4
215
+ * End:
216
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
217
+ * vim<600: noexpandtab sw=4 ts=4
215
218
  */
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * K2HR3 REST API
3
3
  *
4
- * Copyright 2017 Yahoo! Japan Corporation.
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.
@@ -70,7 +70,10 @@ describe('SUB API TEST: EXTDATA', function(){ // eslint-disable-line no-undef
70
70
  });
71
71
 
72
72
  /*
73
- * VIM modelines
74
- *
75
- * vim:set ts=4 fenc=utf-8:
73
+ * Local variables:
74
+ * tab-width: 4
75
+ * c-basic-offset: 4
76
+ * End:
77
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
78
+ * vim<600: noexpandtab sw=4 ts=4
76
79
  */
@@ -0,0 +1,275 @@
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: Mon Dec 25 2017
18
+ # REVISION:
19
+ #
20
+
21
+ #----------------------------------------------------------
22
+ # This script is checking/creating/Restoring config/local.json
23
+ # (and local-development.json) for test environment
24
+ #----------------------------------------------------------
25
+
26
+ #==========================================================
27
+ # Common Variables
28
+ #==========================================================
29
+ PRGNAME=$(basename "$0")
30
+ SCRIPTDIR=$(dirname "$0")
31
+ SCRIPTDIR=$(cd "${SCRIPTDIR}" || exit 1; pwd)
32
+ SRCTOP=$(cd "${SCRIPTDIR}/.." || exit 1; pwd)
33
+
34
+ #
35
+ # Variables
36
+ #
37
+ CONFIGDIR="${SRCTOP}/config"
38
+ LOCAL_JSON="${CONFIGDIR}/local.json"
39
+ LOCAL_JSON_BUP="${LOCAL_JSON}_AUTOTEST_BUP"
40
+ LOCALDEVELOP_JSON="${CONFIGDIR}/local-development.json"
41
+ LOCALDEVELOP_JSON_BUP="${LOCALDEVELOP_JSON}_AUTOTEST_BUP"
42
+ DUMMY_JSON="${CONFIGDIR}/dummyuser.json"
43
+
44
+ #==============================================================
45
+ # Utility functions
46
+ #==============================================================
47
+ #
48
+ # Usage
49
+ #
50
+ PrintUsage()
51
+ {
52
+ echo ""
53
+ echo "Usage: $1 [--help(-h)] [--set(-s) | --restore(-r)]"
54
+ echo ""
55
+ }
56
+
57
+ #==========================================================
58
+ # Parse options
59
+ #==========================================================
60
+ PROC_MODE=""
61
+
62
+ while [ $# -ne 0 ]; do
63
+ if [ -z "$1" ]; then
64
+ break
65
+
66
+ elif [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" = "--help" ] || [ "$1" = "--HELP" ]; then
67
+ PrintUsage "${PRGNAME}"
68
+ exit 0
69
+
70
+ elif [ "$1" = "-s" ] || [ "$1" = "-S" ] || [ "$1" = "--set" ] || [ "$1" = "--SET" ]; then
71
+ if [ -n "${PROC_MODE}" ]; then
72
+ echo "[ERROR] already specified --set(-s) or --restore(-r) option"
73
+ exit 1
74
+ fi
75
+ PROC_MODE="set"
76
+
77
+ elif [ "$1" = "-r" ] || [ "$1" = "-R" ] || [ "$1" = "--restore" ] || [ "$1" = "--RESTORE" ]; then
78
+ if [ -n "${PROC_MODE}" ]; then
79
+ echo "[ERROR] already specified --set(-s) or --restore(-r) option"
80
+ exit 1
81
+ fi
82
+ PROC_MODE="restore"
83
+
84
+ else
85
+ echo "[ERROR] Unknown option $1"
86
+ exit 1
87
+ fi
88
+ shift
89
+ done
90
+
91
+ if [ -z "${PROC_MODE}" ]; then
92
+ echo "[ERROR] You must specify --set(-s) or --restore(-r) option."
93
+ exit 1
94
+ fi
95
+
96
+ #==========================================================
97
+ # Do work
98
+ #==========================================================
99
+ if [ "${PROC_MODE}" = "set" ]; then
100
+ #
101
+ # Set Mode
102
+ #
103
+
104
+ #
105
+ # Check local.json
106
+ #
107
+ if [ -f "${LOCAL_JSON}" ]; then
108
+ if [ ! -L "${LOCAL_JSON}" ]; then
109
+ echo "[ERROR] ${LOCAL_JSON} is existed as real file."
110
+ exit 1
111
+ fi
112
+
113
+ if ! SLINK_FILE=$(readlink "${LOCAL_JSON}"); then
114
+ echo "[ERROR] Could not read link as ${LOCAL_JSON}"
115
+ exit 1
116
+ fi
117
+
118
+ if [ "${SLINK_FILE}" = "${DUMMY_JSON}" ]; then
119
+ #
120
+ # local.json is already linked to dummyuser.json
121
+ #
122
+ echo "[INFO] Already ${LOCAL_JSON} file is linked ${DUMMY_JSON}"
123
+
124
+ else
125
+ #
126
+ # Make backup and create new symbolic link file
127
+ #
128
+ if [ -f "${LOCAL_JSON_BUP}" ]; then
129
+ echo "[ERROR] Could not rename file ${LOCAL_JSON} to ${LOCAL_JSON_BUP}, because ${LOCAL_JSON_BUP} already exists."
130
+ exit 1
131
+ fi
132
+
133
+ #
134
+ # Rename
135
+ #
136
+ if ! mv "${LOCAL_JSON}" "${LOCAL_JSON_BUP}" >/dev/null 2>&1; then
137
+ echo "[ERROR] Could not rename file ${LOCAL_JSON} to ${LOCAL_JSON_BUP}"
138
+ exit 1
139
+ fi
140
+
141
+ #
142
+ # Make symbolic link local.json
143
+ #
144
+ if ! ln -s "${DUMMY_JSON}" "${LOCAL_JSON}" >/dev/null 2>&1; then
145
+ echo "[ERROR] Could not create symbolic file ${DUMMY_JSON} to ${LOCAL_JSON}"
146
+ exit 1
147
+ fi
148
+ fi
149
+ else
150
+ #
151
+ # There is no local.json, thus only make symbolic link local.json
152
+ #
153
+ if ! ln -s "${DUMMY_JSON}" "${LOCAL_JSON}" >/dev/null 2>&1; then
154
+ echo "[ERROR] Could not create symbolic file ${DUMMY_JSON} to ${LOCAL_JSON}"
155
+ exit 1
156
+ fi
157
+ fi
158
+
159
+ #
160
+ # Check local-development.json
161
+ #
162
+ if [ -f "${LOCALDEVELOP_JSON}" ]; then
163
+ if [ -f "${LOCALDEVELOP_JSON_BUP}" ]; then
164
+ echo "[ERROR] Could not rename file ${LOCALDEVELOP_JSON} to ${LOCALDEVELOP_JSON_BUP}, because ${LOCALDEVELOP_JSON_BUP} already exists."
165
+ exit 1
166
+ fi
167
+
168
+ #
169
+ # Rename
170
+ #
171
+ if ! mv "${LOCALDEVELOP_JSON}" "${LOCALDEVELOP_JSON_BUP}" >/dev/null 2>&1; then
172
+ echo "[ERROR] Could not rename file ${LOCALDEVELOP_JSON} to ${LOCALDEVELOP_JSON_BUP}"
173
+ exit 1
174
+ fi
175
+ fi
176
+ else
177
+ #
178
+ # Restore Mode
179
+ #
180
+
181
+ #
182
+ # Restore local.json
183
+ #
184
+ if [ ! -f "${LOCAL_JSON_BUP}" ]; then
185
+ if [ -f "${LOCAL_JSON}" ]; then
186
+ if [ ! -L "${LOCAL_JSON}" ]; then
187
+ echo "[WARNING] Not found ${LOCAL_JSON_BUP} and exists ${LOCAL_JSON} as real file, so nothing to do"
188
+ else
189
+ #
190
+ # local.json is symbolic link
191
+ #
192
+ if ! SLINK_FILE=$(readlink "${LOCAL_JSON}"); then
193
+ echo "[ERROR] Could not read link as ${LOCAL_JSON}"
194
+ exit 1
195
+ fi
196
+
197
+ if [ "${SLINK_FILE}" = "${DUMMY_JSON}" ]; then
198
+ #
199
+ # local.json is linked to dummyuser.json
200
+ #
201
+ if ! rm -f "${LOCAL_JSON}"; then
202
+ echo "[ERROR] Could not remove file ${LOCAL_JSON}"
203
+ exit 1
204
+ fi
205
+ else
206
+ #
207
+ # local.json is not linked to dummyuser.json
208
+ #
209
+ echo "[WARNING] Not found ${LOCAL_JSON_BUP} and exists ${LOCAL_JSON} as symbolic link, but it is not linking to dummyuser.json"
210
+ fi
211
+ fi
212
+ else
213
+ echo "[WARNING] Not found ${LOCAL_JSON_BUP} and ${LOCAL_JSON}."
214
+ fi
215
+ else
216
+ if [ -f "${LOCAL_JSON}" ]; then
217
+ if [ ! -L "${LOCAL_JSON}" ]; then
218
+ echo "[WARNING] ${LOCAL_JSON} is not created by ${PRGNAME} program, because it is not symbolic link."
219
+ else
220
+ if ! SLINK_FILE=$(readlink "${LOCAL_JSON}"); then
221
+ echo "[ERROR] Could not read link as ${LOCAL_JSON}"
222
+ exit 1
223
+ fi
224
+
225
+ if [ "${SLINK_FILE}" != "${DUMMY_JSON}" ]; then
226
+ echo "[WARNING] ${LOCAL_JSON} is not created by ${PRGNAME} program, because it is not symbolic link to ${DUMMY_JSON}."
227
+ else
228
+ # remove
229
+ if ! rm -f "${LOCAL_JSON}"; then
230
+ echo "[ERROR] Could not remove file ${LOCAL_JSON}"
231
+ exit 1
232
+ fi
233
+ fi
234
+ fi
235
+ fi
236
+
237
+ #
238
+ # Rename
239
+ #
240
+ if ! mv "${LOCAL_JSON_BUP}" "${LOCAL_JSON}" >/dev/null 2>&1; then
241
+ echo "[ERROR] Could not rename file ${LOCAL_JSON_BUP} to ${LOCAL_JSON}"
242
+ exit 1
243
+ fi
244
+ fi
245
+
246
+ #
247
+ # Restore local-development.json
248
+ #
249
+ if [ ! -f "${LOCALDEVELOP_JSON_BUP}" ]; then
250
+ echo "[INFO] Not found ${LOCALDEVELOP_JSON_BUP}, skip restoring ${LOCALDEVELOP_JSON}."
251
+ else
252
+ if [ -f "${LOCALDEVELOP_JSON}" ]; then
253
+ echo "[WARNING] ${LOCALDEVELOP_JSON} already exists, could not restoring from ${LOCALDEVELOP_JSON_BUP}."
254
+ else
255
+ #
256
+ # Rename
257
+ #
258
+ if ! mv "${LOCALDEVELOP_JSON_BUP}" "${LOCALDEVELOP_JSON}" >/dev/null 2>&1; then
259
+ echo "[ERROR] Could not rename file ${LOCALDEVELOP_JSON_BUP} to ${LOCALDEVELOP_JSON}"
260
+ exit 1
261
+ fi
262
+ fi
263
+ fi
264
+ fi
265
+
266
+ exit 0
267
+
268
+ #
269
+ # Local variables:
270
+ # tab-width: 4
271
+ # c-basic-offset: 4
272
+ # End:
273
+ # vim600: noexpandtab sw=4 ts=4 fdm=marker
274
+ # vim<600: noexpandtab sw=4 ts=4
275
+ #
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # K2HDKC CONFIGRATION FILE K2HR3 REST API TEST
3
3
  #
4
- # Copyright 2017 Yahoo! Japan Corporation.
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.
@@ -100,7 +100,10 @@ MAXTHREAD = 4
100
100
  #REDUCETIME = 30
101
101
 
102
102
  #
103
- # VIM modelines
104
- #
105
- # vim:set ts=4 fenc=utf-8:
103
+ # Local variables:
104
+ # tab-width: 4
105
+ # c-basic-offset: 4
106
+ # End:
107
+ # vim600: noexpandtab sw=4 ts=4 fdm=marker
108
+ # vim<600: noexpandtab sw=4 ts=4
106
109
  #
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # K2HDKC CONFIGRATION FILE K2HR3 REST API TEST
3
3
  #
4
- # Copyright 2017 Yahoo! Japan Corporation.
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.
@@ -74,7 +74,10 @@ NAME = [.]*
74
74
  CTLPORT = 18031
75
75
 
76
76
  #
77
- # VIM modelines
78
- #
79
- # vim:set ts=4 fenc=utf-8:
77
+ # Local variables:
78
+ # tab-width: 4
79
+ # c-basic-offset: 4
80
+ # End:
81
+ # vim600: noexpandtab sw=4 ts=4 fdm=marker
82
+ # vim<600: noexpandtab sw=4 ts=4
80
83
  #
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * K2HR3 REST API
3
3
  *
4
- * Copyright 2017 Yahoo! Japan Corporation.
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.
@@ -430,7 +430,10 @@ describe('API : LIST', function(){ // eslint-disable-line no-undef
430
430
  });
431
431
 
432
432
  /*
433
- * VIM modelines
434
- *
435
- * vim:set ts=4 fenc=utf-8:
433
+ * Local variables:
434
+ * tab-width: 4
435
+ * c-basic-offset: 4
436
+ * End:
437
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
438
+ * vim<600: noexpandtab sw=4 ts=4
436
439
  */
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * K2HR3 REST API
3
3
  *
4
- * Copyright 2017 Yahoo! Japan Corporation.
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.
@@ -70,7 +70,10 @@ describe('SUB API TEST: LIST', function(){ // eslint-disable-line no-undef
70
70
  });
71
71
 
72
72
  /*
73
- * VIM modelines
74
- *
75
- * vim:set ts=4 fenc=utf-8:
73
+ * Local variables:
74
+ * tab-width: 4
75
+ * c-basic-offset: 4
76
+ * End:
77
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
78
+ * vim<600: noexpandtab sw=4 ts=4
76
79
  */