Vous êtes sur la page 1sur 10

Technical Note

Site Recovery Manager API


VMware vCenter Site Recovery Manager 1.0 and later

TheVMwareSiteRecoveryManagerAPIprovidesaninterfaceforSiteRecoveryManagerinthesameway
thattheVMwareInfrastructureAPI(VIAPI)providesinterfacesfortheVMwareVirtualInfrastructure
Management(VIM)framework.TheSRMAPIprovidesawayforthirdpartysystemstoinitiatetestsor
failoversandcollecttheresults.TheAPIsdonothelpwithsetuporfailback.TheSRMAPIprovidesthe
followingwaysforaclientapplicationtouseWebservices:

LogintotheSRMserver

ObtaintheAPIversion

GetalistofrecoveryplansattheSRMsite

GetthesettingsofaspecificrecoveryplanattheSRMsite

Startaspecificrecoveryplaninrecoveryortestmode

Pausearunningrecoveryplan

Answeraprompt

Restartapausedrecoveryplan

Cancelarecoveryplan

Getthefinalstatusofarecoveryplan

LogoutoftheSRMserver

TheSRMAPIcomplieswiththefollowingstandardsorganizations:

WebServicesInteroperabilityOrganization(WSI)BasicProfile1.0

SimpleObjectAccessProtocol(SOAP)1.1

WebServicesDescriptionLanguage(WSDL)1.1

XMLSchema1.0

Site Recovery Manager API


TousetheSRMAPI,youshouldbefamiliarwiththefollowingconcepts:

WebservicesoperationsAllowyoutocreateclientapplicationsthatcanperformserverside
managementandmonitoringtasks.

WSDLTheWebservicesAPIisdefinedinaWSDLfile.TheWSDLfileisusedbyclientside,
Webservicesutilitiestocreateproxycode(stubs)thatclientapplicationsusetointeractwiththeserver.

SOAPClientapplicationsinvokeoperationsbysendingSOAPformattedmessages.Whenpassingdata
objectsbetweenclientandserver,youneedtobuildorparseaSOAPmessagethatcontainsthedataobject
propertiesasXMLelementscorrespondingtothemessagestructuresdescribedintheWSDL.

VMware, Inc.

Site Recovery Manager API

TheSRMAPIislocatedinthefollowingdirectory:
<installdir>\www

TheSRMAPIinterfaceusesthefollowingdefaultlistenerports:

SOAP9007

WSDL9008

YoucanobtaintheWSDLfortheSRMAPIbyrequestingthefile/srm.wsdlfromtheSRMAPIWSDLport.

Site Recovery Manager WSDL


SRMprovidesaWSDLfileinXMLformat.ClientsideWebservicesusetheWSDLfiletocreatestubsthat
enableclientsideapplicationstointeractwiththeSRMServer.TheWSDLfilespecifiestheoperationsthatthe
clientapplicationcanusetointeractwithandquerytheSRMServer.Theinput,outputandfaultmessagesare
definedforeachoperation.TheSRMWSDLhasthefollowingoperations:

SrmLogin

SrmLogout

GetApiVersion

ListRecoveryPlans

RecoveryPlanSettings

RecoveryPlanStart

RecoveryPlanPause

RecoveryPlanResume

RecoveryPlanCancel

RecoveryPlanAnswerPrompt

GetFinalStatus

TheWSDLfileislocatedinthefollowingdirectory:
<installdir>\www

SNMP Traps
SRMprovidesSimpleNetworkManagementProtocol(SNMP)trapsthatcollectinformationsentbytheAPI.
AlltrapsarecompliantwiththeSNMPv1type.Informationprovidedbythetrapscanbeusedtoinitiate
actionsbyclientapplications.CallersoftheSRMAPIinterfaceshouldlistenforthefollowingSNMPtraps:

vmwareSrmRecoveryProfilePromptDisplay TheRecoveryPlan/Profileispausedwaitingforuser
input

vmwareSrmRecoveryProfilePromptResponse TheRecoveryPlanisnolongerpausedwaitingfor
userinput

vmwareSrmRecoveryVmBegin Startingtorecoveraparticularvirtualmachine

vmwareSrmRecoveryVmEnd Completedrecoveryofaparticularvirtualmachine

vmwareSrmRecoveryVmResultSuccess Aparticularvirtualmachinewasrecoveredsuccessfully

vmwareSrmRecoveryVmResultFailure Aparticularvirtualmachinefailedrecovery

vmwareSrmRecoveryVmResultWarning Aparticularvirtualmachinewasrecoveredbuttheremay
havebeenerrors

vmwareSrmRecoveryProfileExecuteTestBegin Arecoveryisstartingintestmode

vmwareSrmRecoveryProfileExecuteTestEnd ArecoveryfinishedrunninginTestmode

VMware, Inc.

Site Recovery Manager API

vmwareSrmRecoveryProfileExecuteBegin ArecoveryisstartinginRecoverymode

vmwareSrmRecoveryProfileExecuteEnd ArecoveryfinishedrunninginRecoverymode

YoumightneedtoconfiguretheVirtualCenterServertoforwardtheSNMPtrapstotheregisteredSNMP
Server.TheMIBfileislocatedinthefollowingdirectory:
<installdir>\www\VMWARE-SRM-TRAPS-1_0.MIB

Server Certificate Requirements


TheSRMAPIisasecureWebservicerunningontheSRMServer.Todevelopclientapplications,youmust
obtaintheVirtualCenterServercertificate,whichisusedbytheSRMServer,andimportitintothecertificate
storeoftheworkstationyouusetodevelopclientapplications.
To obtain a VirtualCenter Server certificate:
1

Fromyourdevelopmentworkstation,openInternetExplorer.

NavigatetotheVirtualCenterServerusingHTTPSprotocolhttps://<servername>.
ASecurityAlertmessagedisplaysawarningregardingthecertificatescertifyingauthority.

ClickViewCertificate.

ClickInstallCertificatetolaunchtheCertificateImportwizard.KeepthedefaultsettingsandclickNext.

ClickFinish.Asecuritywarningmessagedisplaysconcerningthecertificatescertifyingauthority.

ClickYes.
ACertificateImportwizardsuccessmessagedisplays.

ClickOKtodismissthesuccessmessage.
TheCertificatePropertiespagebecomesactiveagain.

ClickOKintheCertificatedialogboxtocontinuetotheserver.
TheinitialSecurityAlertmessagepresentedinstep2becomesactiveagain.

ClickYesintheSecurityAlertmessagetocontinuewiththeoriginalHTTPSrequest.
TheserverWelcomepagedisplays.ThecertificateisnowinstalledintheIEcertificatecache.

Nowthatyouhavethecertificate,yournexttaskdependsonwhatprogramminglanguageyouusetodevelop
yourclientapplications.

ForC#developers,youcancontinuesettingupyourdevelopmentenvironmentbyfollowingthe
instructionsatSettingUpforMicrosoftC#DevelopmentintheDevelopersSetupGuidelocatedat
VMwaresWebsitesupportpageunderVMwareInfrastructureSDK2.5.0.

ForJavadevelopers,youmustexportthecertificatesfromtheInternetExplorercachetoalocaldirectory.
MinimizetheInternetExplorerbrowserwindow,andexportthecertificatesasdetailedinthefollowing
procedure.

Exporting Cached Certificates to a Local Directory


ForJavadevelopmentinaWindowsenvironment,youmustexportthecertificatetoalocaldirectory:
1

Createadirectoryforthecertificate,usingthenamesetinthevariousbatchfilesfortheVISDK:
C:\VMwareCerts.

FromtheInternetExplorerToolsmenu,selectInternetOptionstoopentheInternetOptionsproperties
page.

ClicktheContenttabtoactivatethecontentadvisor.

ClickCertificatestoopentheCertificatemanager.

VMware, Inc.

Site Recovery Manager API

ClicktheTrustedRootCertificateAuthoritiestabtodisplaythelistoftrustedcertificates.

Scrollthroughthelistofcertificatestofindthecertificate.FortheVirtualCenterServer,thecertificate
nameisVMware.

Clickthecertificatetoselectit.

ClickExport...tolaunchtheCertificateExportWizard.

ClickNexttocontinue.TheExportFileFormatdialogdisplays.

10 Keepthedefaults(DERencodedbinaryX.509(.CER))andclickNexttocontinue.TheFileToExport
dialogdisplays,enablingyoutoenterauniquenameforthecertificate.
11

Chooseafilenameandenterit,alongwiththecompletepathtothedirectory:
C:\VMwareCerts\<servername>.cer
Ifyoudontenterthecompletepath,thecertificateisstoredinyourDocumentsandSettingsfolder.

12

ClickNexttocontinuewiththeexport.ACompletingtheCertificateExportWizardpagedisplays,
summarizingtheinformationaboutthecertificate.

13

ClickFinishtocompletetheexport.ACertificateExportWizardsuccessmessagedisplays.

14

ClickOKtodismissthesuccessmessage.

15

ClickClose.

16

ClickCanceltoclosetheInternetOptionspropertiespage.

Formoreinformationaboutsettingupyourdevelopmentenvironment,seeSettingUpforJava
DevelopmentintheDevelopersSetupGuidelocatedattheVMwareWebsitesupportpageunderVMware
InfrastructureSDK2.5.0.

Site Recovery Manager Methods


ThissectionliststhemethodsavailablewiththeSiteRecoveryManagerAPI.

ManagedObjectReference
ThemethodsforSRMusetheManagedObjectReference_this,whichisareferencetotheSessionManager
usedtomakemethodcalls.ThisisobtainedbycallingRetrieveContentontheServiceInstance.The
ServiceInstanceisobtainedbycreatingaManagedObjectReferencewhosetypeandvalueare
SrmServiceInstance.FollowingisanexampleinC#:
/// <param name="srmUrl">URL (in the form http://x.y.z.w:p/) to the SOAP port on the SRM
server</param>
public void Connect(string srmUrl)
{
_serviceRef = new ManagedObjectReference();
_serviceRef.type = "SrmServiceInstance";
_serviceRef.Value = "SrmServiceInstance";
_service = new Drextapi.SrmBinding();
_service.Url = srmUrl;
_service.CookieContainer = new System.Net.CookieContainer();
_serviceInstanceContent = _service.RetrieveContent(_serviceRef);
}

GetApiVersion
GetstheversionoftheSRMAPIontheSRMServeryouareloggedinto.

VMware, Inc.

Site Recovery Manager API

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.View

Parameters for GetApiVersion


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.

Returns
returnval:theAPIversion.

GetFinalStatus
GettheXMLrepresentationoftherecoveryplanexecutiondetails.
ThismethodreturnsanXMLdocumentthatcanberetrievedoneormorelinesatatime.Youspecifywhatline
tostartatandhowmanylinesyouwant.Onlyafteryouhaveretrievedallofthelinesandputthemtogether
doyouhaveavalidXMLdocument.Thisisdonebecausethedocumentcanbeverylong(thousandsoflines).
Thedocumentreturnedisthedescriptionofthemostrecentrunofthenamedplan.

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.Run

Parameters for GetFinalStatus


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.
offset:integerTheoffsetfromthetopofthedocument.
maxLines:integerThemaximumnumberoflinestoretrieve.
name:xsd:stringThenameoftheplan.
return:stringarrayTheXMLrepresentationoftherecoveryplanexecutiondetails.

Returns
return:stringarrayThisisthelistofstringsinthereturnedXMLformat:
<RecoveryPlanResult>
<RecoveryPlan>
<Name>MyPlan</Name>
<VCServer>10.18.210.221</VCServer>
<DRServer>10.18.210.222</DRServer>
</RecoveryPlan>
<Info>
<StartTime>%Y-%m-%dT%H:%M:%SZ</StartTime>
<EndTime>%Y-%m-%dT%H:%M:%SZ/EndTime>
<Mode>Test</Mode> # Mode is either test or recovery
</Info>
<Results>
# If Status is Success, then <Result> is empty
<Step type="RootStepList" status="Success">
<Name>Root</Name>
<Result/> # No Results
<Children>
<Step type="RecoveryStepGroup" status="Error">
<Name>Shutdown Protected Virtual Machines at Protected Site</Name>
<Result>
<Fault>Dr::Fault::InternalError</Fault>
<Description>error ocurred</Description>
</Result>
<Children/>
</Step>

VMware, Inc.

Site Recovery Manager API

</Children>
</Step>
</Results>
</RecoveryPlanResult>

Faults
InvalidArgument:Thenamedplancouldnotbefound,oroffsetisnegativeortoolarge,ormaxLinesis0or
negative.
InvalidState:Thenamedplanwasnotcompleted,cancelledorerrorthrown.

ListRecoveryPlans
ListsalloftherecoveryplansatthisSRMsite.

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.View

Parameters for ListRecoveryPlans


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.

Returns
returnval:AnarrayofstringslistingeveryrecoveryplanatthisSRMsite.

SrmLogin
Logsintotheserver.ThismethodfailsiftheuserIDorpasswordareinvalid.Italsofailsiftheuserisalready
loggedin.

Required Privileges
System.Anonymous

Parameters for SrmLogin


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.
userName:xsd:stringTheusernameoftheuserloggingontotheserver.
password:xsd:stringPasswordoftheuserloggingontotheserver.

Faults
AlreadyLoggedInFault:Throwniftheuserisalreadyloggedin.
InvalidLogin:Throwniftheusernameandpasswordcombinationisinvalid.

SrmLogout
Logsoutandterminatesthecurrentsession.

Required Privileges
System.Anonymous

VMware, Inc.

Site Recovery Manager API

Parameters for SrmLogout


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.

Fault
NotLoggedIn:Theuserisnotloggedin.

RecoveryPlanAnswerPrompt
Answersapromptforapausedrecoveryplan.

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.Run

Parameters for RecoveryPlanAnswerPrompt


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.
name:xsd:stringThenameoftherecoveryplan.

Faults
InvalidArgument:xsd:stringThenamedrecoveryplancouldnotbefound.
InvalidState:xsd:stringThenamedrecoveryplanisnotpausedorrunning.

RecoveryPlanCancel
Cancelsthenamedrecoveryplan.Therecoveryplanwillnotimmediatelycancelwhenyoucall
RecoveryPlanCancel.Itcantakeseveralminutestocanceldependingonwhatisrunningatthetime.

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.Run

Parameters for RecoveryPlanCancel


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.
name:xsd:stringThenameoftherecoveryplan.

Faults
InvalidArgument:xsd:stringThenamedrecoveryplancouldnotbefound.
InvalidState:xsd:stringThenamedrecoveryplanisnotpausedorrunning.

RecoveryPlanPause
Pausesthenamedrecoveryplan.Therecoveryplanwillnotimmediatelypausewhenyoucall
RecoveryPlanPause.Itcantakeseveralminutestopausedependingonwhatisrunningatthetime.

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.Run

VMware, Inc.

Site Recovery Manager API

Parameters for RecoveryPlanPause


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.
name:xsd:stringThenameoftherecoveryplan.

Faults
InvalidArgument:xsd:stringThenamedrecoveryplancouldnotbefound.
InvalidState:xsd:stringThenamedrecoveryplanisnotrunning.

RecoveryPlanResume
Resumesthenamedrecoveryplan.YoucancallRecoveryPlanResumeonarecoveryplanthatispausedonly.
YoucannotcallRecoveryPlanResumeonarecoveryplanthatisrunningorintheprocessofpausing.

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.Run

Parameters for RecoveryPlanResume


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.
name:xsd:stringThenameoftherecoveryplan.

Faults
InvalidArgument:xsd:stringThenamedrecoveryplancouldnotbefound.
InvalidState:xsd:stringThenamedrecoveryplanisnotpaused.

RecoveryPlanSettings
Getsthesettingsforthenamedrecoveryplan.Youcanusethismethodtocheckonthestatusofarecovery
planthatisrunning.

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.Run

Parameters for RecoveryPlanSettings


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.
name:xsd:stringThenameoftherecoveryplan.

Returns
returnval:resultobject:
class Settings {
/** Name of the RecoveryPlan. */
String name;
/** Description of the RecoveryPlan. */
@optional String description;
/** The current state of the RecoveryPlan. */
RecoveryState state;
}

VMware, Inc.

Site Recovery Manager API

Fault
InvalidArgument:xsd:stringThenamedrecoveryplancouldnotbefound.

RecoveryPlanStart
Startsthenamedrecoveryplan.

Required Privileges
VcDr.RecoveryProfile.com.vmware.vcDr.Run

Parameters for RecoveryPlanStart


_this:ManagedObjectReferenceAreferencetotheSessionManagerusedtomakethemethodcall.Thisis
obtainedbycallingSrmLogin.
name:xsd:stringThenameoftherecoveryplan.
mode:RecoveryModeThemodetherecoveryplanshouldruninRecoveryorTest.

Faults
InvalidArgument:xsd:stringThenamedrecoveryplancouldnotbefound.
InvalidState:xsd:stringThenamedrecoveryplanwasnotuninitialized.

Enumerations
ThissectionliststheenumerationsthatareavailablewiththeSRMAPI.Enumerationsarepredefinedvalues
usedtostoreinformationinenumeratedtypes.

Enum RecoveryMode
Theseenumerationsdeterminewhethertherecoveryplanrunsindisasterortestmode.

Recovery
Runstherecoveryplanwhenthereisadisaster.

Test
Runstherecoveryplanasatest.Itrecoversallthevirtualmachineswithinaspecified,isolatednetwork.When
thetestcompletes,alloftherecoveredvirtualmachinesarepurgedandstoragereturnedtoitsnormalstate.

Enum Recovery State


Theseenumerationsprovidethecurrentstatusofanamedrecoveryplan.

Cancelled
Thenamedrecoveryplaniscancelled,butnotfinished.

Completed
Thenamedrecoveryplanhascompleted.

Error
Thenamedrecoveryplanhascompletedwithoneormoreerrors.

Paused
Thenamedrecoveryplanispaused.
VMware, Inc.

Site Recovery Manager API

Prompting
Thenamedrecoveryplanisrunningbutrequiresauserresponsebeforecontinuing.

Running
Thenamedrecoveryplanisrunning.

Uninitialized
Thenamedrecoveryplanisnotinarunningstate.

If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com
VMware, Inc. 3401 Hillview Ave., Palo Alto, CA 94304 www.vmware.com
Copyright 2008-2009 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws. VMware products are
covered by one or more patents listed at http://www.vmware.com/go/patents. VMware, the VMware boxes logo and design, Virtual SMP, and VMotion are registered
trademarks or trademarks of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective
companies.
Item: EN-000190-00

10

Vous aimerez peut-être aussi