Module: TestLab::Container::Status
- Included in:
- TestLab::Container
- Defined in:
- lib/testlab/container/status.rb
Instance Method Summary collapse
-
#cidr ⇒ Integer
Container CIDR.
-
#cpu_usage ⇒ Object
Container CPU Time.
-
#disk_usage ⇒ Object
Container Disk Usage.
-
#fqdn ⇒ String
Container FQDN.
-
#importable? ⇒ Boolean
Container Importable.
-
#ip ⇒ String
Container IP.
-
#memory_usage ⇒ Object
Container Memory Usage.
-
#mode ⇒ Symbol
Container Mode.
-
#ptr ⇒ String
Container BIND PTR Record.
-
#state ⇒ Symbol
Container State.
-
#status ⇒ Hash
Container Status.
Instance Method Details
#cidr ⇒ Integer
Container CIDR
Returns the CIDR of the container.
20 21 22 |
# File 'lib/testlab/container/status.rb', line 20 def cidr TestLab::Utility.cidr(self.primary_interface.address) end |
#cpu_usage ⇒ Object
Container CPU Time
82 83 84 85 86 87 88 |
# File 'lib/testlab/container/status.rb', line 82 def cpu_usage if self.node.dead? 0 else self.lxc.cpu_usage end end |
#disk_usage ⇒ Object
Container Disk Usage
91 92 93 94 95 96 97 |
# File 'lib/testlab/container/status.rb', line 91 def disk_usage if self.node.dead? 0 else self.lxc.disk_usage / (1024 * 1024) end end |
#fqdn ⇒ String
Container FQDN
Returns the FQDN for the container.
38 39 40 41 42 |
# File 'lib/testlab/container/status.rb', line 38 def fqdn self.domain ||= self.node.domain [self.id, self.domain].join('.') end |
#importable? ⇒ Boolean
Container Importable
If the container has a non-nil sc_url value, we assume since we can supposedly download a shipping container image for the container that it is therefore importable.
135 136 137 |
# File 'lib/testlab/container/status.rb', line 135 def importable? !self.sc_url.nil? end |
#ip ⇒ String
Container IP
Returns the IP of the container.
11 12 13 |
# File 'lib/testlab/container/status.rb', line 11 def ip TestLab::Utility.ip(self.primary_interface.address) end |
#memory_usage ⇒ Object
Container Memory Usage
73 74 75 76 77 78 79 |
# File 'lib/testlab/container/status.rb', line 73 def memory_usage if self.node.dead? 0 else self.lxc.memory_usage / (1024 * 1024) end end |
#mode ⇒ Symbol
Container Mode
What mode the container is in.
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/testlab/container/status.rb', line 116 def mode if self.node.dead? :unknown else if self.is_ephemeral? :ephemeral else :persistent end end end |
#ptr ⇒ String
Container BIND PTR Record
Returns a BIND reverse-DNS PTR record.
29 30 31 |
# File 'lib/testlab/container/status.rb', line 29 def ptr TestLab::Utility.ptr(self.primary_interface.address) end |
#state ⇒ Symbol
Container State
What state the container is in.
104 105 106 107 108 109 110 |
# File 'lib/testlab/container/status.rb', line 104 def state if self.node.dead? :unknown else self.lxc.state end end |
#status ⇒ Hash
Container Status
Returns a hash of status information for the container.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/testlab/container/status.rb', line 49 def status interfaces = self.interfaces.collect do |interface| "#{interface.network_id}:#{interface.name}:#{interface.ip}/#{interface.cidr}" end.join(', ') { :id => self.id, :mode => self.mode, :fqdn => self.fqdn, :state => self.state, :memory_usage => "#{self.memory_usage}M", :cpu_time => "#{self.cpu_usage}s", :disk_usage => "#{self.disk_usage}MB", :distro => self.distro, :release => self.release, :interfaces => interfaces, :provisioners => self.provisioners.map(&:to_s).collect{ |p| p.split('::').last }.join(','), :node_id => self.node.id, :inherited => (self.inherit.nil? ? 'none' : self.inherit), :priority => self.priority } end |