首页 《Lab Manager SOAP API 参考》

《Lab Manager SOAP API 参考》

举报
开通vip

《Lab Manager SOAP API 参考》 Lab Manager SOAP API 参考 vCenter Lab Manager 4.0 CN-000175-00 VMware, Inc. 3401 Hillview Ave. Palo Alto, CA 94304 www.vmware.com 2 VMware, Inc. Lab Manager SOAP API 参考 您可以在 VMware 网站上找到最新的技术文档,网址为: http://www.vmware.com/cn/support/ VMware 网站还提供最新的产...

《Lab Manager SOAP API 参考》
Lab Manager SOAP API 参考 vCenter Lab Manager 4.0 CN-000175-00 VMware, Inc. 3401 Hillview Ave. Palo Alto, CA 94304 www.vmware.com 2 VMware, Inc. Lab Manager SOAP API 参考 您可以在 VMware 网站上找到最新的技术文档,网址为: http://www.vmware.com/cn/support/ VMware 网站还提供最新的产品更新。 如果对本文档有任何意见或建议,请将反馈信息提交至以下地址: docfeedback@vmware.com © 2006-2009 VMware, Inc. 保留所有权利。此产品受到美国和国际版权法及知识产权法保护。 VMware 产品涉及 http://www.vmware.com/go/patents 中列出的一项或多项专利。 VMware、VMware“箱状”及设计、Virtual SMP 和 VMotion 均为 VMware, Inc. 在美国和/或其他法律辖区的注册商标或商 标。此处提到的所有其他商标和名称分别是其各自公司的商标。 Lab Manager 随第三方产品 AxpDataGrid 一起分发,该第三方产品的版权归 Axezz, Oslo, Norway, http://www.axezz.com/axpdatagrid 所有。 VMware, Inc. 3 目录 关于本文档 7 1 VMware vCenter Lab Manager SOAP API 简介 9 将 Lab Manager 与自动测试工具集成 9 支持的操作 9 Lab Manager 数据对象 10 符合标准的兼容性开发平台 10 SOAP API 安全性 10 用户身份验证 10 2 Lab Manager SOAP API 入门 11 开发应用程序的要求 11 获取并导入 WSDL 文件 11 将 WSDL 文件导入开发环境 11 将 Microsoft Visual Studio 与 Lab Manager WSDL 文件结合使用 12 简单和高级 C# 代码示例 13 简单 C# 示例控制台应用程序 13 将 Lab Manager 和 Quality Center 集成的高级 C# 示例 15 3 Lab Manager API 数据类型 19 原始 XML 数据类型 19 Lab Manager 数据类型 19 AuthenticationHeader 20 支持的 API 调用 20 字段 20 C# 示例代码 20 配置 21 计算机 21 4 Lab Manager API 方法引用 23 ConfigurationCapture 24 语法 24 参数 24 响应 24 C# 示例代码 24 ConfigurationCheckout 25 语法 25 参数 25 响应 25 C# 示例代码 25 ConfigurationClone 26 语法 26 参数 26 响应 26 C# 示例代码 26 ConfigurationDelete 27 语法 27 Lab Manager SOAP API 参考 4 VMware, Inc. 参数 27 响应 27 C# 示例代码 27 ConfigurationDeploy 28 语法 28 参数 28 响应 28 C# 示例代码 28 ConfigurationPerformAction 29 语法 29 参数 29 响应 29 C# 示例代码 29 ConfigurationSetPublicPrivate 30 语法 30 参数 30 响应 30 C# 示例代码 30 ConfigurationUndeploy 31 语法 31 参数 31 响应 31 C# 示例代码 31 GetConfiguration 32 语法 32 响应 32 C# 示例代码 32 GetConfigurationByName 33 语法 33 参数 33 响应 33 C# 示例代码 33 GetCurrentOrganizationName 34 语法 34 响应 34 C# 示例代码 34 GetCurrentWorkspaceName 34 语法 34 响应 34 C# 示例代码 35 GetMachine 35 语法 35 参数 35 响应 35 C# 示例代码 35 GetMachineByName 36 语法 36 参数 36 响应 36 C# 示例代码 36 GetSingleConfigurationByName 37 语法 37 参数 37 响应 37 C# 示例代码 37 ListConfigurations 38 VMware, Inc. 5 目录 语法 38 参数 38 响应 38 C# 示例代码 38 ListMachines 39 语法 39 参数 39 响应 39 C# 示例代码 39 LiveLink 40 语法 40 参数 40 响应 40 C# 示例代码 40 MachinePerformAction 41 语法 41 参数 41 响应 41 C# 示例代码 41 SetCurrentOrganizationByName 42 语法 42 参数 42 C# 示例代码 42 SetCurrentWorkspaceByName 43 语法 43 参数 43 C# 示例代码 43 索引 45 Lab Manager SOAP API 参考 6 VMware, Inc. VMware, Inc. 7 使用 VMware®《vCenter Lab Manager SOAP API 指南》,可以开发使用 Lab Manager Web 服务数据、自动 执行任务或将 Lab Manager 与其他软件测试工具集成的应用程序。 目标读者 本指南适用于要将 Lab Manager 数据用于自定义测试解决 方案 气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载 或将 Lab Manager 和其环境中的其他软件测试工 具集成的开发人员。例如,您可以使用 Lab Manager SOAP API 将 Lab Manager 与自动软件测试工具集成。 要使用本指南中的信息,您应该熟悉以下几项: „ 虚拟机技术 „ 分布式、多层系统概念 „ 开发和测试实践 „ Windows 或 Linux 操作系统 „ Web 服务、 SOAP 和 XML 文档反馈 VMware 欢迎您提出宝贵建议,以便改进我们的文档。如有意见或建议,请将反馈发送到 docfeedback@vmware.com。 技术支持和教育资源 下列各节介绍提供的技术支持资源。请通过以下网站访问本文档和其他文档的最新版本: http://www.vmware.com/cn/support/pubs。 在线支持和电话支持 要通过在线支持提交技术支持请求、查看产品和合同信息以及注册您的产品,请访问 http://www.vmware.com/cn/support。 客户只要拥有相应的支持合同,就可以通过电话支持,尽快获得对优先级高的问 快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题 的答复。请访问 http://www.vmware.com/cn/support/phone_support。 支持服务项目 要了解 VMware 支持服务如何帮助您满足业务需求,请访问 http://www.vmware.com/cn/support/services。 关于本文档 Lab Manager SOAP API 参考 8 VMware, Inc. VMware 专业服务 VMware 教育服务课程提供了大量实践操作环境、案例研究示例,以及用作作业参考工具的课程材料。这些 课程可以通过现场指导、教室授课的方式学习,也可以通过在线直播的方式学习。关于现场试点项目及实施的 最佳实践, VMware咨询服务可提供多种服务,协助您评估、计划、构建和管理虚拟环境。要了解有关教育 课程、认证计划和咨询服务的信息,请访问 http://www.vmware.com/cn/services。 VMware, Inc. 9 1 Lab Manager SOAP 应用程序编程接口 (API) 可提供对 Lab Manager 系统的编程访问。使用安全 API,您可以 连接到 Lab Manager 服务器以自动化或执行各种操作。 Lab Manager SOAP API 使用基于 XML 的技术(包括 SOAP)作为通信 协议 离婚协议模板下载合伙人协议 下载渠道分销协议免费下载敬业协议下载授课协议下载 ,使用网络服务描述语言 (WSDL) 作为界面描述语言。Lab Manager WSDL 文件详细介绍了服务(在 Web 服务中称为操作)提供的方法、服务 使用的参数类型和 SOAP 端点。 本章包含下列主题: „ “将 Lab Manager 与自动测试工具集成”(第 9 页) „ “支持的操作”(第 9 页) „ “Lab Manager 数据对象”(第 10 页) „ “符合标准的兼容性开发平台”(第 10 页) „ “SOAP API 安全性”(第 10 页) „ “用户身份验证”(第 10 页) 将 Lab Manager 与自动测试工具集成 借助 Lab Manager SOAP API,您可以使用所选语言和平台与 Lab Manager 数据交互。本指南中的示例使用 的是 C# 编程语言和 Microsoft.NET framework,此外,还支持其他编程语言和开发环境。如果您使用的不是 C# 语言,请参见有关开发环境的文档,了解有关开发 Web 服务应用程序的信息。 使用 SOAP API 除了可以扩展或自定义 Lab Manager 之外,还可以将 Lab Manager 与自动测试系统集成。您 可以在“将 Lab Manager 和 Quality Center 集成的高级 C# 示例”(第 15 页)中查看这种集成的示例。 有关 Lab Manager 解决方案、开发人员资源和社区资源的详细信息,请访问 http://www.vmware.com。 支持的操作 使用首选的启用 Web 的开发环境,您可以使用标准的 Web 服务协议构建 Web 服务客户端应用程序,以便以 编程方式执行下列任务: „ 查询虚拟机信息和配置信息。 „ 对虚拟机和配置执行操作。 „ 捕获、签出、克隆、删除和部署配置。 „ 创建您可以通过电子邮件发送给其他团队成员的 LiveLink 配置 URL。 有关支持的 Web 服务操作的详细信息,请参见“Lab Manager API 方法引用”(第 23 页)。 VMware vCenter Lab Manager SOAP API 简介 1 请注意 配置、虚拟机或模板对象的名称不应该区分大小写。 Lab Manager SOAP API 参考 10 VMware, Inc. Lab Manager 数据对象 Lab Manager SOAP API 使用对象与您组织中的数据交互。对象是 Lab Manager 数据的编程表示形式。对象 属性表示这些数据实体中的字段。例如, Lab Manager 配置由配置对象表示,配置对象包含表示配置名称、 配置数字标识符、部署状态、共享状态以及其他信息的字段。 本文档介绍了如何使用 Lab Manager 数据对象对 Lab Manager 数据执行查询、克隆、捕获和部署等操作。请 参见“Lab Manager API 数据类型”(第 19 页)。 符合标准的兼容性开发平台 Lab Manager SOAP API 符合 SOAP 1.1、WSDL 1.1 以及 WS-I Basic Profile Version 1.1(WS-I 基本配置文件 1.1 版)中确定的其他标准。 Lab Manager SOAP API 可以与符合 WS-I Basic Profile Version 1.1 标准的当前 SOAP 开发环境结合使用。本文档中的示例使用的是 Microsoft Visual Studio .NET 2005 开发环境和 C# 编程 语言。 如果您使用 Visual Studio 进行 .NET 开发, VMware 建议您使用 Visual Studio 2005 或更高版本。 SOAP API 安全性 那些访问您组织中的 Lab Manager 数据的客户端应用程序,授予 Lab Manager Web 控制台上使用的相同安全 保护的限制。 Lab Manager 使用 SSL 公开所有 SOAP API 方法。 当使用 Web 服务 URL 访问具有该 Web 服务 URL 的 SOAP API 时,可能会显示 SSL 证书警告。接受该证书以 使用 API 或将该证书替换为有效的已签署证书。 用户身份验证 客户端应用程序必须为每个 Lab Manager Web 服务方法调用提供有效的用户凭据。所需的凭据为 Lab Manager 用户帐户、密码、组织和工作区名称。必须提供包含要对其执行操作的对象的组织和/或工作区的名称。 Lab Manager 服务器会对这些凭据进行验证。 请注意 某些开发平台上存在实施差异,这可能阻止对 Lab Manager SOAP API 中的部分或所有功能的访问。 请注意 您可以使用非管理员凭据。 VMware, Inc. 11 2 您可以使用 Lab Manager SOAP API 开发 XML Web 服务客户端。 XML Web 服务客户端指任何引用和使用 XML Web 服务的组件或应用程序。这不需要基于客户端的应用程序。在很多情况下, XML Web 服务客户端 可以是其他 Web 应用程序,例如 Web 窗体,甚至是其他 XML Web 服务。 本章包含下列主题: „ “开发应用程序的要求”(第 11 页) „ “获取并导入 WSDL 文件”(第 11 页) „ “简单和高级 C# 代码示例”(第 13 页) 开发应用程序的要求 在开始开发应用程序之前,请了解下列要求: „ VMware 假定您熟悉基本编程概念,并且已经在计算机上设置了编程开发环境。 „ 网络上必须安装、配置并运行 Lab Manager 实例。 „ 必须了解 Lab Manager 服务器实例的地址,该地址以完全限定主机名或 IP 地址开头,例如 https://hostname.company.com/LabManager。 „ 您必须在目标 Lab Manager 服务器上拥有一个帐户。 „ 复制下一节中显示的代码列表,并将其粘贴到 Microsoft Visual Studio 2005 环境中。 获取并导入 WSDL 文件 与任何基于标准的 SOAP API 实施一样,Lab Manager API 定义在 Web 服务上以 XML 格式的 WSDL 文件提 供。要获取此文件,请打开 Internet Explorer 5.5 或更高版本,并导航到 https:///LabManager/SOAP/LabManager.asmx?WSDL 找到 Lab Manager 服务器。 WSDL 文件可定义所有 Lab Manager API 调用和对象。有关 WSDL 的详细信息,请访问 http://www.w3.org/TR/wsdl。 将 WSDL 文件导入开发环境 在获取 WSDL 文件之后,将其导入开发环境并生成用于构建客户端 Web 服务应用程序的必要对象。此过程取 决于开发环境、编程语言和关联的工具。例如,Microsoft Visual Studio 开发环境会自动处理这些任务。有关 其他开发平台的说明,请参见该平台的产品文档。 Lab Manager SOAP API 入门 2 Lab Manager SOAP API 参考 12 VMware, Inc. 将 Microsoft Visual Studio 与 Lab Manager WSDL 文件结合使用 Microsoft Visual Studio 编程语言通过作为其对应的服务器端代理的对象访问 Lab Manager SOAP API。当托 管代码访问 XML Web 服务时,代理类和 .NET Framework 将处理所有基础结构编码。 您必须首先从 WSDL 文件生成代理类对象,才可以将 Lab Manager SOAP API 与 Visual Studio 结合使用。 Visual Studio 提供了 [Add a Web Reference] 向导,以连接到 Web 服务并生成必要的项目。您可以将 Web 引 用添加到现有应用程序或在 Visual Studio 中创建新的应用程序。 请参见 Visual Studio 文档中的“添加和移除 Web 引用”。 使用 Microsoft Visual Studio 2005 添加 Web 引用 1 在 Windows 中,选择 [Start] > [Microsoft Visual Studio .NET 2005]。 2 选择 [New Project] 以创建新的项目,或选择 [Open] 以打开现有项目。 3 在 [URL] 文本框中,键入 https:///LabManager/SOAP/LabManager.asmx 以获取 Lab Manager Web 服务的服务描述。 4 单击 [Go]。 开始在 Lab Manager 服务器和开发环境客户端之间交换证书。将出现一个安全警示,显示从服务器发送 的证书的详细信息。 5 单击 [Yes]。 6 (可选)如果 Visual Studio 环境中出现警示,请单击 [Yes]。 Microsoft Visual Studio 环境将连接到 Web 服务端点并显示 Lab Manager Web 服务 WSDL 文件中描 述的操作。 7 选择 [Web reference name] 文本框中的文本并键入 LabManager,即用于此 Web 引用的命名空间。 LabManager 是一个词,中间没有空格。 8 单击 [Add Reference]。 9 (可选)如果出现证书警告消息,请单击 [Yes]。 10 单击 [Yes]。 Visual Studio 将检索服务描述并生成 LabManager 代理类作为应用程序与 Lab Manager Web 服务的接口。在 过程结束时,该类将添加到项目的 Web References 文件夹中。(单击 [Solution Explorer] 可查看 Web References 文件夹中列出的 LabManagerSoap。) 完成此基本设置任务之后,即可以构建使用 Lab Manager SOAP API 的客户端应用程序。熟悉 API 的最快方 法是查看“简单和高级 C# 代码示例”(第 13 页)中列出的代码示例。 请注意 当 Lab Manager 服务器使用默认的自签署证书时,将生成安全警示消息。您可以使用从 Verisign、 Thawte 和其他证书颁发机构购买的证书替换 Lab Manager 服务器上的证书。 VMware, Inc. 13 第 2章 Lab Manager SOAP API 入门 简单和高级 C# 代码示例 有关设置要求,请参见“开发应用程序的要求”(第 11 页)。 您可以使用“简单 C# 示例控制台应用程序”测试开发工作站和 Lab Manager Web 服务之间的基本 API 编程 连接性。如果您使用的编程语言不是 C#,而且 Web 服务开发环境不是 Microsoft Visual Studio 2005,请参见 相应的文档以了解详细信息。 此代码示例可执行多个简单任务。任何调用 Lab Manager Web 服务的应用程序都需要执行前两个任务。 „ 绑定到 Lab Manager SOAP API。 „ 设置用户名和密码以调用 SOAP。 „ 将 ServicePointManager 证书策略设置为接受 SSL 证书。要进行连接,必须将证书策略设置为接受所 有证书。 „ 根据对象名称调用以获得配置对象。 „ 显示控制台中的所有配置字段。 简单 C# 示例控制台应用程序 复制以下示例代码并将其粘贴到 Microsoft Visual Studio 2005 环境中。 using System; using System.Net; namespace LMConsoleApplication1 { class Class1 { /// /// The main entry point for the application. /// [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 // binding.AuthenticationHeaderValue.username = "jaya"; binding.AuthenticationHeaderValue.password = "Lab Manager"; 请注意 VMware 假定您熟悉基本编程概念,并且已经在计算机上设置了编程开发环境。 Lab Manager SOAP API 参考 14 VMware, Inc. 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 /// /// This class is needed to automatically accept the SSL certificate /// the Lab Manager sends on each API call. /// 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 第 2章 Lab Manager SOAP API 入门 将 Lab Manager 和 Quality Center 集成的高级 C# 示例 本节中的 C# .NET 示例是一个范围更广、更实际的使用 Lab Manager SOAP API 的示例。此代码示例显示了 Lab Manager SOAP API 调用与 Mercury Interactive Corporation Quality Center 产品的集成。示例代码将执 行下列任务: „ 调用 Lab Manager API (Lab Manager SOAP API) 以从库中签出配置并对其进行部署。 „ 使用 Mercury Quality Center 在已部署的配置上运行一系列预定义的测试。 „ 调用 Lab Manager SOAP API 以从工作区中捕获配置,并取消对该配置的部署。 在示例代码中使用下列方法完成上述任务: „ CheckoutDeployConfiguration( ) – 从库中获取配置并将其部署到 Lab Manager 工作区。 „ RunQCTestset() – 运行一系列预定义的 Mercury Interactive Quality Center 测试。有关预定义测试的详细 信息,请参见 Mercury Interactive Quality Center 文档。 „ CaptureUndeployConfiguration( ) – 取消对该配置的部署并将其捕获到库中。 此外, GetLMAPI() 方法将创建与 Lab Manager API 的新绑定并设置身份验证参数。此方法以编程方式将 .NET 服务点管理器的证书策略配置为接受任何证书。 GetLMAPI() 将返回 Lab Manager 绑定的实例。 复制以下示例代码并将其粘贴到 Microsoft Visual Studio 2005 环境中。 using System; using System.Configuration; using System.Collections.Specialized; using System.IO; using System.Net; using TDAPIOLELib; //** From Mercury Quality Center namespace MATRun { /// /// 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. /// class Class1 { /// /// The main entry point for the application. /// [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); Lab Manager SOAP API 参考 16 VMware, Inc. 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"; /// /// The RunQCTestset()method executes a series of predefined /// tests using Mercury Interactive’s Quality Center product. /// 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; testlist = tsf.NewList(""); foreach ( TSTest test in testlist) { VMware, Inc. 17 第 2章 Lab Manager SOAP API 入门 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. /// 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; } /// /// The CaptureUndeployConfiguration() method saves the configuration /// to the Lab Manager Library and undeploys it from the workspace. /// static void CaptureUndeployConfiguration(string configname) { // //** Bind to Lab Manager SOAP Web Service Lab Manager SOAP API 参考 18 VMware, Inc. // 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"); } /// ///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. /// 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 } } /// /// The CertificateAccepter class automatically accepts the SSL /// certificate sent by Lab Manager with each API call from a client /// application. /// 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 本章提供了有关 Lab Manager 中 API 数据类型的详细信息。 本章包含下列主题: „ “原始 XML 数据类型”(第 19 页) „ “Lab Manager 数据类型”(第 19 页) „ “AuthenticationHeader”(第 20 页) „ “配置”(第 21 页) „ “计算机”(第 21 页) 原始 XML 数据类型 Lab Manager SOAP API 数据类型基于表 3-1 中显示的原始 XML 数据类型。这些原始数据类型是用于 Lab Manager API 调用的 Lab Manager 数据类型的构建基块。 Lab Manager 数据类型 当编写客户端应用程序时,请遵守为您的编程语言和开发环境定义的数据键入规则。您的开发工具使用具有这 些 SOAP 数据类型的编程语言映射键入的数据。 Lab Manager 数据类型在 Lab Manager WSDL 文件中定义。有关详细信息,请参见“Lab Manager SOAP API 数据类型”(第 19 页)。 Lab Manager API 数据类型 3 表 3-1. Lab Manager SOAP API 中的原始 XML 数据类型 值 描述 xsd:Boolean 逻辑值,包括 true、 false、 0 和 1。 xsd:date 日期值。 xsd:dateTime 日期 /时间值(时间戳)。 xsd:double 与标准 IEEE 754-1985 中定义的 IEEE 双精度 64 位浮点类型对应的数值。 xsd:int 从 -2147483648 到 2147483647 的数值。 xsd:string 任何字符数据。 表 3-2. Lab Manager SOAP API 数据类型 数据类型 描述 AuthenticationHeader 包含调用方的用户名、密码、组织和工作区名称。这种数据类型在 Lab
本文档为【《Lab Manager SOAP API 参考》】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_720881
暂无简介~
格式:pdf
大小:736KB
软件:PDF阅读器
页数:46
分类:互联网
上传时间:2011-11-29
浏览量:17