Create Custom Adapter in Python

This section provides information on creating custom adapter in Python:

Important

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

  1. To set up Git access to the Action Orchestrator Bitbucket repositories, contact CloudCenter Suite Support team.

  2. Install Python wheel package locally, perform the following:

    1. On Mac or Linux, run sudo pip install wheel.

  3. Fetch source code of Python template adapter, perform the following:

    1. git clone , see Python Adapter Template.

    2. Under the template folder, git checkout dev

  4. Make a clone of the adapter-template python folder. Rename the folder to appropriate custom adapter name.

  5. 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.

  6. Open the custom adapter project in an IDE like Visual Studio Code or another IDE and update the following files:

    1. 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). 

    2. Under activities_python\constants folder:

      1. Update basic_constants.py  using proper convention used while creating schemas.

    3. Under activities_python\actions folder, update verify_target.py for target and account key verification.

    4. Under activities_python\events folder, update event_resolve.py to import proper classes. 

    5. Under yaml folder, replace all demo-adapter  occurrences with the custom adapter name in demo-adapter.yaml.

    6. Under activities_python\common\factories folder, update description in parser.py where parser = argparse.ArgumentParser(description='Template Python activities adapter.')

  7. On command line, under custom adapter folder add the custom adapter project directory to PYTHONPATH using the following command: export PYTHONPATH=PathToCustomPythonAdapterProject

  8. On command line, go under the custom adapter folder and perform the following:

    1. Update setup.py to include any additional libraries in the setup_requires section:

      setup_requires=['pytest-runner']

    2. Run the following python setup command to create a wheel package of the custom adapter:

      python setup.py bdist_wheel 

    3. 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

    4. Run the following kubectl command to deploy the custom adapter in Kubernetes cluster:

      kubectl create -f yaml/demo-adapter.yaml -n orch-platform

  9. Open Action Orchestrator UI and create custom adapter target and account key.

  10. Create New Workflow. Make sure that the custom adapter activities show up in the Workflow Editor toolbox and validate those activities.

  • No labels
© 2017-2019 Cisco Systems, Inc. All rights reserved