@itentialopensource/adapter-netbox 0.6.3 → 0.7.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/CHANGELOG.md +24 -0
- package/README.md +84 -11
- package/adapter.js +551 -1
- package/adapterBase.js +23 -1
- package/entities/.generic/action.json +5 -5
- package/entities/.system/action.json +1 -1
- package/entities/Graphql/action.json +25 -0
- package/entities/Graphql/schema.json +19 -0
- package/error.json +6 -0
- package/package.json +19 -14
- package/pronghorn.json +226 -0
- package/propertiesSchema.json +15 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/updateReport1644854487087.json +95 -0
- package/sampleProperties.json +4 -1
- package/test/integration/adapterTestBasicGet.js +1 -1
- package/test/integration/adapterTestIntegration.js +35 -2
- package/test/unit/adapterBaseTestUnit.js +6 -3
- package/test/unit/adapterTestUnit.js +518 -4
- package/utils/addAuth.js +94 -0
- package/utils/basicGet.js +1 -14
- package/utils/entitiesToDB.js +224 -0
- package/utils/modify.js +1 -1
- package/utils/packModificationScript.js +1 -1
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/removeHooks.js +20 -0
- package/utils/tbScript.js +14 -8
- package/utils/tbUtils.js +98 -19
- package/utils/troubleshootingAdapter.js +2 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
|
|
2
|
+
## 0.7.1 [03-07-2022]
|
|
3
|
+
|
|
4
|
+
* fix graphql with sendGetBody
|
|
5
|
+
|
|
6
|
+
See merge request itentialopensource/adapters/inventory/adapter-netbox!14
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 0.7.0 [02-14-2022]
|
|
11
|
+
|
|
12
|
+
* migration and added a call for graphql
|
|
13
|
+
|
|
14
|
+
See merge request itentialopensource/adapters/inventory/adapter-netbox!13
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 0.6.4 [07-13-2021]
|
|
19
|
+
|
|
20
|
+
* Updates healthcheck endpoint to use /api/status ADAPT-758
|
|
21
|
+
|
|
22
|
+
See merge request itentialopensource/adapters/inventory/adapter-netbox!12
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
2
26
|
## 0.6.3 [03-17-2021]
|
|
3
27
|
|
|
4
28
|
* fix descriptions and summaries
|
package/README.md
CHANGED
|
@@ -125,7 +125,8 @@ This section defines **all** the properties that are available for the adapter,
|
|
|
125
125
|
},
|
|
126
126
|
"healthcheck": {
|
|
127
127
|
"type": "startup",
|
|
128
|
-
"frequency": 300000
|
|
128
|
+
"frequency": 300000,
|
|
129
|
+
"query_object": {}
|
|
129
130
|
},
|
|
130
131
|
"request": {
|
|
131
132
|
"number_redirects": 0,
|
|
@@ -250,6 +251,7 @@ The healthcheck properties defines the API that runs the healthcheck to tell the
|
|
|
250
251
|
| ------- | ------- |
|
|
251
252
|
| type | Required. The type of health check to run. |
|
|
252
253
|
| frequency | Required if intermittent. Defines how often the health check should run. Measured in milliseconds. Default is 300000.|
|
|
254
|
+
| query_object | Query parameters to be added to the adapter healthcheck call.|
|
|
253
255
|
|
|
254
256
|
### Request Properties
|
|
255
257
|
|
|
@@ -398,7 +400,7 @@ There are several node scripts that now accompany the adapter. These scripts are
|
|
|
398
400
|
| npm run troubleshoot | Provides a way to troubleshoot the adapter - runs connectivity, healthcheck and basic get.|
|
|
399
401
|
| npm run connectivity | Provides a connectivity check to the Netbox system.|
|
|
400
402
|
| npm run healthcheck | Checks whether the configured healthcheck call works to Netbox.|
|
|
401
|
-
| npm run basicget | Checks whether the
|
|
403
|
+
| npm run basicget | Checks whether the basic get calls works to Netbox.|
|
|
402
404
|
|
|
403
405
|
## Installing an Itential Product Adapter
|
|
404
406
|
|
|
@@ -412,21 +414,21 @@ if the @itentialopensource directory does not exist, create it:
|
|
|
412
414
|
mkdir @itentialopensource
|
|
413
415
|
```
|
|
414
416
|
|
|
415
|
-
|
|
417
|
+
2. Clone the adapter into your IAP environment.
|
|
416
418
|
|
|
417
419
|
```bash
|
|
418
420
|
cd \@itentialopensource
|
|
419
421
|
git clone git@gitlab.com:\@itentialopensource/adapters/adapter-netbox
|
|
420
422
|
```
|
|
421
423
|
|
|
422
|
-
|
|
424
|
+
3. Run the adapter install script.
|
|
423
425
|
|
|
424
426
|
```bash
|
|
425
427
|
cd adapter-netbox
|
|
426
428
|
npm run adapter:install
|
|
427
429
|
```
|
|
428
430
|
|
|
429
|
-
|
|
431
|
+
4. Restart IAP
|
|
430
432
|
|
|
431
433
|
```bash
|
|
432
434
|
systemctl restart pronghorn
|
|
@@ -446,7 +448,7 @@ Depending on where your code is located, this process is different.
|
|
|
446
448
|
Adapter should be placed into: /opt/pronghorn/current/node_modules/\@itentialopensource
|
|
447
449
|
```
|
|
448
450
|
|
|
449
|
-
|
|
451
|
+
2. Follow Steps 3-4 (above) to install an Itential adapter to load your properties, dependencies and restart IAP.
|
|
450
452
|
|
|
451
453
|
## Using this Adapter
|
|
452
454
|
|
|
@@ -494,7 +496,7 @@ The `verifyCapability` call verifies the adapter can perform the provided action
|
|
|
494
496
|
verifyCapability(entityType, actionType, entityId, callback)
|
|
495
497
|
```
|
|
496
498
|
|
|
497
|
-
The `updateEntityCache` call will update the entity cache.
|
|
499
|
+
The `updateEntityCache` call will update the entity cache.
|
|
498
500
|
```js
|
|
499
501
|
updateEntityCache()
|
|
500
502
|
```
|
|
@@ -548,6 +550,77 @@ getQueue(callback)
|
|
|
548
550
|
|
|
549
551
|
Specific adapter calls are built based on the API of the Netbox. The Adapter Builder creates the proper method comments for generating JS-DOC for the adapter. This is the best way to get information on the calls.
|
|
550
552
|
|
|
553
|
+
|
|
554
|
+
## Extending/Enhancing the Adapter
|
|
555
|
+
|
|
556
|
+
### Adding a Second Instance of an Adapter
|
|
557
|
+
|
|
558
|
+
You can add a second instance of this adapter without adding new code on the file system. To do this go into the IAP Admin Essentials and add a new service config for this adapter. The two instances of the adapter should have unique ids. In addition, they should point to different instances of the other system. For example, they should be configured to talk to different hosts.
|
|
559
|
+
|
|
560
|
+
### Adding Adapter Calls
|
|
561
|
+
|
|
562
|
+
There are multiple ways to add calls to an existing adapter.
|
|
563
|
+
|
|
564
|
+
The easiest way would be to use the Adapter Builder update process. This process takes in a Swagger or OpenAPI document, allows you to select the calls you want to add and then generates a zip file that can be used to update the adapter. Once you have the zip file simple put it in the adapter direcctory and execute `npm run adapter:update`.
|
|
565
|
+
|
|
566
|
+
```bash
|
|
567
|
+
mv updatePackage.zip adapter-netbox
|
|
568
|
+
cd adapter-netbox
|
|
569
|
+
npm run adapter:update
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
If you do not have a Swagger or OpenAPI document, you can use a Postman Collection and convert that to an OpenAPI document using APIMatic and then follow the first process.
|
|
573
|
+
|
|
574
|
+
If you want to manually update the adapter that can also be done the key thing is to make sure you update all of the right files. Within the entities directory you will find 1 or more entities. You can create a new entity or add to an existing entity. Each entity has an action.json file, any new call will need to be put in the action.json file. It will also need to be added to the enum for the ph_request_type in the appropriate schema files. Once this configuration is complete you will need to add the call to the adapter.js file and in order to make it available as a workflow task in IAP, it should also be added to the pronghorn.json file. You can optionally add it to the unit and integration test files. There is more information on how to work on each of these files in the Adapter Technical Resources on Dev Site [HERE](https://developer.itential.io/adapters-resources/)
|
|
575
|
+
|
|
576
|
+
```text
|
|
577
|
+
Files to update
|
|
578
|
+
* entities/<entity>/action.json: add an action
|
|
579
|
+
* entities/<entity>/schema.json (or the schema defined on the action): add action to the enum for ph_request_type
|
|
580
|
+
* adapter.js: add the new method and make sure it calls the proper entity and action
|
|
581
|
+
* pronghorn.json: add the new method
|
|
582
|
+
* test/unit/adapterTestUnit.js (optional but best practice): add unit test(s) - function is there, any required parameters error when not passed in
|
|
583
|
+
* test/integration/adapterTestIntegration.js (optional but best practice): add integration test
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
### Adding Adapter Properties
|
|
587
|
+
|
|
588
|
+
While changing adapter properties is done in the service instance configuration section of IAP, adding properties has to be done in the adapter. To add a property you should edit the propertiesSchema.json with the proper information for the property. In addition, you should modify the sampleProperties to have the new property in it.
|
|
589
|
+
|
|
590
|
+
```text
|
|
591
|
+
Files to update
|
|
592
|
+
* propertiesSchema.json: add the new property and how it is defined
|
|
593
|
+
* sampleProperties: add the new property with a default value
|
|
594
|
+
* test/unit/adapterTestUnit.js (optional but best practice): add the property to the global properties
|
|
595
|
+
* test/integration/adapterTestIntegration.js (optional but best practice): add the property to the global properties
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
### Changing Adapter Authentication
|
|
599
|
+
|
|
600
|
+
Often an adapter is built before knowing the authentication and authentication process can also change over time. The adapter supports many different kinds of authentication but it does require configuration. Some forms of authentication can be defined entirely with the adapter properties but others require configuration.
|
|
601
|
+
|
|
602
|
+
```text
|
|
603
|
+
Files to update
|
|
604
|
+
* entities/<entity>/action.json: change the getToken action as needed
|
|
605
|
+
* entities/<entity>/schemaTokenReq.json: add input parameters (external name is name in other system)
|
|
606
|
+
* entities/<entity>/schemaTokenResp.json: add response parameters (external name is name in other system)
|
|
607
|
+
* propertiesSchema.json: add any new property and how it is defined
|
|
608
|
+
* sampleProperties: add any new property with a default value
|
|
609
|
+
* test/unit/adapterTestUnit.js (optional but best practice): add the property to the global properties
|
|
610
|
+
* test/integration/adapterTestIntegration.js (optional but best practice): add the property to the global properties
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### Enhancing Adapter Integration Tests
|
|
614
|
+
|
|
615
|
+
The adapter integration tests are written to be able to test in either stub (standalone) mode or integrated to the other system. However, if integrating to the other system, you may need to provide better data than what the adapter provides by default as that data is likely to fail for create and update. To provide better data, edit the adapter integration test file. Make sure you do not remove the marker and keep custom code below the marker so you do not impact future migrations. Once the edits are complete, run the integration test as it instructs you to above. When you run integrated to the other system, you can also save mockdata for future use by changing the isSaveMockData flag to true.
|
|
616
|
+
|
|
617
|
+
```text
|
|
618
|
+
Files to update
|
|
619
|
+
* test/integration/adapterTestIntegration.js: add better data for the create and update calls so that they will not fail.
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
As mentioned previously, for most of these changes as well as other possible changes, there is more information on how to work on an adapter in the Adapter Technical Resources on Dev Site [HERE](https://developer.itential.io/adapters-resources/)
|
|
623
|
+
|
|
551
624
|
## Troubleshooting the Adapter
|
|
552
625
|
|
|
553
626
|
Run `npm run troubleshoot` to start the interactive troubleshooting process. The command allows user to verify and update connection, authentication as well as healthcheck configuration. After that it will test these properties by sending HTTP request to the endpoint. If the tests pass, it will persist these changes into IAP.
|
|
@@ -566,26 +639,26 @@ User also have the option to run individual command to perform specific test
|
|
|
566
639
|
npm run troubleshoot
|
|
567
640
|
```
|
|
568
641
|
|
|
569
|
-
|
|
642
|
+
2. Verify the adapter properties are set up correctly.
|
|
570
643
|
|
|
571
644
|
```text
|
|
572
645
|
Go into the Itential Platform GUI and verify/update the properties
|
|
573
646
|
```
|
|
574
647
|
|
|
575
|
-
|
|
648
|
+
3. Verify there is connectivity between the Itential Platform Server and Netbox Server.
|
|
576
649
|
|
|
577
650
|
```text
|
|
578
651
|
ping the ip address of Netbox server
|
|
579
652
|
try telnet to the ip address port of Netbox
|
|
580
653
|
```
|
|
581
654
|
|
|
582
|
-
|
|
655
|
+
4. Verify the credentials provided for Netbox.
|
|
583
656
|
|
|
584
657
|
```text
|
|
585
658
|
login to Netbox using the provided credentials
|
|
586
659
|
```
|
|
587
660
|
|
|
588
|
-
|
|
661
|
+
5. Verify the API of the call utilized for Netbox Healthcheck.
|
|
589
662
|
|
|
590
663
|
```text
|
|
591
664
|
Go into the Itential Platform GUI and verify/update the properties
|