How to use the pypuppetdb.types.Report function in pypuppetdb

To help you get started, we’ve selected a few pypuppetdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github voxpupuli / pypuppetdb / tests / test_types.py View on Github external
def test_report(self):
        report = Report('_', 'node1.puppet.board', 'hash#',
                        '2013-08-01T09:57:00.000Z',
                        '2013-08-01T10:57:00.000Z',
                        '2013-08-01T10:58:00.000Z',
                        '1351535883', 3, '3.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        status='success')

        assert report.node == 'node1.puppet.board'
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2013-08-01T09:57:00.000Z')
        assert report.end == json_to_datetime('2013-08-01T10:57:00.000Z')
        assert report.received == json_to_datetime('2013-08-01T10:58:00.000Z')
        assert report.version == '1351535883'
        assert report.format_ == 3
        assert report.agent_version == '3.2.1'
        assert report.run_time == report.end - report.start
github voxpupuli / pypuppetdb / tests / test_types.py View on Github external
def test_report_with_noop(self):
        report = Report('_', 'node2.puppet.board', 'hash#',
                        '2015-08-31T21:07:00.000Z',
                        '2015-08-31T21:09:00.000Z',
                        '2015-08-31T21:10:00.000Z',
                        '1482347613', 4, '4.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        status='unchanged',
                        noop=True,
                        noop_pending=False)

        assert report.node == 'node2.puppet.board'
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
github voxpupuli / pypuppetdb / tests / test_types.py View on Github external
def test_report_with_cataloguuid_codeid(self):
        report = Report('_', 'node2.puppet.board', 'hash#',
                        '2015-08-31T21:07:00.000Z',
                        '2015-08-31T21:09:00.000Z',
                        '2015-08-31T21:10:00.000Z',
                        '1482347613', 4, '4.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        code_id=None,
                        catalog_uuid="0b3a4943-a164-4cea-bbf0-91d0ee931326",
                        cached_catalog_status="not_used")

        assert report.node == 'node2.puppet.board'
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
github voxpupuli / pypuppetdb / tests / test_types.py View on Github external
def test_report_with_pending_noop(self):
        report = Report('_', 'node2.puppet.board', 'hash#',
                        '2015-08-31T21:07:00.000Z',
                        '2015-08-31T21:09:00.000Z',
                        '2015-08-31T21:10:00.000Z',
                        '1482347613', 4, '4.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        status='unchanged',
                        noop=True,
                        noop_pending=True)

        assert report.node == 'node2.puppet.board'
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
github voxpupuli / pypuppetdb / tests / test_types.py View on Github external
def test_report_with_failed_noop(self):
        report = Report('_', 'node2.puppet.board', 'hash#',
                        '2015-08-31T21:07:00.000Z',
                        '2015-08-31T21:09:00.000Z',
                        '2015-08-31T21:10:00.000Z',
                        '1482347613', 4, '4.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        status='failed',
                        noop=True,
                        noop_pending=False)

        assert report.node == 'node2.puppet.board'
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
github voxpupuli / pypuppetdb / tests / test_types.py View on Github external
def test_report_with_producer(self):
        report = Report('_', "test.test.com", "hash#",
                        '2015-08-31T21:07:00.000Z',
                        '2015-08-31T21:09:00.000Z',
                        '2015-08-31T21:10:00.000Z',
                        '1482347613', 4, '4.2.1',
                        'af9f16e3-75f6-4f90-acc6-f83d6524a6f3',
                        producer="puppet01.test.com")

        assert report.node == "test.test.com"
        assert report.hash_ == 'hash#'
        assert report.start == json_to_datetime('2015-08-31T21:07:00.000Z')
        assert report.end == json_to_datetime('2015-08-31T21:09:00.000Z')
        assert report.received == json_to_datetime('2015-08-31T21:10:00.000Z')
        assert report.version == '1482347613'
        assert report.format_ == 4
        assert report.agent_version == '4.2.1'
        assert report.run_time == report.end - report.start
github voxpupuli / pypuppetdb / pypuppetdb / api.py View on Github external
def reports(self, **kwargs):
        """Get reports for our infrastructure. It is strongly recommended
        to include query and/or paging parameters for this endpoint to
        prevent large result sets and potential PuppetDB performance
        bottlenecks.

        :param \*\*kwargs: The rest of the keyword arguments are passed
                           to the _query function

        :returns: A generating yielding Reports
        :rtype: :class:`pypuppetdb.types.Report`
        """
        reports = self._query('reports', **kwargs)
        for report in reports:
            yield Report(
                api=self,
                node=report['certname'],
                hash_=report['hash'],
                start=report['start_time'],
                end=report['end_time'],
                received=report['receive_time'],
                version=report['configuration_version'],
                format_=report['report_format'],
                agent_version=report['puppet_version'],
                transaction=report['transaction_uuid'],
                environment=report['environment'],
                status=report['status'],
                noop=report.get('noop'),
                noop_pending=report.get('noop_pending'),
                metrics=report['metrics']['data'],
                logs=report['logs']['data'],
github voxpupuli / pypuppetdb / pypuppetdb / api / v4.py View on Github external
def reports(self, **kwargs):
        """Get reports for our infrastructure. It is strongly recommended
        to include query and/or paging parameters for this endpoint to
        prevent large result sets and potential PuppetDB performance
        bottlenecks.

        :param \*\*kwargs: The rest of the keyword arguments are passed
                           to the _query function

        :returns: A generating yielding Reports
        :rtype: :class:`pypuppetdb.types.Report
        """
        reports = self._query('reports', **kwargs)
        for report in reports:
            yield Report(
                api=self,
                node=report['certname'],
                hash_=report['hash'],
                start=report['start_time'],
                end=report['end_time'],
                received=report['receive_time'],
                version=report['configuration_version'],
                format_=report['report_format'],
                agent_version=report['puppet_version'],
                transaction=report['transaction_uuid'],
                environment=report['environment'],
                status=report['status'],
                noop=report['noop'],
                metrics=report['metrics']['data'],
                logs=report['logs']['data']
            )
github voxpupuli / pypuppetdb / pypuppetdb / api / v3.py View on Github external
def reports(self, query):
        """Get reports for our infrastructure. Currently reports can only
        be filtered through a query which requests a specific certname.
        If not it will return all reports.

        This yields a Report object for every returned report."""
        reports = self._query('reports', query=query)
        for report in reports:
            yield Report(
                report['certname'],
                report['hash'],
                report['start-time'],
                report['end-time'],
                report['receive-time'],
                report['configuration-version'],
                report['report-format'],
                report['puppet-version'],
                report['transaction-uuid']
                )
github southampton / cortex / lib / puppet.py View on Github external
catalog_timestamp=node['catalog_timestamp'],
				facts_timestamp=node['facts_timestamp'],
				status_report=node['status_report'],
				noop=node.get('latest_report_noop'),
				noop_pending=node.get('latest_report_noop_pending'),
				events=node['events'],
				unreported=node.get('unreported'),
				unreported_time=node.get('unreported_time'),
				report_environment=node['report_environment'],
				catalog_environment=node['catalog_environment'],
				facts_environment=node['facts_environment'],
				latest_report_hash=node.get('latest_report_hash'),
				cached_catalog_status=node.get('cached_catalog_status')
			)

class CortexPuppetReport(pypuppetdb.types.Report):
	"""
	Override pypuppetdb.types.Report to make the noop status available.
	"""

	# pylint: disable=dangerous-default-value
	def __init__(self, api, node, hash_, start, end, received, version, format_, agent_version, transaction, status=None, metrics={}, logs={}, environment=None, noop=False, noop_pending=False, code_id=None, catalog_uuid=None, cached_catalog_status=None, producer=None):
		# Call super init.
		super(CortexPuppetReport, self).__init__(api, node, hash_, start, end, received, version, format_, agent_version, transaction, status, metrics, logs, environment, noop, noop_pending, code_id, catalog_uuid, cached_catalog_status, producer)
		# Set noop
		self.noop = noop

class CortexPuppetNode(pypuppetdb.types.Node):
	"""
	Override pypuppetdb.types.Node to make the noop status available.
	"""