Example 6: Automate maintenance of the System Tree

You can use this script to reapply System Tree sorting rules to any systems found in the Lost&Found System Tree group.

#Example 6
import mcafee
mc = mcafee.client('localhost','8443','ga','ga','https','json')

#first, as before, get the id of the Lost&Found group
groups = mc.system.findGroups('Lost&Found')
groupId = -1
for group in groups:
  if group['groupPath'] == 'My Organization\\Lost&Found':
    groupId = group['groupId']

  if groupId == -1:
     error = 'Error finding the specified group.'

#find all systems for this group
systems = mc.epogroup.findSystems(str(groupId),'true')
for system in systems:
   id = system['EPOComputerProperties.ParentID']

This example is fairly straightforward given the previous example scripts. This example introduces a new command, epogroup.findSystems, which finds all systems in a given group. The last parameter, 'true' determines whether to search all subgroups. In this example, this parameter is set to true, the command iterates through all systems found under Lost&Found and any of its subgroups, then reapplies the sorting rules to those systems.