ODI: Automating deployment of scenarios to production in Oracle Data Integrator

In this post I will show you how you can automatically deploy scenarios in ODI.

It is rather cumbersome to manually deploy scenarios from a test/development to a production environment.

Typically it involves the following steps:

- Manually (re-)generate all scenarios that need to be deployed and any child scenarios referenced.
- Manually export the (re-)generated scenarios
- Log in to the Operator module for the production environment and manually import the scenarios.

You do the above once or twice manually before getting extremely fed up. Actually I was rather patient (unlike my normal self) and did this about ten times before I got very, very annoyed.

In this post I will show you how you can automate the deployment process. The proposed solution will allow you to logically group scenarios together via marker groups for automatic deployment, thus giving you more flexibility and allowing you to just deploy a subset of scenarios in your project.

To achieve our goal we will make use of the following Oracle Data Integrator features:

- Marker groups
- ODIGenerateAllScen tool
- ODIExportScen tool
- OdiImportScen tool
- Meta-information in the ODI work repository
- Execution of scenarios from a Windows batch file

In a first step we create a new marker group. We will use the marker group to logically group together scenarios we want to deploy. We will subsequently use the marker group in the ODIGenerateAllScen, ODIExportScen, and OdiImportScen tools.

Log on to Designer > Expand Markers > Right click Markers > Select Insert Marker Group

odi_marker_group

As you can see from the figure above I have named the marker group Scenario and added three markers. One of the markers is named XLS (short for scenarios that load data from Excel sheets). Flagging these scenarios (or rather their packages) via a marker will allow us to deploy them separately.

Next we will add the XLS marker to those packages that we wish to logically group together for deployment. In our particular case, all of the Excel related packages.

Right click package > Add Marker > Scenario XLS

odi_marker_xls

In the next step we will create a package that will (re-)generate all packages marked with XLS.

Create a new package, name it GENERATE_SCENARIOS_XLS, add the ODIGenerateAllScen tool to it, and use the following parameters for the tool:

Project: The name of your project
Mode: Replace. This will overwrite the latest version of your scenario.
Marker Group: Scenario
Marker: XLS

Leave the default values for the other parameters.
gen_scen_pack

In a next step we need to export the (re-)generated scenarios to XML. Unfortunately, the OdiExportScen tool does not allow us to make use of marker groups to logically group together scenarios for export. To achieve our goal we need to make use of a workaround.

As ODI is a meta-driven ELT tool we can retrieve information about the marker groups from the ODI work repository.

The query below will exactly do this. It returns alls packages that are marked as XLS.

SELECT
   scen_name AS pack_name
FROM (      
   SELECT 
     LAST_VALUE(d.scen_name) OVER
 (PARTITION BY c.pack_name ORDER BY scen_version) AS scen_name,
     MAX(scen_version) OVER
 (PARTITION BY c.pack_name ) max_scen_version,
     scen_version,
     c.pack_name
   FROM 
      snp_obj_state a 
      join snp_state2 b on (a.i_state = b.i_state)
      JOIN snp_package c ON (a.i_instance = c.i_package)
      JOIN snp_scen d ON (c.i_package = d.i_package)
   WHERE
      state_code = 'XLS'  
)
WHERE 
  scen_version = max_scen_version      

We will employ this query as an implicit cursor in an ODI procedure at the Command on Source. You will first need to create a data server to the ODI work repository in Topology Manager for this to work. As per figure below, set the Technology to the technology of your work repository (in my case Oracle) and set the schema to the logical schema of your work repository (in my case ORCL_ODIWORK_SRC).

odi_export_scenario

We will then use the resultset together with the OdiExportScen tool to create XMLs for our scenario and write them to disk.

OdiExportScen "-SCEN_NAME=#pack_name" "-SCEN_VERSION=-1" 
"-FILE_NAME=D:\ODI\SCEN_#pack_name Version 001.xml" 
"-FORCE_OVERWRITE=YES" "-RECURSIVE_EXPORT=YES"
 "-XML_VERSION=1.0" "-XML_CHARSET=ISO-8859-1"
 "-JAVA_CHARSET=ISO8859_1"

odi_export_scenario_target

Important parameters here are

SCEN_NAME: #pack_name. This is the bind variable from our Command on Source.
SCEN_VERSION: -1. This means that we will export the scenario that was generated last.
FILE_NAME: This is the path on your file system where the XMLs will be generated.

Make sure that you have set the Technology to Sunopsis API.

In a next step add the ODI procedure we just created to our package.

Finally, manually create a scenario for this procedure via ODI Designer.

Now we are in a position to import the exported scenarios from their XML files.

Once again we will use a procedure to achieve this

For command on source use the following query:

SELECT
   scen_name AS pack_name
FROM (      
   SELECT 
     LAST_VALUE(d.scen_name) OVER
 (PARTITION BY c.pack_name ORDER BY scen_version) AS scen_name,
     MAX(scen_version) OVER
 (PARTITION BY c.pack_name ) max_scen_version,
     scen_version,
     c.pack_name
   FROM 
      snp_obj_state a 
      join snp_state2 b on (a.i_state = b.i_state)
      JOIN snp_package c ON (a.i_instance = c.i_package)
      JOIN snp_scen d ON (c.i_package = d.i_package)
   WHERE
      state_code = 'XLS'  
)
WHERE 
  scen_version = max_scen_version        

odi_import_scen_source

For Command on Target use the following command

OdiImportScen "-FILE_NAME=D:\ODI\SCEN_#pack_name Version 001.xml" 
"-IMPORT_MODE=SYNONYM_INSERT_UPDATE"

Name the above procedure IMPORT_SCEN_XLS and generate a scenario for it.

We now have all the components that we need for automated scenario deployment. We will just have to glue them together. We will do this via a batch file. In my particular case this will be a Windows batch. Of course, you can achieve the same in a Linux etc. environment.

ODI allows you to execute scenarios via the startscen.bat. You can find this batch file in the oracledi\bin folder in your ODI home. Three parameters are mandatory for executing this batch:

%1: The name of the scenario. In our case these are the GENERATE_SCENARIOS_XLS and the IMPORT_SCEN_XLS scenarios.
%2: The version number of the scenario. In our case -1, as we want to export the last version of the marked scenarios.
%3: The execution context. In our case we deploy the scenarios from UAT to PRD. So for the export of our scenarios we will use the UAT context, as this is where we (re-)generate and export the marked scenarios. For the import of the marked scenarios we will use the PRD context as we want to import the exported XMLs into the production environment.

You will need to either have agents installed on the same server (one for each environment). I explain how you can install multiple agents on one server in a separate post. Alternatively, you should be able to use a shared folder that both agents can access (I haven’t tried this out).

@echo off
cls
d:
echo generate xls scenarios

cd D:\app\oracle\product\odi_home\oracledi\bin\
call startscen.bat GENERATE_SCENARIOS_XLS -1 UAT

echo import xls scenarios

cd D:\app\oracle\product\odi_home\oracledi\agent_prd\
call startscen.bat IMPORT_SCEN_XLS -1 PRD  

I would like to hear from you how you deploy your scenarios.

In order to master scripting in ODI I recommend the following books.

Java BeanShell

Scripting in Java: Languages, Frameworks, and Patterns

Jython

The Definitive Guide to Jython: Python for the Java Platform.

Jython Essentials (O’Reilly Scripting)


Related posts

8 Comments

  • pedro duran on Feb 11, 2013

    Why not perform a full sinc between work reps?

    DEV(development)
    UAT ( execution) populated with ODI tools, and only the stuff we need on production.
    PRD (truncate select insert between UAT – PRD)

    PS: Changing of course the Work repository ID.

  • Manohar Reddy.S on Jan 16, 2013

    Hi Sir………..
    Q)Group By only one column in Oracle Data Integrator?

    Q)Any pre_requisites to catch the error records in Oracle Data Integrator?

    Q)Main use of Yellow Interface?

    Q)What is the difference between yellow interface and normal interface?

    Q)How to find error records without error table?

    Q)Difference between Context And optimized Context?

    Q)How to use equal operator in filter?

    Q)How to loop 10 xml files in a directory?

    Q)Can we use same IKM for SCD1 and SCD2?

    Thanks&Regards
    Manohar

  • Manohar Reddy.S on Jan 16, 2013

    Hi GMng…………………
    1)How to excute 2 interfaces paralley in Oracle Data Integrator?

    2)Can we use SCD in SnowFlake Schema in Oracle Data Integrator?

    3)How to client finds the error records in production(Is there any programmers in project to track the errors records)?

    4)How to write sub_query in ODI(Procedure,Yellow Interface)

    5)How to truncate the target table before loading into target?

    6)How to import objects from one environment to another environment?

  • Uli Bethke on Jan 04, 2013

    Hey Michael.

    This post is really old and I would not recommend to have an Execution Work Repository for TST or PRD at all – unless your projects are very small (non-enterprise stuff).

    While Solutions can be used to deploy scenarios I can’t see how deployment could be automated with them. I have evaluated Solutions for deploying objects and version control in both ODI 10 and 11 and came across so many bugs and issues that I have limited confidence in them. I also don’t think that Smart Import/Export is the way to go as it will overwrite dependent objects unless you interfere manually. The old import/export with a deployment list is the way to go to automate this.

    Cheers
    uli

  • Michael Rainey on Jan 03, 2013

    Hi Uli,

    I’m curious, would you recommend your automated deployment process over using Solutions in ODI? It seems you would get the same result – ability to regenerate all Scenarios, only one object to export / import (the Solution), etc. Of course, I always like the flexibility of custom code in ODI. :)
    Nice work!

    Regards,
    Michael Rainey

  • Uli Bethke on Jan 02, 2013

    Thanks Gurcan.

    In my opinion this method and execution repositories in general should only be used in very small projects. At an enterprise level I would recommend to have a full work repository in TST and PRD. I am not a big fan of smart import/export as it has various limitations and annoyances. For enterprise level we use the old import/export as this can be automated.

    Cheers
    uli

  • Gurcan Orhan on Jan 02, 2013

    Nice artice, I liked it a lot.

    Cheers,
    Gurcan.

  • AG on Dec 09, 2010

    Is this also way to migrate from say dev – test- prod , we have diff environments. People suggest on forums to take database exports of the master and work rep schemas and deploy them in required environments.

    And them make changes to the topolgy and associate the right agents.

    Please guide via email

Leave Reply