Module: TestLab::Network::Status
- Included in:
- TestLab::Network
- Defined in:
- lib/testlab/network/status.rb
Instance Method Summary collapse
-
#broadcast ⇒ Object
Returns the broadcast address.
-
#cidr ⇒ Integer
Network CIDR.
-
#def_tag ⇒ Object
Debian Network ‘interfaces’ Start Definition Tag.
-
#end_tag ⇒ Object
Debian Network ‘interfaces’ End Definition Tag.
-
#ip ⇒ String
Network IP.
-
#netmask ⇒ Object
Returns the network mask.
-
#network ⇒ Object
Returns the network address.
-
#state ⇒ Object
Network Bridge State.
-
#status ⇒ Object
Network status.
Instance Method Details
#broadcast ⇒ Object
Returns the broadcast address
60 61 62 |
# File 'lib/testlab/network/status.rb', line 60 def broadcast TestLab::Utility.broadcast(self.address) end |
#cidr ⇒ Integer
Network CIDR
Returns the CIDR of the network bridge.
45 46 47 |
# File 'lib/testlab/network/status.rb', line 45 def cidr TestLab::Utility.cidr(self.address) end |
#def_tag ⇒ Object
Debian Network ‘interfaces’ Start Definition Tag
22 23 24 |
# File 'lib/testlab/network/status.rb', line 22 def def_tag "#TESTLAB-DEF-#{self.bridge.to_s.upcase}" end |
#end_tag ⇒ Object
Debian Network ‘interfaces’ End Definition Tag
27 28 29 |
# File 'lib/testlab/network/status.rb', line 27 def end_tag "#TESTLAB-END-#{self.bridge.to_s.upcase}" end |
#ip ⇒ String
Network IP
Returns the IP of the network bridge.
36 37 38 |
# File 'lib/testlab/network/status.rb', line 36 def ip TestLab::Utility.ip(self.address) end |
#netmask ⇒ Object
Returns the network mask
50 51 52 |
# File 'lib/testlab/network/status.rb', line 50 def netmask TestLab::Utility.netmask(self.address) end |
#network ⇒ Object
Returns the network address
55 56 57 |
# File 'lib/testlab/network/status.rb', line 55 def network TestLab::Utility.network(self.address) end |
#state ⇒ Object
Network Bridge State
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/testlab/network/status.rb', line 65 def state if self.node.dead? :unknown else exit_code = self.node.exec(%(sudo brctl show #{self.bridge} 2>&1 | grep -i 'No such device'), :ignore_exit_status => true).exit_code if (exit_code == 0) :not_created else output = self.node.exec(%(sudo ifconfig #{self.bridge} 2>&1 | grep 'MTU'), :ignore_exit_status => true).output if ((output =~ /UP/) || (output =~ /RUNNING/)) :running else :stopped end end end end |
#status ⇒ Object
Network status
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/testlab/network/status.rb', line 7 def status interface = "#{bridge}:#{self.address}" { :id => self.id, :node_id => self.node.id, :state => self.state, :interface => interface, :broadcast => self.broadcast, :network => self.network, :netmask => self.netmask, :provisioners => self.provisioners.map(&:to_s).collect{ |p| p.split('::').last }.join(','), } end |