Cloning an Environment Using a Server-Side Groovy Script
You can include EPM Automate commands in server-side Groovy scripts to clone environments for disaster recovery purposes. This allows setting up disaster recovery without any on-premises footprint.
If passwords contain special characters, see Handling Special Characters. Also, be sure to replace these parameter values to suit your environments:
Table 4-1 Parameters to Change
Parameter | Description |
---|---|
password |
The password of the Service Administrator who is performing the clone operation in the source environment. |
targetpassword |
The password of the Service Administrator who is performing the clone operation in the target environment. |
username |
The user ID of the Service Administrator in the source environment. |
targetusername |
The user ID of the Service Administrator in the target environment. This user must also be assigned to the Identity Domain Administrator role in the target environment. |
email_id |
The email address to which you plan to send information about the cloning process. |
Script for Encrypting Password
EpmAutomate automate = getEpmAutomate()
//Encrypt the password of a Service Administrator in the source environment
EpmAutomateStatus encryptstatus1 = automate.execute('encrypt', 'password','encryptionKey','sourcePassword.epw')
if(encryptstatus1.getStatus() != 0) throwVetoException(encryptstatus1.getOutput())
println(encryptstatus1.getOutput())
//Encrypt the password of a Service Administrator in the target environment
//This user must also have the Identity Domain Administrator
//role in the target environment
EpmAutomateStatus encryptstatus2= automate.execute('encrypt', 'targetpassword',
'encryptionKey', 'targetPassword.epw')
if(encryptstatus2.getStatus() != 0) throwVetoException(encryptstatus2.getOutput())
println(encryptstatus2.getOutput())
Script for Cloning the Environment
This script uses the encrypted password files created using the preceding script.
EpmAutomate automate = getEpmAutomate()
//Log into the target environment
EpmAutomateStatus loginstatus = automate.execute('login', 'username','targetPassword.epw' , 'targeturl')
if(loginstatus.getStatus() != 0) throwVetoException(loginstatus.getOutput())
println(loginstatus.getOutput())
//Recreate the target environment
EpmAutomateStatus recreatestatus = automate.execute('recreate' , '-f' )
if(recreatestatus.getStatus() != 0) throwVetoException(recreatestatus.getOutput())
println(recreatestatus.getOutput())
//Copy Artifact Snapshot from the source environment
//to the target environment
EpmAutomateStatus copystatus = automate.execute('copysnapshotfrominstance',
'Artifact Snapshot', 'sourceusername', 'sourcePassword.epw','source url')
if(copystatus.getStatus() != 0) throwVetoException(copystatus.getOutput())
println(copystatus.getOutput())
//import Artifact Snapshot into the target environment
EpmAutomateStatus importstatus = automate.execute('importsnapshot', 'Artifact Snapshot')
println(importstatus.getOutput())
//Send an email to a designated user with the status of the
//snapshot import process
EpmAutomateStatus emailstatus = automate.execute('sendmail', 'email_id' ,'Status of DR' , 'BODY='+ importstatus.getOutput())
println(emailstatus.getOutput())
//Sign out of the target environment
EpmAutomateStatus logoutstatus = automate.execute('logout')
println(logoutstatus.getOutput())