Skip to content

Instantly share code, notes, and snippets.

@yasuhito
yasuhito / rest.rb
Last active December 11, 2015 08:28
get 'slices/:slice_id' do
rest_api { Slice.find_by!(name: params[:slice_id]) }
end
class Slice
def self.find_by!(query)
# ...
remote_klass =
Trema.trema_process('RoutingSwitch', socket_dir).controller.slice
remote_klass.find_by!(query)
# L2 routing path manager
class PathManager < Trema::Controller
def packet_in(_dpid, message)
path = maybe_create_shortest_path(message)
ports = path ? [path.out_port] : @graph.external_ports
ports.each do |each|
send_packet_out(each.dpid,
raw_data: message.raw_data,
actions: SendOutPort.new(each.number))
end
class RoutingSwitch < Trema::Controller
# ...
def start_topology
TopologyController.new { |topo| topo.add_observer @path_manager }.start
end
end
class PathManager < Trema::Controller
# ...
def delete_link(port_a, port_b, _topology)
@yasuhito
yasuhito / git_issue.zsh
Last active September 4, 2015 10:08
https://gist.github.com/azu/d3fb5f970e4ff945ead4 を percol から peco にしただけのモノです
# peco + git issue
function found_command { which $1 &> /dev/null }
function is_issued() {
ISSUE_TYPE=$(git config issue.type 2>/dev/null)
if [ "$ISSUE_TYPE" != "" ]; then
return 0
else
return 1
fi
}
@yasuhito
yasuhito / gist:9262976
Last active August 29, 2015 13:56
Trema を使っている人々

ソフトウェア・サービス

Wakame-vdc: Datacenter Hypervisor - Open Source Cloud Computing / IaaS

  • プレスリリース: http://axsh.jp/news/publicity/894
  • ソースコード: https://github.com/axsh/wakame-vdc/
  • 主なユーザ
    • 国立情報学研究所 (プライベートクラウド)
    • 九州電力 (プライベートクラウド)
    • 大手メーカー (顧客向けWebシステムの基盤として)
    • NTTPCコミュニケーションズ WebARENA VPSクラウド (パブリッククラウド)
    • 京セラコミュニケーションシステム GreenOffice Unified Cloud (パブリッククラウド)
@yasuhito
yasuhito / gist:9085031
Last active August 29, 2015 13:56
Trema ハンズオン@沖縄

Trema ハンズオン@沖縄

ハンズオンで使う VM とセットアップ方法を説明します。

当日までに VM にログインできることを確認 しておいてください。

必要なハードウェア

@yasuhito
yasuhito / gist:6596629
Created September 17, 2013 16:16
Hello World
$><<[[[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []], [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []], [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []
git clone https://github.com/trema/trema-edge.git
Cloning into 'trema-edge'...
remote: Counting objects: 15697, done.
remote: Compressing objects: 100% (3932/3932), done.
remote: Total 15697 (delta 12073), reused 15309 (delta 11690)
Receiving objects: 100% (15697/15697), 13.43 MiB | 881 KiB/s, done.
Resolving deltas: 100% (12073/12073), done.
@yasuhito
yasuhito / gist:4760689
Created February 12, 2013 06:52
Vote-for-Trema-on-every-packet_in-receive controller
require "rubygems"
require "mechanize"
class VoteForTrema < Controller
def start
info "OK, I'm registered to vote"
end
@yasuhito
yasuhito / gist:4543998
Last active December 11, 2015 04:18
Trema のチュートリアルいろいろ
* Trema in 10 minutes: http://trema-10min.heroku.com/
プログラマ向けの「10 分で分かる Trema」資料です。
* Trema Tutorial: http://trema-tutorial.heroku.com/
* GEC Trema Tutorial: http://trema-tutorial-gec13.heroku.com/
Trema の基本的なチュートリアルです (それぞれ約 3 時間分)
チュートリアル用のファイルは→ https://github.com/trema/tutorial.files
* Test-first OpenFlow Programming with Trema: http://testfirst-trema.heroku.com/
* Trema でテスト駆動 OpenFlow プログラミング: http://trema-tutorial-ja.heroku.com/