Forgive me if this is posted in the wrong forum but there doesn't appear to be one specifically for the SRM API.
So I've downloaded the WSDL files and compiled them to a C# dll and been able to successfully import them into a project. Using some of the example code in the SDK I was able to connect and retrieve Recovery Plans from my SRM instance but I was unable to initate a test or the actual plan itself. The error given in the vSphere client is "Unable to start the requested operation. Another operation might be in progress".
Checking the SRM logs I found this:
2012-01-19T14:31:39.502+11:00 [01708 verbose 'ExtApiSoapAdapter.HTTPService'] User agent is 'Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)'
2012-01-19T14:31:39.720+11:00 [01708 verbose 'ExtApiSoapAdapter.HTTPService'] HTTP Response: Complete (processed 515 bytes)
2012-01-19T14:31:39.720+11:00 [01708 verbose 'ExtApiSoapAdapter.HTTPService'] User agent is 'Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)'
2012-01-19T14:31:39.939+11:00 [02976 verbose 'ExtApiSoapAdapter.HTTPService'] HTTP Response: Complete (processed 675 bytes)
2012-01-19T14:31:39.939+11:00 [02976 verbose 'ExtApiSoapAdapter.HTTPService'] User agent is 'Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)'
2012-01-19T14:31:40.157+11:00 [02976 verbose 'ExtApiSoapAdapter.HTTPService'] HTTP Response: Complete (processed 675 bytes)
2012-01-19T14:31:40.157+11:00 [04744 verbose 'ExtApiSoapAdapter.HTTPService'] User agent is 'Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.1)'
2012-01-19T14:31:40.360+11:00 [03568 info 'Recovery' opID=2d41a360] Starting test workflow for plan 0B462228 'Recovery.' (perform sync)
2012-01-19T14:31:40.360+11:00 [03568 verbose 'PropertyProvider' opID=2d41a360] RecordOp ASSIGN: task, recovery-plan-3147
2012-01-19T14:31:40.360+11:00 [03568 info 'DrTask' opID=2d41a360] Starting task 'dr.recovery.RecoveryManager.test23'
2012-01-19T14:31:40.360+11:00 [04744 verbose 'ExtApiSoapAdapter.HTTPService'] HTTP Response: Complete (processed 399 bytes)
2012-01-19T14:31:40.360+11:00 [02976 info 'Recovery' ctxID=6f54b0ee opID=2d41a360] Running test workflow; plan id: recovery-plan-3147
2012-01-19T14:31:40.360+11:00 [02976 info 'Recovery' ctxID=6f54b0ee opID=2d41a360] Plan found, plan id: recovery-plan-3147, name: Recovery.
2012-01-19T14:31:40.360+11:00 [02976 error 'Recovery' ctxID=6f54b0ee opID=2d41a360] Plan recovery-plan-3147 is in an incorrect state, cannot run test workflow (current state: readySending)
2012-01-19T14:31:40.360+11:00 [02976 error 'Recovery' ctxID=6f54b0ee opID=2d41a360] Plan 'Recovery.' failed: (dr.recovery.fault.InvalidRecoveryState) {
[#10] --> dynamicType = <unset>,
[#10] --> faultCause = (vmodl.MethodFault) null,
[#10] --> fromState = "readySending",
[#10] --> toState = "testInProgress",
[#10] --> msg = "",
[#10] --> }
2012-01-19T14:31:40.360+11:00 [02976 trivia 'Recovery' ctxID=6f54b0ee opID=2d41a360] Clearing recovery task dr.recovery.RecoveryManager.test23
2012-01-19T14:31:40.360+11:00 [02976 verbose 'PropertyProvider' ctxID=6f54b0ee opID=2d41a360] RecordOp ASSIGN: task, recovery-plan-3147
2012-01-19T14:31:40.360+11:00 [02976 verbose 'PropertyProvider' ctxID=6f54b0ee opID=2d41a360] RecordOp ASSIGN: info.stateInfo.state, recovery-plan-3147
2012-01-19T14:31:40.360+11:00 [02976 verbose 'PropertyProvider' ctxID=6f54b0ee opID=2d41a360] RecordOp ASSIGN: info.stateInfo.cancelingOperation, recovery-plan-3147
2012-01-19T14:31:40.360+11:00 [02976 verbose 'PropertyProvider' ctxID=6f54b0ee opID=2d41a360] RecordOp ASSIGN: info.stateInfo.waitingForUserInput, recovery-plan-3147
2012-01-19T14:31:40.360+11:00 [02976 info 'DrTask' ctxID=6f54b0ee opID=2d41a360] Task 'dr.recovery.RecoveryManager.test23' failed with error: (dr.recovery.fault.InvalidRecoveryState) {
[#10] --> dynamicType = <unset>,
[#10] --> faultCause = (vmodl.MethodFault) null,
[#10] --> fromState = "readySending",
[#10] --> toState = "testInProgress",
[#10] --> msg = "",
[#10] --> }
2012-01-19T14:31:40.360+11:00 [02976 verbose 'PropertyProvider' ctxID=6f54b0ee opID=2d41a360] RecordOp ASSIGN: info.error, dr.recovery.RecoveryManager.test23
2012-01-19T14:31:40.360+11:00 [02976 info 'DrTask' ctxID=6f54b0ee opID=2d41a360] Work for task 'dr.recovery.RecoveryManager.test23' completed - new state 'error'
2012-01-19T14:31:40.360+11:00 [02976 verbose 'PropertyProvider' ctxID=6f54b0ee opID=2d41a360] RecordOp ASSIGN: info.state, dr.recovery.RecoveryManager.test23
2012-01-19T14:31:40.360+11:00 [02976 verbose 'PropertyProvider' ctxID=6f54b0ee opID=2d41a360] RecordOp ASSIGN: info.completeTime, dr.recovery.RecoveryManager.test23
2012-01-19T14:31:40.360+11:00 [02976 verbose 'PropertyProvider' ctxID=6f54b0ee] RecordOp ASSIGN: info.progress, dr.recovery.RecoveryManager.test23
2012-01-19T14:31:40.360+11:00 [02976 verbose 'DrTask' opID=2d41a360] Starting VC task 'com.vmware.vcDr.dr.recovery.RecoveryManager.test'
2012-01-19T14:31:40.376+11:00 [00428 verbose 'RecoveryVMODL' ctxID=6f54b0ee opID=7ba5054a] RemotePlanUpdated: [remote recovery-plan-3145]
2012-01-19T14:31:40.376+11:00 [00428 info 'RecoveryVMODL' ctxID=6f54b0ee opID=7ba5054a] RemotePlanUpdated: Updating existing plan
2012-01-19T14:31:40.376+11:00 [00428 trivia 'Folders' ctxID=6f54b0ee opID=7ba5054a] No rename involved in reconfigure of plan Recovery.
2012-01-19T14:31:40.376+11:00 [00428 verbose 'Recovery' ctxID=6f54b0ee opID=7ba5054a] Sync: reflected update: Local versions: (1,1) Remote versions: (1,0).
2012-01-19T14:31:40.376+11:00 [00428 verbose 'Recovery' ctxID=6f54b0ee opID=7ba5054a] UpdateFromRemoteDelta[recovery-plan-3147] Not a peer update, ignoring delta
2012-01-19T14:31:40.391+11:00 [04748 verbose 'DrTask' opID=2d41a360] Created VC task 'com.vmware.vcDr.dr.recovery.RecoveryManager.test:task-109'
2012-01-19T14:31:40.391+11:00 [00428 verbose 'DrTask' opID=2d41a360] Failing task 'com.vmware.vcDr.dr.recovery.RecoveryManager.test:task-109'
2012-01-19T14:31:40.391+11:00 [04748 warning 'DrTask'] SetProgress failed for task 'com.vmware.vcDr.dr.recovery.RecoveryManager.test:task-109': (vim.fault.InvalidState) {
--> dynamicType = <unset>,
--> faultCause = (vmodl.MethodFault) null,
--> msg = "The operation is not allowed in the current state.",
--> }
Now I watched that field in the database (pdr_planproperties table, state column) and when I initiated the plan through there this column didn't change at all throughout the process. I did notice that there were 2 ways of invoking the plan (the old 1.0 API way and the 5.0 way) however I've tried both and they give the same result.
Here's my code for reference:
ServiceRef = new ManagedObjectReference();
ServiceRef.type = "SrmServiceInstance";
ServiceRef.Value = "SrmServiceInstance";
Service = new SrmService();
Service.Timeout = 600000;
Service.CookieContainer = new CookieContainer();
ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(CertOverride);
ServiceInstanceContent = Service.RetrieveContent(ServiceRef);
Service.SrmLoginLocale(ServiceRef, "Administrator", "Password01", null);
ManagedObjectReference[] Plans = Service.ListPlans(ServiceInstanceContent.recovery);
foreach (ManagedObjectReference Ref in Plans)
{
SrmRecoveryPlanInfo Plan = Service.RecoveryPlanGetInfo(Ref);
textBox1.Text += (Plan.name + " " + Plan.description + " " + Plan.state);
}
SrmRecoveryPlanInfo InitiatePlan = Service.RecoveryPlanGetInfo(Plans[0]);
InitiatePlan.state = SrmRecoveryPlanRecoveryState.protecting;
//Service.Start(Plans[0], SrmRecoveryPlanRecoveryMode.test);
Service.RecoveryPlanStart(ServiceInstanceContent.srmApi, InitiatePlan.name, SrmApiRecoveryMode.test);
With all this in mind I've got the feeling that there's a bug in the SRM API which tries to set the state causing the process to fail. If there's another way to initiate the plan I'll give that a go but as of yet I've been unable to find one.
Thanks for your help with this!