Example #1
0
    def test_edge(self):
        resource_a = Resource('node',
                              '/etc/ssh/sshd_config',
                              'file', ['class', 'ssh'],
                              False,
                              '/ssh/manifests/init.pp',
                              15,
                              parameters={})

        resource_b = Resource('node',
                              'sshd',
                              'service', ['class', 'ssh'],
                              False,
                              '/ssh/manifests/init.pp',
                              30,
                              parameters={})

        edge = Edge(resource_a, resource_b, 'notify')

        assert edge.source == resource_a
        assert edge.target == resource_b
        assert edge.relationship == 'notify'
        assert str(edge) == str(
            'file[/etc/ssh/sshd_config] - notify - service[sshd]')
        assert unicode(edge) == unicode(
            'file[/etc/ssh/sshd_config] - notify - service[sshd]')
        assert repr(edge) == str(
            '<Edge: file[/etc/ssh/sshd_config] - notify - service[sshd]>')
Example #2
0
    def edges(self, **kwargs):
        """Get the known catalog edges, formed between two resources.

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

        :returns: A generating yielding Edges.
        :rtype: :class:`pypuppetdb.types.Edge`
        """
        edges = self._query('edges', **kwargs)

        for edge in edges:
            yield Edge.create_from_dict(edge)
Example #3
0
    def edges(self, **kwargs):
        """Get the known catalog edges, formed between two resources.

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

        :returns: A generating yielding Edges.
        :rtype: :class:`pypuppetdb.types.Edge`
        """
        edges = self._query('edges', **kwargs)

        for edge in edges:
            identifier_source = edge['source_type'] + '[' + edge['source_title'] + ']'
            identifier_target = edge['target_type'] + '[' + edge['target_title'] + ']'
            yield Edge(source=self.resources[identifier_source],
                       target=self.resources[identifier_target],
                       relationship=edge['relationship'],
                       node=edge['certname'])