1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-26 19:29:58 -05:00
vsphere-automation-sdk-python/README.md

178 lines
9.1 KiB
Markdown
Raw Normal View History

2016-10-26 19:08:23 -04:00
# VMware vSphere Automation SDK for Python
2017-01-18 17:06:05 -05:00
2016-10-26 19:08:23 -04:00
## Table of Contents
2017-01-18 17:06:05 -05:00
- [Abstract](#abstract)
- [Quick Start Guide](#quick-start-guide)
- [Installing the required Python Packages](#installing-the-required-python-packages)
2017-01-19 00:12:41 -05:00
- [Setting up a vSphere Test Environment](#setting-up-a-vsphere-test-environment)
2017-01-18 17:06:05 -05:00
- [Running the SDK Sample Setup Script](#running-the-sdk-sample-setup-script)
- [Running a complex sample](#running-a-complex-sample)
- [API Documentation and Programming Guide](#api-documentation-and-programming-guide)
- [Submitting samples](#submitting-samples)
2017-01-19 00:12:41 -05:00
- [Required Information](#required-information)
- [Suggested Information](#suggested-information)
- [Contribution Process](#contribution-process)
- [Code Style](#code-style)
2017-01-18 17:06:05 -05:00
- [Resource Maintenance](#resource-maintenance)
- [Maintenance Ownership](#maintenance-ownership)
- [Filing Issues](#filing-issues)
- [Resolving Issues](#resolving-issues)
- [VMware Sample Exchange](#vmware-sample-exchange)
- [Repository Administrator Resources](#repository-administrator-resources)
- [Board Members](#board-members)
- [Approval of Additions](#approval-of-additions)
2016-10-26 19:08:23 -04:00
## Abstract
2017-01-24 18:39:33 -05:00
This document describes the vSphere Automation Python SDK samples that use the vSphere Automation
python client library. Additionally, some of the samples demonstrate the combined use of the
vSphere Automation and vSphere APIs. To support this combined use, the vSphere Automation Python SDK
samples require the vSphere Management SDK packages (pyVmomi) to be installed on the client.
The examples have been developed to work with python 2.7, 3.3, 3.4 and 3.5. (TODO: verify 3.6)
2016-10-26 19:08:23 -04:00
2017-01-18 16:41:28 -05:00
## Quick Start Guide
2017-01-24 18:39:33 -05:00
This document will walk you through getting up and running with the Python SDK Samples.
Prior to running the samples you will need to setup a vCenter test environment and
install local Python packages, the following steps will take you through this process.
2017-01-18 16:41:28 -05:00
Before you can run the SDK samples we'll need to walk you through the following steps:
2017-01-19 00:12:41 -05:00
1. Installing the required Python packages
2. Installing SDK provided packages
3. Setting up a vSphere test environment
2017-01-18 16:41:28 -05:00
4. Running SDK Samples setup script
2017-01-19 00:12:41 -05:00
### Installing the required Python Packages
2017-01-24 18:39:33 -05:00
**Note:** The SDK requires Python v2.7+ (preferably v3.5) to run the setup/samples,
please make sure you have the appropriate version installed before continuing.
If you are on macOS/OSX/Linux, please note that the system installed version of
Python may be outdated and/or not be intended for development and we recommended you [install Python](http://docs.python-guide.org/en/latest/starting/installation/) yourself before installing the required packages. [Virtualenv](https://virtualenv.pypa.io/en/stable/) is also highly recommended.
2017-01-19 00:12:41 -05:00
The required packages are listed in the requirements.txt file and installed using "pip install"; For more details on how to install python packages using pip please refer to the [pip user guide](http://pip.readthedocs.io/en/latest/user_guide/).
pip install -r requirements.txt
2017-01-18 16:41:28 -05:00
### Setting up a vSphere Test Environment
**NOTE:** The samples are intended to be run against a freshly installed **non-Production** vSphere setup as the scripts may make changes to the test environment and in some cases can destroy items when needed.
To run the samples a vSphere test environment is required with the following configuration
* 1 vCenter Server
* 2 ESX hosts
2017-01-19 12:21:41 -05:00
* 1 NFS Datastore with at least 3GB of free capacity
2017-01-18 16:41:28 -05:00
Please have the details of these available but do not have any configuration pre-created on vCenter server or ESXi Hosts, for example there should be no existing datacenters, clusters or attached hosts on the vCenter server.
### Running the SDK Sample Setup Script
Before executing the samples we'll need to setup the vSphere test environment using one of the sample scripts. Before we run the script we'll need to edit one of the files and provide IP addresses for the various machine instances.
2016-10-26 19:08:23 -04:00
2017-01-18 16:41:28 -05:00
First, from the command line change to the SDK ./bin folder.
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
2017-01-18 16:41:28 -05:00
2017-01-24 00:28:27 -05:00
Next, using a text editor open ../samples/vsphere/vcenter/setup/testbed.py and edit the following settings replace everything in < > brackts with your environment information. Leave the rest of the settings in this file at their default values.
2017-01-18 16:41:28 -05:00
2017-01-19 12:21:41 -05:00
config["SERVER"] = "<vcenter_hostname_or_ip>"
config["USERNAME"] = "<vsphere_username>"
config["PASSWORD"] = "<vsphere_password>"
2017-01-18 16:41:28 -05:00
config["ESX_HOST1"] = "<ESX_host1_ipaddress>"
config["ESX_HOST2"] = "<ESX_host2_ipaddress>"
2017-01-19 12:21:41 -05:00
config["ESX_USER"] = "<esx_username>"
config["ESX_PASS"] = "<esx_password>"
2017-01-18 16:41:28 -05:00
2017-01-19 12:21:41 -05:00
config["USE_NFS"] = True
config["NFS_HOST"] = "<nfs_ipaddress>"
2017-01-24 00:52:34 -05:00
config["NFS_REMOTE_PATH"] = "/store1"
2017-01-18 16:41:28 -05:00
Save and close the file.
At this point, we're ready to run the setup script.
This script will perform the following:
* Create 2 test Datacenters
* Create a test Cluster
* Create Test Folders for VM Storage
* Attach the hosts
* Create a Distributed Switch
* Create a Distributed Portgroup
* Attach the NFS datastore (if Selected) to the hosts
* Copy the [Photon OS](https://vmware.github.io/photon/) ISO image downloaded from [VMware's bintray server](https://dl.bintray.com/vmware/photon) to the datastore
* Create directories to add sample ports
**Note:** The setup script may take several minutes to complete.
**To view the available command-line options:**
2017-01-24 00:28:27 -05:00
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -h
2017-01-18 16:41:28 -05:00
**To run the setup script:**
2017-01-24 00:28:27 -05:00
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -st
2017-01-18 16:41:28 -05:00
After completion you will see from the output and also the vSphere Webclient that the environment has now been fully setup and is ready to easily run further samples.
### Running a complex sample
2017-01-24 00:28:27 -05:00
This SDK includes a sample script which can be used to perform a number of actions and give you an indication of how to perform multiple vCenter actions, this script is located in the /samples/vsphere/vcenter/setup/ directory, use the following instructions to run this sample:
2017-01-18 16:41:28 -05:00
**Run the vAPI vCenter sample suite:**
2017-01-24 00:28:27 -05:00
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -rit
2017-01-18 16:41:28 -05:00
2017-01-24 02:33:47 -05:00
## API Documentation
The API documentation can be found here : TODO
2016-10-26 19:08:23 -04:00
## Submitting samples
2017-01-18 18:34:49 -05:00
### Required Information
The following information must be included in the README.md or in the sample docstring in case README already exists in same folder.
2016-10-26 19:08:23 -04:00
* Author Name
* This can include full name, email address or other identifiable piece of information that would allow interested parties to contact author with questions.
* Date
* Date the sample was originally written
* Minimal/High Level Description
* What does the sample do ?
2017-01-18 18:34:49 -05:00
* Any KNOWN limitations or dependencies
### Suggested Information
The following information should be included when possible. Inclusion of information provides valuable information to consumers of the resource.
2016-10-26 19:08:23 -04:00
* vSphere version against which the sample was developed/tested
2017-01-18 17:27:48 -05:00
* SDK version against which the sample was developed/tested
2017-01-06 20:03:13 -05:00
* Python version against which the sample was developed/tested
2017-01-18 18:34:49 -05:00
### Contribution Process
* Follow the [GitHub process](https://help.github.com/articles/fork-a-repo)
* Please use one branch per sample or change-set
* Please use one commit and pull request per sample
* Please post the sample output along with the pull request
* If you include a license with your sample, use the project license
### Code Style
Please conform to pep8 standards. Check your code by running the pep8 tool.
https://pypi.python.org/pypi/pep8
2016-10-26 19:08:23 -04:00
## Resource Maintenance
### Maintenance Ownership
Ownership of any and all submitted samples are maintained by the submitter.
### Filing Issues
Any bugs or other issues should be filed within GitHub by way of the repositorys Issue Tracker.
### Resolving Issues
Any community member can resolve issues within the repository, however only the board member can approve the update. Once approved, assuming the resolution involves a pull request, only a board member will be able to merge and close the request.
### VMware Sample Exchange
It is highly recommended to add any and all submitted samples to the VMware Sample Exchange: <https://developercenter.vmware.com/samples>
Sample Exchange can be allowed to access your GitHub resources, by way of a linking process, where they can be indexed and searched by the community. There are VMware social media accounts which will advertise resources posted to the site and there's no additional accounts needed, as the VMware Sample Exchange uses MyVMware credentials.
2017-01-18 17:06:05 -05:00
## Repository Administrator Resources
### Board Members
2016-10-26 19:08:23 -04:00
Board members are volunteers from the SDK community and VMware staff members, board members are not held responsible for any issues which may occur from running of samples from this repository.
Members:
2017-01-18 17:40:14 -05:00
* Tianhao He (VMware)
* Steve Trefethen (VMware)
2016-10-26 19:08:23 -04:00
2017-01-18 17:06:05 -05:00
### Approval of Additions
2016-10-26 19:08:23 -04:00
Items added to the repository, including items from the Board members, require 2 votes from the board members before being added to the repository. The approving members will have ideally downloaded and tested the item. When two “Approved for Merge” comments are added from board members, the pull can then be committed to the repository.