Class VirtP2V::FixedBlockDevice
In: lib/virt-p2v/blockdevice.rb
lib/virt-p2v/blockdevice.rb
Parent: Object

Methods

[]   []   all_devices   all_devices   new   new  

Attributes

device  [R] 
device  [R] 
size  [R] 
size  [R] 

Public Class methods

[Source]

    # File lib/virt-p2v/blockdevice.rb, line 29
29:     def self.[](device)
30:         raise NoSuchDeviceError unless @@devices.has_key?(device)
31: 
32:         @@devices[device]
33:     end

[Source]

    # File lib/virt-p2v/blockdevice.rb, line 29
29:     def self.[](device)
30:         raise NoSuchDeviceError unless @@devices.has_key?(device)
31: 
32:         @@devices[device]
33:     end

[Source]

    # File lib/virt-p2v/blockdevice.rb, line 25
25:     def self.all_devices
26:         @@devices.values
27:     end

[Source]

    # File lib/virt-p2v/blockdevice.rb, line 25
25:     def self.all_devices
26:         @@devices.values
27:     end

[Source]

    # File lib/virt-p2v/blockdevice.rb, line 37
37:     def initialize(device)
38:         size = 0
39:         begin
40:             # Get the device size, in blocks
41:             File.open("/sys/block/#{device}/size") \
42:                 { |size_f| size = Integer(size_f.gets.chomp) }
43: 
44:             # Get the size in bytes by multiplying by the block size
45:             File.open("/sys/block/#{device}/queue/logical_block_size") \
46:                 { |size_f| size *= Integer(size_f.gets.chomp) }
47:         rescue Errno::ENOENT
48:             # Unlikely, but not fatal
49:         end
50: 
51:         raise InvalidDevice if size == 0
52: 
53:         # cciss device /dev/cciss/c0d0 will be cciss!c0d0 under /sys/block
54:         @device = device.gsub("!", "/")
55:         @size = size
56:         @@devices[@device] = self
57:     end

[Source]

    # File lib/virt-p2v/blockdevice.rb, line 37
37:     def initialize(device)
38:         size = 0
39:         begin
40:             # Get the device size, in blocks
41:             File.open("/sys/block/#{device}/size") \
42:                 { |size_f| size = Integer(size_f.gets.chomp) }
43: 
44:             # Get the size in bytes by multiplying by the block size
45:             File.open("/sys/block/#{device}/queue/logical_block_size") \
46:                 { |size_f| size *= Integer(size_f.gets.chomp) }
47:         rescue Errno::ENOENT
48:             # Unlikely, but not fatal
49:         end
50: 
51:         raise InvalidDevice if size == 0
52: 
53:         # cciss device /dev/cciss/c0d0 will be cciss!c0d0 under /sys/block
54:         @device = device.gsub("!", "/")
55:         @size = size
56:         @@devices[@device] = self
57:     end

[Validate]