This repository is deprecated; please follow the main search page or use the ‘Related code repos’ widget on the right side of the current page.

node-red-hdm-custom-node-for-iox

This repo contains code for Cisco IOx HDM custom node module of Node-RED. HDM stands for Host Device Management. The HDM custom node is a function that outputs real-time on-demand HDM data of IR800. The output includes the results of any show commands of the device.

Requirements

  • Docker deamon up and running.
  • Cisco IR800 device.
  • IOxCore 1.5.0, IOxGPS 1.5.1, IOxMotion 1.5.1 and IOxHdm 1.0 services running on the device.

(If you don't want GPS service or motion service, you need to remove the dependencies in package.yaml and modify the base image in Dockerfile to node0:1.0.)

  • ioxclient installed.

Installation

0.1 Build Node-RED slim Docker image

(If you already have Docker image node0:1.0, you can skip this step.)

Build Docker image node0:1.0 using the following package:
https://github.com/CiscoIOx/node-red-slim-for-iox

0.2 Build gps node Docker image

(If you already have Docker image gpsnode:1.0, you can skip this step.)

Build Docker image gpsnode:1.0 using the following package:
https://github.com/CiscoIOx/node-red-gps-node-for-iox

0.3 Build motion node Docker image

(If you already have Docker image motionnode:1.0, you can skip this step.)

Build Docker image motionnode:1.0 using the following package:
https://github.com/CiscoIOx/node-red-motion-node-for-iox

0.4 Build HDM node Docker image

(If you already have Docker image hdmnode:1.0, you can skip this step.)

Build Docker image hdmnode:1.0 using the following package:
https://github.com/CiscoIOx/node-red-hdm-node-for-iox

1. Build HDM custom node Docker image

Go to the root of this package (same path as Dockerfile) and run:
docker build -t hdmcustomnode:1.0 .

Don't forget the . at the end. It means the current directory.
This will create a Docker image hdmcustomnode:1.0 based on the previously built image hdmnode:1.0.

2. Create IOx application package

Use the following command to build the IOx application package named package.tar.

ioxclient docker package hdmcustomnode:1.0 .

Don't forget the . at the end.

3. Deploy, activate and start the app

Deploy the application onto IR800 using Local Manager or ioxclient.

For Local Manager option:

Access device Local Manager UI using the URL path https://:8443.

Deploy the app using the name nodered and the package package.tar that you created.

image

image

Activate the app with these configurations:

  • Choose iox-nat0 for network and 1880:1880 for custom port mapping.

  • Choose async1 and async0 for device serial ports.

  • The recommended resource profile is:

    • CPU: 200 cpu-units
    • Memory: 128 MB
    • Disk: 10 MB

    You can change the combination upon the consumption of your other apps. The memory should be no less.

image

image

image

Finally start the app.

image

For ioxclient option:

Run the following command to deploy, activate and start the app:

ioxclient app install nodered package.tar

ioxclient app activate --payload activation.json nodered

ioxclient app start nodered

The activation.json file is similar to the Sample Activation payload in GPS service introduction of IOx.

Verify the app is running

Open Node-RED interface at http://:1880.

image

Build a simple flow with inject, Hdm custom IOx connector and debug nodes. Use timestamp as the payload of inject node.

image

Set Repeat to none.

image

Double click the hdm_custom node and type in a show command (any command built for IOS console) and deploy.

image

image

Click the button at timestamp node once. You'll be able to see a result of the show command you assigned.

image

If you set Repeat to interval of every 20 seconds and deploy. (Some results of show commands are long and too frequent requests may break the HDM service, so longer intervals are recommended.)

image

image

image

Set Repeat back to none and deploy to stop data streaming.

More usage

Export flows

Enter IOx appconsole by:

ioxclient app console nodered

image

Run the following command to push flows file and credentials file to Local Manager.

sh /usr/src/node-red/hdmcustom/getflows.sh

image

Go to Local Manager. Click Manage of the nodered app. Click App-DataDir tab, you'll see the flows_$(hostname).json and flows_$(hostname)_cred.json files from there. Download the files to get the flows in Node-RED of this device. The credentials are encrypted.

image

Use the flows on other devices

Go to the Local Manager of a different device. Or you can use Fog Director for multiple devices.

Upload flows_$(hostname).json and flows_$(hostname)_cred.json under App-DataDir tab. These two files should both be uploaded or not. They work in a pair. Use path flows.json and flowscred.json respectively to ensure that they will work on different types of devices.

image

image

Start the nodered app of this second device. You should be able to see the flows with credentials already set up.

image

Example flows are shown below.

image

Set up your own credentialSecret

By default, the credentialSecret in settings.js of the nodered app is set to cisco. If you want to use your own credentailSecret, create a file called cred.json and upload with path cred.json before you start the app in IOx:

{
	"credentialSecret": "your own credentialSecret"

}

image

Make sure you have this cred.json file with the same credentialSecret for all your devices so that the flows_$(hostname)_cred.json file can be decrypted correctly.

Note that once you set credentialSecret you cannot change its value.

Getting help

If you have questions, concerns, bug reports, etc., please file an issue in this repository's Issue Tracker.


Credits and references

  1. https://nodered.org/docs/creating-nodes/
View code on GitHub
  • Owner

  • Contributors

    +1Github contributor
  • Categories

  • Programming Languages

    JavaScript
  • License

    Apache License 2.0

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.