hetzner rdns: allow 404
This commit is contained in:
parent
a0900306e2
commit
4a5caddd23
@ -24,12 +24,12 @@ module Lxc
|
||||
def put(path, params={})
|
||||
req = Net::HTTP::Put.new(uri_for(path))
|
||||
req.set_form_data(params)
|
||||
resp = perform_request(req)
|
||||
resp = perform_request(req, allow_404)
|
||||
JSON.parse(resp.body)
|
||||
end
|
||||
|
||||
def delete(path)
|
||||
perform_request(Net::HTTP::Delete.new(uri_for(path)))
|
||||
def delete(path, allow_404: false)
|
||||
perform_request(Net::HTTP::Delete.new(uri_for(path)), allow_404: allow_404)
|
||||
end
|
||||
|
||||
private
|
||||
@ -39,12 +39,12 @@ module Lxc
|
||||
u
|
||||
end
|
||||
|
||||
def perform_request(req)
|
||||
def perform_request(req, allow_404: false)
|
||||
req.basic_auth(@user, @password)
|
||||
resp = Net::HTTP.start(BASE_URI.hostname, BASE_URI.port, use_ssl: true) do |http|
|
||||
http.request(req)
|
||||
end
|
||||
if resp.code.start_with? "2"
|
||||
if resp.code.start_with?("2") || (allow_404 && resp.code == "404")
|
||||
return resp
|
||||
else
|
||||
raise StandardError.new("failed to perform request for '#{req.path}': #{resp.code} - #{resp.body}")
|
||||
|
@ -32,7 +32,7 @@ def update_hetzner_rdns6(user, password, domain, subnet, network)
|
||||
end
|
||||
records.each do |ip, ptr|
|
||||
puts "delete ptr: #{ip} -> #{ptr}"
|
||||
api.delete("/rnds/#{ip}")
|
||||
api.delete("/rnds/#{ip}", allow_404: true)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user