Automation SDK For VMware VSphere Python Programming

2y ago
55 Views
3 Downloads
440.63 KB
78 Pages
Last View : 2m ago
Last Download : 2m ago
Upload by : Ciara Libby
Transcription

VMware vSphereAutomation SDK forPython ProgrammingGuideModified on 18 JUN 2018vSphere Automation SDK for Python 6.5vCenter Server 6.5VMware ESXi 6.5

VMware vSphere Automation SDK for Python Programming GuideYou can find the most up-to-date technical documentation on the VMware website at:https://docs.vmware.com/If you have comments about this documentation, submit your feedback todocfeedback@vmware.comVMware, Inc.3401 Hillview Ave.Palo Alto, CA 94304www.vmware.comCopyright 2015–2018 VMware, Inc. All rights reserved. Copyright and trademark information.VMware, Inc.2

ContentsAbout VMware vSphere Automation SDK for Python Programming GuideUpdated Information671 Introduction to the vSphere Automation SDKs 8vSphere Automation SDKs Overview8Supported Programming Languages102 Components of the vSphere Automation Virtualization Layer 11Components and Services of a Virtual EnvironmentvSphere Deployment Configurations11123 Retrieving Service Endpoints 15Filtering for Predefined Service Endpoints16Filter Parameters for Predefined Service Endpoints17Connect to the Lookup Service and Retrieve the Service Registration Object17Python Example of Connecting to the Lookup Service and Retrieving a Service RegistrationObject18Retrieve Service Endpoints on vCenter Server Instances18Python Example of Retrieving a Service Endpoint on a vCenter Server InstanceRetrieve a vCenter Server ID by Using the Lookup Service1920Python Example of Retrieving a vCenter Server ID by Using the Lookup ServiceRetrieve a vSphere Automation Endpoint on a vCenter Server Instance2121Python Example of Retrieving a vSphere Automation Endpoint on a vCenter Server Instance224 Authentication Mechanisms 23Retrieve a SAML Token24Python Example of Retrieving a SAML Token25Create a vSphere Automation Session with a SAML Token25Python Example of Creating a vSphere Automation API Session with a SAML TokenCreate a vSphere Automation Session with User CredentialsCreate a Web Services Session262728Python Example of Creating a Web Services Session285 Accessing vSphere Automation Services 30Access a vSphere Automation Service 30VMware, Inc.3

VMware vSphere Automation SDK for Python Programming Guide6 Content Library Service 32Content Library Overview32Content Library Types33Content Library Items33Content Library Storage33Querying Content Libraries34Listing All Content Libraries35Listing Content Libraries of a Specific Type35List Content Libraries by Using Specific Search CriteriaContent Libraries36Create a Local Content Library37Publish an Existing Content Library38Publish a Library at the Time of CreationSubscribe to a Content Library3940Synchronize a Subscribed Content LibraryEditing the Settings of a Content Library4142Removing the Content of a Subscribed LibraryDelete a Content LibraryLibrary Items35434343Create an Empty Library ItemQuerying Library Items4445Edit the Settings of a Library Item46Upload a File from a Local System to a Library ItemUpload a File from a URL to a Library Item4749Download Files to a Local System from a Library Item50Synchronizing a Library Item in a Subscribed Content LibraryRemoving the Content of a Library ItemDeleting a Library Item5152527 Content Library Support for OVF Packages 53Using the Content Library Service to Handle OVF PackagesUpload an OVF Package from a URL to a Library Item5353Upload an OVF Package from a Local File System to a Library ItemUsing the LibraryItem Service to Execute OVF-Specific Tasks5557Deploy a Virtual Machine or Virtual Appliance from an OVF Package in a Content LibraryCreate an OVF Package in a Content Library from a Virtual Machine57588 Tagging Service 60Creating Tags60Creating a Tag CategoryCreating a TagVMware, Inc.61614

VMware vSphere Automation SDK for Python Programming GuideCreating Tag Associations62Assign the Tag to a Content LibraryAssign a Tag to a ClusterUpdating a Tag626364Python Example of Updating a Tag Description649 Virtual Machine Configuration and Operations 66Filtering Virtual Machines66Python Example of Filtering Virtual MachinesCreate a Virtual Machine6767Python Example of Creating a Basic Virtual MachineConfiguring a Virtual MachineName and PlacementBoot Options696970Operating System72CPU and Memory72Networks74Performing Virtual Machine Power Operations77Python Example of Powering On a Virtual MachineVMware, Inc.67785

About VMwarevSphere Automation SDK for PythonProgramming GuideVMware vSphere Automation SDK for Python Programming Guide describes how to use the VMwarevSphere Automation SDK for Python. VMware provides different APIs and SDKs for different applicationsand goals. The vSphere Automation SDK for Python supports the development of clients that use thevSphere Automation SDK for infrastructure support tasks .Intended AudienceThis information is intended for anyone who will develop applications using thevSphere Automation SDK for Python. Some programming background in Python is required.VMware, Inc.6

Updated InformationThis VMware vSphere Automation SDK for Python Programming Guide is updated with each release ofthe product or when necessary.This table provides the update history of the VMware vSphere Automation SDK for Python ProgrammingGuide.RevisionDescription18 JUN 2018Updated some code snippets.15 NOV 2016Initial release.VMware, Inc.7

Introduction to thevSphere Automation SDKs1The vSphere Automation SDKs bundle client libraries for accessing new vSphere Automation featureslike Content Library and existing features like Tagging. The vSphere Automation SDKs contain sampleapplications and API reference documentation for the Content Library and Tagging services. ThevSphere Automation SDKs also provide sample code that retrieves the endpoints of vSphere Automationand vSphere services and establishes a secure connection with the vSphere Automation endpoint.vSphere Automation supports six languages for accessing the vSphere Automation API services andprovides six SDKs for developing client applications for managing components in your virtualenvironment.This chapter includes the following topics:nvSphere Automation SDKs OverviewnSupported Programming LanguagesvSphere Automation SDKs OverviewThe vSphere Automation API provides a unified programming interface to vSphere Automation servicesthat you can use through SDKs provided in six programming languages. The vSphere Automation APIprovides a service-oriented architecture for accessing resources in the virtual environment by issuingrequests to the vSphere Automation Endpoint.vSphere Automation API client applications communicate with services on thePlatform Services Controller and vCenter Server.VMware, Inc.8

VMware vSphere Automation SDK for Python Programming GuideFigure 1‑1. Communication Model of vSphere Automation API Client ApplicationsRetrieve serviceendpointsPlatform Services ControllerLookup ServiceEstablishauthenticatedsessionvCenter Single Sign-OnClientApplicationCommunicatewith servicesvCenter ServervSphere AutomationAPI EndpointContentLibraryТaggingServicevSphere API ServicesvSphere Automation API client applications use the Lookup Service to retrieve the vCenter Single SignOn endpoint, the vSphere Automation Endpoint, and the endpoints of services that are exposed throughthe vSphere API. To access vSphere Automation services such as Content Library and Tagging, clientapplications issue requests to the vSphere Automation Endpoint. By using the vCenter Single Sign-Onservice, client applications can either establish an authenticated vSphere Automation session, orauthenticate individual requests to the vSphere Automation Endpoint.Client applications can access services that are exposed through the vSphere API by using the vSphereManagement SDK.Depending on the vSphere deployment model, client applications can communicate withvSphere Automation services on a single vCenter Server instance or multiple vCenter Server instances.For more information about the vSphere deployment models, see Chapter 2 Components of the vSphereAutomation Virtualization LayerSDK Developer SetupTo start developing a vSphere Automation API client application, you must download the software and setup a development environment. You can find instructions for setting up a development environment in theREADME for each vSphere Automation SDK.VMware, Inc.9

VMware vSphere Automation SDK for Python Programming GuideSDK SamplesThe vSphere Automation SDKs provide sample applications that you can extend to implement clientapplications that serve your needs. The code examples in the vSphere Automation SDKs documentationare based on these sample applications.Supported Programming LanguagesThe vSphere Automation SDKs are packed in six different programming languages that let you build clientapplications on your preferred programming language.nvSphere Automation SDK for JavanvSphere Automation SDK for PythonnvSphere Automation SDK for .NETnvSphere Automation SDK for PerlnvSphere Automation SDK for RubynvSphere Automation SDK for RESTVMware, Inc.10

Components of thevSphere AutomationVirtualization Layer2At the core of vSphere Automation is vSphere, which provides the virtualization layer of the softwaredefined data center. You can use vSphere deployment options for vCenter Server and ESXi hosts to buildvirtual environments of different scales.This chapter includes the following topics:nComponents and Services of a Virtual EnvironmentnvSphere Deployment ConfigurationsComponents and Services of a Virtual EnvironmentStarting with vSphere 6.0, the deployment of the virtual environment consists of two major componentsthat provide different sets of services, the VMware Platform Services Controller and vCenter Server. Youcan deploy vCenter Server with an embedded or external Platform Services Controller.Services Installed with Platform Services ControllerThe Platform Services Controller group of infrastructure services contains vCenter Single Sign-On,License Service, Lookup Service, and VMware Certificate Authority. The services installed with thePlatform Services Controller are common to the entire virtual environment. A Platform Services Controllercan be connected to one or more vCenter Server instances. In a deployment that consists of more thanone Platform Services Controller, the data of each service is replicated across allPlatform Services Controller instances.VMware, Inc.11

VMware vSphere Automation SDK for Python Programming GuideIn vSphere Automation API client applications, you use the vCenter Single Sign-On and the LookupService on the Platform Services Controller to provide a range of functionality.Authentication andSession ManagementYou use the vCenter Single Sign-On service to establish an authenticatedsession with the vSphere Automation Endpoint. You send credentials to thevCenter Single Sign-On service and receive a SAML token that you use toobtain a session ID from the vSphere Automation Endpoint. Alternatively,you can access the vSphere Automation APIs in a sessionless manner byincluding the SAML token in every request that you issue to thevSphere Automation Endpoint.Service DiscoveryYou use the Lookup Service to discover the endpoint URL for the vCenterSingle Sign-On service on the Platform Services Controller, the location ofthe vCenter Server instances, and the vSphere Automation Endpoint.Services Installed with vCenter ServervCenter Server is a central administration point for ESXi hosts. The vCenter Server group of services contains vCenter Server, vSphere Web Client, Inventory Service, vSphere Auto Deploy , vSphere ESXi Dump Collector, VMware vSphere Syslog Collector on Windows and VMware vSphere SyslogService for the vCenter Server Appliance.vCenter Server also provides services that you can access through the vSphere Automation Endpoint.Content Library ServiceYou can use the Content Library Service to share VM templates, vApptemplates, and other files across the software-defined data center. You cancreate, share, and subscribe to content libraries on the samevCenter Server instance or on a remote instance. This promotesconsistency, compliance, efficiency, and automation in deploying workloadsat scale. By using content libraries, you can also create OVF packagesfrom virtual machines and virtual appliances in hosts, resource pools, andclusters. You can then use the OVF packages to provision new virtualmachines in hosts, resource pools, and clusters.Tagging ServiceThis service supports the definition of tags that you can associate withvSphere objects or vSphere Automation resources. ThevSphere Automation SDKs provide the capability to manage tagsprogrammatically.vSphere Deployment ConfigurationsvSphere Automation client applications communicate with services on the Platform Services Controllerand vCenter Server components of the virtual environment. vCenter Server can be deployed with anembedded or external Platform Services Controller.VMware, Inc.12

VMware vSphere Automation SDK for Python Programming GuidevCenter Server with an Embedded Platform Services ControllervCenter Server and Platform Services Controller reside on the same virtual machine or physical server.This deployment is most suitable for small environments such as development or test beds.You can use the Platform Services Controller in two ways to establish secure, authenticated sessions foryour client application, by making requests to the Lookup Service and the vCenter Single Sign-OnService.One way to use the Platform Services Controller is to request an authentication token that can be used toauthenticate requests across services. The client connects to the Lookup Service and retrieves thevCenter Single Sign-On Service endpoint and the vSphere Automation API endpoint. The client then usesthe vCenter Single Sign-On endpoint to authenticate with user credentials and receive a token thatsecurely verifies the client's credentials. This allows the client to authenticate with a number of serviceendpoints without sending user credentials over the network repeatedly.Alternatively, if the client connects directly to the vSphere Automation API endpoint, there is no need forthe client to interact with the vCenter Single Sign-On Service. The client sends user credentials to thevSphere Automation API endpoint, which creates a session identifier that persists across requests.Figure 2‑1. vCenter Server with Embedded Platform Services ControllerVM or Physical ServerPlatform Services ControllerLookupServiceSingle Sign-OnService URLvSphere AutomationEndpoint URLvCenter ServerURLOther ServicesURLsSingleSign-ONServiceSAML TokenVMware ESXivCenter ServervAPIEndpointContent LibraryServiceТaggingServiceOther ServicesVMVMware ESXiVMware, Inc.13

VMware vSphere Automation SDK for Python Programming GuidevCenter Server with an External Platform Services ControllerIn the case of an external Platform Services Controller, the vCenter Server and thePlatform Services Controller are deployed on separate virtual machines or physical servers. ThePlatform Services Controller can be shared across several vCenter Server instances. For largerdeployments or to provide better availability, more than one Platform Services Controller can be deployed.When configured as replication partners within a single vCenter Single Sign-On domain,Platform Services Controller instances replicate all user and system data within the cluster.A client application functions in a similar way as in a Platform Services Controller with embeddedvCenter Server deployment. The only difference is that the client application can access services onmultiple vCenter Server instances, or services only on a particular vCenter Server instance.Figure 2‑2. vCenter Server with External Platform Services ControllerVM or Physical ServerPlatform Services ControllerLookupServiceSingle Sign-OnService URLvSphere AutomationEndpoint URLvCenter ServerURLOther ServicesURLsSingleSign-ONServiceSAML TokenVM or Physical ServerVM or Physical ServervCenter ServervAPIEndpointVMware ESXiVMware, Inc.vCenter ServerContent LibraryServiceТaggingServiceOther ServicesVMware ESXivAPIEndpointVMware ESXiContent LibraryServiceТaggingServiceOther ServicesVMware ESXi14

Retrieving Service Endpoints3To access services and resources in the virtual environment, vSphere Automation API client applicationsmust know the endpoints of vSphere Automation and vSphere services. Client applications retrieveservice endpoints from the Lookup Service that runs on the Platform Services Controller.The Lookup Service provides service registration and discovery by using a Web services API. By usingthe Lookup Service, you can retrieve endpoints of services on the Platform Services Controller andvCenter Server. The following endpoints are available from the Lookup Service.nThe vCenter Single Sign-On endpoint on the Platform Services Controller. You use the vCenterSingle Sign-On service to get a SAML token and establish an authenticated session with avSphere Automation endpoint or a vCenter Server endpoint.nThe vSphere Automation Endpoint on vCenter Server. Through the vSphere Automation Endpoint,you can make requests to vSphere Automation API services such as virtual machine management,Content Library, and Tagging.nThe vCenter Server endpoint. In an environment with external Platform Services Controller instances,you can use the vCenter Server endpoint to get the node ID of a particular vCenter Server instance.By using the node ID , you can retrieve service endpoints on that vCenter Server instance.nThe vSphere API endpoint and endpoints of other vSphere services that run on vCenter Server.Workflow for Retrieving Service EndpointsThe workflow that you use to retrieve service endpoints from the Lookup Service might vary depending onthe endpoints that you need and their number. Follow this general workflow for retrieving serviceendpoints.1Connect to the Lookup Service on the Platform Services Controller and service registration object sothat you can query for registered services.2Create a service registration filter for the endpoints that you want to retrieve.3Use the filter to retrieve registration information for services from the Lookup Service.4Extract one or more endpoint URLs from the array of registration information that you receive fromthe Lookup Service.VMware, Inc.15

VMware vSphere Automation SDK for Python Programming GuideThis chapter includes the following topics:nFiltering for Predefined Service EndpointsnFilter Parameters for Predefined Service EndpointsnConnect to the Lookup Service and Retrieve the Service Registration ObjectnRetrieve Service Endpoints on vCenter Server InstancesnRetrieve a vCenter Server ID by Using the Lookup ServicenRetrieve a vSphere Automation Endpoint on a vCenter Server InstanceFiltering for Predefined Service EndpointsThe Lookup Service maintains a registration list of vSphere services. You can use the Lookup Service toretrieve registration information for any service by setting a registration filter that you pass to the List()function on the Lookup Service. The functions and objects that you can use with the Lookup Service aredefined in the lookup.wsdl file that is part of the SDK.Lookup Service Registration FiltersYou can query for service endpoints through a service registration object that you obtain from the LookupService. You invoke the List() function on the Lookup Service to list the endpoints that you need bypassing LookupServiceRegistrationFilter. LookupServiceRegistrationFilter identifies theservice and the endpoint type that you can retrieve.Optionally, you can include the node ID parameter in the filter to identify the vCenter Server instancewhere the endpoint is hosted. When the node ID is omitted, the List() function returns the set ofendpoint URLs for all instances of the service that are hosted on different vCenter Server instances in theenvironment.For example, a LookupServiceRegistrationFilter for querying the vSphere Automation service hasthese service endpoint elements.Table 3

Jun 18, 2018 · and goals. The vSphere Automation SDK for Python supports the development of clients that use the vSphere Automation SDK for infrastructure support tasks . Intended Audience This information is intended for anyone who will develop applications using the vSphere Automation SDK for Python . Some programming

Related Documents:

o VMware vSphere Web Client o DR to the Cloud services Optional Features: o VMware vSphereSDKs o vSphere Virtual Machine File System (VMFS) o vSphere Virtual SMP o vSphere vMotion o vSphere Storage vMotion o vSphere High Availability (HA) o vSphere Distributed Resource Scheduler (DRS) o vSphere Storage DRS o vSphere Fault Tolerance o vSphere .

1 VMware vSphere and the vSphere Web Services SDK 15 . Introduction to vSphere Clusters 219 VMware DRS 219 VMware HA 220 VMware HCI 220 Creating and Configuring Clusters 221 . 17 vSphere Performance 263 vSphere Performance Data Collection 263 PerformanceManager Objects and Methods 265

1 VMware vSphere and the vSphere Web Services SDK 15 . Introduction to vSphere Clusters 220 VMware DRS 220 VMware HA 221 VMware HCI 221 Creating and Configuring Clusters 222 . 17 vSphere Performance 264 vSphere Performance Data Collection 264 PerformanceManager Objects and Methods 266

vSphere SDK for Perl scripts on ESX/ESXi or vCenter Server systems. Important This book discusses the SDK for Perl that allows you to access vSphere by using the vSphere Web Services SDK, which is available for all supported versions of vSphere. This book does not discuss Perl bindings to vAPI, which was released with vSphere 6.0 for the first .

VMware Products 8 VMware Infrastructure 9 ESX Server 10 VirtualCenter Server 12 VI Client 12 VMware Management APIs 12 VI SDK 13 CIM APIs 14 VIX API 14 GuestSDK 14 VMware VMCI 15 Legacy APIs 15 Other APIs 15 CHAPTER 2: VI SDK BASICS 16 Overview of the VI SDK 16 What Is Included in VI SDK 2.5? 17 Object Model 17 Unified Interface with Different .

AWS SDK for JavaScript AWS SDK for JavaScript code examples AWS SDK for .NET AWS SDK for .NET code examples AWS SDK for PHP AWS SDK for PHP code examples AWS SDK for Python (Boto3) AWS SDK for Python (Boto3) code examples AWS SDK for Ruby AWS SDK for Ruby co

15. Create and manage a vSphere cluster that is enabled with VMware vSphere High Availability and VMware vSphere 16. Distributed Resource Scheduler 17. Discuss solutions for managing the vSphere life cycle 18. Use VMware vSphere Lifecycle Manager to perform upgrades to ESXi hosts and virtual machines 備註事項 1.

Autodesk AutoCAD Architecture 2017 Fundamentals 3-1. Lesson 3 . Floor Plans . The floor plan is central to any architectural drawing. In the first exercise, we convert an AutoCAD 2D floor plan to 3D. In the remaining exercises, we work in 3D. Exercise 3-1: Going from a 2D to 3D Floor plan Drawing Name: New . Estimated Time: 45 minutes