remove commented code and fixed formatting

This commit is contained in:
Davis Phillips 2016-11-09 11:06:03 -06:00 committed by Matt Clay
parent 995cc2cd2d
commit ebdd9cf1a5

View file

@ -724,13 +724,12 @@ class PyVmomiHelper(object):
int(self.params['hardware']['memory_mb']) int(self.params['hardware']['memory_mb'])
# lets try and assign a static ip addresss # lets try and assign a static ip addresss
if 'customize' in self.params: if self.params['customize'] is True:
ip_settings = list() ip_settings = list()
if self.params['ips'] and self.params['network']:
for ip_string in self.params['ips']: for ip_string in self.params['ips']:
ip = IPAddress(self.params['ips']) ip = IPAddress(self.params['ips'])
for network in self.params['networks']: for network in self.params['networks']:
if ip in IPNetwork(network): if ip in IPNetwork(network):
self.params['networks'][network]['ip'] = str(ip) self.params['networks'][network]['ip'] = str(ip)
ipnet = IPNetwork(network) ipnet = IPNetwork(network)
@ -739,34 +738,28 @@ class PyVmomiHelper(object):
) )
ip_settings.append(self.params['networks'][network]) ip_settings.append(self.params['networks'][network])
key = 0
network = get_obj(self.content, [vim.Network], ip_settings[0]['network']) network = get_obj(self.content, [vim.Network], ip_settings[key]['network'])
datacenter = get_obj(self.content, [vim.Datacenter], self.params['datacenter']) datacenter = get_obj(self.content, [vim.Datacenter], self.params['datacenter'])
# get the folder where VMs are kept for this datacenter # get the folder where VMs are kept for this datacenter
destfolder = datacenter.vmFolder destfolder = datacenter.vmFolder
cluster = get_obj(self.content, [vim.ClusterComputeResource],self.params['cluster']) cluster = get_obj(self.content, [vim.ClusterComputeResource],self.params['cluster'])
devices = [] devices = []
adaptermaps = [] adaptermaps = []
try: try:
for device in template.config.hardware.device: for device in template.config.hardware.device:
if hasattr(device, 'addressType'): if hasattr(device, 'addressType'):
nic = vim.vm.device.VirtualDeviceSpec() nic = vim.vm.device.VirtualDeviceSpec()
nic.operation = \ nic.operation = vim.vm.device.VirtualDeviceSpec.Operation.remove
vim.vm.device.VirtualDeviceSpec.Operation.remove
nic.device = device nic.device = device
devices.append(nic) devices.append(nic)
except: except:
pass pass
# for key, ip in enumerate(ip_settings):
# VM device
# single device support # single device support
key = 0
nic = vim.vm.device.VirtualDeviceSpec() nic = vim.vm.device.VirtualDeviceSpec()
nic.operation = vim.vm.device.VirtualDeviceSpec.Operation.add nic.operation = vim.vm.device.VirtualDeviceSpec.Operation.add
nic.device = vim.vm.device.VirtualVmxnet3() nic.device = vim.vm.device.VirtualVmxnet3()
@ -785,6 +778,7 @@ class PyVmomiHelper(object):
nic.device.connectable.allowGuestControl = True nic.device.connectable.allowGuestControl = True
devices.append(nic) devices.append(nic)
# Update the spec with the added NIC
clonespec_kwargs['config'].deviceChange = devices clonespec_kwargs['config'].deviceChange = devices
guest_map = vim.vm.customization.AdapterMapping() guest_map = vim.vm.customization.AdapterMapping()