1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-22 17:39:59 -05:00

raise exception rather than silently exit program when missing parameters

This commit is contained in:
Tianhao He 2017-01-24 23:27:34 -08:00
parent 082f7b2e6b
commit 72e6895c5c
16 changed files with 39 additions and 39 deletions

View File

@ -55,9 +55,9 @@ def parse_cli_args_vm(vm_name):
if args.vm_name:
vm_name = args.vm_name
else:
print("Using vm name({}) specified in testbed.py".format(vm_name))
print("Try to use vm name({}) specified in testbed.py".format(vm_name))
if not vm_name:
exit("vm name is required")
raise Exception("vm name is required")
print("vm name = {}".format(vm_name))
return server, username, password, cleardata, skip_verification, vm_name
@ -74,7 +74,7 @@ def process_cli_args(args):
print("Using vcenter server specified in testbed.py")
server = testbed.config['SERVER']
if not server:
exit("vcenter server is required")
raise Exception("vcenter server is required")
print("vcenter server = {}".format(server))
if args.username:
@ -83,8 +83,8 @@ def process_cli_args(args):
print("Using vc user specified in testbed.py")
username = testbed.config['USERNAME']
if not username:
exit("vc user is required")
print("vc user = {}".format(username))
raise Exception("vc username is required")
print("vc username = {}".format(username))
if args.password:
password = args.password

View File

@ -32,19 +32,19 @@ Inputs:
different folders looking for the entities.
* Two Datacenters
* "Sample DC 1"
* "Sample DC 2"
* "Sample_DC_1"
* "Sample_DC_2"
* One Cluster
* "Sample Cluster"
* "Sample_Cluster"
* 2 host environment
* 1 host in Sample Cluster in Sample DC 1
* 1 host in Sample Cluster in Sample_DC_1
* One network adapter per Host
* Name of Host will be the IP address
* 3 Datastores, any constraints?
* Shared NFS Datastore
* "Shared NFS Volume"
* "Shared_NFS_Volume"
* 2 Local VMFS Datastore (name the datastores based on the host)
* "Local VMFS Datastore on <host_ip>"
* "Local_VMFS_Datastore_on_<host_ip>"
* 1 Standard Portgroups (verify)
* "VM Network" (the default created per host)
* 1 Distributed Switch ("DSwitch 1")

View File

@ -54,8 +54,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for SATA Sample".format(vm_name, vm))
# Create SATA adapter stub used for making requests

View File

@ -54,8 +54,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for SCSI Sample".format(vm_name, vm))
# Create SCSI adapter stub used for making requests

View File

@ -55,8 +55,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Boot Sample".format(vm_name, vm))
# Create Boot stub used for making requests

View File

@ -61,8 +61,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for BootDevice Sample".format(vm_name, vm))
# Create BootDevice stub used for making requests

View File

@ -63,8 +63,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for CD-ROM Sample".format(vm_name, vm))
iso_datastore_path = testbed.config['ISO_DATASTORE_PATH']

View File

@ -55,8 +55,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Cpu Sample".format(vm_name, vm))
# Create Cpu stub used for making requests

View File

@ -83,8 +83,8 @@ def setup(context=None):
global datastore_mo, datacenter_mo, datastore_root_path
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Disk Sample".format(vm_name, vm))
# Get the datacenter and datastore managed objects to be able to create and

View File

@ -58,8 +58,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Disk Sample".format(vm_name, vm))
# Get standard portgroup to use as backing for sample

View File

@ -56,8 +56,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Floppy Sample".format(vm_name, vm))
img_datastore_path = testbed.config['FLOPPY_DATASTORE_PATH']

View File

@ -71,8 +71,8 @@ def validate(context):
if not get_vm(context.stub_config, name):
valid = False
if not valid:
exit('==> Samples Setup validation failed: '
'Missing VMs required to run hardware samples')
raise Exception('==> Samples Setup validation failed: '
'Missing VMs required to run hardware samples')
print('==> Samples Setup validated')

View File

@ -54,8 +54,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Memory Sample".format(vm_name, vm))
# Create Memory stub used for making requests

View File

@ -70,8 +70,8 @@ def run():
global vm, parallel_svc
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Parallel Sample".format(vm_name, vm))
# Create Parallel port stub used for making requests

View File

@ -78,8 +78,8 @@ def run():
global vm, serial_svc
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Serial Sample".format(vm_name, vm))
# Create Serial port stub used for making requests

View File

@ -56,8 +56,8 @@ def run():
global vm
vm = get_vm(stub_config, vm_name)
if not vm:
exit('Sample requires an existing vm with name ({}). '
'Please create the vm first.'.format(vm_name))
raise Exception('Sample requires an existing vm with name ({}).'
'Please create the vm first.'.format(vm_name))
print("Using VM '{}' ({}) for Power Sample".format(vm_name, vm))
# Create Power stub used for making requests