VMware Cloud Community
bozitsu
Contributor
Contributor

Automating failover to recovery site using SRM (API)

Hello,

i am looking for a product that could integrate with SRM (we support following HW vendors: NetApp, EMC, Hitachi, Eternus and HP) and allow automation of failover from primary to disaster triggered by some sort of event on primary site.

Is there any such product

Thanks in advance,

B.

0 Kudos
18 Replies
AnatolyVilchins

http://www.veeam.com/ - I think it can help.

Also I can offer you to use StarWind. This is iSCSI SAN software will provide High Availability with automated failover and failback to your storage. Unfortuantely it doesn't support SRM, but as I know SRM solutions are pretty expensive.

Starwind Software Developer

www.starwindsoftware.com

Kind Regards, Anatoly Vilchinsky
0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

I think Veeam are similiar excluded from SRM. So I'm not sure how they would be able to help.

As far as I know there is no API in SRM to trigger a failover based on X condition. I think the feeling with VMware is that triggering a test/run of plan should be a manual operation. SRM was not designed to offer the kind of immediate failover to another site - that streched cluster availability technologies we designed for such as NetApps MetroCluster.

Regards

Mike Laverick

RTFM Education

http://www.rtfm-ed.co.uk

Author of the SRM Book:http://stores.lulu.com/rtfm

Free PDF or at-cost Hard Copy

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
0 Kudos
Sunchai
Contributor
Contributor

Have you looked at Double-Take Software solutions? I am not sure on the integration with SRM but it does support physical or virtual servers including Vmware ESX. It continuously captures changes as they happen and replicates those changes to one or more servers at any location, locally or globally. it llows you to replicate virtual machines from one virtualization host to another in real time and automatically failover those virtual machines to the host in the event of an outage or disaster.

Sunchai

0 Kudos
bozitsu
Contributor
Contributor

Hi,

thanks for your comments. I am interested in SRM only for now, but still no hope Smiley Happy

@Mike,

as i understood and read about there is a SRM API that describes class events that could be used some event on the production site. There are also some freelance developer on this community that already automated their environments as i understood.

You have the document describing this API on vmware.com

0 Kudos
dmedvitz
Contributor
Contributor

I have done SRM failovers that were initiated by someone calling a powershell script. This is a process that can be automated quite simply.

Feel free to contact me if you have questions.

Dave

0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Really you called SRM Recovery Plans using PowerCLI?

Do share here please....

Regards

Mike Laverick

RTFM Education

http://www.rtfm-ed.co.uk

Author of the SRM Book:http://stores.lulu.com/rtfm

Free PDF or at-cost Hard Copy

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
0 Kudos
dmedvitz
Contributor
Contributor

Grab yourself a copy of the API docs and the WSDL file from the www dir in the SRM installation directory. I'm going to assume that you can use the .NET utilities to create a .cs file and compile to dll. After you've compiled the dll do the following......

http://Reflection.Assembly::LoadFrom(path to dll)

$mof = New-Object ManagedObjectReference

$mof.type = "SrmServiceInstance"

$mof.value = $mof.type

$srm = New-Object SrmBinding

$srm.url = "https://SRM server:9007"

$srm.CookieContainer = New-Object System.Net.CookieContainer

$context = ($srm.RetrieveContent($mof)).srmApi

Now, if you do a $srm | get-member you'll get a list of all of the functions you can call. This includes all of the items in the API doc - all of the other ones are from .NET and can be ignored....

The first parameter for all of the SRM functions is $context (in the docs as _this).

As an FYI, when I tried to run from a DLL compiled from the 4.0 WSDL file, it would hang, so I ended up using the WSDL file from 1.0.

0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Yikes. Using .NET utilities to create a .cs file and compile a .DLL...

I thought i was going to be easy, and you'd found a part of PowerCLI i hadn't found.

I think I will wait for the PowerCLI for SRM from Carter Shanklin... especially if you have compile problems...

Mike Laverick

RTFM Education

http://www.rtfm-ed.co.uk

Author of the SRM Book:http://stores.lulu.com/rtfm

Free PDF or at-cost Hard Copy

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
0 Kudos
dmedvitz
Contributor
Contributor

It's actually not that difficult. I can post the .cs and .dll tomorrow. It should only take a few minutes.

BTW, for whatever reason the square brackets around the Reflection.Assembly in my previous post got replaced, so I'll add that code as well.

I found this quite useful, as I'm able to do Daily automated testing of the SRM recovery plan(s), and get an XML representation of the results for reporting.....

0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

Have you consider documenting this process step-by-step...?

If you did I would consider verifying the process and including it in my SRM 4.0 book. It's nearly finished...

Regards

Mike Laverick

RTFM Education

http://www.rtfm-ed.co.uk

Author of the SRM Book:http://stores.lulu.com/rtfm

Free PDF or at-cost Hard Copy

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
0 Kudos
dmedvitz
Contributor
Contributor

As promised, I've included the .cs source file, the compiled .dll and an Powershell script example that goes through loging in to the SRM services. For those on powershell v2, there is a means by which you can perform SRM tasks w/o going throug the DLL process. The script for this looks like.....

$srm = New-WebServiceProxy -URL "http://server:9008/srm.wsdl" -Namespace SRM

$mof = New-Object SRM.ManagedObjectReference

$mof.type = "SrmServiceInstance"

$mof.value = $mof.type

$srm.url = "https://server:9007"

$srm.CookieContainer = New-Object System.Net.CookieContainer

$context = ($srm.RetrieveContent($mof)).srmApi

$srm.SrmLogin($context, $username, $password)

A word of warning. The wsdl file supplied with SRM 4.0 contains not only the SRM API, but the full vsphere API. This causes the New-WebServiceProxy to take a few minutes to process everything. The good news it it only need to do that at the beginning of the script. For most automation, this shouldn't be a problem. You can add the srm.wsdl from SRM 1.0 (the API hasn't changed) to the /web folder either replacing the 4.0 version or renaming on of them. You would need to update the url in the New-WebServiceProxy accorningly.

Mike, we can talk offline about what you would want to include in your book and what timeframe you have. I'll PM you with contact info.

Dave

0 Kudos
arh3x
Contributor
Contributor

Hello,

I have a little problem to run my script in PowerShell 2.0 (SRM4.0)

I run something like this:

-


$srm = New-WebServiceProxy -Uri "http://server:9008/srm.wsdl" -Namespace SRM

$mof = New-Object SRM.ManagedObjectReference

$mof.type = “SrmServiceInstance”

$mof.value =”SrmServiceInstance”

$srm = New-Object SRM.SrmBinding

$srm.url = “https://server:9007”

$srm.CookieContainer = new-object System.Net.CookieContainer

$context = ($srm.RetrieveContent($mof)).srmApi

in result I get this error:

-


Exception calling "RetrieveContent" with "1" argument(s): "The underlying conne

ction was closed: Could not establish trust relationship for the SSL/TLS secure

channel."

At C:\psp\source3\srm.ps1:8 char:33

+ $context = ($srm.RetrieveContent <<<< ($mof)).srmApi

+ CategoryInfo : NotSpecified: (Smiley Happy [], MethodInvocationException

+ FullyQualifiedErrorId : DotNetMethodException

so what about SSL cert where i must put the file server.cer ?

Mike i read your new book (great work!!!) chapter 13 about scripted in site recovery

but your script isin't runing too.

First of all, look at this command:

New-WebServicesProxy -URL http://srm4nj.corp.com:9008/srm.wsdl -Namespace SRM

i think shoud be( service without "s" and URI parametr)

New-WebServiceProxy -URI http://srm4nj.corp.com:9008/srm.wsdl

-Namespace SRM

so i run

-


$srm = New-WebServiceProxy -Uri "http://10.10.10.111:9008/srm.wsdl" -Namespace SRM

$mof = New-Object SRM.ManagedObjectFramework

$mof.type = “SrmServiceInstance”

$mof.value =”SrmServiceInstance”

$srm = New-Object SRM.SrmBinding

$srm.url = “https://10.10.10.111:9007”

$srm.CookieContainer = new-object System.Net.CookieContainer

$context = $srm.GetContent($mof).srmApi

and this is the error:

-


New-Object : Cannot find type http://SRM.ManagedObjectFramework: make sure the assem

bly containing this type is loaded.

At C:\psp\source3\srm.ps1:2 char:18

+ $mof = New-Object <<<< SRM.ManagedObjectFramework

+ CategoryInfo : InvalidType: (Smiley Happy , PSArgumentExcepti

on

+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb

jectCommand

I'm really grateful to send me some usefull concept.

Best regards

Pavel

0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

This content was written by Dave M (on this forum thread) and was a last minute addition which made it into the book a day or two before the book was released... as such I didn't get an opportunity to test the code provided.

Dave. Can you look at this for me. We might be looking at an errata if it turns out there is an error in the code....

Regards

Mike Laverick

RTFM Education

http://www.rtfm-ed.co.uk

Author of the SRM Book:http://www.rtfm-ed.co.uk/2010/03/22/new-administrating-vmware-site-recovery-manager-4-0/

Free PDF or at-cost Hard Copy

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
0 Kudos
dmedvitz
Contributor
Contributor

Ok. There are two errors in the copy from the book. First is that the -URL should be -URI in the Web-Service proxy calls. The second is that the line

$context = $srm.GetContent($mof).srmApi

should be

$context = ($srm.RetrieveContent($mof)).srmApi

So, Pavel, the code you used first is correct. Mike, I apologize, but we'll need to errata those items....

Pavel, the error you are getting indicates that the SSL certificate installed for the SRM service does not match the url that is being used. If you have a certificate for the SRM server already, you can import it using srm-config. Otherwise you will need generate a new certificate for teh server.

Dave

0 Kudos
Michelle_Laveri
Virtuoso
Virtuoso

OK. I will post an errata on RTFM...

With a little bit of luck I should be able to correct the master document and upload a new PDF to LULU....

Regards

Mike Laverick

RTFM Education

http://www.rtfm-ed.co.uk

Author of the SRM Book:http://www.rtfm-ed.co.uk/2010/03/22/new-administrating-vmware-site-recovery-manager-4-0/

Free PDF or at-cost Hard Copy

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
0 Kudos
dadima2207
Contributor
Contributor

hi,

can you post srm.wsdl from 1.0?

i have some problems with wsdl from 4.0.

Thanks in advance.

Daniele

0 Kudos
ptburkis
Contributor
Contributor

Hi,

If you're interested, I put together a Powershell Module for SRM, feel free to alter it as you wish. It's called PSVMSRM and is available to download from MSDN:

http://archive.msdn.microsoft.com/PSVMSrm

Hope it helps

Peter

0 Kudos
Chandra_G_P
Contributor
Contributor

We are looking to automate VM protestion step, within the protection group in SRM 4.1. Any help on creating script would be much appreciated.

Thank you

CG 

CG
0 Kudos