def enable_notifier(self,enable,id): try: i = int(id) except ValueError: print '%s is not a valid id' % id return notifiermodel = NotifierModel(self.logger,self.config) notifier = notifiermodel.get(i) if notifier == None: print('id: %d does not exist' % i) return notifier.enabled=enable notifiermodel.commit() print('Notifier: %s has been %s'% (notifier.name,'Enabled'if enable else 'Disabled'))
def list_all_notifiers(self): notifiers = PrettyTable(['ID', 'Name', 'Enabled', 'Type', 'Address']) notifiers.align = 'l' notifiermodel = NotifierModel(self.logger,self.config) ids = notifiermodel.get_ids() for id in ids: notifier = notifiermodel.get(id) row = [] row.append(notifier.id) row.append(notifier.name) row.append('Yes' if notifier.enabled else 'No') row.append(notifier.type) row.append(notifier.address) notifiers.add_row(row) print notifiers
def list_all_notifiers(self): notifiers = PrettyTable(['ID', 'Name', 'Enabled', 'Type', 'Address']) notifiers.align = 'l' notifiermodel = NotifierModel(self.logger, self.config) ids = notifiermodel.get_ids() for id in ids: notifier = notifiermodel.get(id) row = [] row.append(notifier.id) row.append(notifier.name) row.append('Yes' if notifier.enabled else 'No') row.append(notifier.type) row.append(notifier.address) notifiers.add_row(row) print notifiers
def enable_notifier(self, enable, id): try: i = int(id) except ValueError: print '%s is not a valid id' % id return notifiermodel = NotifierModel(self.logger, self.config) notifier = notifiermodel.get(i) if notifier == None: print('id: %d does not exist' % i) return notifier.enabled = enable notifiermodel.commit() print('Notifier: %s has been %s' % (notifier.name, 'Enabled' if enable else 'Disabled'))
def list_individual_notifier(self,id): try: i = int(id) except ValueError: print '%s is not a valid id' % id return notifiermodel = NotifierModel(self.logger,self.config) notifier = notifiermodel.get(i) if notifier == None: print('id: %d does not exist' % i) return details = PrettyTable(['Name','Value']) details.align = 'l' details.hrules = ALL details.header = False details.add_row(['ID',notifier.id]) details.add_row(['Name',notifier.name]) details.add_row(['Enabled','Yes' if notifier.enabled else 'No']) details.add_row(['Type',notifier.type]) details.add_row(['Address',notifier.address]) details.add_row(['Pass Count',notifier.pass_count]) details.add_row(['Fail Count',notifier.fail_count]) print details
def list_individual_notifier(self, id): try: i = int(id) except ValueError: print '%s is not a valid id' % id return notifiermodel = NotifierModel(self.logger, self.config) notifier = notifiermodel.get(i) if notifier == None: print('id: %d does not exist' % i) return details = PrettyTable(['Name', 'Value']) details.align = 'l' details.hrules = ALL details.header = False details.add_row(['ID', notifier.id]) details.add_row(['Name', notifier.name]) details.add_row(['Enabled', 'Yes' if notifier.enabled else 'No']) details.add_row(['Type', notifier.type]) details.add_row(['Address', notifier.address]) details.add_row(['Pass Count', notifier.pass_count]) details.add_row(['Fail Count', notifier.fail_count]) print details