class NixAdm::ZFS::Admin

Attributes

host[R]

Public Class Methods

new(host=nil, port=22) click to toggle source
Calls superclass method NixAdm::Status::new
# File src/lib/nixadm/zfs.rb, line 493
def initialize(host=nil, port=22)
  super()

  @host = Host.new(host, port)
end

Public Instance Methods

filesystem(name) click to toggle source

Given full pathname of ZFS object, return corresponding ZFS object. Returns nil upon no match.

# File src/lib/nixadm/zfs.rb, line 501
def filesystem(name)
  pool_name = name.split('/')[0]
  pool = @host.pool(pool_name)

  return nil if pool.nil?

  fs_name = name.split('/')[1..-1].join('/')

  return pool.filesystem(fs_name)
end
object(name) click to toggle source

Given full pathname of ZFS volumne, return corresponding Volume object. Returns nil upon no match.

# File src/lib/nixadm/zfs.rb, line 527
def object(name)
  pool_name = name.split('/')[0]
  pool = @host.pool(pool_name)

  return nil if pool.nil?

  object_name = name.split('/')[1..-1].join('/')

  return pool.object(object_name)
end
replicate(source_fs, dest_fs) click to toggle source

Replicate changes on one ZFS filesystem on one host (src_fs) to another (dst_fs). Filesystem must be in sync. This means they must have most recent snapshots that match. If this is not met, function will abort.

@param src_fs The source host. This is the machine that has the filesystem we want to replicate. Format can be in the form user@host or just host. Whatever is acceptable to ssh is acceptable here.

@param dest_fs The destination host. This is the machine what will receive the delta from the source host, whose filesystem will be updated. Can be in the form user@host or just host. Whatever is acceptable to ssh is acceptable here.

# File src/lib/nixadm/zfs.rb, line 551
def replicate(source_fs, dest_fs)
  snapshot = source_fs.lastSnapshot()

  if snapshot.nil?
    return failure(-1, "No snapshots on filesystem #{sfs.name}")
  end

  return snapshot.send(dest_fs)
end
volume(name) click to toggle source

Given full pathname of ZFS volumne, return corresponding Volume object. Returns nil upon no match.

# File src/lib/nixadm/zfs.rb, line 514
def volume(name)
  pool_name = name.split('/')[0]
  pool = @host.pool(pool_name)

  return nil if pool.nil?

  vol_name = name.split('/')[1..-1].join('/')

  return pool.volume(vol_name)
end