fog-proxmox 0.15.0 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/lib/fog/proxmox/auth/token/access_ticket.rb +2 -2
  4. data/lib/fog/proxmox/compute/models/server.rb +6 -0
  5. data/lib/fog/proxmox/compute/models/snapshot.rb +1 -1
  6. data/lib/fog/proxmox/compute/models/task.rb +1 -1
  7. data/lib/fog/proxmox/core.rb +1 -0
  8. data/lib/fog/proxmox/helpers/disk_helper.rb +10 -10
  9. data/lib/fog/proxmox/helpers/nic_helper.rb +13 -6
  10. data/lib/fog/proxmox/identity/models/group.rb +1 -1
  11. data/lib/fog/proxmox/identity/models/token.rb +1 -1
  12. data/lib/fog/proxmox/identity/models/user.rb +1 -1
  13. data/lib/fog/proxmox/string.rb +2 -2
  14. data/lib/fog/proxmox/version.rb +1 -1
  15. data/spec/compute_spec.rb +3 -2
  16. data/spec/fixtures/proxmox/compute/snapshots.yml +348 -1053
  17. data/spec/helpers/disk_helper_spec.rb +8 -1
  18. data/spec/helpers/nic_helper_spec.rb +2 -2
  19. data/spec/proxmox_vcr.rb +1 -1
  20. metadata +34 -50
  21. data/.bundle/config +0 -4
  22. data/.github/CODE_OF_CONDUCT.md +0 -74
  23. data/.github/CONTRIBUTING.md +0 -20
  24. data/.github/CONTRIBUTORS.md +0 -9
  25. data/.github/FUNDING.yml +0 -12
  26. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  27. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  28. data/.github/ISSUE_TEMPLATE.md +0 -43
  29. data/.github/SUPPORT.md +0 -9
  30. data/.github/fogproxmox.png +0 -0
  31. data/.github/workflows/ci.yml +0 -64
  32. data/.github/workflows/release.yml +0 -38
  33. data/.gitignore +0 -8
  34. data/.rubocop.yml +0 -14
  35. data/.rubocop_todo.yml +0 -255
  36. data/.ruby-gemset +0 -1
  37. data/.solargraph.yml +0 -10
  38. data/.vscode/launch.json +0 -96
  39. data/.vscode/settings.json +0 -45
  40. data/.vscode/tasks.json +0 -27
  41. data/Gemfile +0 -23
  42. data/Rakefile +0 -31
  43. data/bin/console +0 -27
  44. data/bin/setup +0 -27
  45. data/fog-proxmox.gemspec +0 -65
  46. data/tasks/audit.rake +0 -25
  47. data/tasks/lint.rake +0 -22
  48. data/tasks/test.rake +0 -65
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbbd25ac2c953f21c2a4f5b9ab59e30269ab68f9f832abf4dc740743e10a93ec
4
- data.tar.gz: 3c20988aca648ae685ce5c8e86c17af02ae667bbf6fe53ee012616fec2300ebe
3
+ metadata.gz: 76ca5dd7645b67a287e1f668a536de1fcf180f4d363ba2472e03ad33fc1a5194
4
+ data.tar.gz: 551e55a53ce2c316be4134f45251539209e90b6a87ad207653b17754653cfebc
5
5
  SHA512:
6
- metadata.gz: 813919e970090cde4ccac7ec991b06f4a8380bdf0a1e0e85c0f5b73fce6da91d48da381bcba239ba995e5b706d80bf6b9123823f66420967685deb350dd30a22
7
- data.tar.gz: 3d638a97782b63a70e12237e6494bf67386e019b287965eb02d36c92f7c097c36a443fe84b2e53464f13895984be7f9141171a4212fab8d3792d08ebab85920d
6
+ metadata.gz: 7263bb9be5064c515fa658f284afbd696251dde07e2b74d86d61c3f367c19f3b3894b3ff2392fa275f258e5c4b5b640a66808d7c59405038d16c560424eb72a1
7
+ data.tar.gz: b6a10b77669b5782e2ec2d8e4ab8a7ea6bcdd7a6af10abf8a271008f3db9f896e4dad07506d570d022a817a5ce9f908b8c05f9b17634809cffd9e1b872780683
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.15.2](https://github.com/fog/fog-proxmox/compare/v0.15.1...v0.15.2) (2025-08-06)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * release 0.15.2 ([#116](https://github.com/fog/fog-proxmox/issues/116)) ([d460740](https://github.com/fog/fog-proxmox/commit/d46074059cc48e0951109850904b8bc6a030da81))
9
+
10
+ ## [0.15.1](https://github.com/fog/fog-proxmox/compare/v0.15.0...v0.15.1) (2025-02-25)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Fixes EOF OpenSSL error in Proxmox connection ([#102](https://github.com/fog/fog-proxmox/issues/102)) ([ac8b0e1](https://github.com/fog/fog-proxmox/commit/ac8b0e11a39da6b19703b4f4507edf19486899ba))
16
+
3
17
  ## [0.15.0](https://github.com/fog/fog-proxmox/compare/v0.14.0...v0.15.0) (2022-12-01)
4
18
 
5
19
 
@@ -48,11 +48,11 @@ module Fog
48
48
  def auth_body(params = {})
49
49
  raise URIError, 'URI params is required' if params.nil? || params.empty?
50
50
 
51
- if params[:proxmox_username].nil? || params[:proxmox_username].empty?
51
+ if params[:proxmox_username].nil? || params[:proxmox_username].to_s.strip.empty?
52
52
  raise URIError,
53
53
  'proxmox_username is required'
54
54
  end
55
- if params[:proxmox_password].nil? || params[:proxmox_password].empty?
55
+ if params[:proxmox_password].nil? || params[:proxmox_password].to_s.strip.empty?
56
56
  raise URIError,
57
57
  'proxmox_password is required'
58
58
  end
@@ -26,6 +26,7 @@ module Fog
26
26
  module Proxmox
27
27
  class Compute
28
28
  # Server model
29
+ # rubocop:disable ClassLength
29
30
  class Server < Fog::Compute::Server
30
31
  identity :vmid
31
32
  attribute :type
@@ -72,6 +73,10 @@ module Fog
72
73
  super(new_attributes)
73
74
  end
74
75
 
76
+ def to_s
77
+ name
78
+ end
79
+
75
80
  def container?
76
81
  type == 'lxc'
77
82
  end
@@ -260,6 +265,7 @@ module Fog
260
265
  Fog::Proxmox::Compute::Node.new(service: service, node: node_id)
261
266
  end
262
267
  end
268
+ # rubocop:enable ClassLength
263
269
  end
264
270
  end
265
271
  end
@@ -51,7 +51,7 @@ module Fog
51
51
 
52
52
  def save
53
53
  path_params = { node: node_id, type: server_type, vmid: server_id }
54
- body_params = { snapname: name }
54
+ body_params = { snapname: name, vmstate: vmstate }
55
55
  server.tasks.wait_for(service.create_snapshot(path_params, body_params))
56
56
  end
57
57
 
@@ -54,7 +54,7 @@ module Fog
54
54
  end
55
55
 
56
56
  def succeeded?
57
- finished? && exitstatus == 'OK'
57
+ finished? && (exitstatus == 'OK' || exitstatus.include?('WARNING'))
58
58
  end
59
59
 
60
60
  def finished?
@@ -53,6 +53,7 @@ module Fog
53
53
  @connection_options = options[:connection_options] || {}
54
54
  @connection_options[:disable_proxy] = true if ENV['DISABLE_PROXY'] == 'true'
55
55
  @connection_options[:ssl_verify_peer] = false if ENV['SSL_VERIFY_PEER'] == 'false'
56
+ @connection_options[:ignore_unexpected_eof] = true
56
57
  @proxmox_must_reauthenticate = true
57
58
  @persistent = options[:persistent] || false
58
59
  @token ||= options[:proxmox_token]
@@ -118,10 +118,10 @@ module Fog
118
118
  end
119
119
 
120
120
  def self.to_human_bytes(size)
121
- units = %w[Kb Mb Gb Tb Pb]
121
+ units = %w[Kb Mb Gb]
122
122
  i = 0
123
123
  human_size = size.to_s + 'b'
124
- while i < 5 && size >= 1024
124
+ while i < 3 && size >= 1024
125
125
  size = modulo_bytes(size)
126
126
  human_size = size.to_s + units[i]
127
127
  i += 1
@@ -136,28 +136,28 @@ module Fog
136
136
 
137
137
  def self.extract_size(disk_value)
138
138
  size = extract_option('size', disk_value)
139
- size = to_int_gb(to_bytes(size)).to_s if size.match?(/\d+(G)/)
139
+ size = to_int_gb(to_bytes(size)).to_s if size&.match?(/\d+(G)/)
140
140
  size
141
141
  end
142
142
 
143
143
  def self.disk?(id)
144
- DISKS_REGEXP.match(id) ? true : false
144
+ DISKS_REGEXP.match(id) || false
145
145
  end
146
146
 
147
147
  def self.cdrom?(value)
148
- CDROM_REGEXP.match(value) ? true : false
148
+ CDROM_REGEXP.match(value) || false
149
149
  end
150
150
 
151
151
  def self.server_disk?(id)
152
- SERVER_DISK_REGEXP.match(id) ? true : false
152
+ SERVER_DISK_REGEXP.match(id) || false
153
153
  end
154
154
 
155
155
  def self.rootfs?(id)
156
- ROOTFS_REGEXP.match(id) ? true : false
156
+ ROOTFS_REGEXP.match(id) || false
157
157
  end
158
158
 
159
159
  def self.mount_point?(id)
160
- MOUNT_POINT_REGEXP.match(id) ? true : false
160
+ MOUNT_POINT_REGEXP.match(id) || false
161
161
  end
162
162
 
163
163
  def self.container_disk?(id)
@@ -165,11 +165,11 @@ module Fog
165
165
  end
166
166
 
167
167
  def self.template?(volid)
168
- TEMPLATE_REGEXP.match(volid) ? true : false
168
+ TEMPLATE_REGEXP.match(volid) || false
169
169
  end
170
170
 
171
171
  def self.cloud_init?(volid)
172
- CLOUD_INIT_REGEXP.match(volid) ? true : false
172
+ CLOUD_INIT_REGEXP.match(volid) || false
173
173
  end
174
174
 
175
175
  def self.of_type?(disk_h, vm_type)
@@ -98,12 +98,19 @@ module Fog
98
98
 
99
99
  # Convert nic attributes hash into API Proxmox parameters string
100
100
  def self.flatten(nic_hash)
101
- nic_id = nic_hash[nic_name(nic_hash).to_sym]
102
- nic_value = set_mac(nic_id, nic_hash)
103
- options = nic_hash.reject do |key, _value|
104
- [nic_name(nic_hash).to_sym, :id, :macaddr, :hwaddr].include? key.to_sym
101
+ if nic_hash[:hwaddr].nil?
102
+ nic_id = nic_hash[nic_name(nic_hash).to_sym]
103
+ nic_value = set_mac(nic_id, nic_hash)
104
+ options = nic_hash.reject do |key, _value|
105
+ [nic_name(nic_hash).to_sym, :id, :hwaddr, :macaddr].include? key.to_sym
106
+ end
107
+ nic_value += ',' + Fog::Proxmox::Hash.stringify(options) unless options.empty?
108
+ else
109
+ options = nic_hash.reject do |key, _value|
110
+ %i[id model macaddr].include? key.to_sym
111
+ end
112
+ nic_value = Fog::Proxmox::Hash.stringify(options) unless options.empty?
105
113
  end
106
- nic_value += ',' + Fog::Proxmox::Hash.stringify(options) unless options.empty?
107
114
  { "#{nic_hash[:id]}": nic_value }
108
115
  end
109
116
 
@@ -112,7 +119,7 @@ module Fog
112
119
  end
113
120
 
114
121
  def self.nic?(id)
115
- NICS_REGEXP.match(id) ? true : false
122
+ NICS_REGEXP.match(id) || false
116
123
  end
117
124
 
118
125
  def self.extract_ip(nic_value)
@@ -28,7 +28,7 @@ module Fog
28
28
  attribute :members
29
29
 
30
30
  def save(options = {})
31
- service.create_group((attributes.reject { |attribute| %i[users members].include? attribute }).merge(options))
31
+ service.create_group(attributes.reject { |attribute| %i[users members].include? attribute }.merge(options))
32
32
  reload
33
33
  end
34
34
 
@@ -42,7 +42,7 @@ module Fog
42
42
 
43
43
  def save(options = {})
44
44
  requires :tokenid, :userid
45
- token_hash = (attributes.reject { |attribute| %i[userid tokenid info].include? attribute }).merge(options)
45
+ token_hash = attributes.reject { |attribute| %i[userid tokenid info].include? attribute }.merge(options)
46
46
  service.create_token(userid, tokenid, token_hash)
47
47
  reload
48
48
  end
@@ -45,7 +45,7 @@ module Fog
45
45
  end
46
46
 
47
47
  def save(options = {})
48
- service.create_user((attributes.reject { |attribute| [:tokens].include? attribute }).merge(options))
48
+ service.create_user(attributes.reject { |attribute| [:tokens].include? attribute }.merge(options))
49
49
  reload
50
50
  end
51
51
 
@@ -22,8 +22,8 @@ module Fog
22
22
  # module String mixins
23
23
  module String
24
24
  def self.to_boolean(text)
25
- return true if text == true || text =~ (/(true|t|yes|y|1)$/i)
26
- return false if text == false || text.empty? || text =~ (/(false|f|no|n|0)$/i)
25
+ return true if text == true || text =~ /(true|t|yes|y|1)$/i
26
+ return false if text == false || text.empty? || text =~ /(false|f|no|n|0)$/i
27
27
 
28
28
  raise ArgumentError, "invalid value for Boolean: \"#{text}\""
29
29
  end
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Fog
21
21
  module Proxmox
22
- VERSION = '0.15.0'
22
+ VERSION = '0.15.2'
23
23
  end
24
24
  end
data/spec/compute_spec.rb CHANGED
@@ -277,15 +277,16 @@ describe Fog::Proxmox::Compute do
277
277
 
278
278
  it 'CRUD snapshots' do
279
279
  VCR.use_cassette('snapshots') do
280
- node_name = 'pve'
280
+ node_name = 'proxmox-noris'
281
281
  node = @service.nodes.get node_name
282
282
  vmid = node.servers.next_id
283
283
  server_hash = { vmid: vmid }
284
284
  node.servers.create server_hash
285
285
  # Create
286
286
  snapname = 'snapshot1'
287
+ vmstate = 0
287
288
  server = node.servers.get vmid
288
- snapshot_hash = { name: snapname }
289
+ snapshot_hash = { name: snapname, vmstate: vmstate }
289
290
  server.snapshots.create(snapshot_hash)
290
291
  # Find by id
291
292
  snapshot = server.snapshots.get snapname