1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-10 01:17:40 +03:00

F : LXD drivers update ()

This commit is contained in:
Daniel Clavijo Coca 2018-12-05 10:42:51 -06:00 committed by Ruben S. Montero
parent 0e8f8b3bab
commit 9ae54c6934
6 changed files with 37 additions and 19 deletions

View File

@ -221,6 +221,7 @@ else:
# libxml2
main_env.ParseConfig('xml2-config --libs --cflags')
svncterm_path = 'src/vmm_mad/remotes/lib/lxd/svncterm_server/SConstruct'
# SCONS scripts to build
build_scripts=[
@ -269,9 +270,16 @@ build_scripts=[
'src/im_mad/collectd/SConstruct',
'src/client/SConstruct',
'src/docker_machine/SConstruct',
'src/vmm_mad/remotes/lib/lxd/svncterm_server/SConstruct'
svncterm_path
]
# disable svncterm
svncterm = ARGUMENTS.get('svncterm', 'yes')
if svncterm == 'no':
build_scripts.remove(svncterm_path)
else:
pass
for script in build_scripts:
env = main_env.Clone()
SConscript(script, exports='env')

View File

@ -0,0 +1,7 @@
#!/bin/bash
# Sanitize cat arguments to run safely under sudo
# Access container fstab for OpenNebula containers. Example:
# /var/lib/lxd/storage-pools/default/containers/one-34/rootfs/etc/fstab
echo $1 | grep -q '/[^[:space:]]\+/one-[0-9]\+/rootfs/etc/fstab$' && [ -f $1 ] && cat $1

View File

@ -392,8 +392,6 @@ class Container
ds = "#{ds_path}/#{ds_id}/#{vm_id}/disk.#{disk_id}"
Command.execute("#{Mapper::COMMANDS[:chmod_nfs]} #{ds}", false)
_rc, out, _err = Command.execute("#{Mapper::COMMANDS[:file]} #{ds}", false)
case out

View File

@ -57,7 +57,7 @@ class Mapper
:mount => 'sudo mount',
:umount => 'sudo umount',
:kpartx => 'sudo kpartx',
:nbd => 'sudo qemu-nbd',
:nbd => 'sudo -u root -g oneadmin qemu-nbd',
:su_mkdir => 'sudo mkdir -p',
:mkdir => 'mkdir -p',
:cat => 'sudo cat',
@ -66,7 +66,6 @@ class Mapper
:e2fsck => 'sudo e2fsck',
:resize2fs => 'sudo resize2fs',
:xfs_growfs => 'sudo xfs_growfs',
:chmod_nfs => 'chmod o+w',
:rbd => 'sudo rbd --id'
}
@ -182,18 +181,19 @@ class Mapper
def unmap(one_vm, disk, directory)
OpenNebula.log_info "Unmapping disk at #{directory}"
sys_parts = lsblk('')
return false if !sys_parts
sys_parts = lsblk('')
return false unless sys_parts
partitions = []
device = ''
real_path = directory
ds = one_vm.lxdrc[:datastore_location] + "/#{one_vm.sysds_id}"
real_ds = File.readlink(ds) if File.symlink?(ds)
real_path = directory
real_path = real_ds + directory.split(ds)[-1] if directory.include?(ds)
if File.symlink?(ds)
real_ds = File.readlink(ds)
real_path = real_ds + directory.split(ds)[-1] if directory.include?(ds)
end
sys_parts.each { |d|
if d['mountpoint'] == real_path
@ -213,14 +213,16 @@ class Mapper
break if !partitions.empty?
}
partitions.delete_if { |p| !p['mountpoint'] }
partitions.sort! { |a,b|
b['mountpoint'].length <=> a['mountpoint'].length
}
partitions.delete_if { |p| !p['mountpoint'] }
partitions.sort! { |a,b|
b['mountpoint'].length <=> a['mountpoint'].length
}
umount(partitions)
do_unmap(device, one_vm, disk, real_path)
return true

View File

@ -33,6 +33,9 @@ class Qcow2Mapper < Mapper
dsrc = disk_source(one_vm, disk)
cmd = "#{COMMANDS[:nbd]} -c #{device} #{dsrc}"
ds = one_vm.lxdrc[:datastore_location] + "/#{one_vm.sysds_id}"
File.chmod(0664, dsrc) if File.symlink?(ds)
rc, _out, err = Command.execute(cmd, true)
if rc != 0

View File

@ -19,4 +19,4 @@
#
Cmnd_Alias ONE_MAPPER = /bin/lsblk, /sbin/losetup, /bin/mount, /bin/umount, /sbin/kpartx, /usr/bin/qemu-nbd, /bin/mkdir, /usr/bin/catfstab, /sbin/e2fsck, /sbin/resize2fs, /usr/sbin/xfs_growfs, /usr/bin/rbd
oneadmin ALL=(ALL) NOPASSWD: ONE_MAPPER
oneadmin ALL=(ALL:ALL) NOPASSWD: ONE_MAPPER