def moveOrganizer(self, moveTarget, organizerPaths=None, REQUEST=None): """ Move organizers under this organizer to another organizer @param moveTarget: Name of the destination organizer @type moveTarget: string @param organizerPaths: Paths of organizers to be moved @type organizerPaths: list >>> dmd.Events.Status.moveOrganizer('/Events/Ignore', ... ['Ping', 'Snmp']) """ if not moveTarget or not organizerPaths: return self() target = self.getDmdRoot(self.dmdRootName).getOrganizer(moveTarget) movedStuff = False for organizerName in organizerPaths: if moveTarget.find(organizerName) > -1: continue obj = self._getOb(organizerName, None) if obj is None: continue obj._operation = 1 #move object self._delObject(organizerName) target._setObject(organizerName, obj) movedStuff = True if REQUEST: if movedStuff: plural = '' if len(organizerPaths) > 1: plural = 's' for organizerName in organizerPaths: audit(('UI', getDisplayType(self), 'Move'), organizerName, data_={ 'from': getDisplayName(self), 'to': getDisplayName(target) }) messaging.IMessageSender(self).sendToBrowser( 'Organizers Moved', '%s%s %s were moved to %s.' % (getDisplayType(self), plural, ', '.join(organizerPaths), moveTarget)) else: messaging.IMessageSender(self).sendToBrowser( 'Error', 'No %s were moved.' % getDisplayType(self), priority=messaging.WARNING) return target.callZenScreen(REQUEST)
def moveInstances(self, moveTarget, ids=None, REQUEST=None): """Move instances from this EventClass to moveTarget. """ if not moveTarget or not ids: return self() if isinstance(ids, basestring): ids = (ids, ) target = self.getChildMoveTarget(moveTarget) for id in ids: rec = self.instances._getOb(id, None) if rec is None: continue rec._operation = 1 # moving object state self.instances._delObject(id) target.instances._setObject(id, rec) if REQUEST: audit('UI.EventClassMapping.Move', id, data_={ 'from': getDisplayName(self), 'to': getDisplayName(target) }) if REQUEST: REQUEST['RESPONSE'].redirect(target.getPrimaryUrlPath())
def moveInstances(self, moveTarget, ids=None, REQUEST=None): """Move instances from this EventClass to moveTarget. """ if not moveTarget or not ids: return self() if isinstance(ids, basestring): ids = (ids,) target = self.getChildMoveTarget(moveTarget) for id in ids: rec = self.instances._getOb(id, None) if rec is None: continue rec._operation = 1 # moving object state self.instances._delObject(id) target.instances._setObject(id, rec) if REQUEST: audit('UI.EventClassMapping.Move', id, data_={ 'from': getDisplayName(self), 'to': getDisplayName(target) }) if REQUEST: REQUEST['RESPONSE'].redirect(target.getPrimaryUrlPath())
def manage_editEventClassInst(self, name='', eventClassKey='', regex='', rule='', example='', transform='', explanation='', resolution='', REQUEST=None): """Edit an EventClassInst from a web page.""" #save arguments for audit logging values = locals() oldValues = { 'name': getDisplayName(self), 'eventClassKey': self.eventClassKey, 'regex': self.regex, 'rule': self.rule, 'example': self.example, 'transform': self.transform, 'explanation': self.explanation, 'resolution': self.resolution, } redirect = self.rename(name) if eventClassKey and self.eventClassKey != eventClassKey: self.unindex_object() self.sequence = self.eventClass().nextSequenceNumber(eventClassKey) self.eventClassKey = eventClassKey self.index_object() self.regex = regex self.rule = rule self.example = example self.transform = transform self.explanation = explanation self.resolution = resolution if REQUEST: audit('UI.EventClassMapping.Edit', self, data_=values, oldData_=oldValues, skipFields_=['self', 'REQUEST']) messaging.IMessageSender(self).sendToBrowser( 'Saved', SaveMessage()) return self.callZenScreen(REQUEST, redirect)
def manage_editEventClassInst(self, name='', eventClassKey='', regex='', rule='', example='', transform='', explanation='', resolution='', REQUEST=None): """Edit an EventClassInst from a web page.""" #save arguments for audit logging values = locals() oldValues = { 'name':getDisplayName(self), 'eventClassKey':self.eventClassKey, 'regex':self.regex, 'rule':self.rule, 'example':self.example, 'transform':self.transform, 'explanation':self.explanation, 'resolution':self.resolution, } redirect = self.rename(name) if eventClassKey and self.eventClassKey != eventClassKey: self.unindex_object() self.sequence = self.eventClass().nextSequenceNumber(eventClassKey) self.eventClassKey = eventClassKey self.index_object() self.regex = regex self.rule = rule self.example = example self.transform = transform self.explanation = explanation self.resolution = resolution if REQUEST: audit('UI.EventClassMapping.Edit', self, data_=values, oldData_=oldValues, skipFields_=['self','REQUEST']) messaging.IMessageSender(self).sendToBrowser( 'Saved', SaveMessage()) return self.callZenScreen(REQUEST, redirect)
def moveOrganizer(self, moveTarget, organizerPaths=None, REQUEST=None): """ Move organizers under this organizer to another organizer @param moveTarget: Name of the destination organizer @type moveTarget: string @param organizerPaths: Paths of organizers to be moved @type organizerPaths: list >>> dmd.Events.Status.moveOrganizer('/Events/Ignore', ... ['Ping', 'Snmp']) """ if not moveTarget or not organizerPaths: return self() target = self.getDmdRoot(self.dmdRootName).getOrganizer(moveTarget) movedStuff = False for organizerName in organizerPaths: if moveTarget.find(organizerName) > -1: continue obj = self._getOb(organizerName, None) if obj is None: continue obj._operation = 1 #move object self._delObject(organizerName) target._setObject(organizerName, obj) movedStuff = True if REQUEST: if movedStuff: plural = '' if len(organizerPaths) > 1: plural = 's' for organizerName in organizerPaths: audit(('UI', getDisplayType(self), 'Move'), organizerName, data_={'from':getDisplayName(self), 'to':getDisplayName(target)}) messaging.IMessageSender(self).sendToBrowser( 'Organizers Moved', '%s%s %s were moved to %s.' % (getDisplayType(self), plural, ', '.join(organizerPaths), moveTarget) ) else: messaging.IMessageSender(self).sendToBrowser( 'Error', 'No %s were moved.' % getDisplayType(self), priority=messaging.WARNING ) return target.callZenScreen(REQUEST)