Skip to main content
Skip table of contents

Adapter tutorial

Create

While optional, it is assumed that any executable code and dependent libraries comprising an adapter have been created.

1. Navigate to the Adapters tab on the Developers console’s sidebar or menu.

2. Click + Add Adapter.

3. Enter the adapter's name, architecture, and description, and click Create. Adapter names must be unique within a system.

The new adapter will be displayed in the adapter list defined within the selected system.

Configure

When configuring an adapter, you can add, modify, and delete adapter files and modify the adapter’s commands. Files are optional for storing executable commands and can be downloadable. A command to execute the file must be provided if you elect to store commands inside files.

Add new adapter files

1. Navigate to the Adapters tab on the Developers console’s sidebar or menu.

2. Click the adapter you want to add the file to.

3. Click the edit icon next to Configuration.

4. Click File next to each command to which you want to add files and click Upload.

5. Select one or more files to add and click Open and Update Adapter.

Additional files can also be added with the Import Files button.

They can also be added at the bottom.

image-20240112-215829.png

This is what the Adapter page looks like after files are added:

Delete adapter files

Click Delete Adapter within the adapter you want to delete.

When the file is deleted, the switch will automatically set to Command. Any text in Command will remain. Click Update Adapter to save changes.

Update adapter files

Click Replace to replace the file with a new file or Download to download, edit, and replace with your updated file. Click Update Adapter.

Add permissions

CRUD (create, read, update, and delete) permissions can be added to adapters for individual roles:

  1. On the Roles section’s individual role page:

  1. On Edit Permissions within the Adapter settings:

Sample shell scripts

Deploy command

CODE
#!/bin/bash
mkdir ShowTimeAdapter

mv start.sh ShowTimeAdapter
mv stop.sh ShowTimeAdapter
mv status.sh ShowTimeAdapter
mv deploy.sh ShowTimeAdapter
mv undeploy.sh ShowTimeAdapter
mv showTime ShowTimeAdapter

echo "ShowTimeAdapter Deployed"

The deploy command specified to execute the deploy.sh shell script would be:

CODE
./deploy.sh

Start command

CODE
#!/bin/bash
nohup ./ShowTimeAdapter/showTime > ./ShowTimeAdapter/showTime.log 2>&1 &

The start command specified to execute the start.sh shell script would be:

CODE
./ShowTimeAdapter/start.sh

The command takes into account that the deploy script copied the start.sh file to a directory named ShowTimeAdapter. Since the shell script only contains one line, you can specify the start command value as:

CODE
nohup ./ShowTimeAdapter/showTime > ./ShowTimeAdapter/showTime.log 2>&1 &

Stop command

The stop command will kill the adapter process, such as:

CODE
ps -ef | grep showTime | grep -v grep | awk '{print $2}' | xargs kill

If a more sophisticated adapter shutdown is needed, shutdown logic can be incorporated into a shell script. A sample shell script, named stop.sh, is as follows:

CODE
#!/bin/bash
ps -ef | grep showTime | grep -v grep | awk '{print $2}' | xargs kill

The stop command specified to execute the stop.sh shell script would be:

CODE
./ShowTimeAdapter/stop.sh

The command takes into account that the deploy script copied the stop.sh file to a directory named ShowTimeAdapter. Since the shell script only contains one line, you can specify the stop command value as:

CODE
ps -ef | grep showTime | grep -v grep | awk '{print $2}' | xargs kill

Status command

CODE
#!/bin/bash
# The adapter has been deployed if this script is executed. There is no need to test for the undeployed status.
STATUS="Deployed"
if [ "ps -ef | grep showTime | grep -v grep" != "" ] ; then
    STATUS="Running"
else
    STATUS="Stopped"
fi

echo $STATUS

The status command specified to execute the status.sh shell script would be:

CODE
./ShowTimeAdapter/status.sh

Undeploy command

The undeploy command will delete an adapter-specific directory and any files contained within it, such as:

CODE
rm -rf ./ShowTimeAdapter

If a more sophisticated undeployment/deletion of the adapter is needed, undeploy logic can be incorporated into a shell script.

A sample shell script, named undeploy.sh, is as follows:

CODE
#!/bin/bash
rm -rf ./ShowTimeAdapter

Logs command

The logs command will most likely be a cat or tail command that displays the file contents, such as:

CODE
cat ./ShowTimeAdapter/showTime.log

In many cases, the logs command will be directly dependent on the start-up command piping output to a file unless the adapter is written so that it creates its log files. The logic can be incorporated into a shell script if more sophistication is needed to read log files.

A sample shell script, named log.sh, is as follows:

CODE
#!/bin/bash
cat ./ShowTimeAdapter/showTime.log

The logs command specified to execute the logs.sh shell script would be:

CODE
./ShowTimeAdapter/logs.sh

To prevent naming collisions resulting in overwritten files, it is recommended that adapter files be copied to an adapter-specific directory. The files can be copied using a shell command or script. A shell script to accomplish tasks needed for deployment must be included as one of the adapter files in the command’s file section. You should provide an archive/zip file containing all the files required to execute and manage an adapter. The deploy command would be a shell command to extract the archive’s contents, for example:

CODE
tar -xvzf MyAdapter.tar.gz -C /MyAdapter
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.