If one argument is supplied:
path is a an absolute filesystem path
opts is a hash of disk options.
If two arguments are supplied:
position
path is a an absolute filesystem path
opts is a hash of disk options.
Valid options are:
:path is a an absolute filesystem path (overridden by path arg)
:position (overridden by position arg)
:size
:device
# File lib/rudy/metadata/disk.rb, line 44 def initialize(position=nil, path=nil, opts={}) # Swap arg values if only one is supplied. path, position = position, nil if !position.nil? && path.nil? position ||= '01' opts = { :size => 1, :device => current_machine_os.to_s == 'windows' ? DEFAULT_WINDOWS_DEVICE : DEFAULT_LINUX_DEVICE }.merge opts super Rudy::Disks::RTYPE, opts # Rudy::Metadata#initialize @position, @path = position, path # Defaults: #datetime = Backup.format_timestamp(now).split(Rudy::DELIM) @created = Time.now.utc @mounted = false postprocess end
# File lib/rudy/metadata/disk.rb, line 97 def archive raise Rudy::AWS::EC2::VolumeNotAvailable, @volid unless volume_attached? back = Rudy::Backup.new @position, @path, self.descriptors back.create back.size, back.fstype = @size, @fstype back.save :replace back end
# File lib/rudy/metadata/disk.rb, line 106 def backups Rudy::Backups.list self.descriptors end
# File lib/rudy/metadata/disk.rb, line 88 def create(size=nil, zone=nil, snapshot=nil) raise DuplicateRecord, self.name if exists? && !@@global.force vol = Rudy::AWS::EC2::Volumes.create(size || @size, zone || @zone, snapshot) #vol = Rudy::AWS::EC2::Volumes.list(:available).first # debugging @volid, @raw = vol.awsid, true self.save :replace self end
# File lib/rudy/metadata/disk.rb, line 125 def descriptors super :position, :path end
# File lib/rudy/metadata/disk.rb, line 111 def destroy(force=false) if @volid && !volume_deleting? if !force raise Rudy::AWS::EC2::VolumeNotAvailable, @volid if volume_attached? else volume_detach if volume_exists? && volume_attached? sleep 0.1 end raise Rudy::AWS::EC2::VolumeNotAvailable, @volid if volume_in_use? Rudy::AWS::EC2::Volumes.destroy(@volid) if volume_exists? && volume_available? end super() # quotes, otherwise Ruby will send this method's args end
# File lib/rudy/metadata/disk.rb, line 150 def mounted? @mounted == true end
# File lib/rudy/metadata/disk.rb, line 78 def name sep = File::SEPARATOR dirs = @path.split sep if @path && !@path.empty? unless @path == File::SEPARATOR dirs.shift while dirs && (dirs[0].nil? || dirs[0].empty?) end # Calls Rudy::Metadata#name with disk specific components super *dirs end
sdb values are stored as strings. Some quick conversion.
# File lib/rudy/metadata/disk.rb, line 67 def postprocess @position = @position.to_s.rjust(2, '0') if @position.to_s.size == 1 @size &&= @size.to_i @raw = true if @raw == "true" unless @raw.is_a?(TrueClass) @mounted = (@mounted == "true") unless @mounted.is_a?(TrueClass) end
# File lib/rudy/metadata/disk.rb, line 74 def to_s(*args) [self.name.bright, self.volid, self.size, self.fstype].join '; ' end
# File lib/rudy/metadata/disk.rb, line 131 def valid? !@path.nil? && !@path.empty? end
Generated with the Darkfish Rdoc Generator 2.