Adapter for Integration to any Mock Device
This adapter is a mock implementation of device broker. It should be used if there is a need of mock devices for testing purposes.
These instructions will help you get a copy of the project on your local machine for development and testing. Reading this section is also helpful for deployments as it provides you with pertinent information on prerequisites and properties.
The following is a list of required packages for installation on the system the adapter will run on:
Node.js
npm
Git
cd /opt/pronghorn/current/node_modules (* could be in a different place)
if the @itentialopensource directory does not exist, create it:
mkdir @itentialopensource
cd \@itentialopensource
git clone git@gitlab.com:\@itentialopensource/adapters/adapter-mockdevice
or
unzip adapter-mockdevice.zip
or
tar -xvf adapter-mockdevice.tar
cd adapter-mockdevice
npm run adapter:install
systemctl restart pronghorn
npm run adapter:install can be dependent on where the adapter is installed and on the version of Itential Platform so it is subject to fail. If this happens you can replace step 3-5 above with these:
cd adapter-mockdevice
npm run install
npm run lint:errors
npm run test
systemctl restart pronghorn
This section provides sample properties that can be used to configure the adpater in Itential Platform .
{
"name": "mockDevice",
"model": "@itential/adapter-mockdevice",
"type": "Adapter",
"properties": {
"id": "mockDevice",
"type": "MockDevice",
"brokers": [
"device"
],
"groups": [],
"properties": {}
},
"isEncrypted": true,
"loggerProps": {
"description": "Logging",
"log_max_files": 10,
"log_max_file_size": 10485760,
"log_level": "warn",
"log_directory": "/opt/itential/logs",
"log_filename": "mockDevice.log",
"log_timezone_offset": 0,
"console_level": "warn",
"syslog": {
"level": "warning",
"host": "127.0.0.1",
"port": 514,
"protocol": "udp4",
"facility": "local0",
"type": "BSD",
"path": "",
"pid": "process.pid",
"localhost": "",
"app_name": "",
"eol": ""
}
},
"virtual": false
}
Inside of your pronghorn database, a new collection will need to be created called mock_devices. Inside of this collection, all the mock adapters that are to be used will live.
Two example devices are listed below:
{
"_id" : ObjectId("643ebeb47a16b404b2cd9ffe"),
"name" : "nx03-atl",
"authgroup" : "admin",
"ipaddress" : "172.20.100.226",
"address" : "172.20.100.226",
"port" : 22.0,
"device-type" : "cli",
"ostype" : "cisco-nx-cli-5.22",
"ned" : "cisco-nx-cli-5.22",
"admin" : true,
"tenant" : "",
"chosenAdapter" : "mockAdapter",
"origin" : "mockAdapter",
"host" : "mockAdapter",
"online" : "true",
"deleted" : false,
"actions" : [
"addDevice",
"deleteDevice",
"getConfig",
"getDevice",
"getDevicesFiltered",
"isAlive",
"loadConfig",
"restoreConfig",
"runCommand",
"setConfig"
]
}
{
"_id" : ObjectId("643ebed97a16b404b2cd9fff"),
"name" : "Cisco-IOS-Cypress",
"authgroup" : "admin",
"ipaddress" : "172.20.100.226",
"address" : "172.20.100.226",
"port" : 22.0,
"device-type" : "cli",
"ostype" : "cisco-nx-cli-5.22",
"ned" : "cisco-nx-cli-5.22",
"admin" : true,
"tenant" : "",
"chosenAdapter" : "mockAdapter",
"origin" : "mockAdapter",
"host" : "mockAdapter",
"online" : "true",
"deleted" : false,
"actions" : [
"addDevice",
"deleteDevice",
"getConfig",
"getDevice",
"getDevicesFiltered",
"isAlive",
"loadConfig",
"restoreConfig",
"runCommand",
"setConfig"
]
}