mirror of
https://github.com/vmware/vsphere-automation-sdk-python.git
synced 2024-11-23 09:59:59 -05:00
b3bea5c03d
1. Move folders around. 2. Remove samples.cfg 3. Remove inventory sample as it's replaced by contentlibrary samples 4. Update README.md under samples/vsphere
82 lines
3.3 KiB
Python
82 lines
3.3 KiB
Python
"""
|
|
* *******************************************************
|
|
* Copyright (c) VMware, Inc. 2014. All Rights Reserved.
|
|
* *******************************************************
|
|
*
|
|
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
|
|
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
|
|
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
|
|
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
"""
|
|
|
|
__author__ = 'VMware, Inc.'
|
|
__copyright__ = 'Copyright 2014 VMware, Inc. All rights reserved.'
|
|
|
|
import argparse
|
|
from samples.vsphere.common.lookup_service_helper import LookupServiceHelper
|
|
|
|
|
|
class PrintServices(object):
|
|
"""
|
|
Demonstrates service discovery using lookup service APIs.
|
|
The sample prints all the PSC (Platform Service Controller) and Management Node (vCenter Server) and
|
|
some of the critical services (SSO, VAPI, VIM etc.) running on these nodes. This sample can also be used
|
|
to find out the server deployment (e.g. MxN setup with multiple PSC/Management nodes).
|
|
"""
|
|
|
|
def __init__(self):
|
|
self.lswsdlurl = None
|
|
self.lssoapurl = None
|
|
|
|
def options(self):
|
|
self.argparser = argparse.ArgumentParser(description=self.__doc__)
|
|
# setup the argument parser
|
|
self.argparser.add_argument('-lswsdlurl', '--lswsdlurl', help='Lookup service WSDL URL')
|
|
self.argparser.add_argument('-lssoapurl', '--lssoapurl', help='Lookup service SOAP URL')
|
|
self.args = self.argparser.parse_args() # parse all the sample arguments when they are all set
|
|
|
|
def setup(self):
|
|
self.lswsdlurl = self.args.lswsdlurl
|
|
assert self.lswsdlurl is not None
|
|
print('lswsdlurl: {0}'.format(self.lswsdlurl))
|
|
|
|
self.lssoapurl = self.args.lssoapurl
|
|
assert self.lssoapurl is not None
|
|
print('lssoapurl: {0}'.format(self.lssoapurl))
|
|
|
|
def execute(self):
|
|
print('Connecting to lookup service url: {0}'.format(self.lssoapurl))
|
|
lookupservicehelper = LookupServiceHelper(wsdl_url=self.lswsdlurl, soap_url=self.lssoapurl)
|
|
lookupservicehelper.connect()
|
|
|
|
# print the PSC nodes and SSO service endpoint URLs
|
|
for index, sso_url in enumerate(lookupservicehelper.find_sso_urls(), start=1):
|
|
print('=============================')
|
|
print('PSC node: {0}'.format(index))
|
|
print(' SSO URL: {0}'.format(sso_url))
|
|
print('=============================')
|
|
|
|
# print the mgmt (vCenter Server) nodes and some of the critical service endpoint URLs
|
|
for instance_name, node_id in lookupservicehelper.find_mgmt_nodes().items():
|
|
print('=============================')
|
|
print('Mgmt node instance name: {0} node_id: {1}'.format(instance_name, node_id))
|
|
print(' VAPI URL: {0}'.format(lookupservicehelper.find_vapi_url(node_id)))
|
|
print(' VIM URL: {0}'.format(lookupservicehelper.find_vim_url(node_id)))
|
|
print(' SPBM URL: {0}'.format(lookupservicehelper.find_vim_pbm_url(node_id)))
|
|
print('=============================')
|
|
|
|
def cleanup(self):
|
|
pass
|
|
|
|
|
|
def main():
|
|
printServices = PrintServices()
|
|
printServices.options()
|
|
printServices.setup()
|
|
printServices.execute()
|
|
printServices.cleanup()
|
|
|
|
# Start program
|
|
if __name__ == "__main__":
|
|
main() |