Sha256: 40420bdeebbd3a2bd8f21c3eeef0e7af5fcbd12492202d19e0babafab76584ce

Contents?: true

Size: 1.62 KB

Versions: 20

Compression:

Stored size: 1.62 KB

Contents

#
# The controller class of ovs-ofctl.
#
# Author: Yasuhito Takamiya <yasuhito@gmail.com>
#
# Copyright (C) 2008-2012 NEC Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#


require "trema/executables"
require "trema/flow"


module Trema
  class Ofctl
    def add_flow switch, options
      actions = options[ :actions ]
      options.delete :actions
      option_string = options.collect do | k, v |
        "#{ k }=#{ v }"
      end.join( "," )
      sh "sudo #{ Executables.ovs_ofctl } add-flow #{ switch.network_device } #{ option_string },actions=#{ actions } 2>/dev/null"
    end


    def flows switch
      dump_flows( switch ).split( "\n" )[ 1..-1 ].collect do | each |
        Trema::Flow.parse( each )
      end.compact
    end


    def users_flows switch
      flows( switch ).select( &:users_flow? )
    end


    def dump_flows switch
      `sudo #{ Executables.ovs_ofctl } dump-flows #{ switch.network_device } 2>&1`
    end
  end
end


### Local variables:
### mode: Ruby
### coding: utf-8-unix
### indent-tabs-mode: nil
### End:

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
trema-0.3.6 ruby/trema/ofctl.rb
trema-0.3.5 ruby/trema/ofctl.rb
trema-0.3.4 ruby/trema/ofctl.rb
trema-0.3.3 ruby/trema/ofctl.rb
trema-0.3.2 ruby/trema/ofctl.rb
trema-0.3.1 ruby/trema/ofctl.rb
trema-0.3.0 ruby/trema/ofctl.rb
trema-0.2.8 ruby/trema/ofctl.rb
trema-0.2.7 ruby/trema/ofctl.rb
trema-0.2.6 ruby/trema/ofctl.rb
trema-0.2.5 ruby/trema/ofctl.rb
trema-0.2.4 ruby/trema/ofctl.rb
trema-0.2.3 ruby/trema/ofctl.rb
trema-0.2.2.1 ruby/trema/ofctl.rb
trema-0.2.2 ruby/trema/ofctl.rb
trema-0.2.1 ruby/trema/ofctl.rb
trema-0.2.0 ruby/trema/ofctl.rb
trema-0.1.3.2 ruby/trema/ofctl.rb
trema-0.1.3.1 ruby/trema/ofctl.rb
trema-0.1.3 ruby/trema/ofctl.rb