Skip to content

Commit

Permalink
uses absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
aschnell committed Mar 4, 2019
1 parent 09b176a commit 596ffae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/clients/iscsi-lio-server.rb
Expand Up @@ -73,7 +73,7 @@ def run
password = $discovery_auth.fetch_password
mutual_userid = $discovery_auth.fetch_mutual_userid
mutual_password = $discovery_auth.fetch_mutual_password
cmd = 'targetcli'
cmd = '/usr/bin/targetcli'
p1 = "iscsi/ set discovery_auth "
# status == false means "No discovery auth" is not checked, means we need enable discovery auth
if !status
Expand Down
10 changes: 5 additions & 5 deletions src/include/iscsi-lio-server/TargetData.rb
Expand Up @@ -32,7 +32,7 @@ def initialize()
end

def analyze
@output = Yast::Execute.locally("targetcli", "backstores/ ls", stdout: :capture)
@output = Yast::Execute.locally("/usr/bin/targetcli", "backstores/ ls", stdout: :capture)
@backstores_output = @output.split("\n")
@backstores_output.each do |line|
if @backstore_path = RE_BACKSTORE_PATH.match(line)
Expand Down Expand Up @@ -383,7 +383,7 @@ def initialize
def analyze
# We need to re-new @target_list, because something may be deleted
@targets_list = TargetList.new
@target_outout = Yast::Execute.locally!.stdout("targetcli", "ls").split("\n")
@target_outout = Yast::Execute.locally!.stdout("/usr/bin/targetcli", "ls").split("\n")
@target_outout.each do |line|
# handle iqn targets here.
if RE_IQN_TARGET.match(line)
Expand Down Expand Up @@ -507,7 +507,7 @@ def save_current_acl_rule
def acl_auth_info(data)
acl = "iscsi/#{@current_target.fetch_target_name}/tpg#{@current_tpg.fetch_tpg_number}/acls/#{@initiator_name}/"

Yast::Execute.locally!.stdout("targetcli", acl, "get", "auth", data).split("=", 2).last
Yast::Execute.locally!.stdout("/usr/bin/targetcli", acl, "get", "auth", data).split("=", 2).last
end
end

Expand Down Expand Up @@ -608,7 +608,7 @@ def initialize
end

def execute_init_commands
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
commands = [
"set global auto_add_mapped_luns=false",
"set global auto_add_default_portal=false"
Expand All @@ -624,7 +624,7 @@ def execute_init_commands
end

def execute_exit_commands
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
commands = [
"saveconfig",
]
Expand Down
30 changes: 15 additions & 15 deletions src/include/iscsi-lio-server/UI_dialogs.rb
Expand Up @@ -906,7 +906,7 @@ def GetNetConfig
ip_list = []
re_ipv4 = Regexp.new(/[\d+\.]+\//)
re_ipv6 = Regexp.new(/[\w+\:]+\//)
ret = Yast::Execute.locally('ip', 'a', stdout: :capture)
ret = Yast::Execute.locally('/sbin/ip', 'a', stdout: :capture)
ip = ret.split("\n")
ip.each do |line|
line = line.strip
Expand Down Expand Up @@ -1065,7 +1065,7 @@ def get_selected

def add_item(item)
failed = false
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
p1 = "iscsi/" + @target_name + "/tpg" + @tpg_num.to_s + "/acls create " + item[1]
if item[0] < 5000
enable_auto_add_mapped_luns
Expand Down Expand Up @@ -1095,7 +1095,7 @@ def add_item(item)

def delete_item(item)
failed = false
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
p1 = "iscsi/" + @target_name + "/tpg" + @tpg_num.to_s + "/acls delete " + item[1]
begin
Cheetah.run(cmd, p1)
Expand Down Expand Up @@ -1128,7 +1128,7 @@ def items
end

def enable_auto_add_mapped_luns
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
p1 = "set global auto_add_mapped_luns=true"
begin
Cheetah.run(cmd, p1)
Expand All @@ -1140,7 +1140,7 @@ def enable_auto_add_mapped_luns
end

def disable_auto_add_mapped_luns
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
p1 = "set global auto_add_mapped_luns=false"
begin
Cheetah.run(cmd, p1)
Expand Down Expand Up @@ -1332,7 +1332,7 @@ def validate
return false
end
failed_mapping_luns = []
cmd = 'targetcli'
cmd = '/usr/bin/targetcli'
@mapping_luns_added.each do |elem|
p1 = 'iscsi/' + @target_name + "/tpg" + @tpg_num + "/acls/" + @initiator_name + "/ create mapped_lun=" + \
elem[1].to_s + " tpg_lun_or_backstore=" + elem[2].to_s
Expand Down Expand Up @@ -1632,7 +1632,7 @@ def validate
target_name = @info[0]
tpg_num = @info[1]
initiator_name = @info[2]
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
if @auth_by_initiator.value
p1 = "iscsi/" + target_name + "/tpg" + tpg_num + "/acls/" + initiator_name + \
"/ set auth mutual_userid=" + mutual_username + " mutual_password=" + mutual_password
Expand Down Expand Up @@ -1742,7 +1742,7 @@ def validate()
target_name = @info[0]
tpg_num = @info[1]
initiator_name = @info[2]
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
if @auth_by_target.value
p1 = "iscsi/" + target_name + "/tpg" + tpg_num + "/acls/" + initiator_name + \
"/ set auth userid=" + username + " password=" + password
Expand Down Expand Up @@ -1927,7 +1927,7 @@ def contents
end

def validate
cmd = "targetcli iscsi/" + @target_name + "/tpg" + @target_tpg + "/ get attribute authentication"
cmd = "/usr/bin/targetcli iscsi/" + @target_name + "/tpg" + @target_tpg + "/ get attribute authentication"
cmd_out = `#{cmd}`
ret = cmd_out[15, cmd_out.length]
if ret == "1 \n"
Expand Down Expand Up @@ -2055,7 +2055,7 @@ def initialize(target_name)
end

if @mode == 'edit'
cmd = "targetcli iscsi/" + @target_name + "/tpg" + tpg_num + "/ get attribute authentication"
cmd = "/usr/bin/targetcli iscsi/" + @target_name + "/tpg" + tpg_num + "/ get attribute authentication"
cmd_out = `#{cmd}`
ret = cmd_out[15, cmd_out.length]
if ret == "1 \n"
Expand Down Expand Up @@ -2115,7 +2115,7 @@ def validate
portal_addr = @IP_selsection_box.get_addr
port = @target_port_num_field.get_value.to_s
bind_all = @target_bind_all_ip_checkbox.get_value
cmd = 'targetcli'
cmd = '/usr/bin/targetcli'
if @mode == 'new'
p1 = 'iscsi/ create'
if @target_name_input_field.get_value.bytesize > @iscsi_name_length_max
Expand Down Expand Up @@ -2359,7 +2359,7 @@ def contents

def create_ACLs_dialog(info)
if !info.empty?
cmd = "targetcli iscsi/" + info[0] + "/tpg" + info[1] + "/ get attribute authentication"
cmd = "/usr/bin/targetcli iscsi/" + info[0] + "/tpg" + info[1] + "/ get attribute authentication"
cmd_out = `#{cmd}`
ret = cmd_out[15, cmd_out.length]
if ret == "1 \n"
Expand Down Expand Up @@ -2396,7 +2396,7 @@ def handle(event)
info = @edit_target_page.get_target_info
create_ACLs_dialog(info)
when :delete
cmd = 'targetcli'
cmd = '/usr/bin/targetcli'
target = @target_table.get_selected
if target == nil
return nil
Expand Down Expand Up @@ -2509,7 +2509,7 @@ def table_remove_lun(path)
def validate
failed_storage = ""
@luns_added.each do |lun|
cmd = 'targetcli'
cmd = '/usr/bin/targetcli'
if !lun[2].empty?
case lun[4]
when "file"
Expand Down Expand Up @@ -2875,7 +2875,7 @@ def handle(event)
@lun_table.table_remove_lun(lun[3])
return nil
end
cmd = "targetcli"
cmd = "/usr/bin/targetcli"
p1 = "backstores/"
if lun[4] == "file"
p1 += "fileio delete " + lun[2]
Expand Down
10 changes: 5 additions & 5 deletions test/target_data_test.rb
Expand Up @@ -29,7 +29,7 @@
before do
allow(Yast::Execute).to receive(:locally!).and_return(execute_object)

allow(execute_object).to receive(:stdout).with("targetcli", "ls").and_return(output)
allow(execute_object).to receive(:stdout).with("/usr/bin/targetcli", "ls").and_return(output)
end

let(:execute_object) { Yast::Execute.new }
Expand All @@ -46,16 +46,16 @@
let(:output) { fixture("ls-typical") }

before do
allow(execute_object).to receive(:stdout).with("targetcli", acl, "get", "auth", "userid")
allow(execute_object).to receive(:stdout).with("/usr/bin/targetcli", acl, "get", "auth", "userid")
.and_return("userid=teddybear")

allow(execute_object).to receive(:stdout).with("targetcli", acl, "get", "auth", "password")
allow(execute_object).to receive(:stdout).with("/usr/bin/targetcli", acl, "get", "auth", "password")
.and_return("password=plush")

allow(execute_object).to receive(:stdout).with("targetcli", acl, "get", "auth", "mutual_userid")
allow(execute_object).to receive(:stdout).with("/usr/bin/targetcli", acl, "get", "auth", "mutual_userid")
.and_return("mutual_userid=foo")

allow(execute_object).to receive(:stdout).with("targetcli", acl, "get", "auth", "mutual_password")
allow(execute_object).to receive(:stdout).with("/usr/bin/targetcli", acl, "get", "auth", "mutual_password")
.and_return("mutual_password=bar")
end

Expand Down

0 comments on commit 596ffae

Please sign in to comment.