Class: Dribbled::DrbdSet

Inherits:
Hash
  • Object
show all
Defined in:
lib/dribbled/drbd.rb

Constant Summary collapse

PROCDRBD_VERSION_RE =
/^version:\s+(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)\s+\(api:(?<api>\d+)\/proto:(?<proto>[0-9-]+)/
PROCDRBD_RESOURCE_RE =
/^\s*(?<id>\d+):\s+cs:(?<cs>[\w\/]+)\s+(st|ro):(?<ro>[\w\/]+)\s+ds:(?<ds>[\w\/]+)\s+/
PROCDRBD_URESOURCE_RE =
/^\s*(?<id>\d+):\s+cs:(?<cs>[\w\/]+)/
PROCDRBD_ACTIVITY_RE =
/^\s+\[[.>=]+\]\s+(?<activity>[a-z']+):\s+(?<percent>[0-9.]+)%\s+\(\d+\/\d+\)M(finish:\s+(?<finish>[0-9:]+)\s+)*/
PROCDRBD_ACTIVITY_STATUS_RE =
/^\s+finish:\s+(?<finish>[0-9:]+)\s+/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ DrbdSet

Returns a new instance of DrbdSet.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dribbled/drbd.rb', line 17

def initialize(options)
  @log = options[:log].nil? ? nil : options[:log]
  @hostname = options[:hostname]

  resources_run_src = options[:procdrbd]
  @resources_run_raw = nil
  @resources_run = _read_procdrbd(resources_run_src) # sets @resources_run_raw as side-effect; it shouldn't
  @resources_run.each do |r,res|
    self[res.id] = res unless res.nil?
  end

  resources_cfg_src = options[:xmldump].nil? ? IO.popen("#{options[:drbdadm]} dump-xml 2>/dev/null") : options[:xmldump]
  @resources_cfg_raw = nil
  @resources_cfg = _read_xmldump(resources_cfg_src)  # sets @resources_cfg_raw as side-effect; it shouldn't

  @resources_cfg.each do |name,res|
    _process_xml_resource(name,res)
  end

end

Instance Attribute Details

#resources_cfg_rawObject (readonly)

Returns the value of attribute resources_cfg_raw.



9
10
11
# File 'lib/dribbled/drbd.rb', line 9

def resources_cfg_raw
  @resources_cfg_raw
end

#resources_run_rawObject (readonly)

Returns the value of attribute resources_run_raw.



9
10
11
# File 'lib/dribbled/drbd.rb', line 9

def resources_run_raw
  @resources_run_raw
end

Instance Method Details

#versionObject



38
39
40
# File 'lib/dribbled/drbd.rb', line 38

def version
  "#{@version_major}.#{@version_minor}.#{@version_path}"
end