{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Connection Profiles\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_ConnectionProfiles.htm)\n", "\n", "Connection profiles are used to define access methods and security credentials for a specific application. They can be referenced by multiple jobs. To do this, you must deploy the connection profile definition before running the relevant jobs. \n", "\n", "Note: For most types of connection profiles (except for File Transfer connection profiles), the name of the connection profile can contain only the following types of characters: uppercase letters, numbers, hyphens, and underscores. The connection profile name can contain up to 30 characters.\n", "\n", "Arguments:\n", "\n", "- **target_ctm** : (Only when centralized is False) The Control-M/Server to which to deploy the connection profile. If there is only one Control-M/Server, that is the default\n", "- **target_agent** : (Only when centralized is False) The Control-M/Agent to which to deploy the connection profile\n", "- **description** : Description of the connection profile\n", "- **centralized** : (Available with Automation API >= 9.0.20.000) Whether to create the connection profile as a centralized connection profile that is stored in the Control-M database and is available to all Control-M/Agents" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "from aapi import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ConnectionProfileHadoop" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# For Apache spark\n", "\n", "cp_spark = ConnectionProfileHadoop(\n", " 'SPARK_CONNECTION_PROFILE',\n", " target_agent='docker-hadoop',\n", " spark=ConnectionProfileHadoop.Spark(\n", " custom_path='/home'\n", " )\n", ")\n", "\n", "\n", "# For Apache Oozie\n", "\n", "cp_ooze = ConnectionProfileHadoop(\n", " 'OOZIE_CONNECTION_PROFILE',\n", " target_agent='docker-hadoop',\n", " oozie=ConnectionProfileHadoop.Oozie(\n", " ssl_enabled=True,\n", " host='hdp-centos',\n", " port='11000',\n", " extraction_rules=[\n", " ExtractRule(rule_name='rule1', work_flow_name='wf1',\n", " work_flow_user_name='user1', folder_name='fname1', job_name='jname1'),\n", " ExtractRule(rule_name='rule2', work_flow_name='wf2',\n", " work_flow_user_name='user2', folder_name='fname2', job_name='jname2')\n", " ]\n", " )\n", ")\n", "\n", "\n", "# For Apache Sqoop\n", "\n", "cp_sqoop = ConnectionProfileHadoop(\n", " 'SQOOP_CONNECTION_PROFILE',\n", " centralized=True,\n", " sqoop=ConnectionProfileHadoop.Sqoop(\n", " user='user1',\n", " password='mypass',\n", " connection_string='jdbc:mysql://mysql.server/database',\n", " driver_class='com.mysql.jdbc.Driver'\n", " )\n", ")\n", "\n", "# For Apache Tajo\n", "\n", "cp_tajo = ConnectionProfileHadoop(\n", " 'TAJO_CP',\n", " centralized=True,\n", " tajo=ConnectionProfileHadoop.Tajo(binary_path='$TAJO_HOME/bin/', database_name='myjob',\n", " master_server_name='myTajoServer', master_server_port='26001')\n", ")\n", "\n", "\n", "# For Apache Hive\n", "\n", "cp_hive = ConnectionProfileHadoop('HIVE_CONNECTION_PROFILE',\n", " centralized=True,\n", " hive=ConnectionProfileHadoop.Hive(\n", " host='hivehost',\n", " port='10000',\n", " database_name='db'\n", " )\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ConnectionProfileFileTransfer" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileFileTransferFTP" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ftcon = ConnectionProfileFileTransferFTP('FTPConn',\n", " target_agent='agent',\n", " target_ctm='ctmserver',\n", " host_name='FTPServer',\n", " user='FTPUser',\n", " password='ftp_pass',\n", " additional_parameters=[\n", " PackageParams('param1', '1'),\n", " PackageParams('param2', '2'),\n", " ],\n", " home_directory='/home',\n", " os_type='Unix'\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileFileTransferSFTP" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ftcon = ConnectionProfileFileTransferSFTP('SFTPConn',\n", " target_agent='agent',\n", " target_ctm='ctmserver',\n", " host_name='SFTPServer',\n", " user='SFTPUser',\n", " private_key_name='/home/key',\n", " passphrase='passphrase',\n", " ssh_compression=True,\n", " additional_parameters=[\n", " PackageParams('param1', '1'),\n", " PackageParams('param2', '2'),\n", " ],\n", " home_directory='/home',\n", " os_type='Unix'\n", " ) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileFileTransferFTPS" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ftcon = ConnectionProfileFileTransferFTPS('FTPSConn',\n", " target_agent='agent',\n", " target_ctm='ctmserver',\n", " host_name='FTPServer',\n", " user='FTPUser',\n", " password='ftp_pass',\n", " ssl_implicit=True,\n", " clear_command_channel=True,\n", " clear_data_channel=True,\n", " ssl_level=ConnectionProfileFileTransferFTPS.SslLevel.ClientServerAuthentication,\n", " additional_parameters=[\n", " PackageParams('param1', '1'),\n", " PackageParams('param2', '2'),\n", " ],\n", " home_directory='/home',\n", " os_type='Unix'\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileFileTransferLocal" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ftcon = ConnectionProfileFileTransferLocal('LocalConn',\n", " target_agent='agent',\n", " target_ctm='ctmserver',\n", " password='pass',\n", " additional_parameters=[\n", " PackageParams('param1', '1'),\n", " PackageParams('param2', '2'),\n", " ],\n", " home_directory='/home',\n", " os_type='Unix'\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileFileTransferS3Amazon" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ftcon = ConnectionProfileFileTransferS3Amazon('testAmazon',\n", " centralized=True,\n", " access_key='access',\n", " secret_access_key='secretAccess',\n", " verify_destination=True,\n", " additional_parameters=[\n", " PackageParams('param1', '1'),\n", " PackageParams('param2', '2'),\n", " ]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileFileTransferS3Compatible" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ftcon = ConnectionProfileFileTransferS3Compatible('testCompatible',\n", " centralized=True,\n", " access_key='access',\n", " rest_end_point='api.com',\n", " secret_access_key='secretAccess',\n", " verify_destination=True,\n", " additional_parameters=[\n", " PackageParams('param1', '1'),\n", " PackageParams('param2', '2'),\n", " ]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileFileTransferAS2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ftcon = ConnectionProfileFileTransferAS2('AS2_Conn_1',\n", " centralized=True,\n", " workload_automation_groups=['noAI'],\n", " partner_as2_id='partner',\n", " partner_destination_url='dest.com',\n", " partner_certificate_alias='alias'\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ConnectionProfileDatabase" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileDatabaseDB2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpdb = ConnectionProfileDatabaseDB2(\n", " 'DB2_CONNECTION_PROFILE',\n", " centralized=True,\n", " host='DB2Host',\n", " port='50000',\n", " user='user',\n", " password='pass',\n", " database_name='db2'\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileDatabaseJDBC" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpdb = ConnectionProfileDatabaseJDBC(\n", " 'JDBC_CONNECTION_PROFILE',\n", " centralized=True,\n", " host='DB2Host',\n", " port='50000',\n", " user='user',\n", " password='pass',\n", " database_name='db2',\n", " driver='PGDRV'\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileDatabaseMSSql" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpdb = ConnectionProfileDatabaseMSSql(\n", " 'MSSQL_CONNECTION_PROFILE',\n", " centralized=True,\n", " host='DB2Host',\n", " port='50000',\n", " user='user',\n", " password='pass',\n", " database_name='db2',\n", " database_version='2005',\n", " max_concurrent_connections='9',\n", " connection_retry_time_out='34',\n", " connection_idle_time='45'\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileDatabaseOracleSID" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpdb = ConnectionProfileDatabaseOracleSID(\n", " 'ORACLE_CONNECTION_PROFILE',\n", " centralized=True,\n", " sid='ORCL',\n", " user='username',\n", " password='pass'\n", ")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileDatabaseOracleServiceName" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpdb = ConnectionProfileDatabaseOracleServiceName(\n", " 'ORACLE_CONNECTION_PROFILE',\n", " centralized=True,\n", " service_name='ORCL',\n", " user='username',\n", " password='pass'\n", ")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileDatabaseOracleConnectionString" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpdb = ConnectionProfileDatabaseOracleConnectionString(\n", " 'ORACLE_CONNECTION_PROFILE',\n", " centralized=True,\n", " connection_string='host:1521:ORCL',\n", " user='username',\n", " password='pass'\n", ")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileDatabasePostgreSql" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpdb = ConnectionProfileDatabasePostgreSql(\n", " 'POSTGRESQL_CONNECTION_PROFILE',\n", " centralized=True,\n", " database_name='postgres',\n", " user='username',\n", " password='pass'\n", ")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### ConnectionProfileDatabaseSybase" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpdb = ConnectionProfileDatabaseSybase(\n", " 'SYBASE_CONNECTION_PROFILE',\n", " centralized=True,\n", " database_name='postgres',\n", " user='username',\n", " password='pass'\n", ")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ConnectionProfileSAP" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpsap = ConnectionProfileSAP(\n", " 'SAPCON',\n", " centralized=True,\n", " sap_client='100',\n", " language='',\n", " xbp_version='XBP3.0',\n", " app_version='R3',\n", " application_server_logon=ConnectionProfileSAP.ApplicationServerLogon(\n", " host='localhost',\n", " system_number='12'\n", " ),\n", " secured_network_connection=ConnectionProfileSAP.SecuredNetworkConnection(\n", " snc_lib='',\n", " snc_partner_name='',\n", " quality_of_protection='2',\n", " snc_my_name=''\n", " ),\n", " sap_response_time_out='180',\n", " use_extended=True,\n", " solution_manager_connection_profile='IP4-GROUP',\n", " is_solution_manager_connection_profile=True\n", "\n", ")\n", "\n", "print(cpsap.dumps_aapi(indent=2))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ConnectionProfileInformatica" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpinf = ConnectionProfileInformatica('INFORMATICA_CONNECTION',\n", " centralized=True,\n", " host='INF',\n", " port='50000',\n", " user='user',\n", " password='pass',\n", " power_center_domain='domain',\n", " repository='rep',\n", " integration_service='servicename',\n", " security_domain='Native',\n", " connection_type=ConnectionProfileInformatica.ConnectionType.HTTP\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ConnectionProfileAWS" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpaws = ConnectionProfileAWS('AWS_CONNECTION_IAMROLE',\n", " centralized=True,\n", " iam_role='myrole',\n", " region='ap-northeast-1',\n", " proxy_settings=ConnectionProfileAWS.ProxySettings(\n", " host='host',\n", " port='12345',\n", " username='user',\n", " password='pass'\n", " )\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## ConnectionProfileAzure" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cpazure = ConnectionProfileAzure('AZURE_CONNECTION',\n", " centralized=True,\n", " active_directory_domain_name='domain',\n", " subscription_id='id',\n", " application_id='id',\n", " user='myuser',\n", " password='pass',\n", " batch=ConnectionProfileAzure.Batch(\n", " batch_account_name='mybatch',\n", " batch_account_key='key',\n", " location='centralus'\n", " )\n", " )\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.9.4 ('venv': venv)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.4" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "80486a6cd7ee7b40bf3e693bcef8fed73b086a911b6b9e540331391dcdfae705" } } }, "nbformat": 4, "nbformat_minor": 2 }