VMware: Fix Service Content calls in vmware_deploy_ovf

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/59724/head
Abhijeet Kasurde 5 years ago committed by Gonéri Le Bouder
parent 08d7905be2
commit 336be58665

@ -356,7 +356,7 @@ class VMwareDeployOvf(PyVmomi):
self.module.fail_json(msg='%(resource_pool)s could not be located' % self.params) self.module.fail_json(msg='%(resource_pool)s could not be located' % self.params)
for key, value in self.params['networks'].items(): for key, value in self.params['networks'].items():
network = find_network_by_name(self.si, value) network = find_network_by_name(self.content, value)
if not network: if not network:
self.module.fail_json(msg='%(network)s could not be located' % self.params) self.module.fail_json(msg='%(network)s could not be located' % self.params)
network_mapping = vim.OvfManager.NetworkMapping() network_mapping = vim.OvfManager.NetworkMapping()
@ -406,7 +406,7 @@ class VMwareDeployOvf(PyVmomi):
params['propertyMapping'].append(property_mapping) params['propertyMapping'].append(property_mapping)
if self.params['folder']: if self.params['folder']:
folder = self.si.searchIndex.FindByInventoryPath(self.params['folder']) folder = self.content.searchIndex.FindByInventoryPath(self.params['folder'])
if not folder: if not folder:
self.module.fail_json(msg="Unable to find the specified folder %(folder)s" % self.params) self.module.fail_json(msg="Unable to find the specified folder %(folder)s" % self.params)
else: else:
@ -416,7 +416,7 @@ class VMwareDeployOvf(PyVmomi):
ovf_descriptor = self.get_ovf_descriptor() ovf_descriptor = self.get_ovf_descriptor()
self.import_spec = self.si.ovfManager.CreateImportSpec( self.import_spec = self.content.ovfManager.CreateImportSpec(
ovf_descriptor, ovf_descriptor,
resource_pool, resource_pool,
datastore, datastore,
@ -438,9 +438,9 @@ class VMwareDeployOvf(PyVmomi):
if not self.params['allow_duplicates']: if not self.params['allow_duplicates']:
name = self.import_spec.importSpec.configSpec.name name = self.import_spec.importSpec.configSpec.name
match = find_vm_by_name(self.si, name, folder=folder) match = find_vm_by_name(self.content, name, folder=folder)
if match: if match:
self.module.exit_json(instance=gather_vm_facts(self.si, match), changed=False) self.module.exit_json(instance=gather_vm_facts(self.content, match), changed=False)
if self.module.check_mode: if self.module.check_mode:
self.module.exit_json(changed=True, instance={'hw_name': name}) self.module.exit_json(changed=True, instance={'hw_name': name})
@ -567,9 +567,9 @@ class VMwareDeployOvf(PyVmomi):
env = ET.Element('Environment', **attrib) env = ET.Element('Environment', **attrib)
platform = ET.SubElement(env, 'PlatformSection') platform = ET.SubElement(env, 'PlatformSection')
ET.SubElement(platform, 'Kind').text = self.si.about.name ET.SubElement(platform, 'Kind').text = self.content.about.name
ET.SubElement(platform, 'Version').text = self.si.about.version ET.SubElement(platform, 'Version').text = self.content.about.version
ET.SubElement(platform, 'Vendor').text = self.si.about.vendor ET.SubElement(platform, 'Vendor').text = self.content.about.vendor
ET.SubElement(platform, 'Locale').text = 'US' ET.SubElement(platform, 'Locale').text = 'US'
prop_section = ET.SubElement(env, 'PropertySection') prop_section = ET.SubElement(env, 'PropertySection')
@ -601,13 +601,13 @@ class VMwareDeployOvf(PyVmomi):
if self.params['wait']: if self.params['wait']:
wait_for_task(task) wait_for_task(task)
if self.params['wait_for_ip_address']: if self.params['wait_for_ip_address']:
_facts = wait_for_vm_ip(self.si, self.entity) _facts = wait_for_vm_ip(self.content, self.entity)
if not _facts: if not _facts:
self.module.fail_json(msg='Waiting for IP address timed out') self.module.fail_json(msg='Waiting for IP address timed out')
facts.update(_facts) facts.update(_facts)
if not facts: if not facts:
facts.update(gather_vm_facts(self.si, self.entity)) facts.update(gather_vm_facts(self.content, self.entity))
return facts return facts

Loading…
Cancel
Save