@itentialopensource/adapter-nutanix_intentful 0.1.1

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 (153) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +18 -0
  3. package/.jshintrc +3 -0
  4. package/AUTH.md +34 -0
  5. package/BROKER.md +211 -0
  6. package/CALLS.md +1677 -0
  7. package/CHANGELOG.md +9 -0
  8. package/CODE_OF_CONDUCT.md +43 -0
  9. package/CONTRIBUTING.md +13 -0
  10. package/ENHANCE.md +69 -0
  11. package/LICENSE +201 -0
  12. package/PROPERTIES.md +646 -0
  13. package/README.md +343 -0
  14. package/SUMMARY.md +9 -0
  15. package/SYSTEMINFO.md +20 -0
  16. package/TAB1.md +10 -0
  17. package/TAB2.md +303 -0
  18. package/TROUBLESHOOT.md +47 -0
  19. package/adapter.js +26226 -0
  20. package/adapterBase.js +1452 -0
  21. package/changelogs/CHANGELOG.md +0 -0
  22. package/entities/.generic/action.json +214 -0
  23. package/entities/.generic/schema.json +28 -0
  24. package/entities/.system/action.json +50 -0
  25. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  26. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  27. package/entities/.system/schema.json +19 -0
  28. package/entities/.system/schemaTokenReq.json +53 -0
  29. package/entities/.system/schemaTokenResp.json +53 -0
  30. package/entities/AccessControlPolicies/action.json +105 -0
  31. package/entities/AccessControlPolicies/schema.json +23 -0
  32. package/entities/AddressGroups/action.json +105 -0
  33. package/entities/AddressGroups/schema.json +23 -0
  34. package/entities/Alerts/action.json +85 -0
  35. package/entities/Alerts/schema.json +22 -0
  36. package/entities/Audits/action.json +45 -0
  37. package/entities/Audits/schema.json +20 -0
  38. package/entities/Batch/action.json +24 -0
  39. package/entities/Batch/schema.json +19 -0
  40. package/entities/Blackouts/action.json +105 -0
  41. package/entities/Blackouts/schema.json +23 -0
  42. package/entities/Categories/action.json +186 -0
  43. package/entities/Categories/schema.json +27 -0
  44. package/entities/Clusters/action.json +65 -0
  45. package/entities/Clusters/schema.json +21 -0
  46. package/entities/DirectoryServices/action.json +125 -0
  47. package/entities/DirectoryServices/schema.json +24 -0
  48. package/entities/FloatingIp/action.json +105 -0
  49. package/entities/FloatingIp/schema.json +23 -0
  50. package/entities/Hosts/action.json +45 -0
  51. package/entities/Hosts/schema.json +20 -0
  52. package/entities/IdempotenceIdentifiers/action.json +65 -0
  53. package/entities/IdempotenceIdentifiers/schema.json +32 -0
  54. package/entities/IdentityProviders/action.json +126 -0
  55. package/entities/IdentityProviders/schema.json +24 -0
  56. package/entities/ImagePlacementPolicies/action.json +105 -0
  57. package/entities/ImagePlacementPolicies/schema.json +23 -0
  58. package/entities/Images/action.json +166 -0
  59. package/entities/Images/schema.json +26 -0
  60. package/entities/NetworkFunctionChains/action.json +105 -0
  61. package/entities/NetworkFunctionChains/schema.json +23 -0
  62. package/entities/NetworkSecurityRules/action.json +166 -0
  63. package/entities/NetworkSecurityRules/schema.json +26 -0
  64. package/entities/NgtPolicies/action.json +105 -0
  65. package/entities/NgtPolicies/schema.json +23 -0
  66. package/entities/Ovas/action.json +249 -0
  67. package/entities/Ovas/schema.json +52 -0
  68. package/entities/Permissions/action.json +45 -0
  69. package/entities/Permissions/schema.json +20 -0
  70. package/entities/Projects/action.json +105 -0
  71. package/entities/Projects/schema.json +23 -0
  72. package/entities/ProtectionRules/action.json +146 -0
  73. package/entities/ProtectionRules/schema.json +25 -0
  74. package/entities/RecoveryPlanJobs/action.json +126 -0
  75. package/entities/RecoveryPlanJobs/schema.json +24 -0
  76. package/entities/RecoveryPlans/action.json +126 -0
  77. package/entities/RecoveryPlans/schema.json +68 -0
  78. package/entities/RemoteSyslogModules/action.json +105 -0
  79. package/entities/RemoteSyslogModules/schema.json +23 -0
  80. package/entities/RemoteSyslogServers/action.json +126 -0
  81. package/entities/RemoteSyslogServers/schema.json +24 -0
  82. package/entities/Reports/action.json +267 -0
  83. package/entities/Reports/schema.json +31 -0
  84. package/entities/Roles/action.json +105 -0
  85. package/entities/Roles/schema.json +23 -0
  86. package/entities/RoutingPolicies/action.json +145 -0
  87. package/entities/RoutingPolicies/schema.json +25 -0
  88. package/entities/ServiceGroups/action.json +105 -0
  89. package/entities/ServiceGroups/schema.json +23 -0
  90. package/entities/StoragePolicies/action.json +125 -0
  91. package/entities/StoragePolicies/schema.json +24 -0
  92. package/entities/Subnets/action.json +105 -0
  93. package/entities/Subnets/schema.json +23 -0
  94. package/entities/Tasks/action.json +45 -0
  95. package/entities/Tasks/schema.json +20 -0
  96. package/entities/UserGroups/action.json +85 -0
  97. package/entities/UserGroups/schema.json +22 -0
  98. package/entities/Users/action.json +127 -0
  99. package/entities/Users/schema.json +24 -0
  100. package/entities/VirtualNetwork/action.json +105 -0
  101. package/entities/VirtualNetwork/schema.json +23 -0
  102. package/entities/VmHostAffinityLegacyPolicies/action.json +44 -0
  103. package/entities/VmHostAffinityLegacyPolicies/schema.json +20 -0
  104. package/entities/VmHostAffinityPolicies/action.json +145 -0
  105. package/entities/VmHostAffinityPolicies/schema.json +36 -0
  106. package/entities/Vms/action.json +365 -0
  107. package/entities/Vms/schema.json +36 -0
  108. package/entities/Vpc/action.json +45 -0
  109. package/entities/Vpc/schema.json +20 -0
  110. package/entities/VpnConnection/action.json +168 -0
  111. package/entities/VpnConnection/schema.json +26 -0
  112. package/entities/VpnGateway/action.json +105 -0
  113. package/entities/VpnGateway/schema.json +23 -0
  114. package/entities/Whatif/action.json +188 -0
  115. package/entities/Whatif/schema.json +38 -0
  116. package/error.json +190 -0
  117. package/metadata.json +92 -0
  118. package/package.json +81 -0
  119. package/pronghorn.json +12449 -0
  120. package/propertiesDecorators.json +14 -0
  121. package/propertiesSchema.json +1574 -0
  122. package/refs?service=git-upload-pack +0 -0
  123. package/report/adapter-openapi.json +85398 -0
  124. package/report/adapter-openapi.yaml +62985 -0
  125. package/report/adapterInfo.json +10 -0
  126. package/report/auto-adapter-openapi.json +9609 -0
  127. package/report/creationReport.json +2065 -0
  128. package/report/nutanix-openapi.json +85398 -0
  129. package/sampleProperties.json +257 -0
  130. package/test/integration/adapterTestBasicGet.js +83 -0
  131. package/test/integration/adapterTestConnectivity.js +118 -0
  132. package/test/integration/adapterTestIntegration.js +6792 -0
  133. package/test/unit/adapterBaseTestUnit.js +1024 -0
  134. package/test/unit/adapterTestUnit.js +9255 -0
  135. package/utils/adapterInfo.js +206 -0
  136. package/utils/addAuth.js +94 -0
  137. package/utils/artifactize.js +146 -0
  138. package/utils/basicGet.js +50 -0
  139. package/utils/checkMigrate.js +63 -0
  140. package/utils/entitiesToDB.js +179 -0
  141. package/utils/findPath.js +74 -0
  142. package/utils/methodDocumentor.js +273 -0
  143. package/utils/modify.js +152 -0
  144. package/utils/packModificationScript.js +35 -0
  145. package/utils/patches2bundledDeps.js +90 -0
  146. package/utils/pre-commit.sh +32 -0
  147. package/utils/removeHooks.js +20 -0
  148. package/utils/setup.js +33 -0
  149. package/utils/taskMover.js +309 -0
  150. package/utils/tbScript.js +239 -0
  151. package/utils/tbUtils.js +489 -0
  152. package/utils/testRunner.js +298 -0
  153. package/utils/troubleshootingAdapter.js +193 -0
@@ -0,0 +1,257 @@
1
+ {
2
+ "id": "Adapter-nutanix_intentful",
3
+ "type": "NutanixIntentful",
4
+ "properties": {
5
+ "host": "localhost",
6
+ "port": 443,
7
+ "choosepath": "",
8
+ "base_path": "/api/nutanix",
9
+ "version": "v3",
10
+ "cache_location": "none",
11
+ "encode_pathvars": true,
12
+ "encode_queryvars": true,
13
+ "save_metric": false,
14
+ "stub": true,
15
+ "protocol": "https",
16
+ "authentication": {
17
+ "auth_method": "basic user_password",
18
+ "username": "username",
19
+ "password": "password",
20
+ "token": "token",
21
+ "token_timeout": 600000,
22
+ "token_cache": "local",
23
+ "invalid_token_error": 401,
24
+ "auth_field": "header.headers.Authorization",
25
+ "auth_field_format": "Basic {b64}{username}:{password}{/b64}",
26
+ "auth_logging": false,
27
+ "client_id": "",
28
+ "client_secret": "",
29
+ "grant_type": "",
30
+ "sensitive": [],
31
+ "multiStepAuthCalls": [
32
+ {
33
+ "name": "",
34
+ "requestFields": {},
35
+ "responseFields": {},
36
+ "successfullResponseCode": 200
37
+ }
38
+ ],
39
+ "sso": {
40
+ "protocol": "",
41
+ "host": "",
42
+ "port": 0
43
+ }
44
+ },
45
+ "healthcheck": {
46
+ "type": "none",
47
+ "frequency": 60000,
48
+ "query_object": {},
49
+ "addlHeaders": {}
50
+ },
51
+ "throttle": {
52
+ "throttle_enabled": false,
53
+ "number_pronghorns": 1,
54
+ "sync_async": "sync",
55
+ "max_in_queue": 1000,
56
+ "concurrent_max": 1,
57
+ "expire_timeout": 0,
58
+ "avg_runtime": 200,
59
+ "priorities": [
60
+ {
61
+ "value": 0,
62
+ "percent": 100
63
+ }
64
+ ]
65
+ },
66
+ "request": {
67
+ "number_redirects": 0,
68
+ "number_retries": 3,
69
+ "limit_retry_error": [
70
+ 0
71
+ ],
72
+ "failover_codes": [],
73
+ "attempt_timeout": 5000,
74
+ "global_request": {
75
+ "payload": {},
76
+ "uriOptions": {},
77
+ "addlHeaders": {},
78
+ "authData": {}
79
+ },
80
+ "healthcheck_on_timeout": true,
81
+ "return_raw": false,
82
+ "archiving": false,
83
+ "return_request": false
84
+ },
85
+ "proxy": {
86
+ "enabled": false,
87
+ "host": "",
88
+ "port": 1,
89
+ "protocol": "http",
90
+ "username": "",
91
+ "password": ""
92
+ },
93
+ "ssl": {
94
+ "ecdhCurve": "",
95
+ "enabled": false,
96
+ "accept_invalid_cert": false,
97
+ "ca_file": "",
98
+ "key_file": "",
99
+ "cert_file": "",
100
+ "secure_protocol": "",
101
+ "ciphers": ""
102
+ },
103
+ "mongo": {
104
+ "host": "",
105
+ "port": 0,
106
+ "database": "",
107
+ "username": "",
108
+ "password": "",
109
+ "replSet": "",
110
+ "db_ssl": {
111
+ "enabled": false,
112
+ "accept_invalid_cert": false,
113
+ "ca_file": "",
114
+ "key_file": "",
115
+ "cert_file": ""
116
+ }
117
+ },
118
+ "devicebroker": {
119
+ "enabled": false,
120
+ "getDevice": [
121
+ {
122
+ "path": "/get/devices/{id}",
123
+ "method": "GET",
124
+ "query": {},
125
+ "body": {},
126
+ "headers": {},
127
+ "handleFailure": "fail",
128
+ "requestFields": {
129
+ "id": "name"
130
+ },
131
+ "responseDatakey": "",
132
+ "responseFields": {
133
+ "name": "host",
134
+ "ostype": "os",
135
+ "ostypePrefix": "system-",
136
+ "ipaddress": "attributes.ipaddr",
137
+ "port": "443"
138
+ }
139
+ }
140
+ ],
141
+ "getDevicesFiltered": [
142
+ {
143
+ "path": "/get/devices",
144
+ "method": "GET",
145
+ "pagination": {
146
+ "offsetVar": "",
147
+ "limitVar": "",
148
+ "incrementBy": "limit",
149
+ "requestLocation": "query"
150
+ },
151
+ "query": {},
152
+ "body": {},
153
+ "headers": {},
154
+ "handleFailure": "fail",
155
+ "requestFields": {},
156
+ "responseDatakey": "",
157
+ "responseFields": {
158
+ "name": "host",
159
+ "ostype": "os",
160
+ "ostypePrefix": "system-",
161
+ "ipaddress": "attributes.ipaddr",
162
+ "port": "443"
163
+ }
164
+ }
165
+ ],
166
+ "isAlive": [
167
+ {
168
+ "path": "/get/devices/{id}/status",
169
+ "method": "GET",
170
+ "query": {},
171
+ "body": {},
172
+ "headers": {},
173
+ "handleFailure": "fail",
174
+ "requestFields": {
175
+ "id": "name"
176
+ },
177
+ "responseDatakey": "",
178
+ "responseFields": {
179
+ "status": "status",
180
+ "statusValue": "online"
181
+ }
182
+ }
183
+ ],
184
+ "getConfig": [
185
+ {
186
+ "path": "/get/devices/{id}/configPart1",
187
+ "method": "GET",
188
+ "query": {},
189
+ "body": {},
190
+ "headers": {},
191
+ "handleFailure": "fail",
192
+ "requestFields": {
193
+ "id": "name"
194
+ },
195
+ "responseDatakey": "",
196
+ "responseFields": {}
197
+ }
198
+ ],
199
+ "getCount": [
200
+ {
201
+ "path": "/get/devices",
202
+ "method": "GET",
203
+ "query": {},
204
+ "body": {},
205
+ "headers": {},
206
+ "handleFailure": "fail",
207
+ "requestFields": {},
208
+ "responseDatakey": "",
209
+ "responseFields": {}
210
+ }
211
+ ]
212
+ },
213
+ "cache": {
214
+ "enabled": false,
215
+ "entities": [
216
+ {
217
+ "entityType": "",
218
+ "frequency": 1440,
219
+ "flushOnFail": false,
220
+ "limit": 1000,
221
+ "retryAttempts": 5,
222
+ "sort": true,
223
+ "populate": [
224
+ {
225
+ "path": "",
226
+ "method": "GET",
227
+ "pagination": {
228
+ "offsetVar": "",
229
+ "limitVar": "",
230
+ "incrementBy": "limit",
231
+ "requestLocation": "query"
232
+ },
233
+ "query": {},
234
+ "body": {},
235
+ "headers": {},
236
+ "handleFailure": "ignore",
237
+ "requestFields": {},
238
+ "responseDatakey": "",
239
+ "responseFields": {}
240
+ }
241
+ ],
242
+ "cachedTasks": [
243
+ {
244
+ "name": "",
245
+ "filterField": "",
246
+ "filterLoc": ""
247
+ }
248
+ ]
249
+ }
250
+ ]
251
+ }
252
+ },
253
+ "groups": [],
254
+ "brokers": [],
255
+ "logLevel": "none",
256
+ "timeout": 120000
257
+ }
@@ -0,0 +1,83 @@
1
+ /* @copyright Itential, LLC 2020 */
2
+
3
+ /* global describe context before after */
4
+ /* eslint global-require: warn */
5
+ /* eslint no-unused-vars: warn */
6
+ /* eslint import/no-extraneous-dependencies: warn */
7
+ /* eslint import/no-dynamic-require: warn */
8
+ /* eslint import/no-unresolved: warn */
9
+
10
+ const path = require('path');
11
+ const assert = require('assert');
12
+ const mocha = require('mocha');
13
+ const itParam = require('mocha-param');
14
+
15
+ const utils = require('../../utils/tbUtils');
16
+ const basicGet = require('../../utils/basicGet');
17
+ const { name } = require('../../package.json');
18
+ const { methods } = require('../../pronghorn.json');
19
+
20
+ const getPronghornProps = (iapDir) => {
21
+ console.log('Retrieving properties.json file...');
22
+ const rawProps = require(path.join(iapDir, 'properties.json'));
23
+ console.log('Decrypting properties...');
24
+ const pronghornProps = utils.decryptProperties(rawProps, iapDir);
25
+ console.log('Found properties.\n');
26
+ return pronghornProps;
27
+ };
28
+
29
+ let a;
30
+
31
+ describe('[integration] Adapter BasicGET Test', () => {
32
+ context('Testing GET calls without query parameters', () => {
33
+ before(async () => {
34
+ const iapDir = path.join(__dirname, '../../../../../');
35
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
36
+ const sampleProperties = require('../../sampleProperties.json');
37
+ const adapter = { properties: sampleProperties };
38
+ a = basicGet.getAdapterInstance(adapter);
39
+ } else {
40
+ const pronghornProps = getPronghornProps(iapDir);
41
+ console.log('Connecting to Database...');
42
+ const database = await basicGet.connect(pronghornProps);
43
+ console.log('Connection established.');
44
+ const adapter = await database.collection(utils.SERVICE_CONFIGS_COLLECTION).findOne(
45
+ { model: name }
46
+ );
47
+ a = basicGet.getAdapterInstance(adapter);
48
+ }
49
+ });
50
+
51
+ after((done) => {
52
+ done();
53
+ });
54
+
55
+ const basicGets = methods.filter((method) => (method.route.verb === 'GET' && method.input.length === 0));
56
+ if (basicGets.length === 0) {
57
+ console.log('No non-parameter GET calls found.');
58
+ process.exit(0);
59
+ }
60
+ const functionNames = basicGets.map((g) => g.name);
61
+ const request = function request(f, ad) {
62
+ return new Promise((resolve, reject) => {
63
+ const getRespCode = (resp) => {
64
+ if (resp) {
65
+ if (resp.metrics.code !== 200) {
66
+ console.log('\x1b[31m', `Testing ${f} \nResponseCode: ${resp.metrics.code}`);
67
+ }
68
+ resolve(resp.metrics.code);
69
+ } else {
70
+ console.log('\x1b[31m', `call ${f} results in failure`);
71
+ reject(new Error(`${f} failed`));
72
+ }
73
+ };
74
+ ad[f](getRespCode, console.log);
75
+ });
76
+ };
77
+
78
+ itParam('GET call should return 200', functionNames, (fname) => {
79
+ console.log(`\t ${fname}`);
80
+ return request(fname, a).then((result) => assert.equal(result, 200));
81
+ });
82
+ });
83
+ });
@@ -0,0 +1,118 @@
1
+ /* @copyright Itential, LLC 2020 */
2
+
3
+ /* global describe it context before after */
4
+ /* eslint no-unused-vars: warn */
5
+
6
+ const assert = require('assert');
7
+ const https = require('https');
8
+ const mocha = require('mocha');
9
+ const ping = require('ping');
10
+ const dnsLookup = require('dns-lookup-promise');
11
+
12
+ let host;
13
+ process.argv.forEach((val) => {
14
+ if (val.indexOf('--HOST') === 0) {
15
+ [, host] = val.split('=');
16
+ }
17
+ });
18
+
19
+ describe('[integration] Adapter Test', () => {
20
+ context(`Testing network connection on ${host}`, () => {
21
+ after((done) => {
22
+ done();
23
+ });
24
+
25
+ it('DNS resolve', (done) => {
26
+ dnsLookup(host)
27
+ .then((addresses) => {
28
+ try {
29
+ assert.ok(addresses.length > 0);
30
+ done();
31
+ } catch (error) {
32
+ done(error);
33
+ }
34
+ })
35
+ .catch((err) => {
36
+ done(err);
37
+ });
38
+ });
39
+
40
+ it('Responds to ping', (done) => {
41
+ ping.promise.probe(host)
42
+ .then((result) => {
43
+ try {
44
+ assert.ok(result.alive);
45
+ done();
46
+ } catch (error) {
47
+ done(error);
48
+ }
49
+ })
50
+ .catch((err) => {
51
+ done(err);
52
+ });
53
+ });
54
+
55
+ it('Support HTTPS on port 443', (done) => {
56
+ const requestOptions = {
57
+ host,
58
+ port: 443,
59
+ method: 'HEAD'
60
+ };
61
+
62
+ const req = https.request(requestOptions, (res) => {
63
+ try {
64
+ assert.ok(res.statusCode >= 200 && res.statusCode < 400);
65
+ done();
66
+ } catch (error) {
67
+ done(error);
68
+ }
69
+ });
70
+
71
+ req.on('error', (err) => {
72
+ done(err);
73
+ });
74
+
75
+ req.end();
76
+ });
77
+
78
+ it('Support IPv4', (done) => {
79
+ const options = {
80
+ family: 4,
81
+ hints: dnsLookup.ADDRCONFIG
82
+ };
83
+
84
+ dnsLookup.lookup(host, options)
85
+ .then((address, family) => {
86
+ try {
87
+ assert.ok(address !== null && family === 4);
88
+ done();
89
+ } catch (error) {
90
+ done(error);
91
+ }
92
+ })
93
+ .catch((err) => {
94
+ done(err);
95
+ });
96
+ });
97
+
98
+ it('Support IPv6', (done) => {
99
+ const options = {
100
+ family: 6,
101
+ hints: dnsLookup.ADDRCONFIG
102
+ };
103
+
104
+ dnsLookup.lookup(host, options)
105
+ .then((address, family) => {
106
+ try {
107
+ assert.ok(address !== null && family === 6);
108
+ done();
109
+ } catch (error) {
110
+ done(error);
111
+ }
112
+ })
113
+ .catch((err) => {
114
+ done(err);
115
+ });
116
+ });
117
+ });
118
+ });