VMware vCenter Lab Manager 4.0 User guide

Type
User guide
Lab Manager SOAP API Reference
vCenter Lab Manager 4.0
EN-000175-00
VMware, Inc.
3401 Hillview Ave.
Palo Alto, CA 94304
www.vmware.com
2 VMware, Inc.
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. VMware products are covered by one or more patents listed at http://www.vmware.com/go/patents.
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.
Lab Manager is distributed with AxpDataGrid, a third-party product, copyright by Axezz, Oslo, Norway,
http://www.axezz.com/axpdatagrid.
VMware, Inc. 3
Contents
AboutThisBook 7
1 IntroducingVMwarevCenterLabManagerSOAPAPI 9
IntegratingLab ManagerwithAutomatedTestingTools 9
SupportedOperations 9
LabManagerDataObjects 10
StandardsComplianceandCompatibleDevelopmentPlatforms 10
SOAPAPISecurity 10
UserAuthentication 10
2 GettingStartedwiththeLabManagerSOAPAPI 11
RequirementsforDevelopinganApplication 11
ObtainingandImportingtheWSDLFile 11
ImportingtheWSDLFiletoYourDevelopmentEnvironment 11
UseMicrosoftVisualStudiowiththeLab ManagerWSDLFile 12
SimpleandAdvancedC#CodeSamples 13
SimpleC#ExampleConsoleApplication 13
AdvancedC#SampleIntegratingLab ManagerandQualityCenter 15
3 Lab ManagerAPIDataTypes 19
PrimitiveXMLDataTypes 19
Lab ManagerDataTypes 19
AuthenticationHeader 20
SupportedAPICalls 20
Fields 20
C#SampleCode 20
Configuration 21
Machine 21
4 Lab ManagerAPIMethodReference 23
ConfigurationCapture 24
Syntax 24
Arguments 24
Response 24
C#SampleCode 24
ConfigurationCheckout 25
Syntax 25
Arguments 25
Response 25
C#SampleCode 25
ConfigurationClone 26
Syntax 26
Arguments 26
Response 26
C#SampleCode 26
ConfigurationDelete 27
Syntax 27
Lab Manager SOAP API Reference
4 VMware, Inc.
Arguments 27
Response 27
C#SampleCode 27
ConfigurationDeploy 28
Syntax 28
Arguments 28
Response 28
C#SampleCode 28
ConfigurationPerformAction 29
Syntax 29
Arguments 29
Response 29
C#SampleCode 29
ConfigurationSetPublicPrivate 30
Syntax 30
Arguments 30
Response 30
C#SampleCode 30
ConfigurationUndeploy 31
Syntax 31
Arguments 31
Response 31
C#SampleCode 31
GetConfiguration 32
Syntax 32
Response 32
C#SampleCode 32
GetConfigurationByName 33
Syntax 33
Arguments 33
Response 33
C#SampleCode 33
GetCurrentOrganizationName 34
Syntax 34
Response 34
C#SampleCode 34
GetCurrentWorkspaceName 34
Syntax 34
Response 34
C#SampleCode 35
GetMachine 35
Syntax 35
Arguments 35
Response 35
C#SampleCode 35
GetMachineByName 36
Syntax 36
Arguments 36
Response 36
C#SampleCode 36
GetSingleConfigurationByName 37
Syntax 37
Arguments 37
Response 37
C#SampleCode 37
ListConfigurations 38
VMware, Inc. 5
Contents
Syntax 38
Arguments 38
Response 38
C#SampleCode 38
ListMachines 39
Syntax 39
Arguments 39
Response 39
C#SampleCode 39
LiveLink 40
Syntax 40
Arguments 40
Response 40
C#SampleCode 40
MachinePerformAction 41
Syntax 41
Arguments 41
Response 41
C#SampleCode 41
SetCurrentOrganizationByName 42
Syntax 42
Arguments 42
C#SampleCode 42
SetCurrentWorkspaceByName 43
Syntax 43
Arguments 43
C#SampleCode 43
Index 45
Lab Manager SOAP API Reference
6 VMware, Inc.
VMware, Inc. 7
UsetheVMware
®
vCenterLab ManagerSOAPAPIGuidetodevelopapplicationsthatuseLab ManagerWeb
servicedata,automatetasks,orintegrateLab Managerwithothersoftwaretestingtools.
Intended Audience
ThisguideisintendedfordeveloperswhowanttouseLab Managerdataforcustomizedtestingsolutions,or
integrateLab Managerandothersoftwaretestingtoolsintheirenvironment.Forexample,usingthe
Lab ManagerSOAPAPIletsyouintegrateLab Managerwithautomatedsoftwaretestingtools.
Tousetheinformationinthisguide,you
shouldbefamiliarwiththefollowingitems:
Virtualmachinetechnology
Distributed,multitieredsystemsconcepts
Developmentandtestingpractices
WindowsorLinuxoperatingsystems
WebServices,SOAP,andXML
Document Feedback
VMwarewelcomesyoursuggestionsforimprovingourdocumentation.Ifyouhavecomments,sendyour
feedbacktodocfeedback@vmware.com.
Technical Support and Education Resources
Thefollowingsectionsdescribethetechnicalsupportresourcesavailabletoyou.Toaccessthecurrentversion
ofthisbookandotherbooks,gotohttp://www.vmware.com/support/pubs.
Online and Telephone Support
Touseonlinesupporttosubmittechnicalsupportrequests,viewyourproductandcontractinformation,and
registeryourproducts,gotohttp://www.vmware.com/support.
Customerswithappropriatesupportcontractsshouldusetelephonesupportforthefastestresponseon
priority1issues.Gotohttp://www.vmware.com/support/phone_support.
Support Offerings
TofindouthowVMwaresupportofferingscanhelpmeetyourbusinessneeds,goto
http://www.vmware.com/support/services.
About This Book
Lab Manager SOAP API Reference
8 VMware, Inc.
VMware Professional Services
VMwareEducationServicescoursesofferextensivehandsonlabs,casestudyexamples,andcoursematerials
designedtobeusedasonthejobreferencetools.Coursesareavailableonsite,intheclassroom,andlive
online.Foronsitepilotprograms andimplementationbestpractices,VMwareConsultingServicesprovides
offeringsto helpyouassess,plan,
build,andmanageyourvirtualenvironment.Toaccessinformationabout
educationclasses,certificationprograms,andconsultingservices,gotohttp://www.vmware.com/services.
VMware, Inc. 9
1
TheLab ManagerSOAPapplicationprogramminginterface(API)providesprogrammaticaccesstothe
Lab Managersystem.ByusingthesecureAPI,youcanconnecttotheLab Managerservertoautomateor
performvariousoperations.
TheLab ManagerSOAPAPIusesXMLbasedtechnologies,includingSOAP,asthecommunicationprotocol
andWebServicesDescriptionLanguage
(WSDL)astheinterfacedescriptionlanguage.TheLab Manager
WSDLfiledetailstheavailablemethodsoftheservice(calledoperationsinWebServices),parametertypesand
theSOAPendpointfortheservice.
Thischapterincludesthefollowingtopics:
“IntegratingLab ManagerwithAutomatedTestingTools”onpage 9
“SupportedOperations”onpage 9
“LabManagerDataObjects”onpage 10
“StandardsComplianceandCompatibleDevelopmentPlatforms”onpage 10
“SOAPAPISecurity”onpage 10
“UserAuthentication”onpage 10
Integrating Lab Manager with Automated Testing Tools
TheLab ManagerSOAPAPIallowsyoutointeractwithLab Managerdatausingthelanguageandplatform
ofyourchoice.TheexamplesinthisguideusetheC#programminglanguageandtheMicrosoft.NET
framework,butotherprogramminglanguagesanddevelopmentenvironmentsarealsosupported.Ifyouare
usingalanguageother
thanC#,seethedocumentationaboutyourdevelopmentenvironmentforcomparable
informationaboutdevelopingWebserviceapplications.
InadditiontoextendingorcustomizingLab ManagerbyusingtheSOAPAPI,youcanalsointegrate
Lab Managerwithautomatedtestingsystems.YoucanseeanexampleofthisintegrationinAdvancedC#
SampleIntegrating
Lab ManagerandQualityCenteronpage 15.
FormoreinformationaboutLab Managersolutions,developerresources,andcommunityresources,goto
http://www.vmware.com.
Supported Operations
UsingyourpreferredWebenableddevelopmentenvironment,youcanconstructWebserviceclient
applicationsusingstandardWebserviceprotocolstoprogrammaticallyperformthefollowingtasks:
Queryforvirtualmachineandconfigurationinformation.
Performactionsonmachinesandconfigurations.
Introducing VMware vCenter Lab
Manager SOAP API
1
Lab Manager SOAP API Reference
10 VMware, Inc.
Capture,checkout,clone,delete,anddeployconfigurations.
CreateaLiveLinkconfigurationURLthatyoucanemailtootherteammembers.
FordetailedinformationaboutsupportedWebserviceoperations,see“Lab ManagerAPIMethodReference”
onpage 23.
Lab Manager Data Objects
TheLab ManagerSOAPAPIusesobjectstointeractwiththedatainyourorganization.Objectsare
programmaticrepresentationsoftheLab Managerdata.Objectpropertiesrepresentfieldsinthosedata
entities.Forexample,aLab ManagerconfigurationisrepresentedbyaConfigurationobject,whichhasfields
thatrepresenttheconfigurationname,configurationnumeric
identifier,deploymentstatus,sharedstate,and
more.
ThisdocumentdescribeshowtousetheLabManagerdataobjectstoperformoperationssuchasquery,clone,
capture,anddeployonLab Managerdata.See“Lab ManagerAPIDataTypesonpage 19.
Standards Compliance and Compatible Development Platforms
TheLab ManagerSOAPAPIcomplieswithSOAP1.1,WSDL1.1,andotherstandardsidentifiedintheWSI
BasicProfileVersion1.1.TheLab ManagerSOAPAPIworkswithcurrentSOAPdevelopmentenvironments
thatadheretotheBasicProfileVersion1.1standards.TheexamplesinthisdocumentusetheMicrosoftVisual
Studio
.NET2005developmentenvironmentandtheC#programminglanguage.
Ifyouare usingVisualStudiofor.NETdevelopment,VMwarerecommendsthatyouuseVisualStudio2005
orlater.
SOAP API Security
ClientapplicationsthataccesstheLab Managerdatainyourorganizationaresubjecttothesamesecurity
protectionsthatareusedintheLab ManagerWebconsole.Lab ManagerusesSSLexposesallSOAPAPI
methods.
WhenyouusetheWebserviceURLtoaccesstheSOAPAPIwiththeWebserviceURL,you
mightseeanSSL
certificatewarning.AcceptthecertificatetousetheAPIorreplacethecertificatewithavalidsignedcertificate.
User Authentication
ClientapplicationsmustprovidevalidusercredentialswitheachLab ManagerWebservicemethodcall.
The requiredcredentialsareaLab Manageruseraccount,password,organization,andworkspacename.
You mustprovidethenameoftheorganizationand/orworkspacethatcontainstheobjectsonwhichyouwant
toperformoperations.TheLab Managerserverauthenticatesthese
credentials.
N
OTEImplementationdifferencesincertaindevelopmentplatformsmightpreventaccesstosomeorallof
thefeaturesintheLab ManagerSOAPAPI.
NOTEYoucanusenonadministratorcredentials.
VMware, Inc. 11
2
YoucanusetheLab ManagerSOAPAPItodevelopanXMLWebserviceclient.AnXMLWebserviceclientis
anycomponentorapplicationthatreferencesandusesanXMLWebservice.Thisdoesnotrequirea
clientbasedapplication.Inmanycases,XMLWebserviceclientsmightbeotherWeb
applications,suchas
WebFormsorevenotherXMLWebservices.
Thischapterincludesthefollowingtopics:
“RequirementsforDevelopinganApplication”onpage 11
“ObtainingandImportingtheWSDLFile”onpage 11
“SimpleandAdvancedC#CodeSamples”onpage 13
Requirements for Developing an Application
Beforeyoucanstartdevelopinganapplication,reviewtheserequirements:
VMwareassumesthatyouarefamiliarwithbasicprogrammingconceptsandalreadyhavea
programmingdevelopmentenvironmentsetuponyourcomputer.
YoumusthaveaninstanceofLab Managerinstalled,configured,andrunningonyournetwork.
YoumustknowtheaddressoftheLab Managerserverinstance,startingwithitsfullyqualifiedhostname
orIPaddress,forexample,https://hostname.company.com/LabManager.
YoumusthaveanaccountonthetargetLab Managerserver.
Copythecodelistingdisplayedinthenextsection,andpasteitintoyourMicrosoftVisualStudio2005
environment.
Obtaining and Importing the WSDL File
AswithanystandardsbasedSOAPAPIimplementation,theLab ManagerAPIdefinitionisavailableonthe
WebserviceasanXMLformattedWSDLfile.Toobtainthisfile,openInternetExplorer5.5orlaterand
navigatetohttps://<hostname>/LabManager/SOAP/LabManager.asmx?WSDLforyourLab Managerserver.
TheWSDLfiledefinesalltheLab ManagerAPI
callsandobjects.FormoreinformationonWSDL,goto
http://www.w3.org/TR/wsdl.
Importing the WSDL File to Your Development Environment
AfteryouobtaintheWSDLfile,importittoyourdevelopmentenvironmentandgeneratethenecessaryobjects
foruseinbuildingclientWebserviceapplications.Theprocessdependsonyourdevelopmentenvironment,
programminglanguage,andassociatedtools.Forexample,theMicrosoftVisualStudiodevelopment
environmenthandlesthetasksautomatically.Forinstructions
aboutotherdevelopmentplatforms,seethe
productdocumentationforyourplatform.
Getting Started with the Lab Manager
SOAP API
2
Lab Manager SOAP API Reference
12 VMware, Inc.
Use Microsoft Visual Studio with the Lab Manager WSDL File
MicrosoftVisualStudioprogramminglanguagesaccesstheLab ManagerSOAPAPIthroughobjectsthat
serveasproxiesfortheirserversidecounterparts.WhenmanagedcodeaccessesXMLWebservices,aproxy
classandthe.NETFrameworkhandlealloftheinfrastructurecoding.
BeforeyoucanusetheLab ManagerSOAPAPIwithVisual
Studio,youmustfirstgeneratetheproxyclass
objectfromtheWSDLfile.VisualStudioprovidesanAddaWebReferencewizardtoconnecttoaWebservice
andgeneratethenecessaryartifacts.YoucanaddaWebreferencetoanexistingapplicationorcreateanew
applicationinVisualStudio.
SeeAddingandRemovingWebReferencesintheVisualStudiodocumentation.
To add a Web reference by using Microsoft Visual Studio 2005
1InWindows,selectStart>MicrosoftVisualStudio.NET2005.
2 SelectNewProjecttocreateanewproject,orselectOpentoopenanexistingproject.
3IntheURLtextbox,typehttps://<hostname>/LabManager/SOAP/LabManager.asmxtoobtainthe
servicedescriptionofthe
Lab ManagerWebservice.
4ClickGo.
ThecertificateexchangebetweentheLab Managerserverandthedevelopmentenvironmentclient
begins.Asecurityalertdisplaysthedetailsofthecertificatesentfromtheserver.
5ClickYes.
6 (Optional)IfalertfromtheVisualStudioenvironmentappears,clickYes.
TheMicrosoftVisualStudioenvironmentconnectsto
theWebserviceendpointanddisplaysthe
operationsdescribedintheLab ManagerWebserviceWSDLfile.
7 SelectthetextintheWebreferencenametextboxandtypeLabManager,thenamespaceusedforthisWeb
reference.
LabManagerisoneword,withoutspaces.
8ClickAddReference.
9 (Optional)Ifacertificatewarningmessage
appears,clickYes.
10 ClickYes.
VisualStudioretrievestheservicedescriptionandgeneratestheLabManagerproxyclassthatservesasan
interfacetotheLab ManagerWebservicefromyourapplication.Attheendoftheprocess,theclassisadded
totheWebReferencesfolderoftheproject.(ClickSolutionExplorer
toseeLabManagerSoaplistedintheWeb
Referencesfolder .)
Withthisbasicsetuptaskcompleted,youcanbuildclientapplicationsthatusetheLab ManagerSOAPAPI.
ThefastestwaytobecomefamiliarwiththeAPIisbyreviewingthecodesampleslistedin“Simpleand
AdvancedC#CodeSamples”onpage 13.
N
OTEThesecurityalertmessagesaregeneratedwhentheLab Managerserverusesthedefault,
selfsignedcertificates.YoucanreplacethesecertificatesontheLab Managerserverwithcertificates
purchasedfromVerisign,Thawte,andothercertificateauthorities.
VMware, Inc. 13
Chapter 2 Getting Started with the Lab Manager SOAP API
Simple and Advanced C# Code Samples
Reviewthesetuprequirementson“RequirementsforDevelopinganApplication”onpage 11.
YoucantestbasicAPIprogrammingconnectivitybetweenyourdevelopmentworkstationandyour
Lab ManagerWebservicebyusingthe“SimpleC#ExampleConsoleApplication.”Ifyouareusinga
programminglanguageotherthanC#andaWebservicesdevelopment
environmentotherthanMicrosoft
VisualStudio2005,seetheappropriatedocumentationformoreinformation.
Thiscodesampleperformsseveralsimpletasks.Thefirsttwotasksarerequiredofanyapplicationthatmakes
callstoaLab ManagerWebservice.
BindstotheLab ManagerSOAPAPI.
SetsuptheusernameandpasswordformakingaSOAPcall.
SetsuptheServicePointManagercertificatepolicytoaccepttheSSLcertificate.ToconnecttotheYoumust
setupthecertificatepolicytoacceptallcertificates.
Makesacalltogetaconfigurationobjectbasedontheobject’sname.
Displaysallconfigurationfieldsintheconsole.
Simple C# Example Console Application
CopythissamplecodeandpasteitintoyourMicrosoftVisualStudio2005environment.
using 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
//
LabManagerSoap.LabManagerSOAPinterface binding =
new LabManagerSoap.LabManagerSOAPinterface();
//
//** Enter the URL for your system here
//
binding.Url ="https://10.6.1.248/LabManager/SOAP/LabManager.asmx”;
binding.Timeout = 10 * 60 * 1000; // 10 minutes
ServicePointManager.CertificatePolicy = new CertificateAccepter();
//**
//** Allocate AuthenticationHeader object to hold caller’s
//** user name and password
//**
binding.AuthenticationHeaderValue = new
LabManagerSoap.AuthenticationHeader();
//
//** Substitute a real user’s user name, password, organization, and workspace
name here
NOTEVMwareassumesyouarefamiliarwithbasicprogrammingconceptsandalreadyhaveaprogramming
developmentenvironmentsetuponyourcomputer.
Lab Manager SOAP API Reference
14 VMware, Inc.
//
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.GetSingleConfigurationByName("Sample Configuration");
//
//** Print out 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)
{
return true;
}
}
} //** end Namespace}
VMware, Inc. 15
Chapter 2 Getting Started with the Lab Manager SOAP API
Advanced C# Sample Integrating Lab Manager and Quality Center
ThisC#.NETsampleinthissectionisamoreextensive,andmorepractical,sampleofusingtheLab Manager
SOAPAPI.ThiscodesampleshowstheintegrationoftheLab ManagerSOAPAPIcallswithaMercury
InteractiveCorporationQualityCenterproduct.Thesamplecodeperformsthesetasks:
MakesLab ManagerAPI(Lab ManagerSOAPAPI)callstocheckoutaconfigurationfromthelibraryand
deployit.
UsesMercuryQualityCentertorunaseriesofpredefinedtestsonthedeployedconfiguration.
MakesLab ManagerSOAPAPIcallstocapturetheconfigurationandundeployitfromtheworkspace.
Thesetasksareaccomplishedinthesamplecodeusingthesemethods:
CheckoutDeployConfiguration()Obtainstheconfigurationfromthelibraryanddeploysittothe
Lab Managerworkspace.
RunQCTestset()RunsaseriesofpredefinedMercuryInteractiveQualityCentertests.Formore
informationaboutthepredefinedtests,seetheMercuryInteractiveQualityCenterdocumentation.
CaptureUndeployConfiguration()Undeploystheconfigurationandcapturesittothelibrary.
Inaddition,theGetLMAPI()methodcreatesanewbindingtotheLab ManagerAPIandsetsupauthentication
parameters.Thismethodconfiguresthecertificatepolicyforthe.NETservicepointmanagertoacceptany
certificateprogrammatically.GetLMAPI()returnsaninstanceof
theLab Managerbinding.
CopythissamplecodeandpasteitintoyourMicrosoftVisualStudio2005environment.
using System;
using System.Configuration;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using TDAPIOLELib; //** From Mercury Quality Center
namespace MATRun
{
/// <summary>
/// Class1 comprises methods to check out a configuration from the Lab
/// Manager Library and deploy it 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";
}
Lab Manager SOAP API Reference
16 VMware, Inc.
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
//
//** 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 predefined
/// 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;
tsf = (TSTestFactory) testSet.TSTestFactory;
TDAPIOLELib.List testlist;
VMware, Inc. 17
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
///<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 to the Workspace
string srcconfig = "ProofOfBuild-R2"; //** Configuration name
System.DateTime time = System.DateTime.Now;
string configname = version+"-"+
time.ToString().Replace(" ", "_").Replace("/","-");
//
//** Bind to Lab Manager SOAP Web service
//
LabManagerSoap.LabManagerSOAPinterface 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
//** name it(configname)
//
int newCheckoutID = binding.ConfigurationCheckout(config.id, configname);
Console.WriteLine("Deploy configuratioin "+ srcconfig);
//
//** Deploy Configuration
//** false = Do not run images from ESX host
//** 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 undeploys it from the workspace.
///</summary>
static void CaptureUndeployConfiguration(string configname)
Lab Manager SOAP API Reference
18 VMware, Inc.
{
//
//** 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.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.LabManagerSOAPinterface GetLMAPI()
{
//
//** Bind to SOAP interface
//
LabManagerSoap.LabManagerSOAPinterface binding = new
LabManagerSoap.LabManagerSOAPinterface();
//
//**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.AuthenticationHeaderValue.organizationname = "MyOrg";
binding.AuthenticationHeaderValue.workspacename = "MyWorkspace";
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
VMware, Inc. 19
3
ThischapterprovidesdetailedinformationontheAPIdatatypesinLab Manager.
Thischapterincludesthefollowingtopics:
“PrimitiveXMLDataTypesonpage 19
“Lab ManagerDataTypesonpage 19
AuthenticationHeaderonpage 20
“Configuration”onpage 21
“Machine”onpage 21
Primitive XML Data Types
Lab ManagerSOAPAPIdatatypesarebasedontheprimitiveXMLdatatypesshowninTable 31.These
primitivedatatypesarethebuildingblocksfortheLab ManagerdatatypesusedinmakingLab ManagerAPI
calls.
Lab Manager Data Types
Whenyouwriteyourclientapplication,followthedatatypingrulesdefinedforyourprogramminglanguage
anddevelopmentenvironment.Yourdevelopmenttoolmapsthetypeddatainyourprogramminglanguage
withtheseSOAPdatatypes.
TheLab ManagerdatatypesaredefinedintheLab ManagerWSDLfile.See“LabManagerSOAPAPI
Data
Typesonpage 20formoreinformation.
Lab Manager API Data Types
3
Table 3-1. Primitive XML Data Types in the Lab Manager SOAP API
Value Description
xsd:Boolean Alogicalvalue,includingtrue,false,0,and1.
xsd:date Datevalues.
xsd:dateTime Date/timevalues(timestamps).
xsd:double NumericvaluethatcorrespondstotheIEEEdoubleprecision64bitfloatingpointtypedefined
inthestandardIEEE7541985.
xsd:int Numericvaluefrom‐2147483648to2147483647.
xsd:string Anycharacterdata.
Lab Manager SOAP API Reference
20 VMware, Inc.
AuthenticationHeader
Thisdatatypepassestheusername,password,organization,andworkspacenameofthecallerinall
Lab ManagerSOAPAPImethods.
Supported API Calls
ThisdatatypesupportsallAPIcalls.
Fields
C# Sample Code
/**
** 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.LabManagerSOAPinterface binding = new
LabManagerSoap.LabManagerSOAPinterface();
binding.AuthenticationHeaderValue =new
LabManagerSoap.AuthenticationHeader();
binding.AuthenticationHeaderValue.username = "hedley";
binding.AuthenticationHeaderValue.password = "Lab Manager";
binding.AuthenticationHeaderValue.organizationname = "MyOrg";
binding.AuthenticationHeaderValue.workspacename = "MyWorkspace";
ServicePointManager.CertificatePolicy = new CertificateAccepter();
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
Console.ReadLine();
}
Table 3-2. Lab Manager SOAP API Data Types
Data Type Description
AuthenticationHeader Containstheusername,password,organization,andworkspacenameofthecaller.
This datatypeispartofeverySOAPheaderinLab ManagerWebServicemethods.
Configuration Configurationobject.
Machine Machineobject.
Table 3-3. AuthenticationHeader Fields
Field Data Type Description
organizationname string Lab Managerorganizationname.
password string Lab Manageraccountpassword.
username string Lab Manageraccountusername.
workspacename string Lab Managerworkspacename
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42
  • Page 43 43
  • Page 44 44
  • Page 45 45
  • Page 46 46

VMware vCenter Lab Manager 4.0 User guide

Type
User guide

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI