methods/in_common.rb
# Check if a ZFS filesystem exists
# If not create it
Check if a ZFS filesystem exists
If not create it
Check if a ZFS filesystem exists If not create it
def check_zfs_fs_exists(options,dir_name)
  output = ""
  if not File.directory?(dir_name)
    if options['host-os-name'].to_s.match(/SunOS/)
      if dir_name.match(/clients/)
        root_dir = dir_name.split(/\//)[0..-2].join("/")
        if not File.directory?(root_dir)
          check_zfs_fs_exists(root_dir)
        end
      end
      if dir_name.match(/ldoms|zones/)
        zfs_name = options['dpool']+dir_name
      else
        zfs_name = options['zpoolname']+dir_name
      end
      if dir_name.match(/vmware_|openbsd_|coreos_/) or options['host-os-release'].to_i > 10
        options['service'] = File.basename(dir_name)
        mount_dir    = options['tftpdir']+"/"+options['service']
        if not File.directory?(mount_dir)
          Dir.mkdir(mount_dir)
        end
      else
        mount_dir = dir_name
      end
      message = "Information:\tCreating "+dir_name+" with mount point "+mount_dir
      command = "zfs create -o mountpoint=#{mount_dir} #{zfs_name}"
      execute_command(options,message,command)
      if dir_name.match(/vmware_|openbsd_|coreos_/) or options['host-os-release'].to_i > 10
        message = "Information:\tSymlinking "+mount_dir+" to "+dir_name
        command = "ln -s #{mount_dir} #{dir_name}"
        execute_command(options,message,command)
      end
    else
      check_dir_exists(options,dir_name)
    end
  end
  return output
end
def check_zfs_fs_exists ( options , dir_name ) output = "" if not File . directory? ( dir_name ) if options [ 'host-os-name' ] . to_s . match ( / SunOS / ) if dir_name . match ( / clients / ) root_dir = dir_name . split ( / \/ / ) [ 0 .. - 2 ] . join ( "/" ) if not File . directory? ( root_dir ) check_zfs_fs_exists ( root_dir ) end end if dir_name . match ( / ldoms|zones / ) zfs_name = options [ 'dpool' ] + dir_name else zfs_name = options [ 'zpoolname' ] + dir_name end if dir_name . match ( / vmware_|openbsd_|coreos_ / ) or options [ 'host-os-release' ] . to_i > 10 options [ 'service' ] = File . basename ( dir_name ) mount_dir = options [ 'tftpdir' ] + "/" + options [ 'service' ] if not File . directory? ( mount_dir ) Dir . mkdir ( mount_dir ) end else mount_dir = dir_name end message = "Information:\tCreating " + dir_name + " with mount point " + mount_dir command = "zfs create -o mountpoint=#{mount_dir} #{zfs_name}" execute_command ( options , message , command ) if dir_name . match ( / vmware_|openbsd_|coreos_ / ) or options [ 'host-os-release' ] . to_i > 10 message = "Information:\tSymlinking " + mount_dir + " to " + dir_name command = "ln -s #{mount_dir} #{dir_name}" execute_command ( options , message , command ) end else check_dir_exists ( options , dir_name ) end end return output end
Check if a ZFS filesystem exists
If not create it
Check if a ZFS filesystem exists If not create it
options
<not_specific>
dir_name
<not_specific>