Srmloginlocale; Srmloginsites - VMware VC-SRM4-A - vCenter Site Recovery Manager Developer's Manual

Site recovery manager api
Table of Contents

Advertisement

Site Recovery Manager API Developer's Guide

SrmLoginLocale

This method logs in to the SRM server. The Connect public method requires the URL of an SRM server and 
authentication credentials. The SrmLoginLocale method takes the _srcRef managed object reference from 
SrmServiceInstance, and fails if the user name and password combination is invalid, or if the user is already 
logged in. In these examples, a locale string could be provided instead of the null parameter. 
Example 3-3. C# code for SRM login
protected SrmService _service;
protected SrmServiceInstanceContent _sic;
protected ManagedObjectReference _svcRef;
...
public void Connect(string url, string username, string password)
{
_service = new SrmService();
_service.Url = url;
_service.Timeout = 600000;
_service.CookieContainer = new System.Net.CookieContainer();
_sic = _service.RetrieveContent(_svcRef);
_service.SrmLoginLocale(_svcRef, username, password, null);
...
}
The Java code is similar to the C# code but uses a service locator.
Example 3-4. Java code for SRM login
private static SrmPortType srmPort;
private static SrmServiceInstanceContent serviceContent;
private static boolean isConnected = false;
...
srmPort = srmService.getSrmPort();
Map<String, Object> ctxt =
((BindingProvider) srmPort).getRequestContext();
ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
serviceContent = srmPort.retrieveContent(SVC_INST_REF);
srmPort.srmLoginLocale(SVC_INST_REF, userName, password, null);
isConnected = true;
Subsequent SRM methods are called as a subclass of _service, for example _service.ListPlans() in C# or 
srmport.listPlans() in Java.

SrmLoginSites

The SrmLoginSites API is very similar to SrmLoginLocale, except it takes an additional user name and 
password combination for the remote (usually recovery) site. The SrmServiceInstance _this is obtained from 
the local (usually protected) site.
Example 3-5. C# and Java for double SRM login
/// C#
_service.SrmLoginSites(_svcRef, username, password, remoteuser, remotepass, locale);
// Java
_service.srmLoginSites(_svcRef, username, password, remoteuser, remotepass, locale);
Parameters are as follows
_svcRef – managed object reference to SrmServiceInstance
username – user name authorized for access to the local vCenter Server
password – password for that user on the local vCenter Server
remoteuser – user name authorized for access to the remote vCenter Server
20
VMware, Inc.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Vcenter site recovery manager 5.0

Table of Contents