60
VMware® Lab Manager SOAP API Guide VMware Lab Manager 2.5

VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

Embed Size (px)

Citation preview

Page 1: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab ManagerSOAP API Guide

VMware Lab Manager 2.5

Page 2: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc.3401 Hillview Ave.Palo Alto, CA 94304www.vmware.com

2 VMware, Inc.

VMware® Lab Manager SOAP API Guide

You can find the most up-to-date technical documentation on our Web site at

http://www.vmware.com/support/

The VMware Web site also provides the latest product updates.

If you have comments about this documentation, submit your feedback to:

[email protected] 

© 2007 VMware, Inc. All rights reserved. Protected by one or more of U.S. Patent Nos. 6,397,242, 6,496,847, 6,704,925, 6,711,672, 6,725,289, 6,735,601, 6,785,886, 6,789,156, 6,795,966, 6,880,022, 6,944,699, 6,961,806, 6,961,941, 7,069,413, 7,082,598, 7,089,377, 7,111,086, 7,111,145, 7,117,481, 7,149,843, 7,155,558, and 7,222,221; patents pending.

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.

VMware Lab Manager SOAP API GuideRevision: 20070709Item: VLM-ENG-Q207-360

Page 3: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 3

Contents

Preface 7

1 Introducing VMware Lab Manager SOAP API 11Integrating Lab Manager with Automated Testing Tools 12Supported Operations 12Lab Manager Data Objects 12Standards Compliance and Compatible Development Platforms 13Security 13

User Authentication 13

2 Getting Started with the Lab Manager SOAP API 15Requirements 16Obtaining and Importing the WSDL 16

Importing the WSDL File into Your Development Platform 16Instructions for Using Microsoft Visual Studio with Lab Manager WSDL 17

Simple and Advanced Code Samples 18Simple C# Console Application 19Advanced Sample: Integrating Lab Manager and Quality Center 21

3 Lab Manager API Data Types 27Primitive XML Data Types 28Lab Manager Data Types 28AuthenticationHeader 29

Supported API Calls 29Fields 29Sample Usage: C# 29

Configuration 30Machine 30

4 Lab Manager API Method Reference 33ConfigurationCapture 35

Syntax 35

Page 4: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

4 VMware, Inc.

Arguments 35Response 35Sample Code: C# 35

ConfigurationCheckout 36Syntax 36Arguments 36Response 36Sample Code: C# 37

ConfigurationClone 38Syntax 38Arguments 38Response 38Sample Code: C# 38

ConfigurationDelete 39Syntax 39Arguments 39Response 39Sample Code: C# 39

ConfigurationDeploy 40Syntax 40Arguments 40Response 40Sample Code: C# 41

ConfigurationPerformAction 41Syntax 42Arguments 42Response 42Sample Code: C# 42

ConfigurationSetPublicPrivate 43Syntax 43Arguments 43Response 43Sample Code: C# 43

ConfigurationUndeploy 44Syntax 44Arguments 44Response 44Sample Code: C# 44

GetConfiguration 45Syntax 45

Page 5: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 5

Contents

Response 45Sample Code: C# 46

GetConfigurationByName 46Syntax 46Arguments 47Response 47Sample Code: C# 47

GetMachine 48Syntax 48Arguments 48Response 48Sample Code: C# 48

GetMachineByName 49Syntax 49Arguments 49Response 49Sample Code: C# 50

GetSingleConfigurationByName 50Syntax 50Arguments 50Response 51Sample Code: C# 51

ListConfigurations 52Syntax 52Arguments 52Response 52Sample Code: C# 52

ListMachines 53Syntax 53Arguments 53Response 54Sample Code: C# 54

LiveLink 55Syntax 55Arguments 55Response 55Sample Code: C# 55

MachinePerformAction 56Syntax 56Arguments 57

Page 6: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

6 VMware, Inc.

Response 57Sample Code: C# 57

Index 59

Page 7: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 7

This preface provides information about the VMware Lab Manager SOAP API Guide and links to VMware® technical support and educational resources.

This preface contains the following topics:

“About This Book”

“Technical Support and Education Resources”

About This BookUse the VMware Lab Manager SOAP API Guide to develop applications that leverage Lab Manager Web service data, automate tasks, or integrate Lab Manager with other software testing tools.

Intended AudienceThis guide is intended for developers who want to leverage Lab Manager data for customized testing solutions, or integrate Lab Manager and other software testing tools in their environment. For example, using the Lab Manager SOAP API lets you integrate Lab Manager with automated software testing tools, such as Mercury Quality Center. 

This guide assumes you have some familiarity with:

Virtual machine technology

Distributed, multitiered systems concepts

Development and testing practices

Preface

Page 8: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware Lab Manager SOAP API Guide

8 VMware, Inc.

Windows or Linux operating systems

Web Services, SOAP, and XML

Document FeedbackIf you have comments about this documentation, submit your feedback to:

[email protected]

ConventionsTable P‐1 illustrates the typographic conventions used in this manual. 

Technical Support and Education ResourcesThe following sections describe the technical support resources available to you.

Self-Service SupportUse the VMware Technology Network (VMTN) for self‐help tools and technical information:

Product information – http://www.vmware.com/products/

Technology information – http://www.vmware.com/vcommunity/technology

Documentation – http://www.vmware.com/support/pubs

VMTN Knowledge Base – http://www.vmware.com/support/kb

Discussion forums – http://www.vmware.com/community

User groups – http://www.vmware.com/vcommunity/usergroups.html

Table P-1. Conventions in this Manual

Style Elements

Blue (online only) Cross‐references and email addresses

Blue boldface (online only) Links

Black boldface User interface elements such as button names and menu items

Monospace Commands, filenames, directories, and paths

Monospace bold User input

Italic Document titles, glossary terms, and occasional emphasis

< Name >  Variable and parameter names

Page 9: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 9

Preface

For more information about the VMware Technology Network, go to:

http://www.vmtn.net

Online and Telephone SupportUse online support to submit technical support requests, view your product and contract information, and register your products. Go to:

http://www.vmware.com/support

Customers with appropriate support contracts should use telephone support for the fastest response on priority 1 issues. Go to:

http://www.vmware.com/support/phone_support.html

Support OfferingsFind out how VMware support offerings can help meet your business needs. Go to:

http://www.vmware.com/support/services

VMware Education ServicesVMware courses offer extensive hands‐on labs, case study examples, and course materials designed to be used as on‐the‐job reference tools. For more information about VMware Education Services, go to:

http://mylearn1.vmware.com/mgrreg/index.cfm

Page 10: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware Lab Manager SOAP API Guide

10 VMware, Inc.

Page 11: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 11

1

The Lab Manager Web service SOAP API provides programmatic access to the Lab Manager system. By using the secure application programming interface (API), you can connect to Lab Manager Server to automate or perform various operations. 

The Lab Manager Web service SOAP API uses XML‐based technologies, including Simple Object Access Protocol (SOAP) as the communication protocol and Web Services Description Language (WSDL) as the interface description language. The Lab Manager WSDL file details the available methods of the service (called “operations” in Web Services vernacular) and parameter types, as well as the SOAP endpoint for the service.

This chapter covers these topics:

“Integrating Lab Manager with Automated Testing Tools” on page 12

“Supported Operations” on page 12

“Lab Manager Data Objects” on page 12

“Standards Compliance and Compatible Development Platforms” on page 13

“Security” on page 13

Introducing VMware Lab Manager SOAP API 1

Page 12: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

12 VMware, Inc.

Integrating Lab Manager with Automated Testing ToolsThe Lab Manager Web service SOAP API allows you to leverage Lab Manager data using the language and platform of your choice. The examples in this guide use the C# programming language and the Microsoft .NET framework, but other programming languages and development environments are also supported. If you are using a language other than C#, see the documentation on your development environment for comparable information about developing Web service applications.

In addition to extending or customizing Lab Manager by using the SOAP API, you can also integrate Lab Manager with automated testing systems. You can see an example of this integration in “Advanced Sample: Integrating Lab Manager and Quality Center” on page 21.

For more information about Lab Manager solutions, developer resources, and community resources, go to http://www.vmware.com.

Supported OperationsUsing your preferred Web‐enabled development environment, you can construct Web service client applications using standard Web service protocols to programmatically:

Query for virtual machine and configuration information.

Perform actions on machines and configurations.

Capture, checkout, clone, delete, and deploy configurations.

Create a LiveLink configuration URL you can email to other team members.

For detailed information about supported Web service operations, see “Lab Manager API Method Reference” on page 33.

Lab Manager Data ObjectsThe Lab Manager Web service SOAP API interacts with the data in your organization using objects, which are programmatic representations of the Lab Manager data. Object properties represent fields in those data entities. For example, a Lab Manager configuration is represented by a Configuration object, which has fields that represent the configuration name, configuration numeric identifier, deployment status, shared state, and more.

This document describes how to perform operations such as query, clone, capture, and deploy on Lab Manager data using the Lab Manager data objects. For detailed information, see “Lab Manager API Data Types” on page 27.

Page 13: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 13

Chapter 1 Introducing VMware Lab Manager SOAP API

Standards Compliance and Compatible Development Platforms

The Lab Manager Web Service SOAP API complies with SOAP 1.1, WSDL 1.1, and other standards identified in the WS‐I Basic Profile Version 1.1. The Lab Manager Web Service SOAP API works with current SOAP development environments that adhere to the Basic Profile Version 1.1 standards. The examples in this document use the Microsoft Visual Studio .NET 2003 development environment and the C# programming language.

If you are using Visual Studio for .NET development, VMware recommends that you use Visual Studio 2003 or higher.

SecurityClient applications that access the Lab Manager data in your organization are subject to the same security protections that are used in the Lab Manager Web console. Lab Manager exposes all SOAP API methods using SSL.

When accessing the SOAP API with the Web service URL, you might see an SSL certificate warning. Accept the certificate to use the API or replace the certificate with a valid signed certificate.

User AuthenticationClient applications must provide valid credentials—a Lab Manager user account and password—with each Lab Manager Web service method call. The user account must have Administrator privileges on the Lab Manager Server. The Lab Manager Server authenticates these credentials.

NOTE Implementation differences in certain development platforms might prevent access to some or all of the features in the Lab Manager Web service SOAP API.

Page 14: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

14 VMware, Inc.

Page 15: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 15

2

You can review introductory information about using the Lab Manager Web service SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references and uses an XML Web service. This does not need to involve a client‐based application. In many cases, XML Web service clients might be other Web applications, such as Web Forms or even other XML Web services.

This chapter covers these topics:

“Requirements” on page 16

“Obtaining and Importing the WSDL” on page 16

“Simple and Advanced Code Samples” on page 18

Getting Started with the Lab Manager SOAP API 2

Page 16: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

16 VMware, Inc.

RequirementsThe instructions in this chapter assume that an instance of Lab Manager is installed, configured, and running on your network. Before you can start developing an application, review these requirements:

You must know the address of the Lab Manager server instance, starting with its fully‐qualified host name or IP address.

For example, https://hostname.company.com/LabManager.

You must have an account with Lab Manager Administrator privileges on the target Lab Manager server.

If you are not an Administrator, have your Lab Manager Administrator set you up with a Lab Manager account. 

Assuming you have an appropriate account on the Lab Manager Server, you can continue with “Obtaining and Importing the WSDL.”

Obtaining and Importing the WSDLAs with any standards‐based SOAP API implementation, the Lab Manager API definition is available on the Web service as an XML‐formatted WSDL file. 

To obtain the WSDL, launch Internet Explorer 5.5 or higher and navigate to this URL for your Lab Manager Server:

https://<hostname>/LabManager/SOAP/LabManager.asmx?WSDL

The WSDL defines all the Lab Manager API calls and objects. 

For more information on WSDL, see:

http://www.w3.org/TR/wsdl

Importing the WSDL File into Your Development PlatformAfter you obtain the WSDL, import it into your development environment and generate the necessary objects for use in building client Web service applications. The process depends on your development environment, programming language, and associated tools. For example, the Microsoft Visual Studio development environment handles the tasks automatically. 

The next section provides an example of obtaining the WSDL and importing it in the Microsoft Visual Studio 2003. For instructions about other development platforms, see the product documentation for your platform.

Page 17: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 17

Chapter 2 Getting Started with the Lab Manager SOAP API

Instructions for Using Microsoft Visual Studio with Lab Manager WSDL

Microsoft Visual Studio programming languages access the Lab Manager Web service API through objects that serve as proxies for their server‐side counterparts. 

When accessing XML Web services in managed code, a proxy class and the .NET Framework handle all of the infrastructure coding.

Before you can use the Lab Manager Web service API with Visual Studio, you must first generate the proxy class object from the WSDL file. 

Visual Studio provides a wizard (“Add a Web Reference”) to connect to a Web service and generate the necessary artifacts. You can add a Web reference to an existing application or create a new application in Visual Studio.

The instructions below are specific to Microsoft Visual Studio 2003. 

To add a Web reference

1 From the Windows Start menu, launch Microsoft Visual Studio .NET 2003.

The Visual Studio environment opens.

2 Select New Project to create a new project, or select Open to open an existing project. 

3 In Visual Studio, choose Add Web Reference from the Project menu.

4 In the URL text box, type the URL to obtain the service description of the Lab Manager Web service:

https://<hostname>/LabManager/SOAP/LabManager.asmx

5 Click Go.

The certificate exchange between the Lab Manager server and the development environment client begins. A security alert displays the details of the certificate sent from the server.

6 Click Yes to proceed.

NOTE The security alert messages are generated when the Lab Manager server uses the default, self‐signed certificates. You can replace these certificates on the Lab Manager server with certificates purchased from Verisign, Thawte, and other certificate authorities.

Page 18: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

18 VMware, Inc.

An alert from the Visual Studio environment might appear. Click Yes to proceed. The Microsoft Visual Studio environment connects to the Web service endpoint and displays the operations described in the Lab Manager Web service WSDL.

7 Select the text in the Web reference name text box and rename the Web reference to LabManagerSoap, the namespace used for this Web reference.

“LabManagerSoap” is one word, without spaces.

8 Click Add Reference to complete the process.

A certificate warning message might appear. Click Yes.

9 Click Yes again to proceed.

For more information, see the “Adding and Removing Web References” topic in the Visual Studio documentation.

Visual Studio retrieves the service description and generates a proxy class (LabManagerSoap) that serves as an interface to the Lab Manager Web service from your application. At the end of the process, the class gets added to the Web References folder of the project. (Click Solution Explorer to see LabManagerSoap listed in the Web References folder.)

With this basic setup task completed, you can build client applications that use the Lab Manager Web Service SOAP API. The fastest way to become familiar with the API is by walking through the code sample listed in the next section. 

Simple and Advanced Code SamplesThis section contains two code samples—one simple and one more complex—written in C# using the Microsoft Visual Studio 2003 IDE. 

Assuming that you have a Lab Manager instance running, your programming environment is set up, and you have the appropriate permissions on the Lab Manager server (see “Requirements” on page 16), you can test basic API programming connectivity between your development workstation and your Lab Manager Web service by using the “Simple C# Console Application.” Copy the code listing displayed in the next section, and paste it into your Microsoft Visual Studio 2003 environment.

NOTE VMware assumes you are familiar with basic programming concepts and already have a programming development environment set up on your computer. If you are using a programming language other than C# and a Web services development environment other than Microsoft Visual Studio 2003, see the appropriate documentation for more information.

Page 19: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 19

Chapter 2 Getting Started with the Lab Manager SOAP API

The code performs several simple tasks. The first two tasks (binding to the Web service and providing credentials) are typically required of any application that makes calls to a Lab Manager Web service:

Binds to the Lab Manager Web Service SOAP API.

Sets up the user name and password for making a SOAP call.

Sets up the ServicePointManager certificate policy to accept the SSL certificate. You must set up the certificate policy to accept all certificates to connect to the API.

Makes a call to get a configuration object based on name.

Displays all configuration fields in the console.

Simple C# Console Applicationusing System;using System.Net;

namespace LMConsoleApplication1{

class Class1{

/// <summary>/// The main entry point for the application./// </summary>[STAThread]static void Main(string[] args){

try{

////** Bind to the Lab Manager SOAP API Web Service//LabManagerSoap.VMwareLabManagerSOAPinterface binding = new LabManagerSoap.VMwareLabManagerSOAPinterface();////** Enter the URL for your system here//binding.Url ="https://10.6.1.248/LabManager/SOAP/LabManager.asmx;binding.Timeout = 10 * 60 * 1000; // 10 minutesServicePointManager.CertificatePolicy = new CertificateAccepter();

//**//** Allocate AuthenticationHeader object to hold caller’s//** username and password//**binding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();

Page 20: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

20 VMware, Inc.

////** Substitute a real user’s username and password here//binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";

//**//** Call GetSingleConfigurationByName()//** Get default configuration that comes with Lab Manager//** installation and write all property values to console//**LabManagerSoap.Configuration defCfg=

binding.GetSingleConfigurationByName("Sample 1");////** Print out all configuration properties to the Console//Console.WriteLine("Name = " + defCfg.name);Console.WriteLine("ID = " + defCfg.id.ToString());Console.WriteLine("Description = "+ defCfg.description);Console.WriteLine("isPublic = "+ defCfg.isPublic.ToString());Console.WriteLine("isDeployed = "+ defCfg.isDeployed.ToString());Console.WriteLine("fenceMode = "+ defCfg.fenceMode.ToString());Console.WriteLine("type = " + defCfg.type.ToString());Console.WriteLine("owner = " + defCfg.owner);Console.WriteLine("dateCreated = " +

defCfg.dateCreated.ToString());Console.ReadLine();

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}} //** end Main

} //** end Class1

/// <summary>/// This class is needed to automatically accept the SSL certificate/// the Lab Manager sends on each API call./// </summary>

public class CertificateAccepter : System.Net.ICertificatePolicy{

public CertificateAccepter() {}

public bool CheckValidationResult(System.Net.ServicePoint servicePoint,System.Security.Cryptography.X509Certificates.X509Certificate cert,System.Net.WebRequest webRequest, int iProblem)

Page 21: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 21

Chapter 2 Getting Started with the Lab Manager SOAP API

{return true;

}}

} //** end Namespace}

Advanced Sample: Integrating Lab Manager and Quality CenterThe C# .NET example in this section is a more extensive—and more practical—example of using the Lab Manager SOAP API. This sample shows the integration of the Lab Manager SOAP API calls with Mercury Interactive Corporation Quality Center product. The sample code performs these tasks:

Makes Lab Manager API (Lab Manager SOAP API) calls to check out a configuration from the library and deploy it.

Runs a series of predefined tests on the deployed configuration using Mercury Quality Center.

Makes Lab Manager SOAP API calls to capture the configuration and undeploy it from the Workspace.

These tasks are accomplished in the sample code by means of these three methods:

The CheckoutDeployConfiguration() method (page 24) obtains the configuration from the library and deploys it to the Lab Manager Workspace.

The RunQCTestset() method (page 23) runs a series of predefined Mercury Interactive Quality Center tests. (For more information about the predefined tests, see the Mercury Interactive Quality Center documentation.)

The CaptureUndeployConfiguration() method (page 25) undeploys the configuration and captures it to the library.

In addition, the GetLMAPI() method (see code on page 25, static LabManagerSoap.VMwareLabManagerSOAPinterface GetLMAPI()) creates a new binding to the Lab Manager API and sets up authentication parameters. This method configures the certificate policy for the .NET service point manager to accept any certificate programmatically. GetLMAPI() returns an instance of the Lab Manager binding. 

using System;using System.Configuration;using System.Collections.Specialized;using System.IO;using System.Net;using TDAPIOLELib; //** From Mercury Quality Center

Page 22: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

22 VMware, Inc.

namespace MATRun{

/// <summary>/// Class1 comprises methods to check out configurations from the Lab/// Manager library and deploy to the workspace; execute several tests;/// and capture a configuration./// </summary>class Class1{

/// <summary>/// The main entry point for the application./// </summary>[STAThread]

static void Main(string[] args){

NameValueCollection settings=ConfigurationSettings.AppSettings;string filename = null;string buildlocation = null;string buildversion = null;

if ( args.Length > 0 ){

buildlocation = args[0];buildversion = args[1];

}

if ( buildlocation == null ){

buildlocation =@"\\fs.labmanger.com\public\build\outputdir\1423\artifacts";

buildversion = "Lab Manager-2.0.4018";}filename =

@"\\fs.labmanager.com\public\build\build-to-test.bat";StreamWriter f = new StreamWriter(filename);f.WriteLine(String.Format(@"xcopy {0}\setup.exe c:\ /Y",

buildlocation));f.Close();Console.WriteLine(String.Format("Testing {0} at location {1}",

buildversion, buildlocation));

string config = CheckoutDeployConfiguration(buildversion);RunQCTestset();CaptureUndeployConfiguration(config);

} //** End Main() method

//

Page 23: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 23

Chapter 2 Getting Started with the Lab Manager SOAP API

//** Initialize parameters//static string library_config = "ProofOfBuild-R2";static string storage_server ="LM Server";static string perform_capture =”Yes”;static string soap_server = "LM Server";

///<summary>/// The RunQCTestset()method executes a series of pre-defined /// tests using Mercury Interactive’s Quality Center product. ///</summary>

static void RunQCTestset(){

string server = "https://demo12.Lab Manager.com/qcbin";string domain = "Lab Manager_SYSTEMS";string project = "Snapshot_20";string username = "jaya";string password = "Lab Manager";string host = "10.6.1.34";string chosenTestSet = "Install_Verify";

// ----TDConnection tdc = new TDConnection();tdc.InitConnection(server, domain, "");tdc.ConnectProjectEx(domain, project, username, password);if ( tdc.Connected){

TestSetFactory testSetFactory =(TestSetFactory)tdc.TestSetFactory;List testSetList;testSetList = testSetFactory.NewList("");foreach ( TestSet testSet in testSetList){

if ( testSet.Name.ToUpper() == chosenTestSet.ToUpper()){Console.WriteLine("Scheduling "+ testSet.Name);TSScheduler sched = (TSScheduler)testSet.StartExecution(host);sched.RunAllLocally = false;sched.Run(null);ExecutionStatus status = (ExecutionStatus)sched.ExecutionStatus;while ( status.Finished == false ){

System.Threading.Thread.Sleep(30);status.RefreshExecStatusInfo(null, true);

}

// results TDAPIOLELib.TSTestFactory tsf;

Page 24: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

24 VMware, Inc.

tsf = (TSTestFactory) testSet.TSTestFactory; TDAPIOLELib.List testlist; testlist = tsf.NewList(""); foreach ( TSTest test in testlist) { TDAPIOLELib.Run r= (Run) test.LastRun; if (r != null) { Console.WriteLine(test.Name + " " + r.Name + " " + r.Status.ToString()); } } //** end foreach break;

} //** end if } //** end foreach } //** end if } //** end RunQCTestset

///<summary>///The CheckoutDeployConfiguration() method obtains the configuration///from the Lab Manager Library and deploys it to the Lab Manager///Workspace.///</summmary>

static string CheckoutDeployConfiguration( string version){

////** Check out a configuration and deploy it on the Managed// Server pool

string srcconfig = "ProofOfBuild-R2"; //** Configuration nameSystem.DateTime time = System.DateTime.Now;string configname = version+"-"+

time.ToString().Replace(" ", "_").Replace("/","-");

////** Bind to Lab Manager SOAP Web Service//LabManagerSoap.VMwareLabManagerSOAPinterface binding = GetLMAPI();

////** Get configuration information -- Configuration object//LabManagerSoap.Configuration config =

binding.GetSingleConfigurationByName(srcconfig);Console.WriteLine("Checkout configuratioin "+ srcconfig);

////** Check configuration out of Configuration Library and

Page 25: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 25

Chapter 2 Getting Started with the Lab Manager SOAP API

//** name it(configname)//int newCheckoutID = binding.ConfigurationCheckout(config.id, configname);Console.WriteLine("Deploy configuratioin "+ srcconfig);

////** Deploy Configuration//** false = Do not run images from Managed Server//** 1 = Fenced mode, traffic blocked in and out//binding.ConfigurationDeploy(newCheckoutID, false, 1);Console.WriteLine("Deploy is completed");return configname;}

///<summary>/// The CaptureUndeployConfiguration() method saves the configuration/// to the Lab Manager Library and un-deploys it from the workspace.///</summary>

static void CaptureUndeployConfiguration(string configname){////** Bind to Lab Manager SOAP Web Service//LabManagerSoap.VMwareLabManagerSOAPinterface binding = GetLMAPI();LabManagerSoap.Configuration config =

binding.GetSingleConfigurationByName(configname);if ( perform_capture.Equals("Yes") )

{Console.WriteLine("Capture configuration "+ configname);int newConfigCaptureID = binding.ConfigurationCapture(config.id,

configname);}

Console.WriteLine("Undeploy configuration "+ configname);binding.ConfigurationUndeploy(config.id);Console.WriteLine("Undeploy is completed");}

/// <summary>///The GetLMAPI() method creates a new binding to the Lab Manager API ///and sets up authentication and other basic parameters. This method///returns a CertificateAcceptor object./// </summary>

static LabManagerSoap.VMwareLabManagerSOAPinterface GetLMAPI(){

////** Bind to SOAP interface

Page 26: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

26 VMware, Inc.

//LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();////**Allocate caller login object//binding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.Url = binding.Url.Replace("https://qa240.VMware.com",

"https:/demo44.VMware.com");binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "vlm";binding.Timeout = 10 * 60 * 1000; // 10 minutes

ServicePointManager.CertificatePolicy = new CertificateAccepter();return binding; //** return binding reference}

}/// <summary>/// The CertificateAccepter class automatically accepts the SSL/// certificate sent by Lab Manager with each API call from a client/// application./// </summary>

public class CertificateAccepter : System.Net.ICertificatePolicy{

public CertificateAccepter() {}

public bool CheckValidationResult(System.Net.ServicePoint servicePoint,System.Security.Cryptography.X509Certificates.X509Certificate cert,System.Net.WebRequest webRequest, int iProblem)

{return true;

}}//end CertificateAccepter class declaration

}//end namespace declaration

Page 27: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 27

3

This chapter covers these topics about Lab Manager API data types:

“Primitive XML Data Types” on page 28

“Lab Manager Data Types” on page 28

“AuthenticationHeader” on page 29

“Configuration” on page 30

“Machine” on page 30

Lab Manager API Data Types 3

Page 28: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

28 VMware, Inc.

Primitive XML Data TypesLab Manager SOAP API data types are based on the primitive XML data types shown in Table 3‐1. 

These primitive types are the building blocks for the Lab Manager data types used in making Lab Manager API calls. 

Lab Manager Data TypesWhen writing your client application, follow the data typing rules defined for your programming language and development environment.Your development tool handles the mapping of typed data in your programming language with these SOAP data types. 

The Lab Manager data types are defined in the Lab Manager WSDL file. For each type, this chapter lists its properties and description.

Table 3-1. Primitive XML Data Types in the Lab Manager SOAP API

Value Description

xsd:Boolean A logical value, including true, false, 0, and 1.

xsd:date Date values.

xsd:dateTime Date/time values (timestamps).

xsd:double  Numeric value that corresponds to the IEEE double‐precision 64‐bit floating point type defined in the standard IEEE 754‐1985.

xsd:int Numeric value from ‐2147483648 to 2147483647.

xsd:string Any character data.

Table 3-2. Lab Manager SOAP API Data Types

Data Type Description

AuthenticationHeader Contains the user name and password of the caller. This data type is part of every SOAP header in Lab Manager Web Service methods.

Configuration Configuration object.

Machine Machine object.

Page 29: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 29

Chapter 3 Lab Manager API Data Types

AuthenticationHeaderThis data structure passes the user name and password of the caller in all Lab Manager Web service SOAP API methods. 

Supported API CallsAll

Fields

Sample Usage: C#/**** Visual Studio Console application in C#** LMsoap = web reference name for LM Web service** Set up login code for all LM Web service method calls****/try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

binding.AuthenticationHeaderValue =newLabManagerSoap.AuthenticationHeader();

binding.AuthenticationHeaderValue.username = "hedley";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

Table 3-3. AuthenticationHeader Fields

Field Data Type Description

username string Lab Manager account user name.

password string Lab Manager account password.

Page 30: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

30 VMware, Inc.

ConfigurationThis data structure exists for each configuration in the Lab Manager configuration library or Workspace. A configuration is a group of virtual machines (and its operating systems, applications, and data) which Lab Manager controls as a single unit.

An integer ID field uniquely identifies a configuration. Configuration names are not guaranteed to be unique.

MachineThis data structure exists for each virtual machine in the configuration library or Workspace of Lab Manager. An integer ID field uniquely identifies a machine. Machine names are not guaranteed to be unique except within a configuration..

Table 3-4. Configuration Fields

Field Data Type Description

id int Configuration identifier.

name string Configuration name.

description string Configuration description.

isPublic boolean True if others can view and access; false if not.

isDeployed boolean True if deployed; false if not deployed.

fenceMode int 1 = Not fenced.2 = Fenced—Block traffic in and out.3 = Fenced—Allow traffic out only .4 = Fenced—Allow traffic in and out .

type int Configuration type: 1 =Workspace configurations, 2 = library configurations.

owner string Owner user name.

dateCreated dateTime Configuration creation date.

Table 3-5. Machine Fields

Field Data Type Description

id int Machine identifier.

name string Machine name.

description string Machine description.

internalIP string Permanent assigned IP address.

externalIP string Temporary IP address when inside the fence.

Page 31: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 31

Chapter 3 Lab Manager API Data Types

status int 1=Off, 2 =On, 3=Suspended, 4=Stuck, 128=Invalid.

isDeployed boolean True if deployed

Table 3-5. Machine Fields (Continued)

Field Data Type Description

Page 32: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

32 VMware, Inc.

Page 33: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 33

4

This section contains information about Lab Manager Web service methods and how to call them using C# .NET code samples.

Lab Manager API Method Reference 4

Table 4-1. Lab Manager Web Service SOAP API Methods

Method Description

“ConfigurationCapture” on page 35 Captures a Workspace configuration and saves it to a specified Lab Manager storage server.

“ConfigurationCheckout” on page 36 Checks out a configuration from the configuration library and moves it to the Workspace.

“ConfigurationClone” on page 38 Clones a configuration active in the Workspace and saves it to storage.

“ConfigurationDelete” on page 39 Deletes a configuration from the Workspace.

“ConfigurationDeploy” on page 40 Deploys a configuration in the Workspace.

“ConfigurationPerformAction” on page 41 Performs an action on a configuration.

“ConfigurationSetPublicPrivate” on page 43 Sets the configuration state to public or private. Public configurations are accessible for others to use. Private configurations are available only for the owner.

“ConfigurationUndeploy” on page 44 Undeploys a configuration from the Managed Server pool.

“GetConfiguration” on page 45 Returns a Configuration object matching a configuration identifier.

Page 34: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

34 VMware, Inc.

“GetConfigurationByName” on page 46 Returns Configuration objects matching a configuration name. (Configuration names are not guaranteed to be unique.)

“GetMachine” on page 48 Returns a Machine object matching a machine identifier.

“GetMachineByName” on page 49 Returns a Machine object matching a machine name.

“GetSingleConfigurationByName” on page 50

Returns a single Configuration object matching a configuration name.

“ListConfigurations” on page 52 Returns an array of Configuration objects in the Workspace or configuration library.

“ListMachines” on page 53 Returns an array of Configuration objects corresponding to the numeric identifier of a configuration.

“LiveLink” on page 55 Creates a URL to a configuration that can be emailed and clicked on to recreate the configuration. 

“MachinePerformAction” on page 56 Performs an action on a machine.

Table 4-1. Lab Manager Web Service SOAP API Methods (Continued)

Method Description

Page 35: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 35

Chapter 4 Lab Manager API Method Reference

ConfigurationCaptureThis method captures a Workspace configuration and saves it to a specified Lab Manager storage server with a name.

Syntaxint newConfigId = ConfigurationCapture(10,

“Config10Capture”);

Arguments

Response

Sample Code: C#try{

//**//** LabManagerSoap is the name of the web reference in Visual Studio//**LabManagerSoap.VMwareLabManagerSOAPinterface binding = new

LabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Get Configuration objectLabManagerSoap.Configuration Config =

binding.GetSingleConfigurationByName("Config26");

Table 4-2. Arguments

Field Data Type Description

configurationID int Configuration identifier.

newLibraryName string Capture name.

Table 4-3. Response

Field Data Type Description

configurationID int Configuration identifier of the new capture.

Page 36: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

36 VMware, Inc.

//** Get configuration identifier and deployed status from objectint configurationId = Config.id;bool deployed = Config.isDeployed;

//** Capture configuration if it’s deployedif (deployed){

//** Save capture with date and time stampstring captureName=Config.name + DateTime.Now.ToString();string LMStorageServer = "LM Server";binding.ConfigurationCapture(configurationId, captureName);

}}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

ConfigurationCheckoutThis method checks out a configuration from the configuration library and moves it to the Workspace under a different name.

Syntaxint result = ConfigurationCheckout(7, “Config7May10”);

Arguments

Response

Table 4-4. Arguments

Field Data Type Description

configurationID int Numeric identifier of the configuration in the configuration library.

workspaceName string Workspace name of the checked‐out configuration.

Table 4-5. Response

Field Data Type Description

workspaceID int Numeric identifier of the configuration in the Workspace.

Page 37: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 37

Chapter 4 Lab Manager API Method Reference

Sample Code: C#try{

////** LMSoap is the name of the Web reference in Visual Studio.//LabManagerSoap.VMwareLabManagerSOAPinterface binding = new

LabManagerSoap.VMwareLabManagerSOAPinterface();

////** Create login//binding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";binding.Url =

"https://demo18.LabManager.com/LabManager/SOAP/LabManager.asmx";binding.Timeout = 10 * 60 * 1000; // 10 minutesServicePointManager.CertificatePolicy = new CertificateAccepter();

////** Get Configuration object//LabManagerSoap.Configuration Config =

binding.GetSingleConfigurationByName("Win2K3Exchange");int configurationId = Config.id;

////** Timestamp library configuration name as new Workspace name//string checkoutName=Config.name + DateTime.Now.ToString();

////** Check out and move to Workspace//int newConfigID = binding.ConfigurationCheckout(Config.id,

checkoutName);Console.WriteLine("New Config ID=" + newConfigID.ToString());Console.ReadLine();

}catch (Exception e)

{Console.WriteLine("Error="+e.Message);Console.ReadLine();

}

Page 38: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

38 VMware, Inc.

ConfigurationCloneThis method clones a Workspace configuration, saves it in a storage server, and makes it visible in the Workspace under the new name.

Syntaxint result = ConfigurationClone(6, “Config6Clone”);

Arguments

Response

Sample Code: C#try{

//**//** LabManagerSoap is the name of the web reference in Visual Studio//**LabManagerSoap.VMwareLabManagerSOAPinterface binding = new

LabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Clone Configurationint newConfigId = binding.ConfigurationClone(24, "ClonedConfig24");Console.WriteLine("New Config ID=" + newConfigId.ToString());

}

Table 4-6. Arguments

Field Data Type Description

configurationId int Numeric identifier of the configuration in the configuration library.

newWorkspaceName string Workspace name of the clone.

Table 4-7. Response

Field Data Type Description

workspaceId int Numeric identifier of the new Workspace configuration.

Page 39: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 39

Chapter 4 Lab Manager API Method Reference

catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

ConfigurationDeleteThis method deletes a configuration from the Workspace. You cannot delete a deployed configuration.

SyntaxConfigurationDelete(6);

Arguments

Responsenone

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Get Configuration objectLabManagerSoap.Configuration Config=binding.GetSingleConfigurationByName(

"Config24");

//** Get configuration identifier and deployed status from objectint configurationId = Config.id;bool deployed = Config.isDeployed;

Table 4-8. Arguments

Field Data Type Description

configurationID int Numeric identifier of the Workspace configuration.

Page 40: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

40 VMware, Inc.

//** Delete configuration if it isn’t deployedif (!deployed)

{binding.ConfigurationDelete(configurationId);

}else

{//**//** Must undeploy configuration before deleting it//**binding.ConfigurationUndeploy(configurationId);binding.ConfigurationDelete(configurationId);

}}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

ConfigurationDeployThis method allows you to deploy an undeployed configuration which resides in the Workspace.

SyntaxConfigurationDeploy(6, false, 1);

Arguments

Responsenone

Table 4-9. Arguments

Field Data Type Description

configurationID int Numeric identifier of the configuration in the Workspace.

isCached boolean Always set a false value.

isFenced int 1 = Not fenced.2 = Fenced—Block traffic in and out.3 = Fenced—Allow traffic out only.4 = Fenced—Allow traffic in and out.

Page 41: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 41

Chapter 4 Lab Manager API Method Reference

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Get Configuration objectLabManagerSoap.Configuration Config =

binding.GetSingleConfigurationByName("Config24");

//** Get configuration identifier and deployed status from objectint configurationId = Config.id;bool deployed = Config.isDeployed;

//** Deploy configuration if it isn’t already.if (!deployed){

//** Deploy in fenced mode and run from Managed Serversbinding.ConfigurationDeploy(configurationId, true, 1);

}}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

ConfigurationPerformActionThis method performs one of the following configuration actions as indicated by the action identifier:

1—Power On. Turns on a configuration.

2—Power Off. Turns off a configuration. Nothing is saved.

3—Suspend. Freezes the CPU and state of a configuration.

4—Resume. Resumes a suspended configuration.

5—Reset. Reboots a configuration.

6—Snapshot. Saves a configuration state at a specific point in time.

Page 42: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

42 VMware, Inc.

7—Revert. Returns the configuration to a snapshot state.

8—Shutdown. Shuts down a configuration before turning it off.

SyntaxConfigurationPerformAction(int configurationID, int action);

Arguments

Responsenone

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

binding.AuthenticationHeaderValue = newLabManagerSoap.AuthenticationHeader();

binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

int configurationType = 1; //** Get workspace configuration

//**//** Get array of all configurations//**LabManagerSoap.Configuration [] configurations =

binding.ListConfigurations(configurationType);

//**//** Loop through all configurations.//**for (int j=0; j < configurations.Length; j++)

{binding.ConfigurationPerformAction(configurations[j].id,4/*Resume*/);

}

Table 4-10. Arguments

Field Data Type Description

configurationID int Configuration identifier.

action int Action to take on the configuration.

Page 43: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 43

Chapter 4 Lab Manager API Method Reference

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

ConfigurationSetPublicPrivateUse this call to set the state of a configuration to “public” or “private.” If the configuration state is public, others are able to access this configuration. If the configuration is private, only its owner can view it.

SyntaxConfigurationSetPublicPrivate(10, false);

Arguments

Responsenone

Sample Code: C#try{

////** LabManagerSoap is the name of the web reference in Visual Studio//LabManagerSoap.VMwareLabManagerSOAPinterface binding = new

LabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Get Configuration object

Table 4-11. Arguments

Field Data Type Description

configurationID int Configuration identifier.

isPublic boolean true = public, false = private.

Page 44: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

44 VMware, Inc.

LabManagerSoap.Configuration Config =binding.GetSingleConfigurationByName("Config24");

//** Get configuration identifier and shared status from objectbool shared = Config.isPublic;

//** Make configuration public if it isn’t already.if (!shared){

binding.ConfigurationSetPublicPrivate(Config.id, true);}

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

ConfigurationUndeployUndeploys a configuration in the Workspace.

SyntaxConfigurationUndeploy(10);

Arguments

Responsenone

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

binding.Url ="https://demo18.LabManager.com/LabManager/SOAP/LabManager.asmx";

binding.Timeout = 10 * 60 * 1000; // 10 minutesServicePointManager.CertificatePolicy = new CertificateAccepter();binding.AuthenticationHeaderValue = new

Table 4-12. Arguments

Field Data Type Description

configurationID int Configuration numeric identifier.

Page 45: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 45

Chapter 4 Lab Manager API Method Reference

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";////* Get configurations in Workspace, not Library//int configurationType= 1; LabManagerSoap.Configuration[] configurations =

binding.ListConfigurations(configurationType);////** Undeploy all deployed configurations I own//for (int i=0; i < configurations.Length; i++)

{if (configurations[i].owner.Equals("jaya"))

{binding.ConfigurationUndeploy(configurations[i].id);}

}}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

GetConfigurationThis method returns an object of type Configuration matching the configuration ID passed.

SyntaxConfiguration config = GetConfiguration(10);

Response

Table 4-13. Arguments

Field Data Type Description

configurationID int Configuration identifier.

Table 4-14. Response

Field Data Type Description

configuration Configuration Configuration object matching configuration id passed.

Page 46: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

46 VMware, Inc.

Sample Code: C#try{

//** LabManagerSoap is the name of the web reference in Visual StudioLabManagerSoap.VMwareLabManagerSOAPinterface binding = new

LabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Get Configuration objectLabManagerSoap.Configuration Config =

binding.GetConfiguration(26);

//** Write to the console all configuration propertiesConsole.WriteLine("Config name = " + Config.name);Console.WriteLine("Config id = " + Config.id.ToString());Console.WriteLine("Config description = " + Config.description);Console.WriteLine("Config isPublic = " + Config.isPublic.ToString());Console.WriteLine("Config isDeployed = " + Config.isDeployed.ToString());Console.WriteLine("Config fenceMode = " + Config.fenceMode.ToString());Console.WriteLine("Config type = " + Config.type.ToString());Console.WriteLine("Config owner = " + Config.owner);Console.WriteLine("Config dateCreated = " +

Config.dateCreated.ToString());Console.ReadLine();

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

GetConfigurationByNameThis call takes the name of a configuration and returns an array of configurations matching that name. Configuration names are not unique. More than one configuration with a given name can exist. If configurations with that name do not exist, an empty array is returned.

SyntaxConfiguration [] config = GetConfigurationByName(“Config9”);

Page 47: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 47

Chapter 4 Lab Manager API Method Reference

Arguments

Response

Sample Code: C#try{

////** LabManagerSoap is the name of the web reference in Visual Studio//LabManagerSoap.VMwareLabManagerSOAPinterface binding = new

LabManagerSoap.VMwareLabManagerSOAPinterface();//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

////** Get Configuration objects//LabManagerSoap.Configuration [] Configs =

binding.GetConfigurationByName("Config24Capture");

////** Write to the console all configurations and their properties.//for (int i=0; i < Configs.Length; i++)

{Console.WriteLine("Config name = " + Configs[i].name);Console.WriteLine("id = " + Configs[i].id.ToString());Console.WriteLine("description = " + Configs[i].description);Console.WriteLine("isPublic = " +Configs[i].isPublic.ToString());Console.WriteLine("isDeployed = " +Configs[i].isDeployed.ToString());

Table 4-15. Arguments

Field Data Type Description

name string Configuration name.

Table 4-16. Response

Field Data Type Description

configuration[] Configuration Array of Configuration objects with the same name.

Page 48: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

48 VMware, Inc.

Console.WriteLine("fenceMode = " +Configs[i].fenceMode.ToString());Console.WriteLine("type = " + Configs[i].type.ToString());Console.WriteLine("owner = " + Configs[i].owner);Console.WriteLine("dateCreated = " +Configs[i].dateCreated.ToString());Console.WriteLine();Console.ReadLine();}

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

GetMachineThis call takes the numeric identifier of a machine and returns its corresponding Machine object.

SyntaxMachine mach = GetMachine(10);

Arguments

Response

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

binding.AuthenticationHeaderValue = newLabManagerSoap.AuthenticationHeader();

Table 4-17. Arguments

Field Data Type Description

machineID int Machine identifier.

Table 4-18. Response

Field Data Type Description

machine Machine Machine object matching the machine identifier.

Page 49: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 49

Chapter 4 Lab Manager API Method Reference

binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

LabManagerSoap.Machine machine = binding.GetMachine(35);

//** Write to the console all machines in configuration.Console.WriteLine("Machine = " + machine.name);Console.WriteLine("id = " + machine.id.ToString());Console.WriteLine("description = " + machine.description);Console.WriteLine("internalIP = " + machine.internalIP);Console.WriteLine("externalIP = " + machine.externalIP);Console.WriteLine("status = " + machine.status.ToString());Console.WriteLine("isDeployed = " + machine.isDeployed.ToString());Console.ReadLine();

}catch (Exception e)

{Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

GetMachineByNameThis call takes a configuration identifier and a machine name and returns the matching Machine object.

SyntaxMachine mach = GetMachineByName(10, “Config9VM1”);

Arguments

Response

Table 4-19. Arguments

Field Data Type Description

configurationId int Configuration identifier.

name string Machine name.

Table 4-20. Response

Field Data Type Description

machine Machine Machine Object.

Page 50: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

50 VMware, Inc.

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

binding.AuthenticationHeaderValue = newLabManagerSoap.AuthenticationHeader();

binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

LabManagerSoap.Machine machine = binding.GetMachineByName(10,"Config9VM1");

//** Write to the console all machines fieldsConsole.WriteLine("Machine = " + machine.name);Console.WriteLine("id = " + machine.id.ToString());Console.WriteLine("description = " + machine.description);Console.WriteLine("internalIP = " + machine.internalIP);Console.WriteLine("externalIP = " + machine.externalIP);Console.WriteLine("status = " + machine.status.ToString());Console.WriteLine("isDeployed = " + machine.isDeployed.ToString());Console.ReadLine();

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

GetSingleConfigurationByNameThis call takes a configuration name, searches for it in both the configuration library and Workspace and returns its corresponding Configuration object. An error is returned if more than one configuration exists with that name.

SyntaxConfiguration config = GetSingleConfigurationByName(“Config9”);

ArgumentsTable 4-21. Arguments

Field Data Type Description

name string Configuration name.

Page 51: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 51

Chapter 4 Lab Manager API Method Reference

Response

Sample Code: C#try{

//** LabManagerSoap is the name of the web reference in Visual StudioLabManagerSoap.VMwareLabManagerSOAPinterface binding = new

LabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Get Configuration objectLabManagerSoap.Configuration Config =

binding.GetSingleConfigurationByName("Config24Capture");

//** Write to the console all configuration properties.Console.WriteLine("Config name = " + Config.name);Console.WriteLine("Config id = " + Config.id.ToString());Console.WriteLine("Config description = " + Config.description);Console.WriteLine("Config isPublic = " + Config.isPublic.ToString());Console.WriteLine("Config isDeployed = " + Config.isDeployed.ToString());Console.WriteLine("Config fenceMode = " + Config.fenceMode.ToString());Console.WriteLine("Config type = " + Config.type.ToString());Console.WriteLine("Config owner = " + Config.owner);Console.WriteLine("Config dateCreated = " +

Config.dateCreated.ToString());Console.ReadLine();

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

Table 4-22. Response

Field Data Type Description

configuration Configuration Configuration object.

Page 52: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

52 VMware, Inc.

ListConfigurationsThis method returns an array of type Configuration. Depending on configuration type requested, one object is returned for each configuration in the configuration library or each configuration in the Workspace.

SyntaxConfiguration [] config = ListConfigurations(1);

Arguments

Response

Sample Code: C#try{

//**//** LabManagerSoap is the name of the Web reference in Visual Studio.//**LabManagerSoap.VMwareLabManagerSOAPinterface binding = new

LabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Get Configurations in Workspace.int configurationType = 1; //** 1=WorkspaceLabManagerSoap.Configuration [] WSconfigurations =

binding.ListConfigurations(configurationType);

//** Write to the console all configurations

Table 4-23. Arguments

Field Data Type Description

configurationType int 1= Workspace configurations, 2=Library configurations.

Table 4-24. Response

Field Data Type Description

configurations[] Configuration Array Array of Configuration objects.

Page 53: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 53

Chapter 4 Lab Manager API Method Reference

for (int i=0; i < WSconfigurations.Length; i++){

Console.WriteLine("Configuration name = " +WSconfigurations[i].name);Console.WriteLine("id = " + WSconfigurations[i].id.ToString());Console.WriteLine("description = " +WSconfigurations[i].description);Console.WriteLine("isPublic = " +

WSconfigurations[i].isPublic.ToString());Console.WriteLine("isDeployed = "+

WSconfigurations[i].isDeployed.ToString());Console.WriteLine("fenceMode = " +

WSconfigurations[i].fenceMode.ToString());Console.WriteLine("type = " + WSconfigurations[i].type.ToString());Console.WriteLine("owner = " + WSconfigurations[i].owner);Console.WriteLine("dateCreated = " +

WSconfigurations[i].dateCreated.ToString());Console.WriteLine();

}Console.ReadLine();

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

ListMachinesThis method returns an array of type Machine. The method returns one Machine object for each virtual machine in a configuration.

SyntaxMachine [] machines = ListMachines(1);

ArgumentsTable 4-25. Arguments

Field Data Type Description

configurationID int Configuration numeric identifier.

Page 54: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

54 VMware, Inc.

Response

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

binding.Url ="https://demo18.LabManager.com/LabManager/SOAP/LabManager.asmx";

binding.Timeout = 10 * 60 * 1000; // 10 minutesServicePointManager.CertificatePolicy = new CertificateAccepter();

binding.AuthenticationHeaderValue = newLabManagerSoap.AuthenticationHeader();

binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";int configurationType = 1;

//** Get workspace configurationLabManagerSoap.Configuration [] configurations =

binding.ListConfigurations(configurationType);for (int j=0; j < configurations.Length; j++)

{Console.WriteLine("Configuration = " +

configurations[j].name.ToString());LabManagerSoap.Machine [] machines =

binding.ListMachines(configurations[j].id);//** Write to the console all machines in configurationfor (int i=0; i < machines.Length; i++)

{Console.WriteLine("Machine = " + machines[i].name);Console.WriteLine("id = " + machines[i].id.ToString());Console.WriteLine("description = " + machines[i].description);Console.WriteLine("internalIP = " + machines[i].internalIP);Console.WriteLine("externalIP = " + machines[i].externalIP);Console.WriteLine("status = " + machines[i].status.ToString());Console.WriteLine("isDeployed = " +machines[i].isDeployed.ToString());Console.WriteLine();}

Console.ReadLine();}

}

Table 4-26. Response

Field Data Type Description

machine[] Machine array Array of Machine objects.

Page 55: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 55

Chapter 4 Lab Manager API Method Reference

catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

LiveLinkThis method allows you to create a LiveLink URL to a library configuration.

Syntaxstring url = LiveLink(“LiveLinkWin2K”));

Arguments

Response

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

//** Create loginbinding.AuthenticationHeaderValue = new

LabManagerSoap.AuthenticationHeader();binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";binding.Url =

"https://demo18.LabManager.com/LabManager/SOAP/LabManager.asmx";binding.Timeout = 10 * 60 * 1000; // 10 minutesServicePointManager.CertificatePolicy = new CertificateAccepter();

//** Get Configuration object

Table 4-27. Arguments

Field Data Type Description

configurationName string The name of a library configuration.

Table 4-28. Response

Field Data Type Description

URL string A string containing the configuration URL in the library. The URL can be sent in an email to recreate the configuration when clicked.

Page 56: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

56 VMware, Inc.

LabManagerSoap.Configuration Config =binding.GetSingleConfigurationByName("Win2kBEA");

//** If configuration is deployed, livelink itif (Config.isDeployed)

{string captureName= "Win2kBEA" + DateTime.Now.ToString();string url = binding.LiveLink(Config.name);Console.WriteLine("LiveLink URL="+url);Console.ReadLine();}

}catch (Exception e)

{Console.WriteLine("Error="+e.Message);Console.ReadLine();

}

MachinePerformActionThis method performs one of the following machine actions as indicated by the action identifier:

1—Power On. Turns on a machine.

2—Power Off. Turns off a machine. Nothing is saved.

3—Suspend. Freezes a machine CPU and state.

4—Resume. Resumes a suspended machine.

5—Reset. Reboots a machine.

6—Snapshot. Save a machine state at a specific point in time.

7—Revert. Returns a machine to a snapshot state.

8—Shutdown. Shuts down a machine before turning off.

SyntaxMachinePerformAction(3);

Page 57: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 57

Chapter 4 Lab Manager API Method Reference

Arguments

Responsenone

Sample Code: C#try{

LabManagerSoap.VMwareLabManagerSOAPinterface binding = newLabManagerSoap.VMwareLabManagerSOAPinterface();

binding.AuthenticationHeaderValue = newLabManagerSoap.AuthenticationHeader();

binding.AuthenticationHeaderValue.username = "jaya";binding.AuthenticationHeaderValue.password = "Lab Manager";ServicePointManager.CertificatePolicy = new CertificateAccepter();

int configurationType = 1; //** Get workspace configuration

//**//** Get array of all configurations//**LabManagerSoap.Configuration [] configurations =

binding.ListConfigurations(configurationType);

//**//** Loop through all configurations.//**for (int j=0; j < configurations.Length; j++)

{//**//** Get array of all machines in configurations//**LabManagerSoap.Machine [] machines =

binding.ListMachines(configurations[j].id);//**//** Loop through all machines//**for (int i=0; i < machines.Length; i++){

Table 4-29. Arguments

Field Data Type Description

machineID int Machine identifier.

action int Action to take on the machine.

Page 58: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

58 VMware, Inc.

//**//** Check status—if machine is suspended, then resume it//**if (machines[i].status == 3){

binding.MachinePerformAction(machines[i].id, 4);}

}}

}catch (Exception e){

Console.WriteLine("Error: " + e.Message);Console.ReadLine();

}

Page 59: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware, Inc. 59VMware, Inc. 59

Index

CCaptureUndeployConfiguration 25CertificateAccepter() 26CheckoutDeployConfiguration 24Code

simple and advanced samples 18

Ddata types

AuthenticationHeader 29Configuration 30for Lab Manager 28Machine 30primitive XML 28

development environmentsupported 12

GGetLMAPI() 25

Kknowledge base

accessing 8

LLab Manager Web service SOAP API

defining 11languages

supported 12

Ooperations

supported 12

RRunQCTestset() 23

Ssecurity

using SSL 13SOAP API

obtaining the WSDL 16SOAP API methods

ConfigurationCapture 35ConfigurationCheckout 36ConfigurationClone 38ConfigurationDelete 39ConfigurationDeploy 40ConfigurationPerformAction 41ConfigurationSetPublicPrivate 43ConfigurationUndeploy 44GetConfiguration 45GetConfigurationByName 46GetMachine 48GetMachineByName 49GetSingleConfigurationByName 50ListConfigurations 52ListMachines 53LiveLink 55MachinePerformAction 56

Page 60: VMware Lab Manager SOAP API Guide · VMTN Knowledge Base ... SOAP API to develop an XML Web service client. An XML Web service client is any component or application that references

VMware® Lab Manager SOAP API Guide

60 VMware, Inc.

Ttechnical support resources 8

Uuser groups

accessing 8users

authenticating 13

VVMware community forums

accessing 8