k2hr3-api 1.0.38 → 1.0.40
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 +12 -0
- package/README.md +31 -31
- package/app.js +6 -10
- package/bin/run.sh +21 -21
- package/bin/www +1 -1
- package/config/k2hr3-init.sh.templ +5 -5
- package/eslint.config.mjs +68 -0
- package/lib/cacerts.js +8 -7
- package/lib/dummyuserapi.js +1 -1
- package/lib/ipwatch.js +1 -1
- package/lib/k2hr3acrutil.js +12 -14
- package/lib/k2hr3apiutil.js +5 -5
- package/lib/k2hr3cryptutil.js +2 -0
- package/lib/k2hr3dkc.js +25 -28
- package/lib/k2hr3template.js +54 -52
- package/lib/k2hr3tokens.js +4 -4
- package/lib/k8soidc.js +3 -3
- package/lib/openstackapiv2.js +51 -52
- package/lib/openstackapiv3.js +86 -87
- package/lib/openstackep.js +46 -46
- package/package.json +8 -8
- package/routes/acr.js +66 -110
- package/routes/debugVerify.js +12 -14
- package/routes/extdata.js +24 -40
- package/routes/list.js +24 -36
- package/routes/policy.js +72 -120
- package/routes/resource.js +110 -165
- package/routes/role.js +177 -295
- package/routes/service.js +54 -90
- package/routes/userTokens.js +1 -1
- package/routes/userdata.js +12 -20
- package/routes/version.js +39 -23
- package/tests/auto_control_subprocess.sh +9 -9
- package/tests/auto_init_config_json.sh +3 -3
- package/tests/auto_resource.js +417 -478
- package/tests/auto_role.js +55 -71
- package/tests/auto_template.sh +4 -4
- package/tests/auto_version.js +39 -23
- package/tests/k2hdkc_test_load.sh +9 -9
- package/tests/k2hr3template_test.sh +12 -12
- package/tests/k2hr3template_test_vars.js +60 -62
- package/tests/manual_acr_delete.js +11 -12
- package/tests/manual_acr_get.js +9 -10
- package/tests/manual_acr_postput.js +12 -13
- package/tests/manual_extdata_get.js +5 -6
- package/tests/manual_list_gethead.js +12 -13
- package/tests/manual_policy_delete.js +12 -13
- package/tests/manual_policy_gethead.js +27 -27
- package/tests/manual_policy_postput.js +21 -23
- package/tests/manual_resource_delete.js +11 -15
- package/tests/manual_resource_gethead.js +11 -14
- package/tests/manual_resource_postput.js +18 -21
- package/tests/manual_role_delete.js +22 -28
- package/tests/manual_role_gethead.js +53 -53
- package/tests/manual_role_postput.js +28 -31
- package/tests/manual_service_delete.js +11 -13
- package/tests/manual_service_gethead.js +13 -15
- package/tests/manual_service_postput.js +10 -11
- package/tests/manual_test.sh +10 -10
- package/tests/manual_userdata_get.js +14 -15
- package/tests/manual_usertoken_gethead.js +12 -14
- package/tests/manual_usertoken_postput.js +23 -26
- package/tests/manual_version_get.js +12 -13
- package/tests/run_local_test_k2hdkc.sh +4 -4
- package/tests/test.sh +12 -12
|
@@ -42,12 +42,10 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function deleteV1Role(token, name, target_host, port, cuk)
|
|
44
44
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
45
|
+
var headers = {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
'Content-Length': 0,
|
|
48
|
+
};
|
|
51
49
|
|
|
52
50
|
if(apiutil.isSafeString(token)){
|
|
53
51
|
headers['X-Auth-Token'] = token;
|
|
@@ -69,14 +67,13 @@ function deleteV1Role(token, name, target_host, port, cuk)
|
|
|
69
67
|
already_set = true;
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
70
|
+
var options = {
|
|
71
|
+
'host': hostname,
|
|
72
|
+
'port': hostport,
|
|
73
|
+
'path': '/v1/role/' + name + encodeURI(urlarg),
|
|
74
|
+
'method': 'DELETE',
|
|
75
|
+
'headers': headers
|
|
76
|
+
};
|
|
80
77
|
|
|
81
78
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
82
79
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -128,12 +125,10 @@ function deleteV1Role(token, name, target_host, port, cuk)
|
|
|
128
125
|
//
|
|
129
126
|
function deleteV1_IPByCuk(addrs, port, cuk)
|
|
130
127
|
{
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
};
|
|
136
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
128
|
+
var headers = {
|
|
129
|
+
'Content-Type': 'application/json',
|
|
130
|
+
'Content-Length': 0,
|
|
131
|
+
};
|
|
137
132
|
|
|
138
133
|
var urlarg = '';
|
|
139
134
|
var already_set = false;
|
|
@@ -157,14 +152,13 @@ function deleteV1_IPByCuk(addrs, port, cuk)
|
|
|
157
152
|
already_set = true;
|
|
158
153
|
}
|
|
159
154
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
155
|
+
var options = {
|
|
156
|
+
'host': hostname,
|
|
157
|
+
'port': hostport,
|
|
158
|
+
'path': '/v1/role' + encodeURI(urlarg),
|
|
159
|
+
'method': 'DELETE',
|
|
160
|
+
'headers': headers
|
|
161
|
+
};
|
|
168
162
|
|
|
169
163
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
170
164
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -42,19 +42,18 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function getV1Role(token, name, is_expand)
|
|
44
44
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
45
|
+
var headers = {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
'Content-Length': 0,
|
|
48
|
+
'X-Auth-Token': token
|
|
49
|
+
};
|
|
50
|
+
var options = {
|
|
51
|
+
'host': hostname,
|
|
52
|
+
'port': hostport,
|
|
53
|
+
'path': '/v1/role/' + name + (is_expand ? '' : '?expand=false'), // default expand is true
|
|
54
|
+
'method': 'GET',
|
|
55
|
+
'headers': headers
|
|
56
|
+
};
|
|
58
57
|
|
|
59
58
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
60
59
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -103,25 +102,26 @@ function getV1Role(token, name, is_expand)
|
|
|
103
102
|
|
|
104
103
|
function getV1RoleToken(token, name, expire)
|
|
105
104
|
{
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
105
|
+
var headers = {
|
|
106
|
+
'Content-Type': 'application/json',
|
|
107
|
+
'Content-Length': 0,
|
|
108
|
+
};
|
|
111
109
|
if(apiutil.isSafeString(token)){
|
|
112
110
|
headers['X-Auth-Token'] = token;
|
|
113
111
|
}
|
|
114
|
-
|
|
112
|
+
|
|
113
|
+
var urlarg = '';
|
|
115
114
|
if(null !== expire && !isNaN(expire)){
|
|
116
|
-
urlarg
|
|
115
|
+
urlarg = '?expire=' + String(expire);
|
|
117
116
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
|
|
118
|
+
var options = {
|
|
119
|
+
'host': hostname,
|
|
120
|
+
'port': hostport,
|
|
121
|
+
'path': '/v1/role/token/' + name + urlarg,
|
|
122
|
+
'method': 'GET',
|
|
123
|
+
'headers': headers
|
|
124
|
+
};
|
|
125
125
|
|
|
126
126
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
127
127
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -169,21 +169,20 @@ function getV1RoleToken(token, name, expire)
|
|
|
169
169
|
|
|
170
170
|
function getV1RoleTokenList(token, name, expand)
|
|
171
171
|
{
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
};
|
|
172
|
+
var headers = {
|
|
173
|
+
'Content-Type': 'application/json',
|
|
174
|
+
'Content-Length': 0,
|
|
175
|
+
};
|
|
177
176
|
if(apiutil.isSafeString(token)){
|
|
178
177
|
headers['X-Auth-Token'] = token;
|
|
179
178
|
}
|
|
180
|
-
var options
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
var options = {
|
|
180
|
+
'host': hostname,
|
|
181
|
+
'port': hostport,
|
|
182
|
+
'path': '/v1/role/token/list/' + name + (expand ? '?expand=true' : '?expand=false'),
|
|
183
|
+
'method': 'GET',
|
|
184
|
+
'headers': headers
|
|
185
|
+
};
|
|
187
186
|
|
|
188
187
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
189
188
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -231,17 +230,17 @@ function getV1RoleTokenList(token, name, expand)
|
|
|
231
230
|
|
|
232
231
|
function headV1Role(token, roleyrn, port, cuk)
|
|
233
232
|
{
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
};
|
|
233
|
+
var headers = {
|
|
234
|
+
'Content-Type': 'application/json',
|
|
235
|
+
'Content-Length': 0
|
|
236
|
+
};
|
|
239
237
|
if(apiutil.isSafeString(token)){
|
|
240
238
|
headers['X-Auth-Token'] = token;
|
|
241
239
|
}
|
|
242
|
-
|
|
240
|
+
|
|
241
|
+
var urlargs = '';
|
|
243
242
|
if(null !== port){
|
|
244
|
-
urlargs
|
|
243
|
+
urlargs = '?port=' + String(port);
|
|
245
244
|
}
|
|
246
245
|
if(apiutil.isSafeString(cuk)){
|
|
247
246
|
if(apiutil.isSafeString(urlargs)){
|
|
@@ -251,13 +250,14 @@ function headV1Role(token, roleyrn, port, cuk)
|
|
|
251
250
|
}
|
|
252
251
|
urlargs += cuk;
|
|
253
252
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
253
|
+
|
|
254
|
+
var options = {
|
|
255
|
+
'host': hostname,
|
|
256
|
+
'port': hostport,
|
|
257
|
+
'path': '/v1/role/' + roleyrn + urlargs,
|
|
258
|
+
'method': 'HEAD',
|
|
259
|
+
'headers': headers
|
|
260
|
+
};
|
|
261
261
|
|
|
262
262
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
263
263
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -42,27 +42,25 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function postV1Role(method, token, name, policies, alias)
|
|
44
44
|
{
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
45
|
+
var strbody = '';
|
|
46
|
+
var headers = {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
'X-Auth-Token': token
|
|
49
|
+
};
|
|
50
|
+
var options = {
|
|
51
|
+
'host': hostname,
|
|
52
|
+
'port': hostport,
|
|
53
|
+
'method': method
|
|
54
|
+
};
|
|
56
55
|
|
|
57
56
|
if(apiutil.compareCaseString('post', method)){
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
57
|
+
var body = {
|
|
58
|
+
'role': {
|
|
59
|
+
'name': name,
|
|
60
|
+
'policies': policies,
|
|
61
|
+
'alias': alias
|
|
62
|
+
}
|
|
63
|
+
};
|
|
66
64
|
|
|
67
65
|
strbody = JSON.stringify(body);
|
|
68
66
|
headers['Content-Length'] = strbody.length;
|
|
@@ -149,18 +147,17 @@ function postV1Role(method, token, name, policies, alias)
|
|
|
149
147
|
|
|
150
148
|
function postV1RoleHost(method, is_user_token, token, name, target_host, port, cuk, extra, tag, inboundip, outboundip)
|
|
151
149
|
{
|
|
152
|
-
|
|
153
|
-
var
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
150
|
+
var strbody = '';
|
|
151
|
+
var _token = (is_user_token ? ('U=' + token) : ('R=' + token));
|
|
152
|
+
var headers = {
|
|
153
|
+
'Content-Type': 'application/json',
|
|
154
|
+
'X-Auth-Token': _token
|
|
155
|
+
};
|
|
156
|
+
var options = {
|
|
157
|
+
'host': hostname,
|
|
158
|
+
'port': hostport,
|
|
159
|
+
'method': method
|
|
160
|
+
};
|
|
164
161
|
|
|
165
162
|
if(apiutil.compareCaseString('post', method)){
|
|
166
163
|
var host_info = {};
|
|
@@ -47,19 +47,17 @@ function rawDeleteV1Service(token, service, tenant)
|
|
|
47
47
|
basepath += '?tenant=' + encodeURI(tenant);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
50
|
+
var headers = {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
'X-Auth-Token': 'U=' + token
|
|
53
|
+
};
|
|
54
|
+
var options = {
|
|
55
|
+
'host': hostname,
|
|
56
|
+
'port': hostport,
|
|
57
|
+
'path': basepath,
|
|
58
|
+
'method': 'DELETE',
|
|
59
|
+
'headers': headers
|
|
60
|
+
};
|
|
63
61
|
|
|
64
62
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
65
63
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -42,24 +42,22 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function rawGetHeadV1Service(method, token, service, tenant)
|
|
44
44
|
{
|
|
45
|
-
var basepath
|
|
45
|
+
var basepath = '/v1/service/' + service;
|
|
46
46
|
if(apiutil.compareCaseString('HEAD', method) && apiutil.isSafeString(tenant)){
|
|
47
|
-
basepath
|
|
47
|
+
basepath += '?tenant=' + encodeURI(tenant);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
50
|
+
var headers = {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
'X-Auth-Token': 'U=' + token
|
|
53
|
+
};
|
|
54
|
+
var options = {
|
|
55
|
+
'host': hostname,
|
|
56
|
+
'port': hostport,
|
|
57
|
+
'path': basepath,
|
|
58
|
+
'method': method,
|
|
59
|
+
'headers': headers
|
|
60
|
+
};
|
|
63
61
|
|
|
64
62
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
65
63
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -116,17 +116,16 @@ function rawPutPostV1Service(method, token, service, is_create, verify, is_verif
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
119
|
+
var headers = {
|
|
120
|
+
'Content-Type': 'application/json',
|
|
121
|
+
'X-Auth-Token': 'U=' + token
|
|
122
|
+
};
|
|
123
|
+
var options = {
|
|
124
|
+
'host': hostname,
|
|
125
|
+
'port': hostport,
|
|
126
|
+
'path': basepath,
|
|
127
|
+
'method': method
|
|
128
|
+
};
|
|
130
129
|
|
|
131
130
|
if(apiutil.compareCaseString('POST', method)){
|
|
132
131
|
headers['Content-Length'] = strbody.length;
|
package/tests/manual_test.sh
CHANGED
|
@@ -158,11 +158,11 @@ while [ $# -ne 0 ]; do
|
|
|
158
158
|
if [ -z "$1" ]; then
|
|
159
159
|
break
|
|
160
160
|
|
|
161
|
-
elif
|
|
161
|
+
elif echo "$1" | grep -q -i -e "^-h$" -e "^--help$"; then
|
|
162
162
|
PrintUsage "${PRGNAME}"
|
|
163
163
|
exit 0
|
|
164
164
|
|
|
165
|
-
elif
|
|
165
|
+
elif echo "$1" | grep -q -i -e "^-a$" -e "^--apihost$"; then
|
|
166
166
|
#
|
|
167
167
|
# API HOST
|
|
168
168
|
#
|
|
@@ -177,7 +177,7 @@ while [ $# -ne 0 ]; do
|
|
|
177
177
|
fi
|
|
178
178
|
APIHOST="$1"
|
|
179
179
|
|
|
180
|
-
elif
|
|
180
|
+
elif echo "$1" | grep -q -i -e "^-p$" -e "^--apiport$"; then
|
|
181
181
|
#
|
|
182
182
|
# API PORT
|
|
183
183
|
#
|
|
@@ -199,21 +199,21 @@ while [ $# -ne 0 ]; do
|
|
|
199
199
|
fi
|
|
200
200
|
APIPORT="$1"
|
|
201
201
|
|
|
202
|
-
elif
|
|
202
|
+
elif echo "$1" | grep -q -i "^--https$"; then
|
|
203
203
|
if [ -n "${HTTPS_ENV}" ]; then
|
|
204
204
|
echo "[ERROR] already specified --https or --http option"
|
|
205
205
|
exit 1
|
|
206
206
|
fi
|
|
207
207
|
HTTPS_ENV="yes"
|
|
208
208
|
|
|
209
|
-
elif
|
|
209
|
+
elif echo "$1" | grep -q -i "^--http$"; then
|
|
210
210
|
if [ -n "${HTTPS_ENV}" ]; then
|
|
211
211
|
echo "[ERROR] already specified --https or --http option"
|
|
212
212
|
exit 1
|
|
213
213
|
fi
|
|
214
214
|
HTTPS_ENV="no"
|
|
215
215
|
|
|
216
|
-
elif
|
|
216
|
+
elif echo "$1" | grep -q -i -e "^-d$" -e "^--debuglevel$"; then
|
|
217
217
|
#
|
|
218
218
|
# DEBUG option
|
|
219
219
|
#
|
|
@@ -222,25 +222,25 @@ while [ $# -ne 0 ]; do
|
|
|
222
222
|
echo "[ERROR] --debuglevel(-d) option needs parameter(dbg/msg/warn/err)"
|
|
223
223
|
exit 1
|
|
224
224
|
fi
|
|
225
|
-
if
|
|
225
|
+
if echo "$1" | grep -q -i -e "^dbg$" -e "^debug$"; then
|
|
226
226
|
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
227
227
|
echo "[ERROR] --debuglevel(-d) option already is set"
|
|
228
228
|
exit 1
|
|
229
229
|
fi
|
|
230
230
|
DEBUG_ENV_LEVEL=4
|
|
231
|
-
elif
|
|
231
|
+
elif echo "$1" | grep -q -i -e "^msg$" -e "^message$" -e "^info$"; then
|
|
232
232
|
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
233
233
|
echo "[ERROR] --debuglevel(-d) option already is set"
|
|
234
234
|
exit 1
|
|
235
235
|
fi
|
|
236
236
|
DEBUG_ENV_LEVEL=3
|
|
237
|
-
elif
|
|
237
|
+
elif echo "$1" | grep -q -i -e "^wan$" -e "^warn$" -e "^warning$"; then
|
|
238
238
|
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
239
239
|
echo "[ERROR] --debuglevel(-d) option already is set"
|
|
240
240
|
exit 1
|
|
241
241
|
fi
|
|
242
242
|
DEBUG_ENV_LEVEL=2
|
|
243
|
-
elif
|
|
243
|
+
elif echo "$1" | grep -q -i -e "^err$" -e "^error$"; then
|
|
244
244
|
if [ "${DEBUG_ENV_LEVEL}" -ne 0 ]; then
|
|
245
245
|
echo "[ERROR] --debuglevel(-d) option already is set"
|
|
246
246
|
exit 1
|
|
@@ -43,25 +43,24 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
43
43
|
//
|
|
44
44
|
function getV1UserData(registerpath, is_gzip)
|
|
45
45
|
{
|
|
46
|
-
/* eslint-disable indent, no-mixed-spaces-and-tabs */
|
|
47
46
|
var headers;
|
|
48
47
|
if(is_gzip){
|
|
49
|
-
headers
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
headers = {
|
|
49
|
+
'Content-Type': 'application/octet-stream',
|
|
50
|
+
'User-Agent': 'Cloud-Init',
|
|
51
|
+
'Accept-Encoding': 'gzip'
|
|
52
|
+
};
|
|
54
53
|
}else{
|
|
55
|
-
headers
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
headers = {
|
|
55
|
+
'Content-Type': 'application/octet-stream',
|
|
56
|
+
'User-Agent': 'Cloud-Init'
|
|
57
|
+
};
|
|
59
58
|
}
|
|
60
|
-
var options
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
var options = {
|
|
60
|
+
'host': hostname,
|
|
61
|
+
'port': hostport,
|
|
62
|
+
'method': 'GET'
|
|
63
|
+
};
|
|
65
64
|
|
|
66
65
|
options.headers = headers;
|
|
67
66
|
options.path = '/v1/userdata/' + encodeURI(registerpath);
|
|
@@ -42,20 +42,18 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function headV1UserTokens(token, method)
|
|
44
44
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
45
|
+
var headers = {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
'Content-Length': 0,
|
|
48
|
+
'X-Auth-Token': token
|
|
49
|
+
};
|
|
50
|
+
var options = {
|
|
51
|
+
'host': hostname,
|
|
52
|
+
'port': hostport,
|
|
53
|
+
'path': '/v1/user/tokens',
|
|
54
|
+
'method': method,
|
|
55
|
+
'headers': headers
|
|
56
|
+
};
|
|
59
57
|
|
|
60
58
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
61
59
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -42,16 +42,15 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function postV1UserTokens(method, token, othertoken, user, passwd, tenant)
|
|
44
44
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var strbody
|
|
54
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
45
|
+
var headers = {
|
|
46
|
+
'Content-Type': 'application/json'
|
|
47
|
+
};
|
|
48
|
+
var options = {
|
|
49
|
+
'host': hostname,
|
|
50
|
+
'port': hostport,
|
|
51
|
+
'method': method
|
|
52
|
+
};
|
|
53
|
+
var strbody = '';
|
|
55
54
|
|
|
56
55
|
// set token if exists
|
|
57
56
|
var is_user_cred_type = true;
|
|
@@ -66,26 +65,24 @@ function postV1UserTokens(method, token, othertoken, user, passwd, tenant)
|
|
|
66
65
|
if(apiutil.compareCaseString('post', method)){
|
|
67
66
|
// case for POST
|
|
68
67
|
|
|
69
|
-
/* eslint-disable indent, no-mixed-spaces-and-tabs */
|
|
70
68
|
var body;
|
|
71
69
|
if(is_user_cred_type){
|
|
72
|
-
body
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
body = {
|
|
71
|
+
'auth': {
|
|
72
|
+
'tenantName': apiutil.isSafeString(tenant) ? tenant : '',
|
|
73
|
+
'passwordCredentials': {
|
|
74
|
+
'username': user,
|
|
75
|
+
'password': passwd
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
81
79
|
}else{
|
|
82
|
-
body
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
body = {
|
|
81
|
+
'auth': {
|
|
82
|
+
'tenantName': apiutil.isSafeString(tenant) ? tenant : ''
|
|
83
|
+
}
|
|
84
|
+
};
|
|
87
85
|
}
|
|
88
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
89
86
|
|
|
90
87
|
strbody = JSON.stringify(body);
|
|
91
88
|
headers['Content-Length'] = strbody.length;
|