Skip to content

Commit 47e6c61

Browse files
authored
Merge pull request #29 from tianhao64/master
Remove run_sample.sh and add a password arg for main.py
2 parents 58b044f + 44222e1 commit 47e6c61

File tree

9 files changed

+24
-39
lines changed

9 files changed

+24
-39
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,15 @@ Please have the details of these available but do not have any configuration pre
7070
### Running the SDK Sample Setup Script
7171
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.
7272

73-
First, from the command line change to the SDK ./bin folder.
73+
First, set PYTHONPATH to use SDK helper methods
7474

75-
```cmd
76-
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
77-
```
75+
* Linux/Mac:
76+
77+
export PYTHONPATH=${PWD}:$PYTHONPATH
78+
79+
* Windows:
80+
81+
set PYTHONPATH=%cd%;%PYTHONPATH%
7882

7983
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.
8084

@@ -114,13 +118,13 @@ This script will perform the following:
114118
**To view the available command-line options:**
115119

116120
```cmd
117-
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -h
121+
$ python ../samples/vsphere/vcenter/setup/main.py -h
118122
```
119123

120124
**To run the setup script:**
121125

122126
```cmd
123-
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -sv
127+
$ python ../samples/vsphere/vcenter/setup/main.py -sv
124128
```
125129

126130
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
131135
**Run the vAPI vCenter sample suite:**
132136

133137
```cmd
134-
$ ./run_sample.sh ../samples/vsphere/vcenter/setup/main.py -riv
138+
$ python ../samples/vsphere/vcenter/setup/main.py -riv
135139
```
136140

137141
## API Documentation

bin/run_sample.bat

Lines changed: 0 additions & 11 deletions
This file was deleted.

bin/run_sample.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

samples/vsphere/contentlibrary/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ This directory contains samples for Content Library APIs:
1010

1111
Running the samples
1212

13-
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
14-
$ ./run_sample.sh ../samples/vsphere/contentlibrary/<sample-dir>/<sample>.py --server <vCenter Server IP> --username <username> --password <password> <additional-sample-parameters>
13+
$ python <sample-dir>/<sample>.py --server <vCenter Server IP> --username <username> --password <password> <additional-sample-parameters>
1514

1615
The additional sample parameters are as follows (all parameters can be displayed for any sample using option --help)
1716

samples/vsphere/sso/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ for accessing the lookup service. The Lookup Service WSDL files are located in w
77

88
Running the samples
99
```cmd
10-
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
11-
$ ./run_sample.sh ../samples/vsphere/sso/external_psc_sso_workflow.py --lsurl https://<server>/lookupservice/sdk -u '[email protected]' -p 'Admin!23' -v
10+
$ python external_psc_sso_workflow.py --lsurl https://<server>/lookupservice/sdk -u '[email protected]' -p 'Admin!23' -v
1211
```
1312
* Testbed Requirement:
1413
- 1 vCenter Server

samples/vsphere/tagging/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ This directory contains samples for Tagging APIs:
22

33
Running the samples
44

5-
$ cd /path/to/vsphere-automation-sdk-python-samples/bin
6-
$ ./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
5+
$ python tagging_workflow.py --server <vCenter Server IP> --username <username> --password <password> --clustername <clustername> --categoryname <categoryname> --categorydesc <categorydesc> --tagname <tagname> -tagdesc <tagdesc> -v
76

87
* Testbed Requirement:
98
- 1 vCenter Server

samples/vsphere/vcenter/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ This directory contains samples for the vSphere infrastructure and virtual machi
88

99
* with the testbed settings specified in testbed.py in a Linux machine:
1010

11-
$ ./run_sample.sh ../samples/vsphere/vcenter/vm/create/create_default_vm.py -v
11+
$ python samples/vsphere/vcenter/vm/create/create_default_vm.py -v
1212

1313
* Or specify the credentials using command line parameters:
1414

15-
$ ./run_sample.sh ../samples/vsphere/vcenter/vm/create/create_default_vm.py -s \<server> -u \<username> -p \<password> -v
15+
$ python samples/vsphere/vcenter/vm/create/create_default_vm.py -s <server> -u <username> -p <password> -v

samples/vsphere/vcenter/setup/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
# then override testbed.py values
4646
if (args.vcenterserver):
4747
_testbed.config['SERVER'] = args.vcenterserver
48+
if (args.vcenterpassword):
49+
_testbed.config['PASSWORD'] = args.vcenterpassword
4850
if (args.esxhost1):
4951
_testbed.config['ESX_HOST1'] = args.esxhost1
5052
if (args.esxhost2):

samples/vsphere/vcenter/setup/setup_cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def build_arg_parser():
3737
-l, --samples_cleanup
3838
-v, --skipverification
3939
-server, --vcenterserver
40+
-p, --vcenterpassword
4041
-e1, --esxhost1
4142
-e2, --esxhost2
4243
-epass, --esxpassword
@@ -91,6 +92,11 @@ def build_arg_parser():
9192
help='Vcenter server IP to prepare the testbed to run the samples.'
9293
'If not passed as argument, update testbed.py file')
9394

95+
parser.add_argument('-p', '--vcenterpassword',
96+
action='store',
97+
help='Vcenter server password'
98+
'If not passed as argument, update testbed.py file')
99+
94100
parser.add_argument('-e1', '--esxhost1',
95101
action='store',
96102
help='ESX HOST 1 IP to prepare the testbed to run the samples.'

0 commit comments

Comments
 (0)