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

fix network helper method

This commit is contained in:
Tianhao He 2019-02-05 12:41:29 +08:00
parent e4ecfea184
commit 8c44352bab
3 changed files with 18 additions and 11 deletions

View File

@ -21,7 +21,7 @@ from com.vmware.vcenter.vm.hardware_client import (
Disk, Ethernet) Disk, Ethernet)
from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec
from com.vmware.vcenter.vm_client import (Power) from com.vmware.vcenter.vm_client import (Power)
from com.vmware.vcenter_client import VM from com.vmware.vcenter_client import VM, Network
from vmware.vapi.vsphere.client import create_vsphere_client from vmware.vapi.vsphere.client import create_vsphere_client
from samples.vsphere.common.ssl_helper import get_unverified_session from samples.vsphere.common.ssl_helper import get_unverified_session
@ -84,10 +84,11 @@ class CreateBasicVM(object):
datastore_name) datastore_name)
# Get a standard network backing # Get a standard network backing
standard_network = network_helper.get_standard_network_backing( standard_network = network_helper.get_network_backing(
self.client, self.client,
std_portgroup_name, std_portgroup_name,
datacenter_name) datacenter_name,
Network.Type.STANDARD_PORTGROUP)
""" """
Create a basic VM. Create a basic VM.

View File

@ -21,7 +21,7 @@ from com.vmware.vcenter.vm.hardware_client import (
Cpu, Memory, Disk, Ethernet, Cdrom, Serial, Parallel, Floppy, Boot) Cpu, Memory, Disk, Ethernet, Cdrom, Serial, Parallel, Floppy, Boot)
from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec
from com.vmware.vcenter.vm_client import (Hardware, Power) from com.vmware.vcenter.vm_client import (Hardware, Power)
from com.vmware.vcenter_client import VM from com.vmware.vcenter_client import VM, Network
from vmware.vapi.vsphere.client import create_vsphere_client from vmware.vapi.vsphere.client import create_vsphere_client
from samples.vsphere.common.ssl_helper import get_unverified_session from samples.vsphere.common.ssl_helper import get_unverified_session
@ -94,17 +94,19 @@ class CreateExhaustiveVM(object):
# Get a standard network backing # Get a standard network backing
if not self.standard_network: if not self.standard_network:
self.standard_network = network_helper.get_standard_network_backing( self.standard_network = network_helper.get_network_backing(
self.client, self.client,
std_portgroup_name, std_portgroup_name,
datacenter_name) datacenter_name,
Network.Type.STANDARD_PORTGROUP)
# Get a distributed network backing # Get a distributed network backing
if not self.distributed_network: if not self.distributed_network:
self.distributed_network = network_helper.get_distributed_network_backing( self.distributed_network = network_helper.get_network_backing(
self.client, self.client,
dv_portgroup_name, dv_portgroup_name,
datacenter_name) datacenter_name,
Network.Type.DISTRIBUTED_PORTGROUP)
""" """
Create an exhaustive VM. Create an exhaustive VM.

View File

@ -14,6 +14,8 @@
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__vcenter_version__ = '6.5+' __vcenter_version__ = '6.5+'
from com.vmware.vcenter_client import Network
import samples.vsphere.vcenter.helper.network_helper import samples.vsphere.vcenter.helper.network_helper
import samples.vsphere.vcenter.vm.hardware.main import samples.vsphere.vcenter.vm.hardware.main
import samples.vsphere.vcenter.vm.placement import samples.vsphere.vcenter.vm.placement
@ -55,17 +57,19 @@ class VMSetup(object):
# 2. DISTRIBUTED_PORTGROUP on DATACENTER2 # 2. DISTRIBUTED_PORTGROUP on DATACENTER2
########################################################################### ###########################################################################
standard_network = samples.vsphere.vcenter.helper \ standard_network = samples.vsphere.vcenter.helper \
.network_helper.get_standard_network_backing( .network_helper.get_network_backing(
context.client, context.client,
context.testbed.config['STDPORTGROUP_NAME'], context.testbed.config['STDPORTGROUP_NAME'],
context.testbed.config['VM_DATACENTER_NAME']) context.testbed.config['VM_DATACENTER_NAME'],
Network.Type.STANDARD_PORTGROUP)
print('standard_network={}'.format(standard_network)) print('standard_network={}'.format(standard_network))
distributed_network = samples.vsphere.vcenter.helper \ distributed_network = samples.vsphere.vcenter.helper \
.network_helper.get_distributed_network_backing( .network_helper.get_distributed_network_backing(
context.client, context.client,
context.testbed.config['VDPORTGROUP1_NAME'], context.testbed.config['VDPORTGROUP1_NAME'],
context.testbed.config['VM_DATACENTER_NAME']) context.testbed.config['VM_DATACENTER_NAME'],
Network.Type.DISTRIBUTED_PORTGROUP)
print('distributed_network={}'.format(distributed_network)) print('distributed_network={}'.format(distributed_network))
print('=' * 79) print('=' * 79)