@itentialopensource/adapter-aruba_airwave 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.
- package/.eslintignore +6 -0
- package/.eslintrc.js +18 -0
- package/.gitlab/.gitkeep +0 -0
- package/.gitlab/issue_templates/.gitkeep +0 -0
- package/.gitlab/issue_templates/Default.md +17 -0
- package/.gitlab/issue_templates/bugReportTemplate.md +76 -0
- package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
- package/.jshintrc +0 -0
- package/CHANGELOG.md +9 -0
- package/CODE_OF_CONDUCT.md +48 -0
- package/CONTRIBUTING.md +158 -0
- package/LICENSE +201 -0
- package/README.md +544 -0
- package/adapter.js +2860 -0
- package/adapterBase.js +906 -0
- package/entities/.system/action.json +50 -0
- package/entities/.system/mockdatafiles/getToken-default.json +3 -0
- package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
- package/entities/.system/schema.json +19 -0
- package/entities/.system/schemaTokenReq.json +77 -0
- package/entities/.system/schemaTokenResp.json +65 -0
- package/entities/BatchExecuteAPCommandsAPIS/action.json +45 -0
- package/entities/BatchExecuteAPCommandsAPIS/schema.json +20 -0
- package/entities/ConfigurationAPIS/action.json +126 -0
- package/entities/ConfigurationAPIS/schema.json +90 -0
- package/entities/DeviceAPIS/action.json +46 -0
- package/entities/DeviceAPIS/schema.json +20 -0
- package/entities/LOGIN/action.json +24 -0
- package/entities/LOGIN/schema.json +41 -0
- package/entities/QueryAPIS/action.json +298 -0
- package/entities/QueryAPIS/schema.json +32 -0
- package/entities/ReportAPIS/action.json +25 -0
- package/entities/ReportAPIS/schema.json +30 -0
- package/entities/SearchAPIS/action.json +67 -0
- package/entities/SearchAPIS/schema.json +21 -0
- package/error.json +184 -0
- package/package.json +86 -0
- package/pronghorn.json +1589 -0
- package/propertiesSchema.json +801 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/ArubaAirwavePostman.json-OpenApi3Json.json +1583 -0
- package/report/creationReport.json +381 -0
- package/sampleProperties.json +97 -0
- package/test/integration/adapterTestBasicGet.js +85 -0
- package/test/integration/adapterTestConnectivity.js +93 -0
- package/test/integration/adapterTestIntegration.js +1125 -0
- package/test/unit/adapterBaseTestUnit.js +929 -0
- package/test/unit/adapterTestUnit.js +1413 -0
- package/utils/artifactize.js +146 -0
- package/utils/basicGet.js +63 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/pre-commit.sh +27 -0
- package/utils/setup.js +33 -0
- package/utils/tbScript.js +163 -0
- package/utils/tbUtils.js +372 -0
- package/utils/testRunner.js +298 -0
- package/utils/troubleshootingAdapter.js +219 -0
- package/workflows/README.md +3 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* @copyright Itential, LLC 2019 */
|
|
3
|
+
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
async function createBundle(adapterOldDir) {
|
|
8
|
+
// set directories
|
|
9
|
+
const artifactDir = path.join(adapterOldDir, '../artifactTemp');
|
|
10
|
+
const workflowsDir = path.join(adapterOldDir, 'workflows');
|
|
11
|
+
|
|
12
|
+
// read adapter's package and set names
|
|
13
|
+
const adapterPackage = fs.readJSONSync(path.join(adapterOldDir, 'package.json'));
|
|
14
|
+
const originalName = adapterPackage.name.substring(adapterPackage.name.lastIndexOf('/') + 1);
|
|
15
|
+
const shortenedName = originalName.replace('adapter-', '');
|
|
16
|
+
const artifactName = originalName.replace('adapter', 'bundled-adapter');
|
|
17
|
+
|
|
18
|
+
const adapterNewDir = path.join(artifactDir, 'bundles', 'adapters', originalName);
|
|
19
|
+
fs.ensureDirSync(adapterNewDir);
|
|
20
|
+
|
|
21
|
+
const ops = [];
|
|
22
|
+
|
|
23
|
+
// copy old adapterDir to bundled hierarchy location
|
|
24
|
+
ops.push(() => fs.copySync(adapterOldDir, adapterNewDir));
|
|
25
|
+
|
|
26
|
+
// copy readme
|
|
27
|
+
ops.push(() => fs.copySync(path.join(adapterOldDir, 'README.md'), path.join(artifactDir, 'README.md')));
|
|
28
|
+
|
|
29
|
+
// copy changelog
|
|
30
|
+
if (fs.existsSync(path.join(adapterOldDir, 'CHANGELOG.md'))) {
|
|
31
|
+
ops.push(() => fs.copySync(path.join(adapterOldDir, 'CHANGELOG.md'), path.join(artifactDir, 'CHANGELOG.md')));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// copy license
|
|
35
|
+
if (fs.existsSync(path.join(adapterOldDir, 'LICENSE'))) {
|
|
36
|
+
ops.push(() => fs.copySync(path.join(adapterOldDir, 'LICENSE'), path.join(artifactDir, 'LICENSE')));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// create package
|
|
40
|
+
const artifactPackage = {
|
|
41
|
+
name: artifactName,
|
|
42
|
+
version: adapterPackage.version,
|
|
43
|
+
description: `A bundled version of the ${originalName} to be used in adapter-artifacts for easy installation`,
|
|
44
|
+
scripts: {
|
|
45
|
+
test: 'echo "Error: no test specified" && exit 1',
|
|
46
|
+
deploy: 'npm publish --registry=http://registry.npmjs.org'
|
|
47
|
+
},
|
|
48
|
+
keywords: [
|
|
49
|
+
'IAP',
|
|
50
|
+
'artifacts',
|
|
51
|
+
'Itential',
|
|
52
|
+
'Pronghorn',
|
|
53
|
+
'Adapter',
|
|
54
|
+
'Adapter-Artifacts',
|
|
55
|
+
shortenedName
|
|
56
|
+
],
|
|
57
|
+
author: 'Itential Artifacts',
|
|
58
|
+
license: 'Apache-2.0',
|
|
59
|
+
repository: adapterPackage.repository,
|
|
60
|
+
private: false,
|
|
61
|
+
devDependencies: {
|
|
62
|
+
r2: '^2.0.1',
|
|
63
|
+
ajv: '6.10.0',
|
|
64
|
+
'better-ajv-errors': '^0.6.1',
|
|
65
|
+
'fs-extra': '^7.0.1'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
ops.push(() => fs.writeJSONSync(path.join(artifactDir, 'package.json'), artifactPackage, { spaces: 2 }));
|
|
70
|
+
|
|
71
|
+
// create manifest
|
|
72
|
+
const manifest = {
|
|
73
|
+
bundleName: originalName,
|
|
74
|
+
version: adapterPackage.version,
|
|
75
|
+
fingerprint: 'Some verifiable token',
|
|
76
|
+
createdEpoch: '1554836984020',
|
|
77
|
+
artifacts: [
|
|
78
|
+
{
|
|
79
|
+
id: `${shortenedName}-adapter`,
|
|
80
|
+
name: `${shortenedName}-adapter`,
|
|
81
|
+
type: 'adapter',
|
|
82
|
+
location: `/bundles/adapters/${originalName}`,
|
|
83
|
+
description: artifactPackage.description,
|
|
84
|
+
properties: {
|
|
85
|
+
entryPoint: false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// add workflows into artifact
|
|
92
|
+
if (fs.existsSync(workflowsDir)) {
|
|
93
|
+
const workflowFileNames = fs.readdirSync(workflowsDir);
|
|
94
|
+
|
|
95
|
+
// if folder isnt empty and only file is not readme
|
|
96
|
+
if (workflowFileNames.length !== 0 && (!(workflowFileNames.length === 1 && workflowFileNames[0].split('.')[1] === 'md'))) {
|
|
97
|
+
// add workflows to correct location in bundle
|
|
98
|
+
ops.push(() => fs.copySync(workflowsDir, path.join(artifactDir, 'bundles', 'workflows')));
|
|
99
|
+
|
|
100
|
+
// add workflows to manifest
|
|
101
|
+
workflowFileNames.forEach((filename) => {
|
|
102
|
+
const [filenameNoExt, ext] = filename.split('.');
|
|
103
|
+
if (ext === 'json') {
|
|
104
|
+
manifest.artifacts.push({
|
|
105
|
+
id: `workflow-${filenameNoExt}`,
|
|
106
|
+
name: filenameNoExt,
|
|
107
|
+
type: 'workflow',
|
|
108
|
+
location: `/bundles/workflows/${filename}`,
|
|
109
|
+
description: 'Main entry point to artifact',
|
|
110
|
+
properties: {
|
|
111
|
+
entryPoint: false
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
ops.push(() => fs.writeJSONSync(path.join(artifactDir, 'manifest.json'), manifest, { spaces: 2 }));
|
|
120
|
+
|
|
121
|
+
// Run the commands in parallel
|
|
122
|
+
try {
|
|
123
|
+
await Promise.all(ops.map(async (op) => op()));
|
|
124
|
+
} catch (e) {
|
|
125
|
+
throw new Error(e);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const pathObj = {
|
|
129
|
+
bundlePath: artifactDir,
|
|
130
|
+
bundledAdapterPath: path.join(artifactDir, 'bundles', 'adapters', originalName)
|
|
131
|
+
};
|
|
132
|
+
return pathObj;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function artifactize(entryPathToAdapter) {
|
|
136
|
+
const truePath = path.resolve(entryPathToAdapter);
|
|
137
|
+
const packagePath = path.join(truePath, 'package');
|
|
138
|
+
// remove adapter from package and move bundle in
|
|
139
|
+
const pathObj = await createBundle(packagePath);
|
|
140
|
+
const { bundlePath } = pathObj;
|
|
141
|
+
fs.removeSync(packagePath);
|
|
142
|
+
fs.moveSync(bundlePath, packagePath);
|
|
143
|
+
return 'Bundle successfully created and old folder system removed';
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
module.exports = { createBundle, artifactize };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* @copyright Itential, LLC 2020 */
|
|
2
|
+
|
|
3
|
+
/* eslint object-shorthand: warn */
|
|
4
|
+
/* eslint import/no-extraneous-dependencies: warn */
|
|
5
|
+
/* eslint global-require: warn */
|
|
6
|
+
/* eslint import/no-unresolved: warn */
|
|
7
|
+
|
|
8
|
+
const winston = require('winston');
|
|
9
|
+
|
|
10
|
+
const logLevel = 'none';
|
|
11
|
+
const myCustomLevels = {
|
|
12
|
+
levels: {
|
|
13
|
+
spam: 6,
|
|
14
|
+
trace: 5,
|
|
15
|
+
debug: 4,
|
|
16
|
+
info: 3,
|
|
17
|
+
warn: 2,
|
|
18
|
+
error: 1,
|
|
19
|
+
none: 0
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const basicGet = {
|
|
24
|
+
/**
|
|
25
|
+
* @summary create Adapter instance
|
|
26
|
+
*
|
|
27
|
+
* @function getAdapterInstance
|
|
28
|
+
* @param {Object} adapter - adaper configuration object required by IAP
|
|
29
|
+
*/
|
|
30
|
+
getAdapterInstance: (adapter) => {
|
|
31
|
+
const Adapter = require('../adapter');
|
|
32
|
+
const adapterProps = JSON.parse(JSON.stringify(adapter.properties.properties));
|
|
33
|
+
adapterProps.stub = false;
|
|
34
|
+
// need to set global logging
|
|
35
|
+
global.log = winston.createLogger({
|
|
36
|
+
level: logLevel,
|
|
37
|
+
levels: myCustomLevels.levels,
|
|
38
|
+
transports: [
|
|
39
|
+
new winston.transports.Console()
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
return new Adapter(
|
|
43
|
+
adapter.id,
|
|
44
|
+
adapterProps
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @summary connect to mongodb
|
|
50
|
+
*
|
|
51
|
+
* @function connect
|
|
52
|
+
* @param {Object} properties - pronghornProps
|
|
53
|
+
*/
|
|
54
|
+
connect: async function connect(properties) {
|
|
55
|
+
// Connect to Mongo
|
|
56
|
+
const { MongoDBConnection } = require('@itential/database');
|
|
57
|
+
const connection = new MongoDBConnection(properties.mongoProps);
|
|
58
|
+
const database = await connection.connect(true);
|
|
59
|
+
return database;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
module.exports = basicGet;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* @copyright Itential, LLC 2019 */
|
|
3
|
+
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { spawnSync } = require('child_process');
|
|
7
|
+
const { createBundle } = require('./artifactize');
|
|
8
|
+
|
|
9
|
+
const nodeEntryPath = path.resolve('.');
|
|
10
|
+
createBundle(nodeEntryPath).then((pathObj) => {
|
|
11
|
+
const { bundlePath, bundledAdapterPath } = pathObj;
|
|
12
|
+
const npmIgnorePath = path.join(bundledAdapterPath, '.npmignore');
|
|
13
|
+
const adapterPackagePath = path.join(bundledAdapterPath, 'package.json');
|
|
14
|
+
const artifactPackagePath = path.join(bundlePath, 'package.json');
|
|
15
|
+
|
|
16
|
+
// remove node_modules from .npmIgnore so that node_modules are included in the resulting tar from npm pack
|
|
17
|
+
let npmIgnoreString;
|
|
18
|
+
if (fs.existsSync(npmIgnorePath)) {
|
|
19
|
+
npmIgnoreString = fs.readFileSync(npmIgnorePath, 'utf8');
|
|
20
|
+
npmIgnoreString = npmIgnoreString.replace('node_modules', '');
|
|
21
|
+
npmIgnoreString = npmIgnoreString.replace('\n\n', '\n');
|
|
22
|
+
fs.writeFileSync(npmIgnorePath, npmIgnoreString);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// add files to package so that node_modules are included in the resulting tar from npm pack
|
|
26
|
+
const adapterPackage = fs.readJSONSync(adapterPackagePath);
|
|
27
|
+
adapterPackage.files = ['*'];
|
|
28
|
+
fs.writeJSONSync(artifactPackagePath, adapterPackage, { spaces: 2 });
|
|
29
|
+
const npmResult = spawnSync('npm', ['pack', '-q', bundlePath], { cwd: path.resolve(bundlePath, '..') });
|
|
30
|
+
if (npmResult.status === 0) {
|
|
31
|
+
fs.removeSync(bundlePath);
|
|
32
|
+
console.log('Bundle folder removed');
|
|
33
|
+
}
|
|
34
|
+
console.log('Script successful');
|
|
35
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# @copyright Itential, LLC 2019
|
|
3
|
+
|
|
4
|
+
#exit on any failure in the pipeline
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# --------------------------------------------------
|
|
8
|
+
# pre-commit
|
|
9
|
+
# --------------------------------------------------
|
|
10
|
+
# Contains the standard set of tasks to runbefore
|
|
11
|
+
# committing changes to the repo. If any tasks fail
|
|
12
|
+
# then the commit will be aborted.
|
|
13
|
+
# --------------------------------------------------
|
|
14
|
+
|
|
15
|
+
printf "%b" "Running pre-commit hooks...\\n"
|
|
16
|
+
|
|
17
|
+
# verify testing script is stubbed and no credentials
|
|
18
|
+
node utils/testRunner.js -r
|
|
19
|
+
|
|
20
|
+
# security audit on the code
|
|
21
|
+
npm audit --registry=https://registry.npmjs.org --audit-level=moderate
|
|
22
|
+
|
|
23
|
+
# lint the code
|
|
24
|
+
npm run lint
|
|
25
|
+
|
|
26
|
+
# test the code
|
|
27
|
+
npm run test
|
package/utils/setup.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* @copyright Itential, LLC 2019 */
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This script will execute before an npm install command. The purpose is to
|
|
8
|
+
* write out some standard git hooks that will enable folks working on this
|
|
9
|
+
* project to benefit from the protections that the hooks provide.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const precommit = fs.readFileSync('utils/pre-commit.sh', 'utf8');
|
|
13
|
+
|
|
14
|
+
fs.stat('.git', (err) => {
|
|
15
|
+
if (err == null) {
|
|
16
|
+
// git repo, not an npm repo.
|
|
17
|
+
// add pre-commit hook if it doesn't exist
|
|
18
|
+
fs.stat('.git/hooks/pre-commit', (statErr) => {
|
|
19
|
+
if (statErr == null || statErr.code === 'ENOENT') {
|
|
20
|
+
fs.writeFile('.git/hooks/pre-commit', precommit, {
|
|
21
|
+
mode: 0o755
|
|
22
|
+
}, (writeErr) => {
|
|
23
|
+
if (writeErr) {
|
|
24
|
+
return console.log(writeErr.message);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
console.log(statErr.message);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* eslint no-console: warn */
|
|
2
|
+
/* eslint import/no-unresolved: warn */
|
|
3
|
+
/* eslint global-require: warn */
|
|
4
|
+
|
|
5
|
+
// suppress eslint rule in adapter
|
|
6
|
+
/* eslint arrow-parens: warn */
|
|
7
|
+
/* eslint import/no-extraneous-dependencies: warn */
|
|
8
|
+
/* eslint import/no-dynamic-require: warn */
|
|
9
|
+
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const program = require('commander');
|
|
12
|
+
const rls = require('readline-sync');
|
|
13
|
+
const utils = require('./tbUtils');
|
|
14
|
+
const basicGet = require('./basicGet');
|
|
15
|
+
const { name } = require('../package.json');
|
|
16
|
+
const sampleProperties = require('../sampleProperties.json');
|
|
17
|
+
const adapterPronghorn = require('../pronghorn.json');
|
|
18
|
+
|
|
19
|
+
const { troubleshoot, getAdapterConfig, offline } = require('./troubleshootingAdapter');
|
|
20
|
+
|
|
21
|
+
const main = async (command) => {
|
|
22
|
+
const iapDir = path.join(__dirname, '../../../../');
|
|
23
|
+
if (!utils.withinIAP(iapDir)) {
|
|
24
|
+
if (command === 'connectivity') {
|
|
25
|
+
const { host } = sampleProperties.properties;
|
|
26
|
+
console.log(`perform networking diagnositics to ${host}`);
|
|
27
|
+
await utils.runConnectivity(host);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} else if (command === 'healthcheck') {
|
|
30
|
+
const a = basicGet.getAdapterInstance({ properties: sampleProperties });
|
|
31
|
+
await utils.healthCheck(a);
|
|
32
|
+
process.exit(0);
|
|
33
|
+
} else if (command === 'basicget') {
|
|
34
|
+
await utils.runBasicGet();
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
if (rls.keyInYN('Troubleshooting without IAP?')) {
|
|
38
|
+
await offline();
|
|
39
|
+
}
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (command === undefined) {
|
|
44
|
+
await troubleshoot({}, true, true);
|
|
45
|
+
} else if (command === 'install') {
|
|
46
|
+
const { database, serviceItem, pronghornProps } = await getAdapterConfig();
|
|
47
|
+
const filter = { id: pronghornProps.id };
|
|
48
|
+
const profileItem = await database.collection(utils.IAP_PROFILES_COLLECTION).findOne(filter);
|
|
49
|
+
if (!profileItem) {
|
|
50
|
+
console.log(`Could not find IAP profile for id ${pronghornProps.id}`);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
if (serviceItem) {
|
|
54
|
+
console.log(`A service by the name ${name} already exits!`);
|
|
55
|
+
if (rls.keyInYN(`Do you want to completely remove ${name}?`)) {
|
|
56
|
+
console.log(`Removing ${name} from db...`);
|
|
57
|
+
await database.collection(utils.SERVICE_CONFIGS_COLLECTION).deleteOne({ model: name });
|
|
58
|
+
console.log(`${name} removed from db.`);
|
|
59
|
+
if (profileItem.services.includes(serviceItem.name)) {
|
|
60
|
+
const serviceIndex = profileItem.services.indexOf(serviceItem.name);
|
|
61
|
+
profileItem.services.splice(serviceIndex, 1);
|
|
62
|
+
const update = { $set: { services: profileItem.services } };
|
|
63
|
+
await database.collection(utils.IAP_PROFILES_COLLECTION).updateOne(
|
|
64
|
+
{ id: pronghornProps.id }, update
|
|
65
|
+
);
|
|
66
|
+
console.log(`${serviceItem.name} removed from profileItem.services.`);
|
|
67
|
+
console.log(`Rerun the script to reinstall ${serviceItem.name}.`);
|
|
68
|
+
process.exit(0);
|
|
69
|
+
} else {
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
console.log('Exiting...');
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
utils.verifyInstallationDir(__dirname, name);
|
|
78
|
+
utils.npmInstall();
|
|
79
|
+
utils.runTest();
|
|
80
|
+
if (rls.keyInYN(`Do you want to install ${name} to IAP?`)) {
|
|
81
|
+
console.log('Creating database entries...');
|
|
82
|
+
const adapter = utils.createAdapter(
|
|
83
|
+
pronghornProps, profileItem, sampleProperties, adapterPronghorn
|
|
84
|
+
);
|
|
85
|
+
await database.collection(utils.SERVICE_CONFIGS_COLLECTION).insertOne(adapter);
|
|
86
|
+
profileItem.services.push(adapter.name);
|
|
87
|
+
const update = { $set: { services: profileItem.services } };
|
|
88
|
+
await database.collection(utils.IAP_PROFILES_COLLECTION).updateOne(
|
|
89
|
+
{ id: pronghornProps.id }, update
|
|
90
|
+
);
|
|
91
|
+
console.log('Database entry creation complete.');
|
|
92
|
+
}
|
|
93
|
+
console.log('Exiting...');
|
|
94
|
+
process.exit(0);
|
|
95
|
+
}
|
|
96
|
+
} else if (['healthcheck', 'basicget', 'connectivity'].includes(command)) {
|
|
97
|
+
const { serviceItem } = await getAdapterConfig();
|
|
98
|
+
if (serviceItem) {
|
|
99
|
+
const adapter = serviceItem;
|
|
100
|
+
const a = basicGet.getAdapterInstance(adapter);
|
|
101
|
+
if (command === 'healthcheck') {
|
|
102
|
+
await utils.healthCheck(a);
|
|
103
|
+
process.exit(0);
|
|
104
|
+
} else if (command === 'basicget') {
|
|
105
|
+
await utils.runBasicGet(true);
|
|
106
|
+
} else if (command === 'connectivity') {
|
|
107
|
+
const { host } = adapter.properties.properties;
|
|
108
|
+
console.log(`perform networking diagnositics to ${host}`);
|
|
109
|
+
await utils.runConnectivity(host, true);
|
|
110
|
+
process.exit(0);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
console.log(`${name} not installed. Run npm \`run install:adapter\` to install.`);
|
|
114
|
+
process.exit(0);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
program
|
|
120
|
+
.command('connectivity')
|
|
121
|
+
.alias('c')
|
|
122
|
+
.description('networking diagnostics')
|
|
123
|
+
.action(() => {
|
|
124
|
+
main('connectivity');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
program
|
|
128
|
+
.command('install')
|
|
129
|
+
.alias('i')
|
|
130
|
+
.description('install current adapter')
|
|
131
|
+
.action(() => {
|
|
132
|
+
main('install');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
program
|
|
136
|
+
.command('healthcheck')
|
|
137
|
+
.alias('hc')
|
|
138
|
+
.description('perfom none interative healthcheck with current setting')
|
|
139
|
+
.action(() => {
|
|
140
|
+
main('healthcheck');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
program
|
|
144
|
+
.command('basicget')
|
|
145
|
+
.alias('bg')
|
|
146
|
+
.description('perfom basicget')
|
|
147
|
+
.action(() => {
|
|
148
|
+
main('basicget');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Allow commander to parse `process.argv`
|
|
152
|
+
program.parse(process.argv);
|
|
153
|
+
|
|
154
|
+
if (process.argv.length < 3) {
|
|
155
|
+
main();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const allowedParams = ['install', 'healthcheck', 'basicget', 'connectivity'];
|
|
159
|
+
if (process.argv.length === 3 && !allowedParams.includes(process.argv[2])) {
|
|
160
|
+
console.log(`unknown parameter ${process.argv[2]}`);
|
|
161
|
+
console.log('try `node troubleshootingAdapter.js -h` to see allowed parameters. Exiting...');
|
|
162
|
+
process.exit(0);
|
|
163
|
+
}
|