Class: Trema::Command
- Inherits:
-
Object
- Object
- Trema::Command
- Defined in:
- lib/trema/command.rb
Overview
trema command rubocop:disable ClassLength
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Class Method Summary collapse
Instance Method Summary collapse
-
#fetch(name) ⇒ Object
FIXME.
-
#killall ⇒ Object
rubocop:disable MethodLength rubocop:disable AbcSize.
- #port_down(switch_name, port) ⇒ Object
-
#port_up(switch_name, port) ⇒ Object
rubocop:enable MethodLength rubocop:enable AbcSize.
-
#run(args, options) ⇒ Object
rubocop:disable MethodLength.
- #vhost ⇒ Object
- #vlink ⇒ Object
- #vswitch ⇒ Object
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
18 19 20 |
# File 'lib/trema/command.rb', line 18 def controller @controller end |
Class Method Details
.unix_domain_socket(name, check = false) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/trema/command.rb', line 10 def self.unix_domain_socket(name, check = false) path = File.(File.join(Phut.socket_dir, "#{name}.ctl")) if check && !FileTest.socket?(path) raise "Socket file #{path} does not exist." end 'drbunix:' + path end |
Instance Method Details
#fetch(name) ⇒ Object
FIXME
79 80 81 |
# File 'lib/trema/command.rb', line 79 def fetch(name) Phut::Vswitch.find_by(name: name) || Phut::Vhost.find_by(name: name) end |
#killall ⇒ Object
rubocop:disable MethodLength rubocop:disable AbcSize
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/trema/command.rb', line 42 def killall @controller.logger.debug 'Shutting down...' if @controller @controller.stop @controller_thread.kill if @controller_thread @phut_run_thread.kill if @phut_run_thread Phut::Vswitch.destroy_all Phut::Vhost.destroy_all Phut::Netns.destroy_all Phut::Link.destroy_all FileUtils.rm pid_file if FileTest.exist?(pid_file) DRb.stop_service exit 0 if @options[:daemonize] end |
#port_down(switch_name, port) ⇒ Object
62 63 64 |
# File 'lib/trema/command.rb', line 62 def port_down(switch_name, port) Phut::Vswitch.find_by(name: switch_name).bring_port_down(port) end |
#port_up(switch_name, port) ⇒ Object
rubocop:enable MethodLength rubocop:enable AbcSize
58 59 60 |
# File 'lib/trema/command.rb', line 58 def port_up(switch_name, port) Phut::Vswitch.find_by(name: switch_name).bring_port_up(port) end |
#run(args, options) ⇒ Object
rubocop:disable MethodLength
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/trema/command.rb', line 21 def run(args, ) @args = args @options = create_controller trap_signals create_pid_file start_phut if @options[:daemonize] run_as_daemon { start_controller_and_drb_threads } else start_controller_and_drb_threads end rescue NoControllerDefined => e raise e, "#{ruby_file}: #{e.}" end |
#vhost ⇒ Object
70 71 72 |
# File 'lib/trema/command.rb', line 70 def vhost Phut::Vhost end |
#vlink ⇒ Object
74 75 76 |
# File 'lib/trema/command.rb', line 74 def vlink Phut::Link end |
#vswitch ⇒ Object
66 67 68 |
# File 'lib/trema/command.rb', line 66 def vswitch Phut::Vswitch end |