Class: Dribbled::DrbdResource
- Inherits:
-
Object
- Object
- Dribbled::DrbdResource
- Defined in:
- lib/dribbled/drbd.rb
Instance Attribute Summary collapse
-
#activity ⇒ Object
Returns the value of attribute activity.
-
#config ⇒ Object
Returns the value of attribute config.
-
#cs ⇒ Object
Returns the value of attribute cs.
-
#ds ⇒ Object
Returns the value of attribute ds.
-
#finish ⇒ Object
Returns the value of attribute finish.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#in_configuration ⇒ Object
Returns the value of attribute in_configuration.
-
#in_kernel ⇒ Object
Returns the value of attribute in_kernel.
-
#name ⇒ Object
Returns the value of attribute name.
-
#percent ⇒ Object
Returns the value of attribute percent.
-
#primary ⇒ Object
Returns the value of attribute primary.
-
#ro ⇒ Object
Returns the value of attribute ro.
-
#secondary ⇒ Object
Returns the value of attribute secondary.
Instance Method Summary collapse
- #check ⇒ Object
- #in_configuration? ⇒ Boolean
- #in_kernel? ⇒ Boolean
-
#initialize(res, hostname) ⇒ DrbdResource
constructor
A new instance of DrbdResource.
- #inspect ⇒ Object
- #status ⇒ Object
- #to_s(mode = :line) ⇒ Object
Constructor Details
#initialize(res, hostname) ⇒ DrbdResource
Returns a new instance of DrbdResource.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/dribbled/drbd.rb', line 143 def initialize(res,hostname) @id = res @name = nil @config = nil @ds = nil @cs = nil @ro = nil @activity = nil @percent = nil @finish = nil @primary = { :hostname => nil, :disk => nil, :device => nil } @secondary = { :hostname => nil, :disk => nil, :device => nil } @in_kernel = false @in_configuration = false end |
Instance Attribute Details
#activity ⇒ Object
Returns the value of attribute activity.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def activity @activity end |
#config ⇒ Object
Returns the value of attribute config.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def config @config end |
#cs ⇒ Object
Returns the value of attribute cs.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def cs @cs end |
#ds ⇒ Object
Returns the value of attribute ds.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def ds @ds end |
#finish ⇒ Object
Returns the value of attribute finish.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def finish @finish end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
140 141 142 |
# File 'lib/dribbled/drbd.rb', line 140 def id @id end |
#in_configuration ⇒ Object
Returns the value of attribute in_configuration.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def in_configuration @in_configuration end |
#in_kernel ⇒ Object
Returns the value of attribute in_kernel.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def in_kernel @in_kernel end |
#name ⇒ Object
Returns the value of attribute name.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def name @name end |
#percent ⇒ Object
Returns the value of attribute percent.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def percent @percent end |
#primary ⇒ Object
Returns the value of attribute primary.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def primary @primary end |
#ro ⇒ Object
Returns the value of attribute ro.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def ro @ro end |
#secondary ⇒ Object
Returns the value of attribute secondary.
141 142 143 |
# File 'lib/dribbled/drbd.rb', line 141 def secondary @secondary end |
Instance Method Details
#check ⇒ Object
229 230 231 |
# File 'lib/dribbled/drbd.rb', line 229 def check end |
#in_configuration? ⇒ Boolean
163 164 165 |
# File 'lib/dribbled/drbd.rb', line 163 def in_configuration? @in_configuration end |
#in_kernel? ⇒ Boolean
159 160 161 |
# File 'lib/dribbled/drbd.rb', line 159 def in_kernel? @in_kernel end |
#inspect ⇒ Object
225 226 227 |
# File 'lib/dribbled/drbd.rb', line 225 def inspect "#{self.class}: #{@id}[#{@name}]: #{@cs},#{@ds},#{@ro}" end |
#status ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/dribbled/drbd.rb', line 167 def status s = :unknown o = 'unable to assert health' if self.cs == 'Unconfigured' [:ok,"#{self.id}[unconfigured]"] else if self.in_kernel? and self.in_configuration? if self.cs == 'Connected' and self.ds == 'UpToDate/UpToDate' and (self.ro == 'Primary/Secondary' or self.ro == 'Secondary/Primary') s = :ok else if ['SyncSource','SyncTarget','VerifyS','VerifyT','PausedSyncS','PausedSyncT','StandAlone'].include? self.cs s = :warning elsif not self.in_configuration? s = :warning else s = :critical end end else s = :unknown end end [s,self.to_s(:concise)] end |
#to_s(mode = :line) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/dribbled/drbd.rb', line 194 def to_s(mode=:line) ph = @primary[:hostname].gsub(/\.[a-z0-9-]+\.[a-z0-9-]+$/,'') unless @primary[:hostname].nil? sh = @secondary[:hostname].gsub(/\.[a-z0-9-]+\.[a-z0-9-]+$/,'') unless @secondary[:hostname].nil? if @ro == 'Primary/Secondary' h1 = ph; dev1 = @primary[:device] h2 = sh; dev2 = @secondary[:device] else h1 = sh; dev1 = @secondary[:device] h2 = ph; dev2 = @primary[:device] end percent_finish = @activity.nil? ? nil : '[%3d%% %8s]' % [@percent,@finish] case mode when :line fmt_string = '%2d %6s %-13s %15s %-22s %-20s %10s %-11s %10s %-11s' percent_finish = @activity.nil? ? nil : '[%3d%% %8s]' % [@percent,@finish] when :concise fmt_string = '%s>%s:%s%s:%s:%s' percent_finish = @activity.nil? ? nil : '[%d%%,%s]' % [@percent,@finish] when :verbose fmt_string = '%s' else fmt_string = '%s' end fmt_string % [@id,@name,@cs,percent_finish,@ro,@ds,h1,dev1,h2,dev2] end |