Skip to content

Instantly share code, notes, and snippets.

@bmbouter
bmbouter / external_epoll_loop.py
Created March 12, 2014 19:21
Python external epoll loop example with Proton 0.7 RC
import select
from proton import Message
from proton import Messenger
known_selectables = {}
def epoll_events(sel):
events = 0
if sel.capacity > 0:
@bmbouter
bmbouter / find_print.py
Created July 24, 2015 13:20
monkey patch stderr and stdout to show call stack when a specific print statement occurs.
import sys
class fake_out:
def __init__(self, stream):
self._stream = stream
for name in dir(stream):
if name != "write" and not name.startswith("_"):
setattr(self, name, getattr(stream, name))
def write(self, s):
self._stream.write(s)
if "enter your password" in s.lower():
@bmbouter
bmbouter / foreman.dot
Last active August 29, 2015 14:28 — forked from ehelms/foreman.dot
@startuml
[Browser] as browser
node "Client" {
[Client (RHSM)] as client_rhsm
[Goferd+Katello Agent] as client_goferd
[Puppet] as client_puppet
}
@bmbouter
bmbouter / pulp_synchronous.dot
Last active October 23, 2015 18:26
Pulp Synchronous Request
@startuml
title Synchronous Task Example (create repo)
autonumber
actor "API Client" as client
client -> "Pulp API (httpd)" as httpd : create repo
httpd -> MongoDB: create repo record(s)
MongoDB -> httpd: return after creating new record(s)
httpd -> client: create repo API response
@bmbouter
bmbouter / pulp_asynchronous.dot
Last active October 23, 2015 19:35
Pulp Asynchronous Request
@startuml
title Asynchronous Task Example (sync)
actor "API Client" as client
autonumber
client -> httpd: sync repo
httpd -> MongoDB: create TaskStatus record
httpd -> "resource_manager Queue" as rmQueue: dispatch Task to Resource Manager Queue
httpd -> client: TaskStatus info including UUID
@bmbouter
bmbouter / pulp_consumer_action.dot
Created October 23, 2015 19:31
Pulp Consumer Action
@startuml
title Pulp Consumer Action Example (bind to repo)
actor "API Client" as client
autonumber
client -> httpd: bind consumer 'foo' to repo 'bar'
httpd -> MongoDB: create TaskStatus record
httpd -> "Dedicated Queue for Consumer 'foo'" as fooQueue: dispatch message to bind to repo 'bar'
...Time passes until consumer 'foo' Connects to Qpid...
@bmbouter
bmbouter / pulp_architecture_diagram.dot
Created October 23, 2015 21:02
Pulp Architecture Diagram
@startuml
title Pulp Architecture Diagram
actor client
node httpd
database MongoDB
node pulp_celerybeat
node pulp_resource_manager
node "pulp_worker1" as worker1
@bmbouter
bmbouter / pulp_cancel_tasks.sh
Created November 2, 2016 17:42
This gist will cancel all incomplete and unstarted Pulp tasks. This is designed for Pulp 2.y
# This gist will cancel all incomplete and unstarted Pulp 2.y tasks
pulp-admin -u admin -p admin tasks list | grep -ohe '[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}' | sort | uniq | while read uuid ; do
pulp-admin -u admin -p admin tasks cancel --task-id $uuid
done
@bmbouter
bmbouter / sprint.py
Last active August 17, 2017 17:59
A helper script to produce a Pulp blog post and written email from sprint demo data.
import argparse
import csv
"""
Make a Python 3 virtualenv and install requests and PyYAML
pyvenv sprint_demos
source sprint_demos/bin/activate
Run the script using the Python3 interpreter
#!/usr/bin/env python26
# python26 docs-fixer.py /path/to/docs/html
# originally made by github user werwty.
import os
import sys
inserted_html="""