Skip to content

Commit

Permalink
B #6162: Only stdin supported for datastore driver
Browse files Browse the repository at this point in the history
Deprecate the use of arguments for passing messages to the datastore
driver actions.
  • Loading branch information
rsmontero committed Mar 29, 2023
1 parent 5646954 commit 5a83b45
Show file tree
Hide file tree
Showing 38 changed files with 71 additions and 199 deletions.
2 changes: 1 addition & 1 deletion share/etc/oned.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]

#*******************************************************************************
Expand Down
19 changes: 3 additions & 16 deletions src/datastore_mad/one_datastore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def initialize(ds_type, sys_ds_type, options = {})
:concurrency => 10,
:threaded => true,
:retries => 0,
:stdin => false,
:local_actions => {
ACTION[:stat] => nil,
ACTION[:cp] => nil,
Expand Down Expand Up @@ -236,15 +235,8 @@ def do_image_action(id, ds, action, stdin, sys = '', encode64 = false)
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)

Expand Down Expand Up @@ -287,15 +279,13 @@ def get_ds_type(drv_message)
['--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|
Expand All @@ -308,8 +298,6 @@ def get_ds_type(drv_message)
sys_ds_type = arg.split(',').map {|a| a.strip }
when '--timeout'
timeout = arg.to_i
when '--stdin'
stdin = true
end
end
rescue StandardError => _e
Expand All @@ -318,6 +306,5 @@ def get_ds_type(drv_message)

ds_driver = DatastoreDriver.new(ds_type, sys_ds_type,
:concurrency => threads,
:timeout => timeout,
:stdin => stdin)
:timeout => timeout)
ds_driver.start_driver
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/clone
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/cp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/export
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/mkfs
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/monitor
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/rm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/snap_delete
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/snap_flatten
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/ceph/snap_revert
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/common/stat
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/dev/cp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/clone
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/cp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/export
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/mkfs
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/monitor
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/rm
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/snap_delete
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/snap_flatten
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/fs/snap_revert
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 1 addition & 2 deletions src/datastore_mad/remotes/rsync/increment_flatten
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 2 additions & 6 deletions src/datastore_mad/remotes/rsync/monitor
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading

0 comments on commit 5a83b45

Please sign in to comment.