drbd 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/drbd.rb +52 -7
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -84,14 +84,54 @@ class DRBD
84
84
  status[:ds1] == "UpToDate" && status[:ds2] == "UpToDate" && status[:resynced_percent] == nil
85
85
  end
86
86
 
87
- def up?
88
- status[:cs] == "Connected" || status[:cs] == "SyncTarget"
87
+ def connected?
88
+ status[:cs] == "Connected"
89
89
  end
90
90
 
91
91
  def down?
92
- status[:cs] == "Unconfigured"
92
+ status[:cs] == "Unconfigured" || status.nil?
93
93
  end
94
+
95
+ def primary?
96
+ stauts[:ro0] == "Primary"
97
+ end
98
+
99
+ def primary!
100
+ args = "-- --overwrite-data-of-peer primary #{self.name}"
101
+ command = "ssh #{drbd.host} \"#{drbd.command} #{args}\""
102
+ system(command)
103
+ drbd.load_status!
104
+ nil
105
+ end
106
+
107
+ def role
108
+ status[:ro1]
109
+ end
110
+
111
+ def connect!
112
+ args = "connect #{self.name}"
113
+ command = "ssh #{drbd.host} \"#{drbd.command} #{args}\""
114
+ system(command)
115
+ drbd.load_status!
116
+ nil
117
+ end
94
118
 
119
+ def attach!
120
+ args = "attach #{self.name}"
121
+ command = "ssh #{drbd.host} \"#{drbd.command} #{args}\""
122
+ system(command)
123
+ drbd.load_status!
124
+ nil
125
+ end
126
+
127
+ def detach!
128
+ args = "detach #{self.name}"
129
+ command = "ssh #{drbd.host} \"#{drbd.command} #{args}\""
130
+ system(command)
131
+ drbd.load_status!
132
+ nil
133
+ end
134
+
95
135
  def up!
96
136
  args = "up #{self.name}"
97
137
  command = "ssh #{drbd.host} \"#{drbd.command} #{args}\""
@@ -110,8 +150,8 @@ class DRBD
110
150
 
111
151
  def init_metadata!
112
152
  if self.down?
113
- #drbdmeta 0 v08 /dev/mapper/dikobraz-www--emailmaster--cz_root_meta 0 create-md
114
- command = "ssh #{drbd.host} \"sudo /sbin/drbdmeta --force #{local_minor} v08 #{local_host.meta_disk} 0 create-md\""
153
+ args = "-- --force create-md r0#{self.name}"
154
+ command = "ssh #{drbd.host} \"#{drbd.command} #{args}\""
115
155
  system(command)
116
156
  return true
117
157
  else
@@ -123,9 +163,14 @@ class DRBD
123
163
  def local_host
124
164
  hosts.select{|h| h.name == drbd.host}.first
125
165
  end
126
-
166
+
167
+ def local_disk
168
+ return nil if local_host == nil
169
+ local_host.disk
170
+ end
171
+
127
172
  def local_minor
128
- retrurn nil if local_host == nil
173
+ return nil if local_host == nil
129
174
  local_host.minor
130
175
  end
131
176
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drbd
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adam Kliment
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-18 00:00:00 +01:00
18
+ date: 2011-01-24 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency