Exception: Kitchen::Driver::ProxmoxErrors::ApiError
- Inherits:
-
StandardError
- Object
- StandardError
- Kitchen::Driver::ProxmoxErrors::ApiError
- Defined in:
- lib/kitchen/driver/proxmox/errors.rb
Overview
Structured error raised by ApiClient on non-2xx responses.
Instance Attribute Summary collapse
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(status_code, response_body) ⇒ ApiError
constructor
A new instance of ApiError.
-
#local_storage_conflict? ⇒ Boolean
Returns true when clone fails because the template uses local storage and cannot be cloned to a different node.
-
#vmid_conflict? ⇒ Boolean
Returns true when the error indicates a VMID is already in use or cannot be locked (concurrent clone race).
-
#vmid_race_lost? ⇒ Boolean
Returns true when the error indicates another process owns the VM (lost a VMID race — VM was started or configured by another clone).
Constructor Details
#initialize(status_code, response_body) ⇒ ApiError
Returns a new instance of ApiError.
10 11 12 13 14 |
# File 'lib/kitchen/driver/proxmox/errors.rb', line 10 def initialize(status_code, response_body) @status_code = status_code.to_i @response_body = response_body super("Proxmox API error #{status_code}: #{response_body}") end |
Instance Attribute Details
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
8 9 10 |
# File 'lib/kitchen/driver/proxmox/errors.rb', line 8 def response_body @response_body end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
8 9 10 |
# File 'lib/kitchen/driver/proxmox/errors.rb', line 8 def status_code @status_code end |
Instance Method Details
#local_storage_conflict? ⇒ Boolean
Returns true when clone fails because the template uses local storage and cannot be cloned to a different node.
39 40 41 |
# File 'lib/kitchen/driver/proxmox/errors.rb', line 39 def local_storage_conflict? response_body.match?(/uses local storage/i) end |
#vmid_conflict? ⇒ Boolean
Returns true when the error indicates a VMID is already in use or cannot be locked (concurrent clone race).
18 19 20 21 22 23 24 |
# File 'lib/kitchen/driver/proxmox/errors.rb', line 18 def vmid_conflict? return false unless status_code == 400 || status_code == 500 response_body.match?(/already exists/i) || response_body.match?(/unable to create VM \d+/i) || response_body.match?(/can't lock file.*lock-\d+/i) end |
#vmid_race_lost? ⇒ Boolean
Returns true when the error indicates another process owns the VM (lost a VMID race — VM was started or configured by another clone).
28 29 30 31 32 33 34 35 |
# File 'lib/kitchen/driver/proxmox/errors.rb', line 28 def vmid_race_lost? return false unless status_code == 400 || status_code == 500 response_body.match?(/already running/i) || response_body.match?(/hotplug problem/i) || response_body.match?(/does not exist/i) || response_body.match?(/can't lock file.*lock-\d+/i) end |