mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-28 17:57:22 +03:00
F #5260: Add device mapper for LXC
It allows to use LVM and RDM drivers.
This commit is contained in:
parent
17025ead9d
commit
aa6b6f5941
@ -25,6 +25,7 @@ require 'storageutils'
|
||||
require 'qcow2'
|
||||
require 'raw'
|
||||
require 'rbd'
|
||||
require 'device'
|
||||
|
||||
require_relative '../lib/xmlparser'
|
||||
require_relative '../lib/opennebula_vm'
|
||||
@ -339,6 +340,8 @@ class Disk
|
||||
Qcow2Mapper.new
|
||||
elsif @xml['DISK_TYPE'].downcase == 'rbd'
|
||||
RBDMapper.new(self)
|
||||
elsif @xml['DISK_TYPE'].downcase == 'block'
|
||||
DeviceMapper.new
|
||||
else
|
||||
RawMapper.new
|
||||
end
|
||||
|
32
src/vmm_mad/remotes/lib/lxc/storage/mappers/device.rb
Normal file
32
src/vmm_mad/remotes/lib/lxc/storage/mappers/device.rb
Normal file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
$LOAD_PATH.unshift File.dirname(__FILE__)
|
||||
|
||||
require 'command'
|
||||
|
||||
# Mapping utilities for raw devices (e.g LVM, RDM)
|
||||
class DeviceMapper
|
||||
|
||||
# Maps raw image file to linux loopdevice
|
||||
def map(disk)
|
||||
ds_path = source(disk)
|
||||
|
||||
if File.symlink?(ds_path)
|
||||
return File.readlink(ds_path) # Raw device path
|
||||
end
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
def unmap(_device)
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns the source file for the disk
|
||||
def source(disk)
|
||||
"#{disk.sysds_path}/#{disk.vm_id}/disk.#{disk.id}"
|
||||
end
|
||||
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user