From ade24a262f013497fd6cca73711f2111eef51c11 Mon Sep 17 00:00:00 2001 From: Tianhao He Date: Wed, 16 Aug 2017 22:40:55 -0700 Subject: [PATCH 1/3] remove bin directory --- README.md | 18 +++++++++++------- bin/run_sample.bat | 11 ----------- bin/run_sample.sh | 13 ------------- samples/vsphere/contentlibrary/README.md | 3 +-- samples/vsphere/sso/README.md | 3 +-- samples/vsphere/tagging/README.md | 3 +-- samples/vsphere/vcenter/README.md | 4 ++-- 7 files changed, 16 insertions(+), 39 deletions(-) delete mode 100644 bin/run_sample.bat delete mode 100755 bin/run_sample.sh diff --git a/README.md b/README.md index 4a48b091..07b5056a 100644 --- a/README.md +++ b/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 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 -$ cd /path/to/vsphere-automation-sdk-python-samples/bin -``` +* Linux/Mac: + + 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. @@ -114,13 +118,13 @@ This script will perform the following: **To view the available command-line options:** ```cmd -$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -h +$ python ../samples/vsphere/vcenter/setup/main.py -h ``` **To run the setup script:** ```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. @@ -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:** ```cmd -$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -riv +$ python ../samples/vsphere/vcenter/setup/main.py -riv ``` ## API Documentation diff --git a/bin/run_sample.bat b/bin/run_sample.bat deleted file mode 100644 index 009101a1..00000000 --- a/bin/run_sample.bat +++ /dev/null @@ -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 diff --git a/bin/run_sample.sh b/bin/run_sample.sh deleted file mode 100755 index a7f9a06d..00000000 --- a/bin/run_sample.sh +++ /dev/null @@ -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 $@ diff --git a/samples/vsphere/contentlibrary/README.md b/samples/vsphere/contentlibrary/README.md index 0c20cd95..8d700455 100644 --- a/samples/vsphere/contentlibrary/README.md +++ b/samples/vsphere/contentlibrary/README.md @@ -10,8 +10,7 @@ This directory contains samples for Content Library APIs: Running the samples - $ cd /path/to/vsphere-automation-sdk-python-samples/bin - $ ./run_sample.sh ../samples/vsphere/contentlibrary//.py --server --username --password + $ python /.py --server --username --password The additional sample parameters are as follows (all parameters can be displayed for any sample using option --help) diff --git a/samples/vsphere/sso/README.md b/samples/vsphere/sso/README.md index 0a49d366..6e569261 100644 --- a/samples/vsphere/sso/README.md +++ b/samples/vsphere/sso/README.md @@ -7,8 +7,7 @@ for accessing the lookup service. The Lookup Service WSDL files are located in w Running the samples ```cmd -$ cd /path/to/vsphere-automation-sdk-python-samples/bin -$ ./run_sample.sh ../samples/vsphere/sso/external_psc_sso_workflow.py --lsurl https:///lookupservice/sdk -u 'administrator@vsphere.local' -p 'Admin!23' -v +$ python external_psc_sso_workflow.py --lsurl https:///lookupservice/sdk -u 'administrator@vsphere.local' -p 'Admin!23' -v ``` * Testbed Requirement: - 1 vCenter Server diff --git a/samples/vsphere/tagging/README.md b/samples/vsphere/tagging/README.md index 0b9ccb6b..b9df6415 100644 --- a/samples/vsphere/tagging/README.md +++ b/samples/vsphere/tagging/README.md @@ -2,8 +2,7 @@ This directory contains samples for Tagging APIs: Running the samples - $ cd /path/to/vsphere-automation-sdk-python-samples/bin - $ ./run_sample.sh ../samples/vsphere/tagging/tagging_workflow.py --server --username --password --clustername --categoryname --categorydesc --tagname -tagdesc -v + $ python tagging_workflow.py --server --username --password --clustername --categoryname --categorydesc --tagname -tagdesc -v * Testbed Requirement: - 1 vCenter Server diff --git a/samples/vsphere/vcenter/README.md b/samples/vsphere/vcenter/README.md index 41c8386a..ea701e42 100644 --- a/samples/vsphere/vcenter/README.md +++ b/samples/vsphere/vcenter/README.md @@ -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: - $ ./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: - $ ./run_sample.sh ../samples/vsphere/vcenter/vm/create/create_default_vm.py -s \ -u \ -p \ -v + $ python samples/vsphere/vcenter/vm/create/create_default_vm.py -s -u -p -v From be279fb622ec1c3e7f9c2448f96acdf5dc1dae5b Mon Sep 17 00:00:00 2001 From: Tianhao He Date: Thu, 17 Aug 2017 00:27:34 -0700 Subject: [PATCH 2/3] add vc password parameter --- samples/vsphere/vcenter/setup/main.py | 2 ++ samples/vsphere/vcenter/setup/setup_cli.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/samples/vsphere/vcenter/setup/main.py b/samples/vsphere/vcenter/setup/main.py index c5fc110d..e4617faa 100644 --- a/samples/vsphere/vcenter/setup/main.py +++ b/samples/vsphere/vcenter/setup/main.py @@ -45,6 +45,8 @@ _testbed = testbed.get() # then override testbed.py values if (args.vcenterserver): _testbed.config['SERVER'] = args.vcenterserver +if (args.vcpassword): + _testbed.config['PASSWORD'] = args.vcpassword if (args.esxhost1): _testbed.config['ESX_HOST1'] = args.esxhost1 if (args.esxhost2): diff --git a/samples/vsphere/vcenter/setup/setup_cli.py b/samples/vsphere/vcenter/setup/setup_cli.py index 7b04d332..9d2493fe 100644 --- a/samples/vsphere/vcenter/setup/setup_cli.py +++ b/samples/vsphere/vcenter/setup/setup_cli.py @@ -91,6 +91,11 @@ def build_arg_parser(): help='Vcenter server IP to prepare the testbed to run the samples.' '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', action='store', help='ESX HOST 1 IP to prepare the testbed to run the samples.' From 44222e1dee7febe304f8abfe5c927015e040bdb8 Mon Sep 17 00:00:00 2001 From: Pavan Bidkar Date: Thu, 17 Aug 2017 23:53:35 +0530 Subject: [PATCH 3/3] Fixed argument name in main.py to vcenterpassword, which was differing with build_arg_parser() from setup_cli.py. Added Argument in help text (#3) Signed-off-by: Pavan Bidkar pbidkar@vmware.com Signed-off-by: pgbidkar --- samples/vsphere/vcenter/setup/main.py | 4 ++-- samples/vsphere/vcenter/setup/setup_cli.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/vsphere/vcenter/setup/main.py b/samples/vsphere/vcenter/setup/main.py index e4617faa..ea1a4589 100644 --- a/samples/vsphere/vcenter/setup/main.py +++ b/samples/vsphere/vcenter/setup/main.py @@ -45,8 +45,8 @@ _testbed = testbed.get() # then override testbed.py values if (args.vcenterserver): _testbed.config['SERVER'] = args.vcenterserver -if (args.vcpassword): - _testbed.config['PASSWORD'] = args.vcpassword +if (args.vcenterpassword): + _testbed.config['PASSWORD'] = args.vcenterpassword if (args.esxhost1): _testbed.config['ESX_HOST1'] = args.esxhost1 if (args.esxhost2): diff --git a/samples/vsphere/vcenter/setup/setup_cli.py b/samples/vsphere/vcenter/setup/setup_cli.py index 9d2493fe..67016736 100644 --- a/samples/vsphere/vcenter/setup/setup_cli.py +++ b/samples/vsphere/vcenter/setup/setup_cli.py @@ -37,6 +37,7 @@ def build_arg_parser(): -l, --samples_cleanup -v, --skipverification -server, --vcenterserver + -p, --vcenterpassword -e1, --esxhost1 -e2, --esxhost2 -epass, --esxpassword