1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-27 13:57:23 +03:00

B #6162: Only stdin supported for datastore driver

Deprecate the use of arguments for passing messages to the datastore
driver actions.
This commit is contained in:
Ruben S. Montero 2023-03-29 13:28:13 +02:00
parent 564695413f
commit 5a83b45ce1
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
38 changed files with 71 additions and 199 deletions

View File

@ -662,7 +662,7 @@ TM_MAD = [
DATASTORE_MAD = [
EXECUTABLE = "one_datastore",
ARGUMENTS = "-i -t 15 -d dummy,fs,lvm,ceph,dev,iscsi_libvirt,vcenter,restic,rsync -s shared,ssh,ceph,fs_lvm,fs_lvm_ssh,qcow2,vcenter"
ARGUMENTS = "-t 15 -d dummy,fs,lvm,ceph,dev,iscsi_libvirt,vcenter,restic,rsync -s shared,ssh,ceph,fs_lvm,fs_lvm_ssh,qcow2,vcenter"
]
#*******************************************************************************

View File

@ -93,7 +93,6 @@ class DatastoreDriver < OpenNebulaDriver
:concurrency => 10,
:threaded => true,
:retries => 0,
:stdin => false,
:local_actions => {
ACTION[:stat] => nil,
ACTION[:cp] => nil,
@ -236,15 +235,8 @@ class DatastoreDriver < OpenNebulaDriver
path = File.join(@local_scripts_path, ds)
end
if @options[:stdin]
arguments = " - #{id}"
else
arguments = " #{stdin} #{id}"
stdin = nil
end
cmd = File.join(path, ACTION[action].downcase)
cmd << arguments
cmd << " #{id}"
rc = LocalCommand.run(cmd, log_method(id), stdin)
@ -287,15 +279,13 @@ opts = GetoptLong.new(
['--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT],
['--ds-types', '-d', GetoptLong::OPTIONAL_ARGUMENT],
['--system-ds-types', '-s', GetoptLong::OPTIONAL_ARGUMENT],
['--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT],
['--stdin', '-i', GetoptLong::NO_ARGUMENT]
['--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT]
)
ds_type = nil
sys_ds_type = nil
threads = 15
timeout = nil
stdin = false
begin
opts.each do |opt, arg|
@ -308,8 +298,6 @@ begin
sys_ds_type = arg.split(',').map {|a| a.strip }
when '--timeout'
timeout = arg.to_i
when '--stdin'
stdin = true
end
end
rescue StandardError => _e
@ -318,6 +306,5 @@ end
ds_driver = DatastoreDriver.new(ds_type, sys_ds_type,
:concurrency => threads,
:timeout => timeout,
:stdin => stdin)
:timeout => timeout)
ds_driver.start_driver

View File

@ -35,12 +35,8 @@ source ${DRIVER_PATH}/../../etc/datastore/ceph/ceph.conf
# -------- Get cp and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -37,12 +37,8 @@ source ${DRIVER_PATH}/../../etc/datastore/ceph/ceph.conf
# -------- Get cp and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
export DRV_ACTION

View File

@ -36,12 +36,8 @@ source ${DRIVER_PATH}/../../etc/datastore/ceph/ceph.conf
# -------- Get rm and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -38,12 +38,8 @@ source ${DRIVER_PATH}/../../etc/datastore/datastore.conf
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -37,12 +37,8 @@ source ${DRIVER_PATH}/ceph_utils.sh
# -------- Get datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -37,12 +37,8 @@ source ${DRIVER_PATH}/../../etc/datastore/ceph/ceph.conf
# -------- Get rm and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -38,12 +38,8 @@ source ${DRIVER_PATH}/../../etc/datastore/ceph/ceph.conf
# -------- Get image and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -38,12 +38,8 @@ source ${DRIVER_PATH}/../../etc/datastore/ceph/ceph.conf
# -------- Get image and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -38,12 +38,8 @@ source ${DRIVER_PATH}/../../etc/datastore/ceph/ceph.conf
# -------- Get image and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -36,12 +36,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get stat and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -36,12 +36,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get cp and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
export DRV_ACTION

View File

@ -36,12 +36,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get cp and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -37,12 +37,8 @@ source ${DRIVER_PATH}/../../etc/datastore/fs/fs.conf
# -------- Get cp and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
export DRV_ACTION

View File

@ -35,12 +35,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get rm and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -37,12 +37,8 @@ source ${DRIVER_PATH}/../../etc/datastore/datastore.conf
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -35,12 +35,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -35,12 +35,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get rm and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -32,12 +32,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get image and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -28,12 +28,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get image and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -32,12 +32,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get image and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -58,8 +58,7 @@ require 'rexml/document'
require_relative '../../tm/lib/backup'
require_relative '../../tm/lib/tm_action'
daction64 = ARGV[0]
daction64 = STDIN.read if daction64 == '-'
daction64 = STDIN.read
# Parse input data.

View File

@ -31,12 +31,8 @@ source ${DRIVER_PATH}/../libfs.sh
# -------- Get datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"

View File

@ -69,10 +69,8 @@ require_relative '../../tm/lib/tm_action'
# - vm.xml description
# - list of disks in the backup
# ------------------------------------------------------------------------------
daction64 = ARGV[0]
daction64 = STDIN.read if daction64 == '-'
_request_id = ARGV[1]
daction64 = STDIN.read
_request_id = ARGV[0]
begin
action = Base64.decode64 daction64

View File

@ -58,8 +58,7 @@ require 'rexml/document'
require_relative '../../tm/lib/backup'
require_relative '../../tm/lib/tm_action'
daction64 = ARGV[0]
daction64 = STDIN.read if daction64 == '-'
daction64 = STDIN.read
# Parse input data.

View File

@ -57,10 +57,8 @@ require 'base64'
require_relative '../../tm/lib/tm_action'
daction64 = ARGV[0]
daction64 = STDIN.read if daction64 == '-'
_ds_id = ARGV[1]
daction64 = STDIN.read
_ds_id = ARGV[0]
# Image path in the form:
# rsync://100/0:6da1c7,1:06132a,2:03fc2a//var/lib/one//datastores/100/13/6da1c7/disk.0.0

View File

@ -51,9 +51,8 @@ $LOAD_PATH << File.dirname(__FILE__)
require 'vcenter_driver'
drv_action_enc = ARGV[0]
id = ARGV[1]
drv_action_enc = STDIN.read if drv_action_enc == '-'
id = ARGV[0]
drv_action_enc = STDIN.read
DRV_ACTION_DS = '/DS_DRIVER_ACTION_DATA/DATASTORE/'

View File

@ -125,9 +125,8 @@ def find_image_type(target_file)
target_file_type
end
drv_action_enc = ARGV[0]
id = ARGV[1]
drv_action_enc = STDIN.read if drv_action_enc == '-'
id = ARGV[0]
drv_action_enc = STDIN.read
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(drv_action_enc),

View File

@ -55,8 +55,7 @@ $LOAD_PATH << File.dirname(__FILE__)
require 'opennebula'
drv_action_enc = ARGV[0]
drv_action_enc = STDIN.read if drv_action_enc == '-'
drv_action_enc = STDIN.read
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(drv_action_enc),

View File

@ -55,8 +55,7 @@ $LOAD_PATH << File.dirname(__FILE__)
require 'vcenter_driver'
drv_action_enc = ARGV[0]
drv_action_enc = STDIN.read if drv_action_enc == '-'
drv_action_enc = STDIN.read
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(drv_action_enc),

View File

@ -59,9 +59,8 @@ def not_dsid_or_dsref_valid?(ds_id, ds_ref)
ds_id.nil? || ds_ref.nil?
end
drv_action_enc = ARGV[0]
id = ARGV[1]
drv_action_enc = STDIN.read if drv_action_enc == '-'
id = ARGV[0]
drv_action_enc = STDIN.read
drv_action = OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(drv_action_enc),

View File

@ -59,8 +59,7 @@ def img_not_imported?(imported)
imported.nil? || imported.empty?
end
drv_action_enc = ARGV[0]
drv_action_enc = STDIN.read if drv_action_enc == '-'
drv_action_enc = STDIN.read
drv_action =OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(drv_action_enc),

View File

@ -55,8 +55,7 @@ $LOAD_PATH << File.dirname(__FILE__)
require 'vcenter_driver'
drv_action_enc = ARGV[0]
drv_action_enc = STDIN.read if drv_action_enc == '-'
drv_action_enc = STDIN.read
drv_action =OpenNebula::XMLElement.new
drv_action.initialize_xml(Base64.decode64(drv_action_enc),

View File

@ -300,7 +300,7 @@ class MarketPlaceDriver < OpenNebulaDriver
end
if stdin
arguments = " - #{id}"
arguments = " #{id}"
else
arguments = " #{drv_action} #{id}"
drv_action = nil
@ -347,14 +347,12 @@ opts = GetoptLong.new(
['--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT],
['--market-types', '-m', GetoptLong::OPTIONAL_ARGUMENT],
['--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT],
['--proxy', '-p', GetoptLong::OPTIONAL_ARGUMENT],
['--stdin', '-i', GetoptLong::NO_ARGUMENT]
['--proxy', '-p', GetoptLong::OPTIONAL_ARGUMENT]
)
mp_type = nil
threads = 15
timeout = nil
stdin = false
begin
opts.each do |opt, arg|
@ -367,8 +365,6 @@ begin
timeout = arg.to_i
when '--proxy'
ENV['http_proxy'] = arg
when '--stdin'
stdin = true
end
end
rescue StandardError
@ -377,7 +373,5 @@ end
mp_driver = MarketPlaceDriver.new(mp_type,
:concurrency => threads,
:timeout => timeout,
:stdin => stdin)
:timeout => timeout)
mp_driver.start_driver

View File

@ -37,12 +37,8 @@ source ${DRIVER_PATH}/../../datastore/ceph/ceph_utils.sh
# -------- Get datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
ID=$1
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb -b $DRV_ACTION"

View File

@ -35,12 +35,8 @@ source ${DRIVER_PATH}/../../datastore/libfs.sh
# -------- Get datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
DS_ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
DS_ID=$1
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb -b $DRV_ACTION"

View File

@ -35,12 +35,8 @@ source ${DRIVER_PATH}/../../datastore/libfs.sh
# -------- Get datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
DS_ID=$2
if [ "${DRV_ACTION}" = "-" ]; then
DRV_ACTION=`cat -`
fi
DRV_ACTION=`cat -`
DS_ID=$1
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb -b $DRV_ACTION"