Sha256: b137862a2b89bfaad2a19f19926af97356db71a0e441f79eb73f691773468f8b
Contents?: true
Size: 1.14 KB
Versions: 12
Compression:
Stored size: 1.14 KB
Contents
# LinuxAdmin Mountable Disk Mixin # # Copyright (C) 2013 Red Hat Inc. # Licensed under the MIT License class LinuxAdmin module Mountable attr_accessor :fs_type attr_accessor :mount_point module ClassMethods def mount_point_exists?(mount_point) result = self.run!(cmd(:mount)) result.output.split("\n").any? { |line| line.split[2] == mount_point } end def mount_point_available?(mount_point) !mount_point_exists?(mount_point) end end def self.included(base) base.extend(ClassMethods) end def format_to(filesystem) run!(cmd(:mke2fs), :params => { '-t' => filesystem, nil => self.path}) @fs_type = filesystem end def mount(mount_point) FileUtils.mkdir(mount_point) unless File.directory?(mount_point) if self.class.mount_point_exists?(mount_point) raise ArgumentError, "disk already mounted at #{mount_point}" end run!(cmd(:mount), :params => { nil => [self.path, mount_point] }) @mount_point = mount_point end def umount run!(cmd(:umount), :params => { nil => [@mount_point] }) end end end
Version data entries
12 entries across 12 versions & 1 rubygems