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
- #consistent? ⇒ Boolean
- #down! ⇒ Object
- #down? ⇒ Boolean
- #init_metadata! ⇒ Object
-
#initialize(nokogiri_resource, drbd) ⇒ Resource
constructor
A new instance of Resource.
- #local_host ⇒ Object
- #local_minor ⇒ Object
- #resync_running? ⇒ Boolean
- #state ⇒ Object
- #up! ⇒ Object
- #up? ⇒ Boolean
Constructor Details
#initialize(nokogiri_resource, drbd) ⇒ Resource
Returns a new instance of Resource.
69 70 71 72 73 74 75 76 77 |
# File 'lib/drbd.rb', line 69 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.
61 62 63 |
# File 'lib/drbd.rb', line 61 def drbd @drbd end |
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
61 62 63 |
# File 'lib/drbd.rb', line 61 def hosts @hosts end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
61 62 63 |
# File 'lib/drbd.rb', line 61 def name @name end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
61 62 63 |
# File 'lib/drbd.rb', line 61 def protocol @protocol end |
#status ⇒ Object
Returns the value of attribute status.
62 63 64 |
# File 'lib/drbd.rb', line 62 def status @status end |
Class Method Details
Instance Method Details
#consistent? ⇒ Boolean
83 84 85 |
# File 'lib/drbd.rb', line 83 def consistent? status[:ds1] == "UpToDate" && status[:ds2] == "UpToDate" && status[:resynced_percent] == nil end |
#down! ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/drbd.rb', line 103 def down! args = "down #{self.name}" command = "ssh #{drbd.host} \"#{drbd.command} #{args}\"" system(command) drbd.load_status! nil end |
#down? ⇒ Boolean
91 92 93 |
# File 'lib/drbd.rb', line 91 def down? status[:cs] == "Unconfigured" end |
#init_metadata! ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/drbd.rb', line 111 def if self.down? #drbdmeta 0 v08 /dev/mapper/dikobraz-www--emailmaster--cz_root_meta 0 create-md command = "ssh #{drbd.host} \"sudo /sbin/drbdmeta --force #{local_minor} v08 #{local_host.} 0 create-md\"" system(command) return true else return false end end |
#local_host ⇒ Object
123 124 125 |
# File 'lib/drbd.rb', line 123 def local_host hosts.select{|h| h.name == drbd.host}.first end |
#local_minor ⇒ Object
127 128 129 130 |
# File 'lib/drbd.rb', line 127 def local_minor retrurn nil if local_host == nil local_host.minor end |
#resync_running? ⇒ Boolean
79 80 81 |
# File 'lib/drbd.rb', line 79 def resync_running? not status[:resynced_percent] == nil end |
#state ⇒ Object
132 133 134 |
# File 'lib/drbd.rb', line 132 def state status[:cs] end |
#up! ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/drbd.rb', line 95 def up! args = "up #{self.name}" command = "ssh #{drbd.host} \"#{drbd.command} #{args}\"" system(command) drbd.load_status! nil end |
#up? ⇒ Boolean
87 88 89 |
# File 'lib/drbd.rb', line 87 def up? status[:cs] == "Connected" || status[:cs] == "SyncTarget" end |