def test_event_failed(): event = Event('node1.puppet.board', 'success', '2013-08-01T10:57:00.000Z', 'hash#', '/etc/ssh/sshd_config', 'ensure', 'Nothing to say', 'present', 'absent', 'file') assert event.status == 'success' assert event.failed is False
def events(self, **kwargs): """A report is made up of events which can be queried either individually or based on their associated report hash. It is strongly recommended to include query and/or paging parameters for this endpoint to prevent large result sets or PuppetDB performance bottlenecks. :param \*\*kwargs: The rest of the keyword arguments are passed to the _query function :returns: A generator yielding Events :rtype: :class:`pypuppetdb.types.Event` """ events = self._query('events', **kwargs) for event in events: yield Event( node=event['certname'], status=event['status'], timestamp=event['timestamp'], hash_=event['report'], title=event['resource_title'], property_=event['property'], message=event['message'], new_value=event['new_value'], old_value=event['old_value'], type_=event['resource_type'], class_=event['containing_class'], execution_path=event['containment_path'], source_file=event['file'], line_number=event['line'], )
def events(self, query, order_by=None, limit=None): """A report is made up of events. This allows to query for events based on the reprt hash. This yields an Event object for every returned event.""" events = self._query('events', query=query, order_by=order_by, limit=limit) for event in events: yield Event( event['certname'], event['status'], event['timestamp'], event['report'], event['resource-title'], event['property'], event['message'], event['new-value'], event['old-value'], event['resource-type'], event['containing-class'], event['containment-path'], event['file'], event['line'], )
def test_event_failed(self): event = Event( 'node', 'success', '2013-08-01T10:57:00.000Z', 'hash#', '/etc/ssh/sshd_config', 'ensure', 'Nothing to say', 'present', 'absent', 'file', 'Ssh::Server', ['Stage[main]', 'Ssh::Server', 'File[/etc/ssh/sshd_config]'], '/etc/puppet/modules/ssh/manifests/server.pp', 80) assert event.status == 'success' assert event.failed is False
def events(self, **kwargs): """A report is made up of events which can be queried either individually or based on their associated report hash. It is strongly recommended to include query and/or paging parameters for this endpoint to prevent large result sets or PuppetDB performance bottlenecks. :param \*\*kwargs: The rest of the keyword arguments are passed to the _query function :returns: A generator yielding Events :rtype: :class:`pypuppetdb.types.Event` """ events = self._query('events', **kwargs) for event in events: yield Event.create_from_dict(event)
def test_event(): event = Event('node1.puppet.board', 'failure', '2013-08-01T10:57:00.000Z', 'hash#', '/etc/ssh/sshd_config', 'ensure', 'Nothing to say', 'present', 'absent', 'file') assert event.node == 'node1.puppet.board' assert event.status == 'failure' assert event.failed is True assert event.timestamp == json_to_datetime('2013-08-01T10:57:00.000Z') assert event.hash_ == 'hash#' assert event.item['title'] == '/etc/ssh/sshd_config' assert event.item['type'] == 'file' assert event.item['property'] == 'ensure' assert event.item['message'] == 'Nothing to say' assert event.item['old'] == 'absent' assert event.item['new'] == 'present' assert str(event) == str('file[/etc/ssh/sshd_config]/hash#') assert repr(event) == str('Event: file[/etc/ssh/sshd_config]/hash#')
def events(self, query): """A report is made up of events. This allows to query for events based on the reprt hash. This yields an Event object for every returned event.""" events = self._query('events', query=query) for event in events: yield Event( event['certname'], event['status'], event['timestamp'], event['report'], event['resource-title'], event['property'], event['message'], event['new-value'], event['old-value'], event['resource-type'], )
def test_event(self): event = Event( 'node', 'failure', '2013-08-01T10:57:00.000Z', 'hash#', '/etc/ssh/sshd_config', 'ensure', 'Nothing to say', 'present', 'absent', 'file', 'Ssh::Server', ['Stage[main]', 'Ssh::Server', 'File[/etc/ssh/sshd_config]'], '/etc/puppet/modules/ssh/manifests/server.pp', 80) assert event.node == 'node' assert event.status == 'failure' assert event.failed is True assert event.timestamp == json_to_datetime('2013-08-01T10:57:00.000Z') assert event.hash_ == 'hash#' assert event.item['title'] == '/etc/ssh/sshd_config' assert event.item['type'] == 'file' assert event.item['property'] == 'ensure' assert event.item['message'] == 'Nothing to say' assert event.item['old'] == 'absent' assert event.item['new'] == 'present' assert str(event) == str('file[/etc/ssh/sshd_config]/hash#') assert unicode(event) == unicode('file[/etc/ssh/sshd_config]/hash#') assert repr(event) == str('Event: file[/etc/ssh/sshd_config]/hash#')
'run_time_max': datetime.timedelta(seconds=1000), 'with_failures': 2, 'with_changes': 2, 'with_skips': 2, }, }, } EVENT_DATA = { '["=", "report", "hash1"]': [ Event( u'node1.example.com', u'otherstatus', u'2014-06-18T13:02:54.122000Z', u'14eaf89f52496f94bae336d454b60fac6189ff1b', u'srvadmin-idrac7', u'ensure', u'failure message here', u'present', u'absent', u'Package', ), ], '["=", "report", "hash2"]': [ Event( u'node1.example.com', u'failure', u'2014-06-18T13:02:54.122000Z', u'14eaf89f52496f94bae336d454b60fac6189ff1b', u'srvadmin-idrac7', u'ensure', u'failure message here',