Create Custom Adapter in Python
This section provides information on creating custom adapter in Python:
Windows is not supported anymore. It is not possible to run python adapter locally on windows. Template now supports running commands in jail environment and uses some specific libraries
To set up Git access to the Action Orchestrator Bitbucket repositories, contact CloudCenter Suite Support team.
Install Python wheel package locally, perform the following:
On Mac or Linux, run sudo pip install wheel.
Fetch source code of Python template adapter, perform the following:
git clone , see Python Adapter Template.
Under the template folder, git checkout dev.
Make a clone of the adapter-template python folder. Rename the folder to appropriate custom adapter name.
To create schema for adapters from UI, see Creating Schema.
Follow the schema creation order described in Create Schemas doc.
When creating adapter schema please remember that the name of MICROSERVICE NAME should be the same as demo-adapter-name used when building docker container.
When creating target schema please notice that SCHEMA TYPE should be the same as used in adapter BasicConstants.TARGET_NAME.
When creating activity schema please notice that SCHEMA TYPE should be the same as used in adapter BasicConstants.ACTIVITY_x_NAME.
Open the custom adapter project in an IDE like Visual Studio Code or another IDE and update the following files:
Under activities_python\actions folder, rename action_helloworld.py to appropriate activity name, update activity inputs and outputs using proper convention used while creating activity schema. By default action_helloworld.py supports two input properties (input_one, input.two) and two output properties (output_one, output_two).
Under activities_python\constants folder:
Update basic_constants.py using proper convention used while creating schemas.
Under activities_python\actions folder, update verify_target.py for target and account key verification.
Under activities_python\events folder, update event_resolve.py to import proper classes.
Under yaml folder, replace all demo-adapter occurrences with the custom adapter name in demo-adapter.yaml.
Under activities_python\common\factories folder, update description in parser.py where parser = argparse.ArgumentParser(description='Template Python activities adapter.')
On command line, under custom adapter folder add the custom adapter project directory to PYTHONPATH using the following command: export PYTHONPATH=PathToCustomPythonAdapterProject
On command line, go under the custom adapter folder and perform the following:
Update setup.py to include any additional libraries in the setup_requires section:
Run the following python setup command to create a wheel package of the custom adapter:
python setup.py bdist_wheel
Run docker build command to build a docker image. Change demo-adapter-name in the command to proper adapter name defined in demo-adapter.yaml:
docker build . -t demo-adapter-name -f Dockerfile
Run the following kubectl command to deploy the custom adapter in Kubernetes cluster:
kubectl create -f yaml/demo-adapter.yaml -n orch-platform
Open Action Orchestrator UI and create custom adapter target and account key.
Create New Workflow. Make sure that the custom adapter activities show up in the Workflow Editor toolbox and validate those activities.
- No labels