Remove print statements

pull/18777/head
James Tanner 8 years ago committed by Matt Clay
parent d051701359
commit 222f9bc08a

@ -129,7 +129,7 @@ import atexit
import os import os
import ssl import ssl
import time import time
from pprint import pprint
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url
class PyVmomiHelper(object): class PyVmomiHelper(object):
@ -237,8 +237,6 @@ class PyVmomiHelper(object):
self.params['esxi']['datacenter']) self.params['esxi']['datacenter'])
self.folders = self._build_folder_tree(self.datacenter.vmFolder) self.folders = self._build_folder_tree(self.datacenter.vmFolder)
self.folder_map = self._build_folder_map(self.folders) self.folder_map = self._build_folder_map(self.folders)
#pprint(self.folder_map)
#sys.exit(1)
return (self.folders, self.folder_map) return (self.folders, self.folder_map)
@ -471,7 +469,6 @@ class PyVmomiHelper(object):
clonespec = vim.vm.CloneSpec() clonespec = vim.vm.CloneSpec()
clonespec.location = relospec clonespec.location = relospec
print "cloning VM..."
template = get_obj(self.content, [vim.VirtualMachine], self.params['template_src']) template = get_obj(self.content, [vim.VirtualMachine], self.params['template_src'])
task = template.Clone(folder=destfolder, name=self.params['guest'], spec=clonespec) task = template.Clone(folder=destfolder, name=self.params['guest'], spec=clonespec)
self.wait_for_task(task) self.wait_for_task(task)
@ -480,21 +477,11 @@ class PyVmomiHelper(object):
return ({'changed': False, 'failed': True, 'msg': task.info.error.msg}) return ({'changed': False, 'failed': True, 'msg': task.info.error.msg})
else: else:
#import epdb; epdb.st()
vm = task.info.result vm = task.info.result
#if wait_for_ip and not poweron:
# print "powering on the VM ..."
# self.set_powerstate(vm, 'poweredon')
if wait_for_ip: if wait_for_ip:
print "powering on the VM ..."
self.set_powerstate(vm, 'poweredon', force=False) self.set_powerstate(vm, 'poweredon', force=False)
print "waiting for IP ..."
self.wait_for_vm_ip(vm) self.wait_for_vm_ip(vm)
vm_facts = self.gather_facts(vm) vm_facts = self.gather_facts(vm)
#import epdb; epdb.st()
return ({'changed': True, 'failed': False, 'instance': vm_facts}) return ({'changed': True, 'failed': False, 'instance': vm_facts})
@ -503,7 +490,6 @@ class PyVmomiHelper(object):
# https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.TaskInfo.html # https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.TaskInfo.html
# https://github.com/virtdevninja/pyvmomi-community-samples/blob/master/samples/tools/tasks.py # https://github.com/virtdevninja/pyvmomi-community-samples/blob/master/samples/tools/tasks.py
while task.info.state not in ['success', 'error']: while task.info.state not in ['success', 'error']:
print(task.info.state)
time.sleep(1) time.sleep(1)
def wait_for_vm_ip(self, vm, poll=100, sleep=5): def wait_for_vm_ip(self, vm, poll=100, sleep=5):
@ -511,10 +497,8 @@ class PyVmomiHelper(object):
facts = {} facts = {}
thispoll = 0 thispoll = 0
while not ips and thispoll <= poll: while not ips and thispoll <= poll:
print "polling for IP"
newvm = self.getvm(uuid=vm.config.uuid) newvm = self.getvm(uuid=vm.config.uuid)
facts = self.gather_facts(newvm) facts = self.gather_facts(newvm)
print "\t%s %s" % (facts['ipv4'], facts['ipv6'])
if facts['ipv4'] or facts['ipv6']: if facts['ipv4'] or facts['ipv6']:
ips = True ips = True
else: else:

@ -81,7 +81,6 @@ import atexit
import os import os
import ssl import ssl
import time import time
from pprint import pprint
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url
@ -191,8 +190,6 @@ class PyVmomiHelper(object):
self.params['esxi']['datacenter']) self.params['esxi']['datacenter'])
self.folders = self._build_folder_tree(self.datacenter.vmFolder) self.folders = self._build_folder_tree(self.datacenter.vmFolder)
self.folder_map = self._build_folder_map(self.folders) self.folder_map = self._build_folder_map(self.folders)
#pprint(self.folder_map)
#sys.exit(1)
return (self.folders, self.folder_map) return (self.folders, self.folder_map)
@ -435,7 +432,6 @@ class PyVmomiHelper(object):
clonespec.location = relospec clonespec.location = relospec
#clonespec.powerOn = power_on #clonespec.powerOn = power_on
print "cloning VM..."
template = get_obj(self.content, [vim.VirtualMachine], self.params['template_src']) template = get_obj(self.content, [vim.VirtualMachine], self.params['template_src'])
task = template.Clone(folder=destfolder, name=self.params['guest'], spec=clonespec) task = template.Clone(folder=destfolder, name=self.params['guest'], spec=clonespec)
self.wait_for_task(task) self.wait_for_task(task)
@ -444,21 +440,11 @@ class PyVmomiHelper(object):
return ({'changed': False, 'failed': True, 'msg': task.info.error.msg}) return ({'changed': False, 'failed': True, 'msg': task.info.error.msg})
else: else:
#import epdb; epdb.st()
vm = task.info.result vm = task.info.result
#if wait_for_ip and not poweron:
# print "powering on the VM ..."
# self.set_powerstate(vm, 'poweredon')
if wait_for_ip: if wait_for_ip:
print "powering on the VM ..."
self.set_powerstate(vm, 'poweredon', force=False) self.set_powerstate(vm, 'poweredon', force=False)
print "waiting for IP ..."
self.wait_for_vm_ip(vm) self.wait_for_vm_ip(vm)
vm_facts = self.gather_facts(vm) vm_facts = self.gather_facts(vm)
#import epdb; epdb.st()
return ({'changed': True, 'failed': False, 'instance': vm_facts}) return ({'changed': True, 'failed': False, 'instance': vm_facts})
@ -467,7 +453,6 @@ class PyVmomiHelper(object):
# https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.TaskInfo.html # https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.TaskInfo.html
# https://github.com/virtdevninja/pyvmomi-community-samples/blob/master/samples/tools/tasks.py # https://github.com/virtdevninja/pyvmomi-community-samples/blob/master/samples/tools/tasks.py
while task.info.state not in ['success', 'error']: while task.info.state not in ['success', 'error']:
print(task.info.state)
time.sleep(1) time.sleep(1)
def wait_for_vm_ip(self, vm, poll=100, sleep=5): def wait_for_vm_ip(self, vm, poll=100, sleep=5):
@ -475,10 +460,8 @@ class PyVmomiHelper(object):
facts = {} facts = {}
thispoll = 0 thispoll = 0
while not ips and thispoll <= poll: while not ips and thispoll <= poll:
print "polling for IP"
newvm = self.getvm(uuid=vm.config.uuid) newvm = self.getvm(uuid=vm.config.uuid)
facts = self.gather_facts(newvm) facts = self.gather_facts(newvm)
print "\t%s %s" % (facts['ipv4'], facts['ipv6'])
if facts['ipv4'] or facts['ipv6']: if facts['ipv4'] or facts['ipv6']:
ips = True ips = True
else: else:

Loading…
Cancel
Save