Lab Manager SOAP API Reference vCenter Lab Manager 4.
Lab Manager SOAP API Reference You can find the most up-to-date technical documentation on the VMware 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-2009 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws.
Contents About This Book 7 1 Introducing VMware vCenter Lab Manager SOAP API 9 Integrating Lab Manager with Automated Testing Tools 9 Supported Operations 9 Lab Manager Data Objects 10 Standards Compliance and Compatible Development Platforms 10 SOAP API Security 10 User Authentication 10 2 Getting Started with the Lab Manager SOAP API 11 Requirements for Developing an Application 11 Obtaining and Importing the WSDL File 11 Importing the WSDL File to Your Development Environment 11 Use Microsoft Visual
Lab Manager SOAP API Reference Arguments 27 Response 27 C# Sample Code 27 ConfigurationDeploy 28 Syntax 28 Arguments 28 Response 28 C# Sample Code 28 ConfigurationPerformAction 29 Syntax 29 Arguments 29 Response 29 C# Sample Code 29 ConfigurationSetPublicPrivate 30 Syntax 30 Arguments 30 Response 30 C# Sample Code 30 ConfigurationUndeploy 31 Syntax 31 Arguments 31 Response 31 C# Sample Code 31 GetConfiguration 32 Syntax 32 Response 32 C# Sample Code 32 GetConfigurationByName 33 Syntax 33 Arguments 33 Respo
Contents Syntax 38 Arguments 38 Response 38 C# Sample Code 38 ListMachines 39 Syntax 39 Arguments 39 Response 39 C# Sample Code 39 LiveLink 40 Syntax 40 Arguments 40 Response 40 C# Sample Code 40 MachinePerformAction 41 Syntax 41 Arguments 41 Response 41 C# Sample Code 41 SetCurrentOrganizationByName 42 Syntax 42 Arguments 42 C# Sample Code 42 SetCurrentWorkspaceByName 43 Syntax 43 Arguments 43 C# Sample Code 43 Index 45 VMware, Inc.
Lab Manager SOAP API Reference 6 VMware, Inc.
About This Book Use the VMware® vCenter Lab Manager SOAP API Guide to develop applications that use Lab Manager Web service data, automate tasks, or integrate Lab Manager with other software testing tools. Intended Audience This guide is intended for developers who want to use Lab Manager data for customized testing solutions, or integrate Lab Manager and other software testing tools in their environment.
Lab Manager SOAP API Reference VMware Professional Services VMware Education Services courses offer extensive hands‐on labs, case study examples, and course materials designed to be used as on‐the‐job reference tools. Courses are available onsite, in the classroom, and live online. For onsite pilot programs and implementation best practices, VMware Consulting Services provides offerings to help you assess, plan, build, and manage your virtual environment.
1 Introducing VMware vCenter Lab Manager SOAP API 1 The Lab Manager SOAP application programming interface (API) provides programmatic access to the Lab Manager system. By using the secure API, you can connect to the Lab Manager server to automate or perform various operations. The Lab Manager SOAP API uses XML‐based technologies, including SOAP, as the communication protocol and Web Services Description Language (WSDL) as the interface description language.
Lab Manager SOAP API Reference Capture, checkout, clone, delete, and deploy configurations. Create a LiveLink configuration URL that you can email to other team members. For detailed information about supported Web service operations, see “Lab Manager API Method Reference” on page 23. Lab Manager Data Objects The Lab Manager SOAP API uses objects to interact with the data in your organization. Objects are programmatic representations of the Lab Manager data.
2 Getting Started with the Lab Manager SOAP API 2 You can use the Lab Manager 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 require 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.
Lab Manager SOAP API Reference Use Microsoft Visual Studio with the Lab Manager WSDL File Microsoft Visual Studio programming languages access the Lab Manager SOAP API through objects that serve as proxies for their server‐side counterparts. When managed code accesses XML Web services, a proxy class and the .NET Framework handle all of the infrastructure coding. Before you can use the Lab Manager SOAP API with Visual Studio, you must first generate the proxy class object from the WSDL file.
Chapter 2 Getting Started with the Lab Manager SOAP API Simple and Advanced C# Code Samples Review the setup requirements on “Requirements for Developing an Application” on page 11. You can test basic API programming connectivity between your development workstation and your Lab Manager Web service by using the “Simple C# Example Console Application.
Lab Manager SOAP API Reference // binding.AuthenticationHeaderValue.username = "jaya"; binding.AuthenticationHeaderValue.password = "Lab Manager"; binding.AuthenticationHeaderValue.organizationname = "MyOrg"; binding.AuthenticationHeaderValue.workspacename = "My’Workspace"; //** //** 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 Advanced C# Sample Integrating Lab Manager and Quality Center This C# .NET sample in this section is a more extensive, and more practical, sample of using the Lab Manager SOAP API. This code sample shows the integration of the Lab Manager SOAP API calls with a Mercury Interactive Corporation Quality Center product.
Lab Manager SOAP API Reference 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.
Chapter 2 Getting Started with the Lab Manager SOAP API 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 /// ///The CheckoutDeployConfiguration() method obtains the configuration ///from the Lab Manager Library and deploys it to the Lab Manager ///Workspace.
Lab Manager SOAP API Reference { // //** Bind to Lab Manager SOAP Web Service // LabManagerSoap.LabManagerSOAPinterface 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.
3 Lab Manager API Data Types 3 This chapter provides detailed information on the API data types in Lab Manager. This chapter includes the following topics: “Primitive XML Data Types” on page 19 “Lab Manager Data Types” on page 19 “AuthenticationHeader” on page 20 “Configuration” on page 21 “Machine” on page 21 Primitive XML Data Types Lab Manager SOAP API data types are based on the primitive XML data types shown in Table 3‐1.
Lab Manager SOAP API Reference Table 3-2. Lab Manager SOAP API Data Types Data Type Description AuthenticationHeader Contains the user name, password, organization, and workspace name of the caller. This data type is part of every SOAP header in Lab Manager Web Service methods. Configuration Configuration object. Machine Machine object. AuthenticationHeader This data type passes the user name, password, organization, and workspace name of the caller in all Lab Manager SOAP API methods.
Chapter 3 Lab Manager API Data Types Configuration This data type 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 that 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.
Lab Manager SOAP API Reference Table 3-5. Machine Fields (Continued) Field Data Type Description internalIP string Permanent assigned IP address. isDeployed boolean True if deployed. macAddress string MAC address assigned to the primary NIC. memory int Memory size in MB. name string Machine name. OwnerFullName string Full name of the virtual machine owner. status int 1 = Off. 2 = On. 3 = Suspended. 4 = Stuck. 128 = Invalid. 22 VMware, Inc.
4 Lab Manager API Method Reference 4 Table 4‐1 lists the vCenter Lab Manager SOAP API methods. For more detailed information about the methods and how to call them using C# .NET code samples, click the individual links. Table 4-1. Lab Manager SOAP API Methods Method Description “ConfigurationCapture” on page 24 Captures a workspace configuration and saves it to a specified Lab Manager datastore.
Lab Manager SOAP API Reference ConfigurationCapture This method captures a workspace configuration and saves it. Syntax int newConfigId = ConfigurationCapture(10, “Config10Capture”); Arguments Field Data Type Description configurationID int Configuration identifier. newLibraryName string Capture name. Response Field Data Type Description configurationID int Configuration identifier of the new capture.
Chapter 4 Lab Manager API Method Reference ConfigurationCheckout This method checks out a configuration from the library and moves it to the workspace under a different name. Syntax int result = ConfigurationCheckout(7, “Config7May10”); Arguments Field Data Type Description configurationID int Numeric identifier of the configuration in the configuration library. workspaceName string The checked‐out configuration name.
Lab Manager SOAP API Reference Console.ReadLine(); } catch (Exception e) { Console.WriteLine("Error="+e.Message); Console.ReadLine(); } ConfigurationClone This method clones a workspace configuration, saves it in a datastore, and makes it visible in the workspace under the new name. Syntax int result = ConfigurationClone(6, “Config6Clone”); Arguments Field Data Type Description configurationId int Numeric identifier of the configuration in the configuration library.
Chapter 4 Lab Manager API Method Reference ConfigurationDelete This method deletes a configuration from the workspace. You cannot delete a deployed configuration. Syntax ConfigurationDelete(6); Arguments Field Data Type Description configurationID int Numeric identifier of the workspace configuration. Response No response. C# Sample Code try { LabManagerSoap.LabManagerSOAPinterface binding = new LabManagerSoap.LabManagerSOAPinterface(); //** Create login binding.
Lab Manager SOAP API Reference ConfigurationDeploy This method allows you to deploy an undeployed configuration which resides in the workspace. Syntax ConfigurationDeploy(6, false, 1); Arguments Field Data Type Description configurationID int Numeric identifier of the configuration in the workspace. isCached boolean Always set a false value. fenceMode int 1 = Nonfenced 2 = FenceBlockInAndOut 3 = FenceAllowOutOnly 4 = FenceAllowInAndOut Response No response.
Chapter 4 Lab Manager API Method Reference ConfigurationPerformAction This 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.
Lab Manager SOAP API 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, all Lab Manager users in all organizations can access this configuration (read only). If the configuration is private, only its owner and administrators can view it.
Chapter 4 Lab Manager API Method Reference ConfigurationUndeploy Undeploys a configuration in the workspace and discards its state. Syntax ConfigurationUndeploy(10); Arguments Field Data Type Description configurationID int Configuration numeric identifier. Response No response. C# Sample Code try { LabManagerSoap.LabManagerSOAPinterface binding = new LabManagerSoap.LabManagerSOAPinterface(); binding.Url = "https://demo18.LabManager.com/LabManager/SOAP/LabManager.asmx"; binding.
Lab Manager SOAP API Reference GetConfiguration This method returns an object of type Configuration matching the configuration ID passed. Syntax Configuration config = GetConfiguration(10); Field Data Type Description configurationID int Configuration identifier. Field Data Type Description configuration Configuration Configuration object matching configuration id passed. Response C# Sample Code try { //** LabManagerSoap is the name of the Web reference in Visual Studio LabManagerSoap.
Chapter 4 Lab Manager API Method Reference GetConfigurationByName This call takes the name of a configuration and returns an array of configurations matching that name. Workspace configuration names are unique. More than one configuration with a given name can exist. If configurations with that name do not exist, an empty array is returned. Syntax Configuration [] config = GetConfigurationByName(“Config9”); Arguments Field Data Type Description name string Configuration name.
Lab Manager SOAP API Reference Console.WriteLine(); Console.ReadLine(); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadLine(); } GetCurrentOrganizationName This call returns the current organization’s name. Syntax string organizationName = GetCurrentOrganizationName(); Response Field Data Type Description organization name string Returns the current organization name. C# Sample Code try { LabManagerSoap.LabManagerSOAPinterface binding = new LabManagerSoap.
Chapter 4 Lab Manager API Method Reference C# Sample Code try { LabManagerSoap.LabManagerSOAPinterface binding = new LabManagerSoap.LabManagerSOAPinterface(); binding.AuthenticationHeaderValue = new LabManagerSoap.AuthenticationHeader(); binding.AuthenticationHeaderValue.username = "jaya"; binding.AuthenticationHeaderValue.password = "Lab Manager"; binding.AuthenticationHeaderValue.organizationname; ServicePointManager.CertificatePolicy = new CertificateAccepter(); string workspaceName = binding.
Lab Manager SOAP API Reference 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.
Chapter 4 Lab Manager API Method Reference Console.WriteLine("Error: " + e.Message); Console.ReadLine(); } GetSingleConfigurationByName This call takes a configuration name, searches for it in both the configuration library and workspace and returns its corresponding Configuration object. Syntax Configuration config = GetSingleConfigurationByName(“Config9”); Arguments Field Data Type Description name string Configuration name.
Lab Manager SOAP API Reference 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 Field Data Type Description configurationType int 1= Workspace configurations, 2=Library configurations.
Chapter 4 Lab Manager API Method Reference Console.ReadLine(); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadLine(); } ListMachines This method returns an array of type Machine. The method returns one Machine object for each virtual machine in a configuration. Syntax Machine [] machines = ListMachines(1); Arguments Field Data Type Description configurationID int Configuration numeric identifier.
Lab Manager SOAP API Reference Console.WriteLine("externalIP = " + machines[i].externalIP); Console.WriteLine("status = " + machines[i].status.ToString()); Console.WriteLine("isDeployed = " + machines[i].isDeployed.ToString()); Console.WriteLine(); } Console.ReadLine(); } } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadLine(); } LiveLink This method allows you to create a LiveLink URL to a library configuration.
Chapter 4 Lab Manager API Method Reference string url = binding.LiveLink(Config.name); Console.WriteLine("LiveLink URL="+url); Console.ReadLine(); } } catch (Exception e) { Console.WriteLine("Error="+e.Message); Console.ReadLine(); } MachinePerformAction This 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.
Lab Manager SOAP API Reference 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++) { //** //** Check status—if machine is suspended, then resume it //** if (machines[i].status == 3) { binding.
Chapter 4 Lab Manager API Method Reference string organizationName = GetCurrentOrganizationName(); Console.WriteLine("Current organization I am logged in: " + organizationName); Console.ReadLine(); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadLine(); } SetCurrentWorkspaceByName Sets the workspace to be used for each successive log in. This method works when the workspace name is empty in the authorization header.
Lab Manager SOAP API Reference 44 VMware, Inc.
Index C S CaptureUndeployConfiguration 17 CertificateAccepter() 18 CheckoutDeployConfiguration 17 security, using SSL 10 SOAP API methods ConfigurationCapture 24 ConfigurationCheckout 25 ConfigurationClone 26 ConfigurationDelete 27 ConfigurationDeploy 28 ConfigurationPerformAction 29 ConfigurationSetPublicPrivate 30 ConfigurationUndeploy 31 GetConfiguration 32 GetConfigurationByName 33 GetCurrentOrganizationName 34 GetCurrentWorkspaceName 34 GetMachine 23, 35 GetMachineByName 36 GetSingleConfigurationBy
Lab Manager SOAP API Reference 46 VMware, Inc.