mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-01 20:56:42 +09:00
The remote scripts directory (former SCRIPTS_REMOTE_DIR) is now fixed
to /var/lib/one-remotes and the configuration attribute is gone. The
old default /var/tmp/one was broken in several ways: /var/tmp content
is aged away by systemd-tmpfiles, the world-writable parent allows
squatting on the directory, and the configurable location was silently
not honored by many drivers, probes and static files (sudoers,
AppArmor, tmpfiles, cron).
- The remotes are synced to /var/lib/one-remotes on the hosts; the
directory is created by the node packages, as it cannot be created
by the unprivileged oneadmin
- The node monitoring DB moves along to /var/lib/one-remotes-db;
it cannot live inside the remotes directory as the sync
(rsync --delete) would remove it. The monitord client migrates
the DB from the legacy location on its first start
- Helpers executed through sudo are installed at a fixed path
(/usr/lib/one/sbin) by the node packages, so they are no longer
executed from an oneadmin-writable location
- Remote hooks (REMOTE = yes) run from /var/lib/one-remotes/hooks.
Hook commands given as an absolute path are executed as-is and
must be updated manually
- Fix remotes sync to run the mkdir on the host: the local shell
interpreted the unquoted ';' and ran it on the frontend instead
- onecfg migrator drops SCRIPTS_REMOTE_DIR from oned.conf and the
stock :remote_hook_base_path from onehem-server.conf
142 lines
5.5 KiB
Ruby
142 lines
5.5 KiB
Ruby
# -------------------------------------------------------------------------- #
|
|
# Copyright 2002-2026, OpenNebula Project, OpenNebula Systems #
|
|
# #
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
# not use this file except in compliance with the License. You may obtain #
|
|
# a copy of the License at #
|
|
# #
|
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
|
# #
|
|
# Unless required by applicable law or agreed to in writing, software #
|
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
|
# See the License for the specific language governing permissions and #
|
|
# limitations under the License. #
|
|
#--------------------------------------------------------------------------- #
|
|
|
|
# Holds configuration about sudoers requirements for OpeNebula
|
|
class Sudoers
|
|
|
|
NODECMDS = [:NET, :NETNS, :OVS, :LVM, :LXC, :MEM, :VGPU, :VTPM, :NFS, :SCSI, :FABRIC,
|
|
:FS]
|
|
|
|
attr_accessor :cmds
|
|
|
|
def initialize(lib_location, libexec_location = '/usr/libexec/one')
|
|
# Commands required to be used as root, without password, by oneadmin
|
|
@cmds = {
|
|
:NET => [
|
|
'iptables',
|
|
'ip6tables',
|
|
'ipset',
|
|
'ip link *',
|
|
'ip neighbour *',
|
|
'ip route *',
|
|
'ip rule *',
|
|
'ip tuntap *',
|
|
'nft',
|
|
"#{libexec_location}/tproxy",
|
|
'bridge',
|
|
'devlink',
|
|
'ethtool'
|
|
],
|
|
:NETNS => [
|
|
'ip netns add *',
|
|
'ip netns delete *',
|
|
'ip netns pids *',
|
|
"#{libexec_location}/ip_netns_exec ip address *",
|
|
"#{libexec_location}/ip_netns_exec ip link *",
|
|
"#{libexec_location}/ip_netns_exec ip -j link show *",
|
|
"#{libexec_location}/ip_netns_exec ip route *",
|
|
"#{libexec_location}/ip_netns_exec sysctl -w " \
|
|
'net.ipv4.conf.all.arp_ignore=0 net.ipv4.conf.default.arp_ignore=0'
|
|
],
|
|
:LVM => [
|
|
'lvcreate', 'lvremove', 'lvs', 'vgdisplay', 'lvchange', 'lvscan', 'lvextend',
|
|
'dmsetup'
|
|
],
|
|
:OVS => ['ovs-ofctl', 'ovs-vsctl', 'ovs-appctl'],
|
|
:CEPH => ['rbd'],
|
|
:HA => [
|
|
'systemctl start opennebula-flow',
|
|
'systemctl stop opennebula-flow',
|
|
'systemctl start opennebula-gate',
|
|
'systemctl stop opennebula-gate',
|
|
'systemctl start opennebula-form',
|
|
'systemctl stop opennebula-form',
|
|
'systemctl start opennebula-hem',
|
|
'systemctl stop opennebula-hem',
|
|
'systemctl start opennebula-showback.timer',
|
|
'systemctl stop opennebula-showback.timer',
|
|
'service opennebula-flow start',
|
|
'service opennebula-flow stop',
|
|
'service opennebula-gate start',
|
|
'service opennebula-gate stop',
|
|
'service opennebula-form start',
|
|
'service opennebula-form stop',
|
|
'service opennebula-hem start',
|
|
'service opennebula-hem stop',
|
|
'arping',
|
|
'ip address *'
|
|
],
|
|
:LXC => [
|
|
'mount', 'umount', 'bindfs', 'losetup', 'qemu-nbd', 'lxc-attach', 'lxc-config',
|
|
'lxc-create', 'lxc-destroy', 'lxc-info', 'lxc-ls', 'lxc-start', 'lxc-stop',
|
|
'lxc-console', 'e2fsck', 'resize2fs', 'xfs_growfs', 'rbd-nbd', 'lxc-device',
|
|
'lxc-freeze', 'lxc-unfreeze'
|
|
],
|
|
:MARKET => ["#{lib_location}/sh/create_container_image.sh"],
|
|
:MEM => ['sysctl vm.drop_caches=3 vm.compact_memory=1'],
|
|
:VGPU => ['sudo', "#{libexec_location}/vgpu"],
|
|
:VTPM => ['sudo', "#{libexec_location}/vtpm_setup"],
|
|
:NFS => ['mount', 'umount', '/usr/bin/sed -i -f /proc/self/fd/0 /etc/fstab'],
|
|
:SCSI => [
|
|
'blockdev',
|
|
'multipath',
|
|
'multipathd',
|
|
'iscsiadm',
|
|
'tee',
|
|
'find',
|
|
'cat /etc/iscsi/initiatorname.iscsi'
|
|
],
|
|
:FABRIC => ['dmidecode'],
|
|
:FS => ['mkfs']
|
|
}
|
|
end
|
|
|
|
# Return a list of commands full path
|
|
def aliases
|
|
cmnd_aliases = {}
|
|
|
|
cmds.keys.each do |label|
|
|
cmd_path = []
|
|
|
|
cmds[label].each do |cmd|
|
|
if cmd[0] == '/'
|
|
cmd_path << cmd
|
|
next
|
|
end
|
|
|
|
cmd_parts = cmd.split
|
|
cmd_parts[0] = which(cmd_parts[0])
|
|
|
|
if cmd_parts[0].empty?
|
|
STDERR.puts "command not found: #{cmd}"
|
|
exit 1
|
|
end
|
|
|
|
cmd_path << cmd_parts.join(' ')
|
|
end
|
|
|
|
cmnd_aliases["ONE_#{label}"] = cmd_path
|
|
end
|
|
|
|
cmnd_aliases
|
|
end
|
|
|
|
def which(cmd)
|
|
`which #{cmd} 2>/dev/null`.strip
|
|
end
|
|
|
|
end
|