VMware® Lab Manager SOAP API Guide VMware Lab Manager 2.
VMware® Lab Manager SOAP API Guide VMware Lab Manager SOAP API Guide Revision: 20061220 Item: VL-ENG-Q406-301 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: docfeedback@vmware.com © 2006 VMware, Inc. All rights reserved. Protected by one or more of U.S. Patent Nos.
Contents Preface 7 1 Introducing VMware Lab Manager SOAP API 11 Integrating Lab Manager with Automated Testing Tools 12 Supported Operations 12 Lab Manager Data Objects 12 Standards Compliance and Compatible Development Platforms 13 Security 13 User Authentication 13 2 Getting Started with the Lab Manager SOAP API 15 Requirements 16 Obtaining and Importing the WSDL 16 Importing the WSDL File into Your Development Platform 16 Instructions for Using Microsoft Visual Studio with Lab Manager WSDL Simple and
VMware® Lab Manager SOAP API Guide Arguments 35 Response 35 Sample Code: C# 35 ConfigurationCheckout 36 Syntax 36 Arguments 36 Response 36 Sample Code: C# 37 ConfigurationClone 38 Syntax 38 Arguments 38 Response 38 Sample Code: C# 38 ConfigurationDelete 39 Syntax 39 Arguments 39 Response 39 Sample Code: C# 39 ConfigurationDeploy 40 Syntax 40 Arguments 40 Response 40 Sample Code: C# 41 ConfigurationPerformAction 41 Syntax 42 Arguments 42 Response 42 Sample Code: C# 42 ConfigurationSetPublicPrivate 43 Syntax
Contents Response 45 Sample Code: C# 46 GetConfigurationByName 46 Syntax 46 Arguments 47 Response 47 Sample Code: C# 47 GetMachine 48 Syntax 48 Arguments 48 Response 48 Sample Code: C# 48 GetMachineByName 49 Syntax 49 Arguments 49 Response 49 Sample Code: C# 50 GetSingleConfigurationByName 50 Syntax 50 Arguments 50 Response 51 Sample Code: C# 51 ListConfigurations 52 Syntax 52 Arguments 52 Response 52 Sample Code: C# 52 ListMachines 53 Syntax 53 Arguments 53 Response 54 Sample Code: C# 54 LiveLink 55 Synta
VMware® Lab Manager SOAP API Guide Response 57 Sample Code: C# 57 Index 59 6 VMware, Inc.
Preface 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 Book Use 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.
VMware® Lab Manager SOAP API Guide Windows or Linux operating systems Web Services, SOAP, and XML Document Feedback If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com Conventions Table P‐1 illustrates the typographic conventions used in this manual. Table P-1.
Preface For more information about the VMware Technology Network, go to: http://www.vmtn.net Online and Telephone Support Use 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.
VMware® Lab Manager SOAP API Guide 10 VMware, Inc.
1 Introducing VMware Lab Manager SOAP API 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.
VMware® Lab Manager SOAP API Guide Integrating Lab Manager with Automated Testing Tools The 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.
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 .
VMware® Lab Manager SOAP API Guide 14 VMware, Inc.
2 Getting Started with the Lab Manager SOAP API 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.
VMware® Lab Manager SOAP API Guide Requirements The 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.
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.
VMware® Lab Manager SOAP API Guide 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.
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.
VMware® Lab Manager SOAP API Guide // //** 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.
Chapter 2 Getting Started with the Lab Manager SOAP API { return true; } } } //** end Namespace} Advanced Sample: Integrating Lab Manager and Quality Center The 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.
VMware® Lab Manager SOAP API Guide namespace MATRun { /// /// Class1 comprises methods to check out configurations from the Lab /// Manager library and deploy to the workspace; execute several tests; /// and capture a configuration. /// class Class1 { /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { NameValueCollection settings=ConfigurationSettings.
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"; /// /// The RunQCTestset()method executes a series of pre-defined /// tests using Mercury Interactive’s Quality Center product. /// static void RunQCTestset() { string server = "https://demo12.Lab Manager.
VMware® Lab Manager SOAP API Guide 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.
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.
VMware® Lab Manager SOAP API Guide // LabManagerSoap.VMwareLabManagerSOAPinterface binding = new LabManagerSoap.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.
3 Lab Manager API Data Types 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 VMware, Inc.
VMware® Lab Manager SOAP API Guide Primitive XML Data Types Lab Manager SOAP API data types are based on the primitive XML data types shown in Table 3‐1. 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.
Chapter 3 Lab Manager API Data Types AuthenticationHeader This data structure passes the user name and password of the caller in all Lab Manager Web service SOAP API methods. Supported API Calls All Fields Table 3-3. AuthenticationHeader Fields Field Data Type Description username string Lab Manager account user name. password string Lab Manager account password.
VMware® Lab Manager SOAP API Guide Configuration This 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. Table 3-4. Configuration Fields Field Data Type Description id int Configuration identifier.
Chapter 3 Lab Manager API Data Types Table 3-5. Machine Fields (Continued) Field Data Type Description status int 1=Off, 2 =On, 3=Suspended, 4=Stuck, 128=Invalid. isDeployed boolean True if deployed VMware, Inc.
VMware® Lab Manager SOAP API Guide 32 VMware, Inc.
4 Lab Manager API Method Reference 4 This section contains information about Lab Manager Web service methods and how to call them using C# .NET code samples. 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.
VMware® Lab Manager SOAP API Guide Table 4-1. Lab Manager Web Service SOAP API Methods (Continued) 34 Method Description “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.
Chapter 4 Lab Manager API Method Reference ConfigurationCapture This method captures a Workspace configuration and saves it to a specified Lab Manager storage server with a name. Syntax int newConfigId = ConfigurationCapture(10, “Config10Capture”); Arguments Table 4-2. Arguments Field Data Type Description configurationID int Configuration identifier. newLibraryName string Capture name. Response Table 4-3.
VMware® Lab Manager SOAP API Guide //** Get configuration identifier and deployed status from object int configurationId = Config.id; bool deployed = Config.isDeployed; //** Capture configuration if it’s deployed if (deployed) { //** Save capture with date and time stamp string captureName=Config.name + DateTime.Now.ToString(); string LMStorageServer = "LM Server"; binding.ConfigurationCapture(configurationId, captureName); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.
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.
VMware® Lab Manager SOAP API Guide ConfigurationClone This method clones a Workspace configuration, saves it in a storage server, and makes it visible in the Workspace under the new name. Syntax int result = ConfigurationClone(6, “Config6Clone”); Arguments 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. Response Table 4-7.
Chapter 4 Lab Manager API Method Reference catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadLine(); } ConfigurationDelete This method deletes a configuration from the Workspace. You cannot delete a deployed configuration. Syntax ConfigurationDelete(6); Arguments Table 4-8. Arguments Field Data Type Description configurationID int Numeric identifier of the Workspace configuration. Response none Sample Code: C# try { LabManagerSoap.
VMware® Lab Manager SOAP API Guide //** Delete configuration if it isn’t deployed if (!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.
Chapter 4 Lab Manager API Method Reference Sample Code: C# try { LabManagerSoap.VMwareLabManagerSOAPinterface binding = new LabManagerSoap.VMwareLabManagerSOAPinterface(); //** Create login binding.AuthenticationHeaderValue = new LabManagerSoap.AuthenticationHeader(); binding.AuthenticationHeaderValue.username = "jaya"; binding.AuthenticationHeaderValue.password = "Lab Manager"; ServicePointManager.CertificatePolicy = new CertificateAccepter(); //** Get Configuration object LabManagerSoap.
VMware® Lab Manager SOAP API Guide 7—Revert. Returns the configuration to a snapshot state. 8—Shutdown. Shuts down a configuration before turning it off. Syntax ConfigurationPerformAction(int configurationID, int action); Arguments Table 4-10. Arguments Field Data Type Description configurationID int Configuration identifier. action int Action to take on the configuration. Response none Sample Code: C# try { LabManagerSoap.VMwareLabManagerSOAPinterface binding = new LabManagerSoap.
Chapter 4 Lab Manager API Method Reference } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadLine(); } ConfigurationSetPublicPrivate Use 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. Syntax ConfigurationSetPublicPrivate(10, false); Arguments Table 4-11.
VMware® Lab Manager SOAP API Guide LabManagerSoap.Configuration Config = binding.GetSingleConfigurationByName("Config24"); //** Get configuration identifier and shared status from object bool 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(); } ConfigurationUndeploy Undeploys a configuration in the Workspace.
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.
VMware® Lab Manager SOAP API Guide Sample Code: C# try { //** LabManagerSoap 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"; ServicePointManager.
Chapter 4 Lab Manager API Method Reference Arguments Table 4-15. Arguments Field Data Type Description name string Configuration name. Response Table 4-16. Response Field Data Type Description configuration[] Configuration Array of Configuration objects with the same name. Sample Code: C# try { // //** LabManagerSoap is the name of the web reference in Visual Studio // LabManagerSoap.VMwareLabManagerSOAPinterface binding = new LabManagerSoap.
VMware® Lab Manager SOAP API Guide 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.
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.
VMware® Lab Manager SOAP API Guide Sample Code: C# try { LabManagerSoap.VMwareLabManagerSOAPinterface binding = new LabManagerSoap.VMwareLabManagerSOAPinterface(); binding.AuthenticationHeaderValue = new LabManagerSoap.AuthenticationHeader(); binding.AuthenticationHeaderValue.username = "jaya"; binding.AuthenticationHeaderValue.password = "Lab Manager"; ServicePointManager.CertificatePolicy = new CertificateAccepter(); LabManagerSoap.Machine machine = binding.
Chapter 4 Lab Manager API Method Reference Response Table 4-22. Response Field Data Type Description configuration Configuration Configuration object. Sample Code: C# try { //** LabManagerSoap 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.
VMware® Lab Manager SOAP API Guide ListConfigurations This 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. Syntax Configuration [] config = ListConfigurations(1); Arguments Table 4-23. Arguments Field Data Type Description configurationType int 1= Workspace configurations, 2=Library configurations. Response Table 4-24.
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].
VMware® Lab Manager SOAP API Guide Response Table 4-26. Response Field Data Type Description machine[] Machine array Array of Machine objects. Sample Code: C# try { LabManagerSoap.VMwareLabManagerSOAPinterface binding = new LabManagerSoap.VMwareLabManagerSOAPinterface(); binding.Url = "https://demo18.LabManager.com/LabManager/SOAP/LabManager.asmx"; binding.Timeout = 10 * 60 * 1000; // 10 minutes ServicePointManager.CertificatePolicy = new CertificateAccepter(); binding.
Chapter 4 Lab Manager API Method Reference catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadLine(); } LiveLink This method allows you to create a LiveLink URL to a library configuration. Syntax string url = LiveLink(“LiveLinkWin2K”)); Arguments Table 4-27. Arguments Field Data Type Description configurationName string The name of a library configuration. Response Table 4-28.
VMware® Lab Manager SOAP API Guide LabManagerSoap.Configuration Config = binding.GetSingleConfigurationByName("Win2kBEA"); //** If configuration is deployed, livelink it if (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.
Chapter 4 Lab Manager API Method Reference Arguments Table 4-29. Arguments Field Data Type Description machineID int Machine identifier. action int Action to take on the machine. Response none Sample Code: C# try { LabManagerSoap.VMwareLabManagerSOAPinterface binding = new LabManagerSoap.VMwareLabManagerSOAPinterface(); binding.AuthenticationHeaderValue = new LabManagerSoap.AuthenticationHeader(); binding.AuthenticationHeaderValue.username = "jaya"; binding.AuthenticationHeaderValue.
VMware® Lab Manager SOAP API Guide //** //** 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(); } 58 VMware, Inc.
Index C O CaptureUndeployConfiguration 25 CertificateAccepter() 26 CheckoutDeployConfiguration 24 Code operations simple and advanced samples 18 supported 12 R RunQCTestset() 23 D S data types security AuthenticationHeader 29 Configuration 30 for Lab Manager 28 Machine 30 primitive XML 28 development environment supported 12 using SSL 13 SOAP API obtaining the WSDL 16 SOAP API methods ConfigurationCapture 35 ConfigurationCheckout 36 ConfigurationClone 38 ConfigurationDelete 39 G Configuration
VMware® Lab Manager SOAP API Guide T technical support resources 8 U user groups accessing 8 users authenticating 13 V VMware community forums accessing 8 60 VMware, Inc.