Exemple #1
0
    def catalogs(self, **kwargs):
        """Get the catalog information from the infrastructure based on path
        and/or query results. 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 Catalogs
        :rtype: :class:`pypuppetdb.types.Catalog`
        """
        catalogs = self._query('catalogs', **kwargs)

        if type(catalogs) == dict:
            catalogs = [
                catalogs,
            ]

        for catalog in catalogs:
            yield Catalog(node=catalog['certname'],
                          edges=catalog['edges']['data'],
                          resources=catalog['resources']['data'],
                          version=catalog['version'],
                          transaction_uuid=catalog['transaction_uuid'],
                          environment=catalog['environment'],
                          code_id=catalog.get('code_id'),
                          catalog_uuid=catalog.get('catalog_uuid'))
Exemple #2
0
 def test_catalog(self):
     catalog = Catalog('node', [], [], 'unique', None)
     assert catalog.node == 'node'
     assert catalog.version == 'unique'
     assert catalog.transaction_uuid is None
     assert catalog.resources == {}
     assert catalog.edges == []
     assert str(catalog) == str('node/None')
     assert unicode(catalog) == unicode('node/None')
     assert repr(catalog) == str('<Catalog: node/None>')
Exemple #3
0
 def test_catalog_producer(self):
     catalog = Catalog('node', [], [],
                       'unique',
                       None,
                       producer="puppet01.test.com")
     assert catalog.node == 'node'
     assert catalog.version == 'unique'
     assert catalog.transaction_uuid is None
     assert catalog.resources == {}
     assert catalog.edges == []
     assert catalog.producer == 'puppet01.test.com'
     assert str(catalog) == str('node/None')
     assert str(catalog) == str('node/None')
     assert repr(catalog) == str('<Catalog: node/None>')
Exemple #4
0
 def test_catalog_uuid(self):
     catalog = Catalog('node', [], [],
                       'unique',
                       None,
                       catalog_uuid='univerallyuniqueidentifier')
     assert catalog.node == 'node'
     assert catalog.version == 'unique'
     assert catalog.transaction_uuid is None
     assert catalog.resources == {}
     assert catalog.edges == []
     assert str(catalog) == str('node/None')
     assert str(catalog) == str('node/None')
     assert repr(catalog) == str('<Catalog: node/None>')
     assert catalog.catalog_uuid == 'univerallyuniqueidentifier'
Exemple #5
0
    def catalogs(self, **kwargs):
        """Get the catalog information from the infrastructure based on path
        and/or query results. 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 Catalogs
        :rtype: :class:`pypuppetdb.types.Catalog`
        """

        catalogs = self._query('catalogs', **kwargs)

        if type(catalogs) == dict:
            catalogs = [
                catalogs,
            ]

        for catalog in catalogs:
            yield Catalog.create_from_dict(catalog)
Exemple #6
0
 def catalog(self, node):
     """Get the most recent catalog for a given node"""
     c = self._query('catalogs', path=node)
     return Catalog(c['data']['name'], c['data']['edges'],
                    c['data']['resources'], c['data']['version'],
                    c['data']['transaction-uuid'])