Run the whole sample suite which contains all vCenter samples using main.py in samples.vsphere.vcenter.setup package. Please see the README in the setup package for detailed steps.
Run an individual sample in an existing environment. You can either pass the environment parameters through command line arguments or specify them in setup.py in the setup package.
<h2>Sample Program Structure for the Content Library and Tagging Samples</h2>
<p>
The Content Library and Tagging samples use a framework to facilitate different
aspects of using the samples. Some of the framework capabilities are:
<ul>
<li>Command line argument parsing.</li>
<li>Specifying mandatory and optional arguments for a sample.</li>
<li>Sample setup, execution and post-execution cleanup.</li>
<li>Information about samples.</li>
</ul>
</p>
Each sample extends the class <code>samples_base</code>.
This class uses <code>service_manager_factory</code> to create and manage the
vAPI service endpoint and vSphere service port. Every sample implements the
following methods from the class <code>samples_base</code>:
</p>
<ul>
<li><code>_options()</code> - Called by <code>samples_base</code> during <code>parse_args</code> phase. This occurs during initialization.</li>
<li><code>_setup()</code> - Called by <code>samples_base</code> during <code>before</code> phase. This occurs after authentication and vAPI and vSphere service initialization.</li>
<li><code>_execute()</code> - Called by <code>samples_base</code> during <code>run</code> phase. At this point all the connections and services are initialized.</li>
<li><code>_cleanup()</code> - Called by <code>samples_base</code> during <code>after</code> phase. This occurs before disconnecting the services.</li>
</ul>
<h3>Samples configuration</h3>
You can specify server, username and password in the configuration file
(sample.cfg). If you use a configuration file, you can run samples without
specifying these options on the command line.
When you run a sample, you can override the configuration file values by
<li><code>src/samples/vsphere/common/lookup_service_helper</code> provides methods for discovering management nodes and service endpoint URLs on management nodes from lookup service.</li>
<li><code>src/samples/vsphere/common/platform_service_controller</code> uses lookup_service_helper to discover the Single Sign-On URL (on any of the Platform Service Controller node) and then retrieves the SAML token from the Single Sign-On server by authenticating the given user.</li>
<li><code>src/samples/vsphere/common/service_manager</code> login to the vAPI and vim service endpoints (on a management node).</li>
The following parameters are needed for running the samples:
</p>
<ul>
<li><code>lswsdlurl</code> -lookup service WSDL file URL. See <ahref="#using_wsdl"> Using WSDL</a></li>
<li><code>lssoapurl</code> - Platform Service controller's/node's (any, since data is replicated) lookupservice soap URL. Ex: https://psc/lookupservice/sdk</li>
<li><code>mgmtinstancename</code> - Instance name of the vCenter Server management node. When only one node is registered, it is selected by default; otherwise, omit the parameter to get a list of available nodes.</li>
<li><code>username</code> - username for authentication with the SSO server</li>
<li><code>password</code> - password for the SSO user</li>
<li><code>skipverification</code> - Do not verify server certificate</li>
</ul>
You can also specify these parameters in the configuration file (sample.cfg).
If you use a configuration file, you can run samples without specifying these
options on the command line.
<aname="using_wsdl"></a>
<h3>Working with lookup service WSDL</h3>
The vSphere Automation SDK for Python samples use the vSphere Automation Lookup Service to obtain the URLs for other vSphere Automation services (SSO, vAPI, VIM, SPBM, etc.).
The SDK contains the Lookup Service WSDL files. The samples use the python SUDS client for accessing the lookup service.
<br/>
The Lookup Service WSDL files are located in the following SDK directory:
You must specify the WSDL file location in the <code>client/samples/src/sample.cfg</code> file and in the lookupservice.wsdl file (located in the WSDL directory).
<ol>
<li>In sample.cfg, set 'lswsdlurl' to the lokkupservice WSDL file location. Use a local file URL specification:
e.g. lswsdlurl=file:///path/to/the/VMware-vSphere-Automation-SDK-Python-6.5.0/client/wsdl/lookupservice.wsdl</br>
(Note: You can also specify the lookup service WSDL path to the sample as a command line option)</li>
<li>In lookupservice.wsdl, set 'import location' to the local lookup WSDL file. Use a local file URL specification.
<h2>Running the samples from the command line</h2>
<p>
You can run the samples from command line using the scripts supplied in <code>VMware-vSphere-Automation-SDK-Python-<version>/client/bin</code> directory:
</p>
Before running the samples:
<ol>
<li>You must set the <code>PYTHON_HOME</code> environment variable to the base directory for the python 2.7</li>
<li>You must install all the dependencies required by the samples on client. See <ahref="#dependencies"> Sample Dependencies</a></li>
Instance name of the vCenter Server management node.
When only one node is registered, it is selected by
default; otherwise, omit the parameter to get a list
of available nodes.
-u USERNAME, --username USERNAME
SSO user name
-p PASSWORD, --password PASSWORD
SSO user password
-v, --skipverification
Do not verify server certificate
</pre>
<p>
Note: In the above example <b>mgmtinstancename</b> is optional and can be omitted if there's a single vCenter Server management node in the deployment.
When there is more than one management node, the user MUST specify the management node instance name against which the sample needs
to run, else the sample throws <b>MultipleManagementNodeException</b>.