mirror of
https://github.com/vmware/vsphere-automation-sdk-python.git
synced 2024-11-26 11:19:59 -05:00
Modified script to incorporate Review comments
This commit is contained in:
parent
ead9df5c42
commit
be3b51e4b7
@ -11,69 +11,30 @@
|
|||||||
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
|
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
|
||||||
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
"""
|
"""
|
||||||
import atexit
|
|
||||||
|
|
||||||
from com.vmware.vcenter.vm_client import Power
|
|
||||||
from samples.vsphere.common import vapiconnect
|
from samples.vsphere.common import vapiconnect
|
||||||
from samples.vsphere.common.sample_util import parse_cli_args_vm
|
from samples.vsphere.common.sample_util import parse_cli_args
|
||||||
from samples.vsphere.common.sample_util import pp
|
from samples.vsphere.common.sample_util import pp
|
||||||
from samples.vsphere.vcenter.setup import testbed
|
from com.vmware.vcenter_client import VM
|
||||||
|
|
||||||
from samples.vsphere.vcenter.helper.vm_helper import get_vm
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Demonstrates getting list of VMs present in vCenter
|
Demonstrates getting list of VMs present in vCenter
|
||||||
|
|
||||||
Sample Prerequisites:
|
Sample Prerequisites:
|
||||||
vCenter/ESX
|
vCenter/ESX
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
"""
|
|
||||||
* *******************************************************
|
|
||||||
* Copyright (c) VMware, Inc. 2016. 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.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from com.vmware.vcenter.vm.hardware.boot_client import Device as BootDevice
|
|
||||||
from com.vmware.vcenter.vm.hardware_client import (
|
|
||||||
Disk, Ethernet)
|
|
||||||
from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec
|
|
||||||
from com.vmware.vcenter.vm_client import (Power)
|
|
||||||
from com.vmware.vcenter_client import VM
|
|
||||||
from samples.vsphere.common import vapiconnect
|
|
||||||
from samples.vsphere.common.sample_util import parse_cli_args
|
|
||||||
from samples.vsphere.vcenter.setup import testbed
|
|
||||||
|
|
||||||
from samples.vsphere.vcenter.helper.vm_helper import get_vm
|
|
||||||
|
|
||||||
"""
|
|
||||||
Demonstrates how to List the VMs present in a vCenter server:
|
|
||||||
|
|
||||||
Sample Prerequisites:
|
|
||||||
- VC
|
|
||||||
- ESX
|
|
||||||
- datacenter
|
|
||||||
"""
|
|
||||||
|
|
||||||
stub_config = None
|
stub_config = None
|
||||||
|
cleardata = False
|
||||||
|
|
||||||
def setup(context=None):
|
def setup(context=None):
|
||||||
global stub_config, cleardata
|
global stub_config, cleardata
|
||||||
server, username, password, cleardata, skip_verification = \
|
server, username, password, cleardata, skip_verification = \
|
||||||
parse_cli_args()
|
parse_cli_args()
|
||||||
stub_config = vapiconnect.connect(server,
|
stub_config = vapiconnect.connect(server,
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
skip_verification)
|
skip_verification)
|
||||||
|
#atexit.register(vapiconnect.logout, stub_config)
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
@ -83,7 +44,6 @@ def run():
|
|||||||
def list_vms(stub_config):
|
def list_vms(stub_config):
|
||||||
"""
|
"""
|
||||||
List VMs present in server
|
List VMs present in server
|
||||||
|
|
||||||
"""
|
"""
|
||||||
vm_svc = VM(stub_config)
|
vm_svc = VM(stub_config)
|
||||||
list_of_vms = vm_svc.list()
|
list_of_vms = vm_svc.list()
|
||||||
|
Loading…
Reference in New Issue
Block a user