Difference between revisions of "Talk:QuickBooks support phone number,(1-800-919-0992) QuickBooks technical support phone number, QuickBooks customer support phone number,"

From Zenoss Wiki
Jump to: navigation, search
Line 6: Line 6:
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 
## Copyright 2015 GoVanguard Inc. Written by Shane William Scott. http://gvit.com
 
## Copyright 2015 GoVanguard Inc. Written by Shane William Scott. http://gvit.com
def exciseObjectTumor(deviceOrganizerToSearch = '/zport/dmd/Devices', typeToFix = {'meta_type': 'Software', 'id': 'os'}, doItForReal = False):
+
def exciseObjectTumor(deviceOrganizerToSearch = '/zport/dmd/Devices', doItForReal = False):
 
     sync()
 
     sync()
 
     problemsFound = 0
 
     problemsFound = 0
     if deviceOrganizerToSearch != None and typeToFix.has_key('id'):
+
     if deviceOrganizerToSearch != None:
 
         print "Getting organizer..."
 
         print "Getting organizer..."
 
         organizerOb = dmd.Devices.getOrganizer(deviceOrganizerToSearch)
 
         organizerOb = dmd.Devices.getOrganizer(deviceOrganizerToSearch)
Line 16: Line 16:
 
             devicesToSearch = organizerOb.getSubDevices()
 
             devicesToSearch = organizerOb.getSubDevices()
 
     if len(devicesToSearch) > 0:
 
     if len(devicesToSearch) > 0:
         print 'Searching %s devices in %s for duplicates of %s in _objects...' % (str(len(devicesToSearch)), deviceOrganizerToSearch, str(typeToFix['id']))
+
         print 'Searching %s devices in %s for duplicates in _objects...' % (str(len(devicesToSearch)), deviceOrganizerToSearch)
 
         for d in devicesToSearch:
 
         for d in devicesToSearch:
            obs = []
 
 
             oldObs = d._objects
 
             oldObs = d._objects
             newObs = None
+
             newObs = list(set([str(obId) for obId in d._objects]))
            obsCount = 0
+
             if len(oldObs) > len(newObs):
            for ob in oldObs:
+
                if ob['id'] == typeToFix['id']:
+
                    obsCount = obsCount + 1
+
                    continue
+
                obs.append(ob)
+
             obs.append(typeToFix)
+
            if obsCount > 1:
+
 
                 problemsFound = problemsFound + 1
 
                 problemsFound = problemsFound + 1
                 print "Device %s has too many %s obs in _objects. Fixing." % (d.titleOrId(), typeToFix['id'])
+
                 print "Device %s has duplicates in _objects. Fixing." % (d.titleOrId())
                 newObs = tuple(obs)
+
                 d._objects = tuple([eval(obId) for obId in newObs])
                d._objects = newObs
+
 
                 if doItForReal == True:
 
                 if doItForReal == True:
 
                     commit()
 
                     commit()
Line 38: Line 29:
 
         print "No devices scanned."
 
         print "No devices scanned."
 
     if problemsFound > 0:
 
     if problemsFound > 0:
         print "Found and cut out a total of %s %s object duplicates." % (str(problemsFound), typeToFix['id'])
+
         print "Found and cut out a total of %s object entry duplicates." % (str(problemsFound))
 
         if doItForReal == False:
 
         if doItForReal == False:
 
             print "...but doItForReal was set to False so the changes are not commited"
 
             print "...but doItForReal was set to False so the changes are not commited"
 
     else:
 
     else:
         print "Congrats! You're clean! Nothing showed up during the scan for duplicated %s objects." % (typeToFix['id'])
+
         print "Congrats! You're clean! Nothing showed up during the scan for duplicated object entries."
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Execute the method supplying the object dictionary exhibiting duplication. Pass doItForReal to 'True' for actions to be committed. Actions are not committed by default.
+
Execute the method. Pass doItForReal to 'True' for actions to be committed. Actions are not committed by default.
  
 
Examples:
 
Examples:
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
exciseObjectTumor(typeToFix = {'meta_type': 'Software', 'id': 'os'}, doItForReal = True)
+
exciseObjectTumor(doItForReal = True)
exciseObjectTumor(typeToFix = {'meta_type': 'DeviceHW', 'id': 'hw'}, doItForReal = True)
+
exciseObjectTumor(typeToFix = {'meta_type': 'ZCatalog', 'id': 'componentSearch'}, doItForReal = True)
+
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Tips]]
 
[[Category:Tips]]
 
[[Category:ZenDMD]]
 
[[Category:ZenDMD]]

Revision as of 14:56, 4 November 2015

DevOps and Security services

As the zenoss user on the ZenMaster, zendmd.

Copy and paste in the following definition:

## Copyright 2015 GoVanguard Inc. Written by Shane William Scott. http://gvit.com
def exciseObjectTumor(deviceOrganizerToSearch = '/zport/dmd/Devices', doItForReal = False):
    sync()
    problemsFound = 0
    if deviceOrganizerToSearch != None:
        print "Getting organizer..."
        organizerOb = dmd.Devices.getOrganizer(deviceOrganizerToSearch)
        if organizerOb:
            print "Collecting device list..."
            devicesToSearch = organizerOb.getSubDevices()
    if len(devicesToSearch) > 0:
        print 'Searching %s devices in %s for duplicates in _objects...' % (str(len(devicesToSearch)), deviceOrganizerToSearch)
        for d in devicesToSearch:
            oldObs = d._objects
            newObs = list(set([str(obId) for obId in d._objects]))
            if len(oldObs) > len(newObs):
                problemsFound = problemsFound + 1
                print "Device %s has duplicates in _objects. Fixing." % (d.titleOrId())
                d._objects = tuple([eval(obId) for obId in newObs])
                if doItForReal == True:
                    commit()
    else:
        print "No devices scanned."
    if problemsFound > 0:
        print "Found and cut out a total of %s object entry duplicates." % (str(problemsFound))
        if doItForReal == False:
            print "...but doItForReal was set to False so the changes are not commited"
    else:
        print "Congrats! You're clean! Nothing showed up during the scan for duplicated object entries."

Execute the method. Pass doItForReal to 'True' for actions to be committed. Actions are not committed by default.

Examples:

exciseObjectTumor(doItForReal = True)