mirror of
https://github.com/vmware/vsphere-automation-sdk-python.git
synced 2024-11-22 09:39:58 -05:00
Merge pull request #29 from tianhao64/master
Remove run_sample.sh and add a password arg for main.py
This commit is contained in:
commit
47e6c610c4
18
README.md
18
README.md
@ -70,11 +70,15 @@ Please have the details of these available but do not have any configuration pre
|
|||||||
### Running the SDK Sample Setup Script
|
### 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.
|
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.
|
||||||
|
|
||||||
First, from the command line change to the SDK ./bin folder.
|
First, set PYTHONPATH to use SDK helper methods
|
||||||
|
|
||||||
```cmd
|
* Linux/Mac:
|
||||||
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
|
|
||||||
```
|
export PYTHONPATH=${PWD}:$PYTHONPATH
|
||||||
|
|
||||||
|
* Windows:
|
||||||
|
|
||||||
|
set PYTHONPATH=%cd%;%PYTHONPATH%
|
||||||
|
|
||||||
Next, using a text editor open ../samples/vsphere/vcenter/setup/testbed.py and edit the following settings replace everything in < > brackets with your environment information. Leave the rest of the settings in this file at their default values.
|
Next, using a text editor open ../samples/vsphere/vcenter/setup/testbed.py and edit the following settings replace everything in < > brackets with your environment information. Leave the rest of the settings in this file at their default values.
|
||||||
|
|
||||||
@ -114,13 +118,13 @@ This script will perform the following:
|
|||||||
**To view the available command-line options:**
|
**To view the available command-line options:**
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -h
|
$ python ../samples/vsphere/vcenter/setup/main.py -h
|
||||||
```
|
```
|
||||||
|
|
||||||
**To run the setup script:**
|
**To run the setup script:**
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -sv
|
$ python ../samples/vsphere/vcenter/setup/main.py -sv
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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.
|
||||||
@ -131,7 +135,7 @@ This SDK includes a sample script which can be used to perform a number of actio
|
|||||||
**Run the vAPI vCenter sample suite:**
|
**Run the vAPI vCenter sample suite:**
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -riv
|
$ python ../samples/vsphere/vcenter/setup/main.py -riv
|
||||||
```
|
```
|
||||||
|
|
||||||
## API Documentation
|
## API Documentation
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
@echo off
|
|
||||||
setlocal ENABLEDELAYEDEXPANSION
|
|
||||||
:: Clear the command-prompt screen
|
|
||||||
cls
|
|
||||||
set SRCDIR=%cd%\..\
|
|
||||||
set LIBDIR=%cd%\..\lib
|
|
||||||
set PYTHONPATH=%PYTHONPATH%;%SRCDIR%
|
|
||||||
setlocal DisableDelayedExpansion
|
|
||||||
:: Run the sample
|
|
||||||
python %*
|
|
||||||
endlocal
|
|
@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
SCRIPTDIR=`dirname $0`
|
|
||||||
cd $SCRIPTDIR
|
|
||||||
PATHDIR=`pwd`
|
|
||||||
PROJECT_ROOT=$PATHDIR/..
|
|
||||||
SRCDIR=$PROJECT_ROOT/
|
|
||||||
LIBDIR=$PROJECT_ROOT/lib
|
|
||||||
|
|
||||||
# add the src directory to the python path
|
|
||||||
export PYTHONPATH=$PYTHONPATH:$SRCDIR
|
|
||||||
|
|
||||||
# run the sample
|
|
||||||
python $@
|
|
@ -10,8 +10,7 @@ This directory contains samples for Content Library APIs:
|
|||||||
|
|
||||||
Running the samples
|
Running the samples
|
||||||
|
|
||||||
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
|
$ python <sample-dir>/<sample>.py --server <vCenter Server IP> --username <username> --password <password> <additional-sample-parameters>
|
||||||
$ ./run_sample.sh ../samples/vsphere/contentlibrary/<sample-dir>/<sample>.py --server <vCenter Server IP> --username <username> --password <password> <additional-sample-parameters>
|
|
||||||
|
|
||||||
The additional sample parameters are as follows (all parameters can be displayed for any sample using option --help)
|
The additional sample parameters are as follows (all parameters can be displayed for any sample using option --help)
|
||||||
|
|
||||||
|
@ -7,8 +7,7 @@ for accessing the lookup service. The Lookup Service WSDL files are located in w
|
|||||||
|
|
||||||
Running the samples
|
Running the samples
|
||||||
```cmd
|
```cmd
|
||||||
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
|
$ python external_psc_sso_workflow.py --lsurl https://<server>/lookupservice/sdk -u 'administrator@vsphere.local' -p 'Admin!23' -v
|
||||||
$ ./run_sample.sh ../samples/vsphere/sso/external_psc_sso_workflow.py --lsurl https://<server>/lookupservice/sdk -u 'administrator@vsphere.local' -p 'Admin!23' -v
|
|
||||||
```
|
```
|
||||||
* Testbed Requirement:
|
* Testbed Requirement:
|
||||||
- 1 vCenter Server
|
- 1 vCenter Server
|
||||||
|
@ -2,8 +2,7 @@ This directory contains samples for Tagging APIs:
|
|||||||
|
|
||||||
Running the samples
|
Running the samples
|
||||||
|
|
||||||
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
|
$ python tagging_workflow.py --server <vCenter Server IP> --username <username> --password <password> --clustername <clustername> --categoryname <categoryname> --categorydesc <categorydesc> --tagname <tagname> -tagdesc <tagdesc> -v
|
||||||
$ ./run_sample.sh ../samples/vsphere/tagging/tagging_workflow.py --server <vCenter Server IP> --username <username> --password <password> --clustername <clustername> --categoryname <categoryname> --categorydesc <categorydesc> --tagname <tagname> -tagdesc <tagdesc> -v
|
|
||||||
|
|
||||||
* Testbed Requirement:
|
* Testbed Requirement:
|
||||||
- 1 vCenter Server
|
- 1 vCenter Server
|
||||||
|
@ -8,8 +8,8 @@ This directory contains samples for the vSphere infrastructure and virtual machi
|
|||||||
|
|
||||||
* with the testbed settings specified in testbed.py in a Linux machine:
|
* with the testbed settings specified in testbed.py in a Linux machine:
|
||||||
|
|
||||||
$ ./run_sample.sh ../samples/vsphere/vcenter/vm/create/create_default_vm.py -v
|
$ python samples/vsphere/vcenter/vm/create/create_default_vm.py -v
|
||||||
|
|
||||||
* Or specify the credentials using command line parameters:
|
* Or specify the credentials using command line parameters:
|
||||||
|
|
||||||
$ ./run_sample.sh ../samples/vsphere/vcenter/vm/create/create_default_vm.py -s \<server> -u \<username> -p \<password> -v
|
$ python samples/vsphere/vcenter/vm/create/create_default_vm.py -s <server> -u <username> -p <password> -v
|
||||||
|
@ -45,6 +45,8 @@ _testbed = testbed.get()
|
|||||||
# then override testbed.py values
|
# then override testbed.py values
|
||||||
if (args.vcenterserver):
|
if (args.vcenterserver):
|
||||||
_testbed.config['SERVER'] = args.vcenterserver
|
_testbed.config['SERVER'] = args.vcenterserver
|
||||||
|
if (args.vcenterpassword):
|
||||||
|
_testbed.config['PASSWORD'] = args.vcenterpassword
|
||||||
if (args.esxhost1):
|
if (args.esxhost1):
|
||||||
_testbed.config['ESX_HOST1'] = args.esxhost1
|
_testbed.config['ESX_HOST1'] = args.esxhost1
|
||||||
if (args.esxhost2):
|
if (args.esxhost2):
|
||||||
|
@ -37,6 +37,7 @@ def build_arg_parser():
|
|||||||
-l, --samples_cleanup
|
-l, --samples_cleanup
|
||||||
-v, --skipverification
|
-v, --skipverification
|
||||||
-server, --vcenterserver
|
-server, --vcenterserver
|
||||||
|
-p, --vcenterpassword
|
||||||
-e1, --esxhost1
|
-e1, --esxhost1
|
||||||
-e2, --esxhost2
|
-e2, --esxhost2
|
||||||
-epass, --esxpassword
|
-epass, --esxpassword
|
||||||
@ -91,6 +92,11 @@ def build_arg_parser():
|
|||||||
help='Vcenter server IP to prepare the testbed to run the samples.'
|
help='Vcenter server IP to prepare the testbed to run the samples.'
|
||||||
'If not passed as argument, update testbed.py file')
|
'If not passed as argument, update testbed.py file')
|
||||||
|
|
||||||
|
parser.add_argument('-p', '--vcenterpassword',
|
||||||
|
action='store',
|
||||||
|
help='Vcenter server password'
|
||||||
|
'If not passed as argument, update testbed.py file')
|
||||||
|
|
||||||
parser.add_argument('-e1', '--esxhost1',
|
parser.add_argument('-e1', '--esxhost1',
|
||||||
action='store',
|
action='store',
|
||||||
help='ESX HOST 1 IP to prepare the testbed to run the samples.'
|
help='ESX HOST 1 IP to prepare the testbed to run the samples.'
|
||||||
|
Loading…
Reference in New Issue
Block a user