Class: Phut::Vhost
Overview
An interface class to vhost emulation utility program.
Instance Attribute Summary collapse
-
#ip_address ⇒ Object
readonly
Returns the value of attribute ip_address.
-
#mac_address ⇒ Object
readonly
Returns the value of attribute mac_address.
-
#network_device ⇒ Object
Returns the value of attribute network_device.
Instance Method Summary collapse
-
#initialize(ip_address, mac_address, promisc, name = nil, logger = NullLogger.new) ⇒ Vhost
constructor
A new instance of Vhost.
- #maybe_stop ⇒ Object
- #name ⇒ Object
- #run(all_hosts = []) ⇒ Object
- #running? ⇒ Boolean
- #stop ⇒ Object
- #to_s ⇒ Object
Methods included from ShellRunner
Constructor Details
#initialize(ip_address, mac_address, promisc, name = nil, logger = NullLogger.new) ⇒ Vhost
Returns a new instance of Vhost.
15 16 17 18 19 20 21 22 |
# File 'lib/phut/vhost.rb', line 15 def initialize(ip_address, mac_address, promisc, name = nil, logger = NullLogger.new) @ip_address = ip_address @promisc = promisc @name = name @mac_address = mac_address @logger = logger end |
Instance Attribute Details
#ip_address ⇒ Object (readonly)
Returns the value of attribute ip_address.
11 12 13 |
# File 'lib/phut/vhost.rb', line 11 def ip_address @ip_address end |
#mac_address ⇒ Object (readonly)
Returns the value of attribute mac_address.
12 13 14 |
# File 'lib/phut/vhost.rb', line 12 def mac_address @mac_address end |
#network_device ⇒ Object
Returns the value of attribute network_device.
13 14 15 |
# File 'lib/phut/vhost.rb', line 13 def network_device @network_device end |
Instance Method Details
#maybe_stop ⇒ Object
42 43 44 45 |
# File 'lib/phut/vhost.rb', line 42 def maybe_stop return unless running? stop end |
#name ⇒ Object
24 25 26 |
# File 'lib/phut/vhost.rb', line 24 def name @name || @ip_address end |
#run(all_hosts = []) ⇒ Object
32 33 34 35 |
# File 'lib/phut/vhost.rb', line 32 def run(all_hosts = []) @all_hosts ||= all_hosts sh "rvmsudo vhost run #{run_options}" end |
#running? ⇒ Boolean
47 48 49 |
# File 'lib/phut/vhost.rb', line 47 def running? FileTest.exists?(pid_file) end |
#stop ⇒ Object
37 38 39 40 |
# File 'lib/phut/vhost.rb', line 37 def stop fail "vhost (name = #{name}) is not running!" unless running? sh "vhost stop -n #{name} -s #{Phut.socket_dir}" end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/phut/vhost.rb', line 28 def to_s "vhost (name = #{name}, IP address = #{@ip_address})" end |