3

Hi I am using pyvmomi against vSphere 6.0 to query tasks ,but TaskManager managed object (ManagedObjectReference:TaskManager) only lists recent tasks, is it possbile to go back and get a list of all tasks for a particular day or for specific time frame in the last 24 hours? I am using this code to get the information.

 si = 

    connect.SmartConnect(host='xxx.abc.yyy.com',port=xxx,user='domain\user',pwd=xxxx)
    content=si.RetrieveContent()
    task = content.taskManager
    for tasks in task.recentTask:
        tasks.info.entityName + ' ' + tasks.info.state + '    '   + str(tasks.info.completeTime) --ONLY SHOWS for the last few minutes or so.

I need to be able to ,say pass time frame and get the tasks for that time frame within the past 24 hours. Thanks

jramacha
  • 117
  • 2
  • 13
  • 2
    If anyone is looking,after researching for the last 24 hours , I have this script which can list the last for the last 24 hours. si = connect.SmartConnect(host='xxx',port=443,user='xx',pwd=xxx) content=si.RetrieveContent() taskManager = content.taskManager tasks = taskManager.CreateCollectorForTasks(vim.TaskFilterSpec()) tasks.ResetCollector() alltasks = tasks.ReadNextTasks(999) yesterday = datetime.now() - timedelta(1) # Get yesterday's time eastern = pytz.timezone('US/Eastern') for task in alltasks if task.startTime > eastern.localize(yesterday): print task – jramacha Dec 01 '16 at 18:59
  • 2
    If anyone is looking I posted the code on github. https://github.com/jramacha/pyvmomi-community-samples/blob/master/samples/gettasksbyuser.py – jramacha Dec 08 '16 at 18:16

0 Answers0