Skip to content

Instantly share code, notes, and snippets.

View cemsbr's full-sized avatar

Carlos Eduardo Moreira dos Santos cemsbr

  • São Paulo, Brazil
View GitHub Profile
@cemsbr
cemsbr / multiple_exceptions.py
Created June 15, 2016 17:16
Throw multiple validation errors
# based on http://stackoverflow.com/questions/6470428/catch-multiple-exceptions-in-one-line-except-block
class ValidationError(Exception):
pass
class ValidationErrors(ValidationError):
def __str__(self):
return ' '.join(str(e) for e in self.args[0])
@cemsbr
cemsbr / test_barrier_reply.py
Created July 27, 2016 14:52
Pattern for testing raw dumps
import unittest
from pyof.v0x01.controller2switch.barrier_reply import BarrierReply
from tests.rawdump import RawDump
class TestBarrierReply(unittest.TestCase):
def setUp(self):
self.message = BarrierReply(xid=5)
self.raw_file = RawDump('v0x01').read('ofpt_barrier_reply')
@cemsbr
cemsbr / flows.json
Created November 12, 2016 16:10
Switch flows *:8181/kytos/stats/00:00:00:00:00:00:00:01/flows
{
"data": [
{
"byte_count": 2.210526315789474,
"flow_id": "270c2bf0814144dd2d61754c99c36ea7",
"packet_count": 0.05263157894736842
},
{
"byte_count": 1061.964344855589,
"flow_id": "28839aa2f877f12efb7936affe6e2ad5",
@cemsbr
cemsbr / flow.json
Created November 12, 2016 16:21
Stats of a flow
{
"data": {
"byte_count": [],
"packet_count": [],
"timestamps": []
}
}
@cemsbr
cemsbr / flows_ping_h1.json
Created November 14, 2016 00:04
h1 ping h2, this is dpid ...:01
{
"data": [
{
"actions": [
{
"port": 2,
"type": "action_output"
}
],
"buffer_id": null,
@cemsbr
cemsbr / flows_ping_h2.json
Created November 14, 2016 00:05
h1 ping h2, this is dpid ...:02
{
"data": [
{
"actions": [
{
"port": 2,
"type": "action_output"
}
],
"buffer_id": null,
@cemsbr
cemsbr / flows_iperf_h1.json
Created November 14, 2016 00:11
h1 iperf h2, this is dpid ...:01
{
"data": [
{
"actions": [
{
"port": 2,
"type": "action_output"
}
],
"buffer_id": null,
@cemsbr
cemsbr / flows_iperf_h2.json
Created November 14, 2016 00:12
h1 iperf h2, this is dpid ...:02
{
"data": [
{
"actions": [
{
"port": 2,
"type": "action_output"
}
],
"buffer_id": null,
@cemsbr
cemsbr / chord.html
Last active November 14, 2016 22:54
Flow chord
<!DOCTYPE html>
<script>//<![CDATA[
document.write('<script src="//' + (location.hostname || 'localhost') + ':35729/livereload.js?snipver=1"><\/script>')
//]]></script>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
[tox]
envlist = py36
[testenv]
whitelist_externals=
rm
make
commands=
; Force packaging even if setup.{py,cfg} haven't changed