Class: DRBD::Resource
- Inherits:
-
Object
- Object
- DRBD::Resource
- Defined in:
- lib/drbd.rb
Instance Attribute Summary collapse
-
#drbd ⇒ Object
readonly
Returns the value of attribute drbd.
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #attach! ⇒ Object
- #connect! ⇒ Object
- #connected? ⇒ Boolean
- #consistent? ⇒ Boolean
- #detach! ⇒ Object
- #disconnect! ⇒ Object
- #down! ⇒ Object
- #down? ⇒ Boolean
- #init_metadata! ⇒ Object
-
#initialize(nokogiri_resource, drbd) ⇒ Resource
constructor
A new instance of Resource.
- #local_disk ⇒ Object
- #local_host ⇒ Object
- #local_minor ⇒ Object
- #primary!(opts = {}) ⇒ Object
- #primary? ⇒ Boolean
- #resize! ⇒ Object
- #resync_running? ⇒ Boolean
- #role ⇒ Object
- #secondary! ⇒ Object
- #secondary? ⇒ Boolean
- #state ⇒ Object
- #syncer! ⇒ Object
- #up! ⇒ Object
Constructor Details
#initialize(nokogiri_resource, drbd) ⇒ Resource
Returns a new instance of Resource.
129 130 131 132 133 134 135 136 137 |
# File 'lib/drbd.rb', line 129 def initialize nokogiri_resource, drbd xml = nokogiri_resource @drbd = drbd @name = xml['name'] @protocol = xml['protocol'] @hosts = xml.xpath(".//host").to_a.map do |host_xml| Host.new host_xml end end |
Instance Attribute Details
#drbd ⇒ Object (readonly)
Returns the value of attribute drbd.
121 122 123 |
# File 'lib/drbd.rb', line 121 def drbd @drbd end |
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
121 122 123 |
# File 'lib/drbd.rb', line 121 def hosts @hosts end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
121 122 123 |
# File 'lib/drbd.rb', line 121 def name @name end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
121 122 123 |
# File 'lib/drbd.rb', line 121 def protocol @protocol end |
#status ⇒ Object
Returns the value of attribute status.
122 123 124 |
# File 'lib/drbd.rb', line 122 def status @status end |
Class Method Details
Instance Method Details
#attach! ⇒ Object
224 225 226 227 228 229 230 |
# File 'lib/drbd.rb', line 224 def attach! args = "attach #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |
#connect! ⇒ Object
201 202 203 204 205 206 207 |
# File 'lib/drbd.rb', line 201 def connect! args = "connect #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |
#connected? ⇒ Boolean
147 148 149 |
# File 'lib/drbd.rb', line 147 def connected? status[:cs] == "Connected" end |
#consistent? ⇒ Boolean
143 144 145 |
# File 'lib/drbd.rb', line 143 def consistent? status[:ds1] == "UpToDate" && status[:ds2] == "UpToDate" && status[:resynced_percent] == nil end |
#detach! ⇒ Object
232 233 234 235 236 237 238 |
# File 'lib/drbd.rb', line 232 def detach! args = "detach #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |
#disconnect! ⇒ Object
209 210 211 212 213 214 215 |
# File 'lib/drbd.rb', line 209 def disconnect! args = "disconnect #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |
#down! ⇒ Object
248 249 250 251 252 253 254 |
# File 'lib/drbd.rb', line 248 def down! args = "down #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |
#down? ⇒ Boolean
151 152 153 154 155 |
# File 'lib/drbd.rb', line 151 def down? return true if status.nil? return true if status[:cs] == "Unconfigured" return false end |
#init_metadata! ⇒ Object
256 257 258 259 260 261 262 263 264 265 |
# File 'lib/drbd.rb', line 256 def if self.down? args = "-- --force create-md #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) return true else return false end end |
#local_disk ⇒ Object
272 273 274 275 |
# File 'lib/drbd.rb', line 272 def local_disk return nil if local_host == nil local_host.disk end |
#local_host ⇒ Object
268 269 270 |
# File 'lib/drbd.rb', line 268 def local_host hosts.select{|h| h.name == drbd.host}.first end |
#local_minor ⇒ Object
277 278 279 280 |
# File 'lib/drbd.rb', line 277 def local_minor return nil if local_host == nil local_host.minor end |
#primary!(opts = {}) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/drbd.rb', line 165 def primary!(opts = {}) if opts[:force] == true args = "-- --overwrite-data-of-peer primary #{self.name}" else args = "primary #{self.name}" end command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |
#primary? ⇒ Boolean
157 158 159 |
# File 'lib/drbd.rb', line 157 def primary? status[:ro1] == "Primary" end |
#resize! ⇒ Object
217 218 219 220 221 222 |
# File 'lib/drbd.rb', line 217 def resize! args = "-- --assume-peer-has-space resize #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! end |
#resync_running? ⇒ Boolean
139 140 141 |
# File 'lib/drbd.rb', line 139 def resync_running? not status[:resynced_percent] == nil end |
#role ⇒ Object
197 198 199 |
# File 'lib/drbd.rb', line 197 def role status[:ro1] end |
#secondary! ⇒ Object
180 181 182 183 184 185 186 |
# File 'lib/drbd.rb', line 180 def secondary! args = "-- --overwrite-data-of-peer secondary #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |
#secondary? ⇒ Boolean
161 162 163 |
# File 'lib/drbd.rb', line 161 def secondary? stutus[:ro1] == "Secondary" end |
#state ⇒ Object
282 283 284 |
# File 'lib/drbd.rb', line 282 def state status[:cs] end |
#syncer! ⇒ Object
188 189 190 191 192 193 194 195 |
# File 'lib/drbd.rb', line 188 def syncer! args = "syncer #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |
#up! ⇒ Object
240 241 242 243 244 245 246 |
# File 'lib/drbd.rb', line 240 def up! args = "up #{self.name}" command = "#{drbd.command} #{args}" self.drbd.ssh_exec(command) drbd.load_status! nil end |