Drbd is a project mainly written in Ruby, based on the MIT license.
Ruby wrapper for DRBD
= DRBD
Ruby wrapper for DRBD
== It is usefull for
== Limitations
== Installation
gem install drbd
== How it works
you can connect to remote node with hostname, login will be executed with current user and his key
d = Drbd.new("fqdn.domain.tld")
or you can "recycle" existing Net::SSH session to improve performance:
ssh = Net:SSH.start("fwdn.domain.tld", "root", :password => 'secret')
d = Drbd.new(ssh)
specify command to be executed:
d = Drbd.new("fqdn.domain.tld", :command => 'sudo /sbin/drbdadm')
obtain array of configured configured resources
r = d.resources.first
stateless execute command (WARNING! let's check the source what it does)
r.primary!
r.primary!(:force => true)
r.secondary!
r.connect!
r.attach!
r.detach!
r.up!
r.down!
analyze actual state
r.resync_running?
r.consistent?
r.connected?
r.down?
r.primary?
r.secondary?
get resource name
r.name
get resource protocol
r.protocol
get hosts for resource
r.hosts
get node addresses
r.hosts.map{|h| h.address }
get status for resource
r.status
resource status is hash with keys:
[:cs, :resynced_percent, :minor, :ro1, :ds1, :ro2, :ds2, :name]
r.status
find resource by name
r = d.find_resource_by_name("r0")
find resource by backing disk
r = d.find_resource_by_disk("/dev/volgroup-logvolume--name")
true if both of devices are UpToDate
r.consinstent?
true if resynced_percent is present in status
r.resync_running?
true if resource status is "Connected"
r.up?
true if resource status is "Unconfigured"
r.down?
stateless perform drbdadm up on resource (use at your own risk!)
r.up!
stateless perform drbdadm down on resource (use at your own risk!)
r.down!
stateless perform forced drbdadm create-md on resource (use at your own risk!)
if resource is not down, returns false and does nothing
r.init_metadata
back-reference to the DRBD object
r.drbd
uptate status of all resources
r.drbd.load_status!
d.load_status!
== TODO
== Copyright
Copyright (c) 2011 Adam Kliment, Virtualmaster.cz. See LICENSE for details.