Showing posts with label More on ODI. Show all posts
Showing posts with label More on ODI. Show all posts

Monday, 21 April 2014

Sending Mail in ODI 11g

How to send an E-mail through ODI?

                  Let us see how to send emails using Jython Scripts in ODI.
       
                 We knows very well that ODI has the lot of technologies and it is the best ELT tool available right now.

Follow the steps given below

1. Create an ODI Procedure and use the Technology as Jython.

2. Create a command within the ODI Procedure. Name : Sending Email's Through ODI

3. Double click on the command and use the following code in the target command

import smtplib
import string
BODY = string.join((
"From: %s" % 'SENDER_EMAIL_ID',
"To: %s" % 'RECEPIENT_EMAIL_ID',
"Subject: %s" % 'Awesome Note From ODI....',
"",'Hi, This is a Test Email from ODI... Put your Auditing logic bla bla bla here.....'
), "\r\n")
sender = smtplib.SMTP('smtp.gmail.com',587)
sender.set_debuglevel(1)
sender.ehlo()
sender.starttls()
sender.ehlo()
sender.login('USERNAME', 'PASSWORD')
sender.sendmail('SENDER_EMAIL_ID',['RECEPIENT_EMAIL_ID'],BODY)
sender.close()

MAKE SURE THAT YOU WILL BE REPLACING ALL THE VALUES IN BOLD AS PER WHAT YOU HAVE...


4. Now execute the procedure
5.Go to the operator navigator and check for the session status.




Now you are done and Successfully sent the mail using ODI :) Check your inbox :) 

Friday, 21 March 2014

using ODI DecryptingPassword Protected Documents

How to do it...

  1. Open a command line console and go to the c:\temp directory. Add a text file of your choice in this directory. Here we are using a file called test.txt
  2. Run the following from the command line:
    c:\temp> aescrypt -e -p oracledi test.txt
    This will generate an encrypted file named test.txt.aes that is protected with the password oracledi. If you try to edit the content of this new file, you will see that it has indeed been encrypted:
           
Rename the original test.txt file to test.txt.ori. We will now use ODI to decrypt the file and restore the original content.
3. In ODI Topology, create a new Data Server in the File technology called AESCRYPT. We will use this data server as a placeholder for the password that we need for this operation. We can also use this to locate the file that we will work on. You can leave the User name empty (we do not need it here), but do set the Password value to oracledi.
getInfo("SRC_PASS")@> <%=odiRef.getInfo("SRC_SCHEMA")%>\foo.txt.
aes
Save the procedure and run it.


In the JDBC tab, select the ODI File JDBC Driver and use the default JDBC URL:
jdbc:snps:dbfile.
4. Create a physical schema under that server. Set both the Schema name and Work Schema name toc:\temp.
Create a logical schema to point to this physical schema for the default context:
FILE_AESCRYPT
5. Switch to the Designer operator, and in the project of your choice, create a procedure calledCh11_Password_Decrypt_File.
Add a new step to this procedure, and call this Decrypt.
In the Command on Target tab, set the Technology to OS Command (leave all other fields to their default values) and type the following command (this is all one line of code, so please ignore the carriage returns that are only due to formatting):
<%=odiRef.getInfo("SRC_SCHEMA")%>\aescrypt -d -p <@=odiRef.getInfo("SRC_PASS")@> <%=odiRef.getInfo("SRC_SCHEMA")%>\test.txt.aes
The technology OS Command (Operating System) can be used execute any type of command at the OS level. One note of caution though: if the script or program that you execute returns anything else than 0, ODI will consider that the program failed. Typically there are two techniques that can be combined to solve this problem:
Redirect any output or errors to other files. For instance, dir 1>dir.out 2>dir.err, where 1 represents the standard output and 2 represents the errors output.
Use Jython code to execute the code and retrieve the return code in a variable. Then evaluate this variable to see whether the returned value indicates an error or is simply informational.
In the Command on Source tab, set the Technology to File, set the logical Schema name toFILE_AESCRYPT, and leave all other fields to their default values. There will be no code on the source side.
6. Save the procedure and execute it.
7. Now, if you go to the Operator window to look into the details of the code that was generated, you can see that the password is not revealed in the operator logs. We are looking in the following screenshot at the code generated for the task:
Now back to the console, You can see the original Document