Auto generation of AI Plugins with Control-M WorkbenchΒΆ
Control-M Workbench version 9.21.100 or above allows users to auto generate python code for their AI plugins. We will use the ext.autogen
module from the Control-M Python Client to generate all classes of Jobs and ConnectionProfiles of all plugins in a workbench environment.
If you want to follow along, import the Example Plugin file into your workbench.
[1]:
import ctm_python_client.ext.autogen as autogen
# this will autogenerate a file called generatedplugins.py with the definitions of all plugins you have in workbench
autogen.generate_ai_plugins_classes(output_file="./generatedplugins.py")
After calling generate_ai_plugins_classes
, a new python file is generated
[9]:
!type generatedplugins.py
from aapi import *
import attrs
# Auto generated code for AI Plugin Example Plugin
@attrs.define
class AIJobExampleplugin(AIJob):
_type = AIJob.type_field('Example Plugin')
examplefield = AIJob.field('ExampleField')
examplewithdefault = AIJob.field_optional('ExampleFieldWithDefault', default='Some Value')
@attrs.define
class ConnectionProfileAIExampleplugin(AIConnectionProfile):
_type = AIConnectionProfile.type_field('Example Plugin')
examplepassword = AIConnectionProfile.field('ExamplePassword')
We can now import all objects from this file (Jobs and Connection Profiles):
[2]:
from generatedplugins import *
With the new classes for Jobs and Connection Profiles, we can create flows with our Application Integrator Plugins:
[6]:
cp = ConnectionProfileAIExampleplugin("TESTCP", centralized=True, examplepassword="password")
job = AIJobExampleplugin("MyExampleJob", connection_profile="TESTCP", examplefield="My field")
[4]:
from ctm_python_client.core.workflow import *
w = Workflow.workbench()
w.add(cp)
job_name = w.add(job, inpath="TestApplicationIntegrator")
[5]:
run = w.run()
print(run.get_output(job_name))
Environment information:
+-------------------------+--------------------------------------------------+
|Connection Profile Name |TESTCP |
+-------------------------+--------------------------------------------------+
|Connection Profile Scope |Centralized |
+-------------------------+--------------------------------------------------+
=============================================
Operation: Execute
Step name: '[Unnamed step]'
=============================================
Command line:
-------------
echo "Example Plugin"
echo "=== Job Properties ==="
echo "Your Example Field = My field"
echo "Your Example Field with Default = Some Value"
echo " === Connection profile properties ==="
echo "Your example password = ****** "
Exit code is: 0
Job statistics:
+-------------------------+-------------------------+
|Start Time |20230213085531 |
+-------------------------+-------------------------+
|End Time |20230213085532 |
+-------------------------+-------------------------+
|Elapsed Time |71 |
+-------------------------+-------------------------+
Exit Code = 0
Exit Message = Normal completion