Clonage d'un environnement à l'aide d'un script Groovy côté serveur

Vous pouvez inclure des commandes EPM Automate dans des scripts Groovy côté serveur pour cloner des environnements à des fins de récupération après sinistre. Cela permet la configuration d'une récupération après sinistre sans aucune empreinte sur site.

Si les mots de passe contiennent des caractères spéciaux, reportez-vous à la section Gestion des caractères spéciaux. Veillez également à remplacer ces valeurs de paramètre en fonction de vos environnements :

Table 4-1 Paramètres à modifier

Paramètre  Description
password Mot de passe de l'administrateur de service qui effectue l'opération de clonage dans l'environnement source.
targetpassword Mot de passe de l'administrateur de service qui effectue l'opération de clonage dans l'environnement cible.
username ID utilisateur de l'administrateur de service dans l'environnement source.
targetusername ID utilisateur de l'administrateur de service dans l'environnement cible. Cet utilisateur doit également être affecté au rôle Administrateur de domaine d'identité dans l'environnement cible.
email_id Adresse électronique à laquelle vous prévoyez d'envoyer des informations à propos du processus de clonage.

Script pour le cryptage d'un mot de passe

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 pour le clonage d'un environnement

Ce script utilise les fichiers de mots de passe cryptés créés à l'aide du script précédent.

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())