Sha256: 8a841ba93ac43bc1b78dd45d80fbe902828747c0497e66c9bc3e43656ab0ea99

Contents?: true

Size: 1.75 KB

Versions: 19

Compression:

Stored size: 1.75 KB

Contents

#
# Copyright (C) 2008-2013 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/util"


module Trema
  module Command
    include Trema::Util


    def trema_kill name
      unless maybe_kill( name )
        exit_now! "unknown name: #{ name }"
      end
    end


    ############################################################################
    private
    ############################################################################


    def maybe_kill name
      killed = maybe_kill_app( name ) || nil
      killed ||= maybe_shutdown_host( name )
      killed ||= maybe_shutdown_switch( name )
      # [TODO] kill a link by its name. Needs a good naming convension for link.
      killed
    end


    def maybe_kill_app name
      app = find_app_by_name( name )
      app.kill! if app
      app
    end


    def maybe_shutdown_host name
      host = find_host_by_name( name )
      host.shutdown! if host
      host
    end


    def maybe_shutdown_switch name
      switch = find_switch_by_name( name )
      switch.shutdown if switch
      switch
    end
  end
end


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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
trema-0.4.6 ruby/trema/command/kill.rb
trema-0.4.5 ruby/trema/command/kill.rb
trema-0.4.4 ruby/trema/command/kill.rb
trema-0.4.3 ruby/trema/command/kill.rb
trema-0.4.2 ruby/trema/command/kill.rb
trema-0.4.1 ruby/trema/command/kill.rb
trema-0.4.0 ruby/trema/command/kill.rb
trema-0.3.21 ruby/trema/command/kill.rb
trema-0.3.20 ruby/trema/command/kill.rb
trema-0.3.19 ruby/trema/command/kill.rb
trema-0.3.18 ruby/trema/command/kill.rb
trema-0.3.17 ruby/trema/command/kill.rb
trema-0.3.16 ruby/trema/command/kill.rb
trema-0.3.15 ruby/trema/command/kill.rb
trema-0.3.14 ruby/trema/command/kill.rb
trema-0.3.13 ruby/trema/command/kill.rb
trema-0.3.12 ruby/trema/command/kill.rb
trema-0.3.11 ruby/trema/command/kill.rb
trema-0.3.10 ruby/trema/command/kill.rb