1 Reply Latest reply on Jul 28, 2016 2:59 PM by Peter M

    Invoking server tasks with Python api


      I'm having issues trying to invoke a server task using the Python api. Basic environment is ePO 5.3.1 running (clustered) on Win Server 2008R2 with the McAfee-supplied python remote client. The reason I'm trying the Python route is I want to run a report on a bi-weekly basis and I've been unable to bend the Advanced cron syntax to cooperate. If I can get the Python script to work i can use Windows Task Scheduler to run it bi-weekly. But I digress.

         I have defined a test server task in ePO and run it both manually and on a schedule (it runs a canned McAfee query and emails me the results). I have run the task manually both while the task is enabled and disabled. The server task works.

        However, when I try to invoke the server task with the scheduler.runServerTask method, I get an error back that the task is invalid.


      >>> mc.scheduler.runServerTask('TEST')

      Traceback (most recent call last):

        File "<stdin>", line 1, in <module>

        File "C:\Python27\scripts\mcafee.py", line 454, in __call__

          raise e

      mcafee.CommandInvokerError: The task 'TEST' can't be run because it is invalid


      Doing a scheduler.listServerTask  shows  the following:


      >>> mc.scheduler.getServerTask('TEST')

      {u'startDate': u'2016-07-28T00:00:01-04:00', u'endDate': u'Fri Jul 29 23:59:00 EDT 2016', u'description': u'', u'enabled

      ': u'false', u'valid': False, u'nextRunTime': u'None', u'id': 83, u'name': u'TEST'}


        Note the field in bold.  I believe this is what is preventing the Python script from invoking the task, however I can not find out what sets this field or where to change it. Running the task manually works just fine:



      Source:Server Task
      Start Date:7/28/16 1:42:36 PM
      Duration:Less than a minute
      User Name:<me>
      7/28/16 1:42:37 PM  Started: Run Query
      7/28/16 1:42:37 PM   Completed: Run Query (The query 'VSE: Threats Detected in the Last 7 Days' was run as a scheduled command or part of a scheduled command chain.)
      7/28/16 1:42:37 PM   Started: Email File - <my email>,
      7/28/16 1:42:38 PM   Completed: Email File - <my email>, (Email was successfully sent to the SMTP server for delivery to Email File.)


        Does anyone have any ideas about what it takes to mark a task as "valid" so that the runServerTask method will invoke the task?


      Thanks in advance,