Created
October 23, 2020 15:13
-
-
Save jlsherrill/7c9f244f4674f2d27684a1f9bba831b0 to your computer and use it in GitHub Desktop.
katello-agent replacement POC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'qpid_proton' | |
MESSAGE = '{"data": {"consumer_id": "e6c21274-e8a2-4484-a4cb-8d4edba0710b", "task_id": "abcd"}, "pam": null, "replyto": "pulp.task", "request": {"args": [[{"type_id": "rpm", "unit_key": {"name": "screen"}}], {"importkeys": true}], "classname": "Content", "cntr": [[], {}], "kws": {}, "method": "uninstall"}, "routing": [null, "pulp.agent.e6c21274-e8a2-4484-a4cb-8d4edba0710b"], "secret": "abcdefg", "sn": "23fc34ce-2992-45df-91cc-4169f62d0e5f", "version": "2.0"}' | |
class SimpleSend < Qpid::Proton::MessagingHandler | |
def initialize(url, address, expected) | |
super() | |
@url = url | |
@address = address | |
@sent = 0 | |
@confirmed = 0 | |
@expected = expected | |
end | |
def on_container_start(container) | |
ssl_domain = Qpid::Proton::SSLDomain.new(Qpid::Proton::SSLDomain::MODE_CLIENT) | |
ssl_domain.credentials("/tmp/client.crt", "/tmp/client.crt", nil) | |
c = container.connect(@url, { :ssl_domain => ssl_domain }) | |
c.open_sender(@address) | |
end | |
def on_sendable(sender) | |
while sender.credit > 0 && @sent < @expected | |
msg = Qpid::Proton::Message.new(MESSAGE, { :id => @sent } ) | |
sender.send(msg) | |
@sent = @sent + 1 | |
end | |
end | |
def on_tracker_accept(tracker) | |
@confirmed = @confirmed + 1 | |
if @confirmed == @expected | |
puts "All #{@expected} messages confirmed!" | |
tracker.connection.close | |
end | |
end | |
end | |
cert = "/etc/pki" | |
url = "amqps://localhost:5671" | |
address = "pulp.agent.e6c21274-e8a2-4484-a4cb-8d4edba0710b" | |
Qpid::Proton::Container.new(SimpleSend.new(url, address, 1)).run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment