Esempio n. 1
0
    def testWinSerivceComponentReindexOnServiceOrganizerZMonitorChange(self):
        """
        Ensure the WinServices in the componentSearch catalog are re-indexed 
        when saveZenProperties is called on the Service Organizer and zMonitor
        is Changed 
        """

        svcOrg = self.dmd.Services
        winSvc = self.dev.getMonitoredComponents(type='WinService')
        #by default monitor is off; should find nothing
        self.assertFalse(winSvc)
        monitored = svcOrg.zMonitor
        self.assertFalse(monitored)

        #fake request and turn zMonitor to true
        request = FakeRequest()
        request.form = {'zMonitor': True}
        kwargs = {'REQUEST': request}
        svcOrg.saveZenProperties(**kwargs)

        #verify monitored flag changed and that component is now found
        monitored = svcOrg.zMonitor
        self.assertTrue(monitored)
        winSvc2 = self.dev.getMonitoredComponents(type='WinService')
        self.assertTrue(winSvc2)

        #test that changing zProperty directly does not affect catalog
        svcOrg.setZenProperty('zMonitor', False)
        winSvc2 = self.dev.getMonitoredComponents(type='WinService')
        #catalog will find component even though zMonitor is false
        #because index was not updated
        self.assertTrue(winSvc2)
Esempio n. 2
0
    def testWinSerivceComponentReindexOnServiceOrganizerZMonitorChange(self):
        """
        Ensure the WinServices in the componentSearch catalog are re-indexed 
        when saveZenProperties is called on the Service Organizer and zMonitor
        is Changed 
        """

        svcOrg = self.dmd.Services
        winSvc = self.dev.getMonitoredComponents(type='WinService')
        #by default monitor is off; should find nothing
        self.assertFalse( winSvc )
        monitored = svcOrg.zMonitor
        self.assertFalse( monitored )
                
        #fake request and turn zMonitor to true
        request = FakeRequest()
        request.form = {'zMonitor': True}
        kwargs = {'REQUEST': request}
        svcOrg.saveZenProperties(**kwargs)
        
        #verify monitored flag changed and that component is now found
        monitored = svcOrg.zMonitor
        self.assertTrue( monitored )
        winSvc2 = self.dev.getMonitoredComponents(type='WinService')
        self.assertTrue ( winSvc2 )

        #test that changing zProperty directly does not affect catalog
        svcOrg.setZenProperty('zMonitor', False)
        winSvc2 = self.dev.getMonitoredComponents(type='WinService')
        #catalog will find component even though zMonitor is false
        #because index was not updated
        self.assertTrue ( winSvc2 )
Esempio n. 3
0
    def _setDeviceBatchProps(self,
                             method='',
                             extraarg=None,
                             selectstatus='none',
                             goodevids=[],
                             badevids=[],
                             offset=0,
                             count=50,
                             filter='',
                             orderby='titleOrId',
                             orderdir='asc',
                             **kwargs):
        d = {
            'lockDevicesFromUpdates': 'sendEventWhenBlocked',
            'lockDevicesFromDeletion': 'sendEventWhenBlocked',
            'unlockDevices': '',
            'setGroups': 'groupPaths',
            'setSystems': 'systemPaths',
            'setLocation': 'locationPath',
            'setPerformanceMonitor': 'performanceMonitor',
            'moveDevices': 'moveTarget',
            'removeDevices': ('deleteStatus', 'deleteHistory', 'deletePerf'),
            'setProdState': 'state',
            'setPriority': 'priority'
        }
        if not method or not method in d:
            IMessageSender(self.request).sendToBrowser(
                'Unable to Perform Action',
                'An empty or invalid action was attempted.',
                priority=messaging.CRITICAL)
            return self()

        request = FakeRequest()
        argdict = dict(REQUEST=request)
        if d[method]:
            d_method = d[method]
            if isinstance(d_method, (tuple, list)):
                for argName in d_method:
                    argdict[argName] = self.request.get(argName, None)
            else:
                argdict[d_method] = extraarg
        action = getattr(self.context, method)
        argdict['deviceNames'] = self._getDeviceBatch(selectstatus, goodevids,
                                                      badevids, offset, count,
                                                      filter, orderby,
                                                      orderdir)
        # This will call the method on the context, which will redirect to a
        # new (or the same) screen and set a message
        try:
            result = action(**argdict)
        except Exception:
            msgs = {
                'lockDevicesFromUpdates': 'lock devices from updates',
                'lockDevicesFromDeletion': 'lock devices from deletion',
                'unlockDevices': 'unlock devices',
                'setGroups': 'change device groups',
                'setSystems': 'change device systems',
                'setLocation': 'set the location',
                'setPerformanceMonitor': 'set the performance monitor',
                'moveDevices': 'move devices',
                'removeDevices': 'delete devices',
                'setProdState': 'set production state',
                'setPriority': 'set priority'
            }
            IMessageSender(self.request).sendToBrowser(
                'Unable to Perform Action',
                'There was an error attempting to %s.' % msgs[method],
                priority=messaging.CRITICAL)
        else:
            return result