Replace deprecated File.exists?
File.exists? was deprecated in Ruby 2.1 and was removed in Ruby 3.2, in favor of File.exist? . Change-Id: I3df6b9554be0ea3484840e5c6196cdefd9e6b89a
This commit is contained in:
parent
d9bd2f0cd5
commit
9848342cd7
@ -19,7 +19,7 @@ class Puppet::Provider::SwiftRingBuilder < Puppet::Provider
|
||||
|
||||
def lookup_ring
|
||||
object_hash = {}
|
||||
if File.exists?(builder_file_path(policy_index))
|
||||
if File.exist?(builder_file_path(policy_index))
|
||||
if rows = swift_ring_builder(builder_file_path(policy_index)).split("\n")
|
||||
while row = rows.shift do
|
||||
if row.start_with?('Devices:')
|
||||
|
@ -217,7 +217,7 @@ Puppet::Type.type(:swift_storage_policy).provide(:ruby) do
|
||||
private
|
||||
|
||||
def self.get_swift_conf_file
|
||||
if File.exists? '/etc/swift/swift.conf'
|
||||
if File.exist? '/etc/swift/swift.conf'
|
||||
file = '/etc/swift/swift.conf'
|
||||
else
|
||||
file = '/etc/swift/swift.conf'
|
||||
|
@ -49,12 +49,12 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
|
||||
it 'ring_account_device should exist when found in builder file' do
|
||||
allow(provider.class).to receive(:swift_ring_builder).and_return account_builder_output
|
||||
expect(File).to receive(:exists?).with(builder_file_path).and_return(true)
|
||||
expect(File).to receive(:exist?).with(builder_file_path).and_return(true)
|
||||
expect(provider.exists?).to eq({:id=>"1", :region=>"1", :zone=>"1", :weight=>"1.00", :partitions=>"262144", :balance=>"0.00", :meta=>"", :policy_index=>''})
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring' do
|
||||
expect(File).to receive(:exists?).with(builder_file_path).and_return(true)
|
||||
expect(File).to receive(:exist?).with(builder_file_path).and_return(true)
|
||||
expect(provider).to receive(:builder_file_path).twice.and_return(builder_file_path)
|
||||
expect(provider).to receive(:swift_ring_builder).and_return account_builder_output
|
||||
resources = provider.lookup_ring
|
||||
|
@ -46,12 +46,12 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
|
||||
it 'ring_container_device should exist when found in builder file' do
|
||||
expect(provider).to receive(:swift_ring_builder).and_return container_builder_output
|
||||
expect(File).to receive(:exists?).with(builder_file_path).and_return(true)
|
||||
expect(File).to receive(:exist?).with(builder_file_path).and_return(true)
|
||||
expect(provider.exists?).to eq({:id=>"1", :region=>"1", :zone=>"1", :weight=>"1.00", :partitions=>"262144", :balance=>"0.00", :meta=>"", :policy_index=>''})
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring' do
|
||||
expect(File).to receive(:exists?).with(builder_file_path).and_return(true)
|
||||
expect(File).to receive(:exist?).with(builder_file_path).and_return(true)
|
||||
expect(provider).to receive(:builder_file_path).twice.and_return(builder_file_path)
|
||||
expect(provider).to receive(:swift_ring_builder).and_return container_builder_output
|
||||
resources = provider.lookup_ring
|
||||
|
@ -58,12 +58,12 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
|
||||
it 'ring_object_device should exist when found in builder file' do
|
||||
expect(provider).to receive(:swift_ring_builder).and_return object_builder_output
|
||||
expect(File).to receive(:exists?).with(builder_file_path).and_return(true)
|
||||
expect(File).to receive(:exist?).with(builder_file_path).and_return(true)
|
||||
expect(provider.exists?).to eq({:id=>"1", :region=>"1", :zone=>"1", :weight=>"1.00", :partitions=>"262144", :balance=>"0.00", :meta=>"", :policy_index=>''})
|
||||
end
|
||||
|
||||
it 'should be able to lookup the local ring' do
|
||||
expect(File).to receive(:exists?).with(builder_file_path).and_return(true)
|
||||
expect(File).to receive(:exist?).with(builder_file_path).and_return(true)
|
||||
expect(provider).to receive(:builder_file_path).twice.and_return(builder_file_path)
|
||||
expect(provider).to receive(:swift_ring_builder).and_return object_builder_output
|
||||
resources = provider.lookup_ring
|
||||
@ -135,12 +135,12 @@ Devices: id region zone ip address:port replic_ip:replic_port
|
||||
|
||||
it 'ring_object_device should exist when found in builder file with policy_index=1' do
|
||||
expect(provider_policy1).to receive(:swift_ring_builder).and_return object_builder_policy1_output
|
||||
expect(File).to receive(:exists?).with(builder_file_path_policy1).and_return(true)
|
||||
expect(File).to receive(:exist?).with(builder_file_path_policy1).and_return(true)
|
||||
expect(provider_policy1.exists?).to eq({:id=>"1", :region=>"1", :zone=>"1", :weight=>"1.00", :partitions=>"262144", :balance=>"0.00", :meta=>"", :policy_index=>"1"})
|
||||
end
|
||||
|
||||
it 'lookup local ring and object resource names should start with policy_index if a policy is set' do
|
||||
expect(File).to receive(:exists?).with(builder_file_path_policy1).and_return(true)
|
||||
expect(File).to receive(:exist?).with(builder_file_path_policy1).and_return(true)
|
||||
expect(provider_policy1).to receive(:builder_file_path).twice.and_return(builder_file_path_policy1)
|
||||
expect(provider_policy1).to receive(:swift_ring_builder).and_return object_builder_output
|
||||
resources = provider_policy1.lookup_ring
|
||||
|
Loading…
x
Reference in New Issue
Block a user