Sha256: 3e3f2e3bd9c467dfe2da3c46ce8982b3ac9d9a197659f009bd0b4d63f4e8afaf

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

class TestLab
  class Network

    module Status

      # Network status
      def status
        interface = "#{bridge}:#{ip}"
        {
          :id => self.id,
          :node_id => self.node.id,
          :state => self.state,
          :interface => interface,
          :broadcast => self.broadcast,
          :network => self.network,
          :netmask => self.netmask
        }
      end

      # Returns the network mask
      def netmask
        TestLab::Utility.netmask(self.ip)
      end

      # Returns the network address
      def network
        TestLab::Utility.network(self.ip)
      end

      # Returns the broadcast address
      def broadcast
        TestLab::Utility.broadcast(self.ip)
      end

      # Network Bridge State
      def state
        output = self.node.ssh.exec(%(sudo ifconfig #{self.bridge} | grep 'MTU'), :silence => true, :ignore_exit_status => true).output.strip
        if ((output =~ /UP/) && (output =~ /RUNNING/))
          :running
        else
          :stopped
        end
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
testlab-0.2.1 lib/testlab/network/status.rb
testlab-0.2.0 lib/testlab/network/status.rb
testlab-0.1.0 lib/testlab/network/status.rb