Working with Application Integrator

Control-M Application Integrator is a web-based application that allows you to create custom job types that you can easily deploy in the Control-M environment. These jobs can be managed alongside any Control-M job, which enables you to manage on-premises and multi-cloud application workflows for commercial, custom, and home-grown applications through a single platform.

Control-M Python Client allows you to work with Application Integrator Job Types by providing a base class which you can create your own Application Integrator job types

Building Custom Application Integrator Job Types with AIJob

You create Application Integrator Job types through the Application Integrator web interface. After you deploy a job to an Agent, you can use it as any other Job type from the job palette in the Planning domain.

To use the new job type that you create in Control-M Python Client, you need to create the JobType as a class in your code. This is made easy by the AIJob class that serves as the base class that provides all the necessary functionalities to make your class work as a valid Automation API definition.

Let’s see a simple example.

Below we create a simple Application Integrator JobType called AI SSHCommand. It accepts two paramaters that we define in the Application Integrator web interface: Command and Flags in addition to the Connection Profile.

Note: You cannot add or edit Application Integrator connection profiles in Control-M Python Client. You must add them in the Application Integrator web interface.

AI Job parameters

Let’s create the class in Control-M Python Client

[1]:
from ctm_python_client.core.comm import *
from ctm_python_client.core.workflow import *

from aapi import *
import attrs

# All JobTypes are decorated with attrs

@attrs.define
class AIJobSSHCommand(AIJob):   # We derive from AIJob, the name of the class can be any valid python class name
    _type = AIJob.type_field('AI SSHCommand')   # We add a "type" field, with the same name you would see in the web interface.
                                                # the name in type IS important and should match the one seen in the Web Interface
                                                # in the Planning section

    command = AIJob.field('Command')            # the field name argument needs to match the one in the Web interface
                                                # the name of the field (lower case command) can be any valid python variable name

    flags = AIJob.field_optional('Flags')       # this is an optional field, similar to AIJob.field() but not mandatory to use



[2]:
# Let's check that the Automation API Json is ok

workflow = BaseWorkflow()   # BaseWorkflow is a workflow which is not connected to any environment
aijob = AIJobSSHCommand('MySSHCommand',
                connection_profile='HOSTCP',
                command='ls',
                flags='-q')
workflow.add(aijob, inpath='AIfolder')

print(workflow.dumps_json(indent=2))

{
  "AIfolder": {
    "Type": "Folder",
    "MySSHCommand": {
      "Type": "Job:ApplicationIntegrator:AI SSHCommand",
      "ConnectionProfile": "HOSTCP",
      "AI-Command": "ls",
      "AI-Flags": "-q"
    }
  }
}
[5]:
# Let's check that the Automation API Json is ok

workflow = BaseWorkflow()   # BaseWorkflow is a workflow which is not connected to any environment

# the flags variable is a optional field, we can create job without an optional field
aijob = AIJobSSHCommand('MySSHCommand',
                connection_profile='HOSTCP',
                command='ls')
workflow.add(aijob, inpath='AIfolder')

print(workflow.dumps_json(indent=2))
{
  "AIfolder": {
    "Type": "Folder",
    "MySSHCommand": {
      "Type": "Job:ApplicationIntegrator:AI AI SSHCommand",
      "ConnectionProfile": "HOSTCP",
      "AI-Command": "ls"
    }
  }
}