fog-proxmox 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +13 -9
  3. data/docs/compute.md +17 -17
  4. data/docs/identity.md +6 -6
  5. data/examples/compute.rb +1 -1
  6. data/examples/identity.rb +1 -1
  7. data/fog-proxmox.gemspec +4 -4
  8. data/lib/fog/compute/proxmox.rb +2 -2
  9. data/lib/fog/compute/proxmox/models/disk.rb +2 -2
  10. data/lib/fog/compute/proxmox/models/disks.rb +3 -3
  11. data/lib/fog/compute/proxmox/models/interface.rb +2 -2
  12. data/lib/fog/compute/proxmox/models/interfaces.rb +4 -4
  13. data/lib/fog/compute/proxmox/models/node.rb +6 -6
  14. data/lib/fog/compute/proxmox/models/nodes.rb +3 -3
  15. data/lib/fog/compute/proxmox/models/server.rb +6 -6
  16. data/lib/fog/compute/proxmox/models/server_config.rb +8 -8
  17. data/lib/fog/compute/proxmox/models/servers.rb +3 -3
  18. data/lib/fog/compute/proxmox/models/snapshot.rb +3 -3
  19. data/lib/fog/compute/proxmox/models/snapshots.rb +3 -3
  20. data/lib/fog/compute/proxmox/models/storage.rb +3 -3
  21. data/lib/fog/compute/proxmox/models/storages.rb +3 -3
  22. data/lib/fog/compute/proxmox/models/task.rb +2 -2
  23. data/lib/fog/compute/proxmox/models/tasks.rb +3 -3
  24. data/lib/fog/compute/proxmox/models/volume.rb +2 -2
  25. data/lib/fog/compute/proxmox/models/volumes.rb +3 -3
  26. data/lib/fog/compute/proxmox/requests/action_server.rb +2 -2
  27. data/lib/fog/compute/proxmox/requests/clone_server.rb +2 -2
  28. data/lib/fog/compute/proxmox/requests/create_backup.rb +2 -2
  29. data/lib/fog/compute/proxmox/requests/create_server.rb +2 -2
  30. data/lib/fog/compute/proxmox/requests/create_snapshot.rb +2 -2
  31. data/lib/fog/compute/proxmox/requests/create_spice.rb +2 -2
  32. data/lib/fog/compute/proxmox/requests/create_term.rb +2 -2
  33. data/lib/fog/compute/proxmox/requests/create_vnc.rb +2 -2
  34. data/lib/fog/compute/proxmox/requests/delete_server.rb +2 -2
  35. data/lib/fog/compute/proxmox/requests/delete_snapshot.rb +2 -2
  36. data/lib/fog/compute/proxmox/requests/delete_volume.rb +2 -2
  37. data/lib/fog/compute/proxmox/requests/get_node_statistics.rb +2 -2
  38. data/lib/fog/compute/proxmox/requests/get_server_config.rb +2 -2
  39. data/lib/fog/compute/proxmox/requests/get_server_status.rb +2 -2
  40. data/lib/fog/compute/proxmox/requests/get_snapshot_config.rb +2 -2
  41. data/lib/fog/compute/proxmox/requests/get_task.rb +2 -2
  42. data/lib/fog/compute/proxmox/requests/get_vnc.rb +2 -2
  43. data/lib/fog/compute/proxmox/requests/get_volume.rb +2 -2
  44. data/lib/fog/compute/proxmox/requests/list_nodes.rb +2 -2
  45. data/lib/fog/compute/proxmox/requests/list_servers.rb +2 -2
  46. data/lib/fog/compute/proxmox/requests/list_snapshots.rb +2 -2
  47. data/lib/fog/compute/proxmox/requests/list_storages.rb +2 -2
  48. data/lib/fog/compute/proxmox/requests/list_tasks.rb +2 -2
  49. data/lib/fog/compute/proxmox/requests/list_volumes.rb +2 -2
  50. data/lib/fog/compute/proxmox/requests/log_task.rb +2 -2
  51. data/lib/fog/compute/proxmox/requests/migrate_server.rb +2 -2
  52. data/lib/fog/compute/proxmox/requests/move_disk.rb +2 -2
  53. data/lib/fog/compute/proxmox/requests/move_volume.rb +2 -2
  54. data/lib/fog/compute/proxmox/requests/next_vmid.rb +2 -2
  55. data/lib/fog/compute/proxmox/requests/resize_container.rb +2 -2
  56. data/lib/fog/compute/proxmox/requests/resize_server.rb +2 -2
  57. data/lib/fog/compute/proxmox/requests/rollback_snapshot.rb +2 -2
  58. data/lib/fog/compute/proxmox/requests/status_task.rb +2 -2
  59. data/lib/fog/compute/proxmox/requests/stop_task.rb +2 -2
  60. data/lib/fog/compute/proxmox/requests/template_server.rb +2 -2
  61. data/lib/fog/compute/proxmox/requests/update_server.rb +2 -2
  62. data/lib/fog/compute/proxmox/requests/update_snapshot.rb +2 -2
  63. data/lib/fog/identity/proxmox.rb +2 -2
  64. data/lib/fog/identity/proxmox/models/domain.rb +3 -3
  65. data/lib/fog/identity/proxmox/models/domain_type.rb +2 -2
  66. data/lib/fog/identity/proxmox/models/domains.rb +3 -3
  67. data/lib/fog/identity/proxmox/models/group.rb +2 -2
  68. data/lib/fog/identity/proxmox/models/groups.rb +3 -3
  69. data/lib/fog/identity/proxmox/models/permission.rb +2 -2
  70. data/lib/fog/identity/proxmox/models/permissions.rb +3 -3
  71. data/lib/fog/identity/proxmox/models/pool.rb +2 -2
  72. data/lib/fog/identity/proxmox/models/pools.rb +3 -3
  73. data/lib/fog/identity/proxmox/models/principal.rb +2 -2
  74. data/lib/fog/identity/proxmox/models/role.rb +2 -2
  75. data/lib/fog/identity/proxmox/models/roles.rb +3 -3
  76. data/lib/fog/identity/proxmox/models/user.rb +2 -2
  77. data/lib/fog/identity/proxmox/models/users.rb +3 -3
  78. data/lib/fog/identity/proxmox/requests/change_password.rb +2 -2
  79. data/lib/fog/identity/proxmox/requests/check_permissions.rb +2 -2
  80. data/lib/fog/identity/proxmox/requests/create_domain.rb +2 -2
  81. data/lib/fog/identity/proxmox/requests/create_group.rb +2 -2
  82. data/lib/fog/identity/proxmox/requests/create_pool.rb +2 -2
  83. data/lib/fog/identity/proxmox/requests/create_role.rb +2 -2
  84. data/lib/fog/identity/proxmox/requests/create_user.rb +2 -2
  85. data/lib/fog/identity/proxmox/requests/delete_domain.rb +2 -2
  86. data/lib/fog/identity/proxmox/requests/delete_group.rb +2 -2
  87. data/lib/fog/identity/proxmox/requests/delete_pool.rb +2 -2
  88. data/lib/fog/identity/proxmox/requests/delete_role.rb +2 -2
  89. data/lib/fog/identity/proxmox/requests/delete_user.rb +2 -2
  90. data/lib/fog/identity/proxmox/requests/get_domain.rb +2 -2
  91. data/lib/fog/identity/proxmox/requests/get_group.rb +2 -2
  92. data/lib/fog/identity/proxmox/requests/get_pool.rb +2 -2
  93. data/lib/fog/identity/proxmox/requests/get_role.rb +2 -2
  94. data/lib/fog/identity/proxmox/requests/get_user.rb +2 -2
  95. data/lib/fog/identity/proxmox/requests/list_domains.rb +2 -2
  96. data/lib/fog/identity/proxmox/requests/list_groups.rb +2 -2
  97. data/lib/fog/identity/proxmox/requests/list_permissions.rb +2 -2
  98. data/lib/fog/identity/proxmox/requests/list_pools.rb +2 -2
  99. data/lib/fog/identity/proxmox/requests/list_roles.rb +2 -2
  100. data/lib/fog/identity/proxmox/requests/list_users.rb +2 -2
  101. data/lib/fog/identity/proxmox/requests/read_version.rb +2 -2
  102. data/lib/fog/identity/proxmox/requests/update_domain.rb +2 -2
  103. data/lib/fog/identity/proxmox/requests/update_group.rb +2 -2
  104. data/lib/fog/identity/proxmox/requests/update_permissions.rb +2 -2
  105. data/lib/fog/identity/proxmox/requests/update_pool.rb +2 -2
  106. data/lib/fog/identity/proxmox/requests/update_role.rb +2 -2
  107. data/lib/fog/identity/proxmox/requests/update_user.rb +2 -2
  108. data/lib/fog/network/proxmox.rb +2 -2
  109. data/lib/fog/network/proxmox/models/network.rb +2 -2
  110. data/lib/fog/network/proxmox/models/networks.rb +3 -3
  111. data/lib/fog/network/proxmox/models/node.rb +3 -3
  112. data/lib/fog/network/proxmox/models/nodes.rb +3 -3
  113. data/lib/fog/network/proxmox/requests/create_network.rb +2 -2
  114. data/lib/fog/network/proxmox/requests/delete_network.rb +2 -2
  115. data/lib/fog/network/proxmox/requests/get_network.rb +2 -2
  116. data/lib/fog/network/proxmox/requests/get_node.rb +2 -2
  117. data/lib/fog/network/proxmox/requests/list_networks.rb +2 -2
  118. data/lib/fog/network/proxmox/requests/list_nodes.rb +2 -2
  119. data/lib/fog/network/proxmox/requests/power_node.rb +2 -2
  120. data/lib/fog/network/proxmox/requests/update_network.rb +2 -2
  121. data/lib/fog/proxmox.rb +4 -17
  122. data/lib/fog/proxmox/core.rb +1 -1
  123. data/lib/fog/proxmox/helpers/controller_helper.rb +5 -6
  124. data/lib/fog/proxmox/version.rb +1 -1
  125. data/lib/fog/storage/proxmox.rb +2 -2
  126. data/spec/compute_spec.rb +2 -2
  127. data/spec/helpers/controller_helper_spec.rb +17 -2
  128. data/spec/identity_spec.rb +3 -3
  129. data/spec/network_spec.rb +2 -2
  130. data/spec/spec_helper.rb +1 -0
  131. metadata +10 -10
@@ -19,8 +19,8 @@
19
19
  # frozen_string_literal: true
20
20
 
21
21
  module Fog
22
- module Network
23
- class Proxmox
22
+ module Proxmox
23
+ class Network
24
24
  # class Real list_networks request
25
25
  class Real
26
26
  def list_networks(path_params, query_params)
@@ -19,8 +19,8 @@
19
19
  # frozen_string_literal: true
20
20
 
21
21
  module Fog
22
- module Network
23
- class Proxmox
22
+ module Proxmox
23
+ class Network
24
24
  # class Real list_nodes request
25
25
  class Real
26
26
  def list_nodes
@@ -19,8 +19,8 @@
19
19
  # frozen_string_literal: true
20
20
 
21
21
  module Fog
22
- module Network
23
- class Proxmox
22
+ module Proxmox
23
+ class Network
24
24
  # class Real power_node request
25
25
  class Real
26
26
  def power_node(path_params, body_params)
@@ -18,8 +18,8 @@
18
18
  # along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module Fog
21
- module Network
22
- class Proxmox
21
+ module Proxmox
22
+ class Network
23
23
  # class Real update_network request
24
24
  class Real
25
25
  def update_network(path_params, body_params)
data/lib/fog/proxmox.rb CHANGED
@@ -25,26 +25,13 @@ require 'fog/core'
25
25
  require 'fog/json'
26
26
 
27
27
  module Fog
28
- # Identity module
29
- module Identity
30
- autoload :Proxmox, File.expand_path('identity/proxmox', __dir__)
31
- end
32
- # Compute module
33
- module Compute
34
- autoload :Proxmox, File.expand_path('compute/proxmox', __dir__)
35
- end
36
- # Storage module
37
- module Storage
38
- autoload :Proxmox, File.expand_path('storage/proxmox', __dir__)
39
- end
40
- # Network module
41
- module Network
42
- autoload :Proxmox, File.expand_path('network/proxmox', __dir__)
43
- end
44
-
45
28
  # Proxmox module
46
29
  module Proxmox
47
30
  extend Fog::Provider
31
+ autoload :Identity, File.expand_path('identity/proxmox', __dir__)
32
+ autoload :Compute, File.expand_path('compute/proxmox', __dir__)
33
+ autoload :Storage, File.expand_path('storage/proxmox', __dir__)
34
+ autoload :Network, File.expand_path('network/proxmox', __dir__)
48
35
  service(:identity, 'Identity')
49
36
  service(:compute, 'Compute')
50
37
  service(:storage, 'Storage')
@@ -33,7 +33,7 @@ module Fog
33
33
 
34
34
  # fallback
35
35
  def self.not_found_class
36
- Fog::Compute::Proxmox::NotFound
36
+ Fog::Proxmox::Compute::NotFound
37
37
  end
38
38
 
39
39
  def initialize_identity(options)
@@ -23,16 +23,15 @@ module Fog
23
23
  module ControllerHelper
24
24
 
25
25
  CONTROLLERS = %w[ide sata scsi virtio mp rootfs].freeze
26
-
27
26
  def self.extract(name, controller_value)
28
- values = controller_value.scan(/#{name}=(\w+)/)
29
- name_value = values.first if values
30
- name_value&.first
27
+ matches = controller_value.match(/[,]{0,1}#{name}[=]{1}(?<name_value>[\w\/]+)/)
28
+ matches ? matches[:name_value] : matches
31
29
  end
32
30
 
33
31
  def self.extract_index(name, key)
34
- idx_a = key.to_s.scan(/#{name}(\d+)/).first
35
- idx_a.first.to_i if idx_a
32
+ matches = key.to_s.match(/#{name}(?<index>\d+)/)
33
+ index = matches ? matches[:index] : matches
34
+ index ? index.to_i : -1
36
35
  end
37
36
 
38
37
  def self.valid?(name, key)
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Fog
21
21
  module Proxmox
22
- VERSION = '0.6.0'
22
+ VERSION = '0.7.0'
23
23
  end
24
24
  end
@@ -19,9 +19,9 @@
19
19
  # frozen_string_literal: true
20
20
 
21
21
  module Fog
22
- module Storage
22
+ module Proxmox
23
23
  # Procmox storage service
24
- class Proxmox < Fog::Service
24
+ class Storage < Fog::Service
25
25
  # Models
26
26
  model_path 'fog/storage/proxmox'
27
27
  end
data/spec/compute_spec.rb CHANGED
@@ -20,11 +20,11 @@
20
20
  require 'spec_helper'
21
21
  require_relative './proxmox_vcr'
22
22
 
23
- describe Fog::Compute::Proxmox do
23
+ describe Fog::Proxmox::Compute do
24
24
  before :all do
25
25
  @proxmox_vcr = ProxmoxVCR.new(
26
26
  vcr_directory: 'spec/fixtures/proxmox/compute',
27
- service_class: Fog::Compute::Proxmox
27
+ service_class: Fog::Proxmox::Compute
28
28
  )
29
29
  @service = @proxmox_vcr.service
30
30
  @pve_url = @proxmox_vcr.url
@@ -23,7 +23,7 @@ require 'fog/proxmox/helpers/controller_helper'
23
23
  describe Fog::Proxmox::ControllerHelper do
24
24
 
25
25
  let(:net) do
26
- { net0: 'virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1' }
26
+ { net0: 'virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1,mp=/opt/path' }
27
27
  end
28
28
  let(:net_no_options) do
29
29
  { net0: 'virtio=66:89:C5:59:AA:96' }
@@ -35,7 +35,7 @@ require 'fog/proxmox/helpers/controller_helper'
35
35
  { ide2: 'none,media=cdrom' }
36
36
  end
37
37
  let(:mp) do
38
- { mp0: 'local-lvm:1' }
38
+ { mp0: 'local-lvm:1,mp=/opt/path' }
39
39
  end
40
40
  let(:rootfs) do
41
41
  { rootfs: 'local-lvm:1' }
@@ -58,6 +58,21 @@ require 'fog/proxmox/helpers/controller_helper'
58
58
  cache = Fog::Proxmox::ControllerHelper.extract('cache',scsi[:scsi10])
59
59
  assert_equal 'none', cache
60
60
  end
61
+ it "returns mp" do
62
+ path = Fog::Proxmox::ControllerHelper.extract('mp',mp[:mp0])
63
+ assert_equal '/opt/path', path
64
+ end
65
+ end
66
+
67
+ describe '#extract_index' do
68
+ it "net0 returns 0" do
69
+ index = Fog::Proxmox::ControllerHelper.extract_index('net',:net0)
70
+ assert index == 0
71
+ end
72
+ it "scsi10 returns 10" do
73
+ index = Fog::Proxmox::ControllerHelper.extract_index('scsi',:scsi10)
74
+ assert index == 10
75
+ end
61
76
  end
62
77
 
63
78
  describe '#last_index' do
@@ -20,11 +20,11 @@
20
20
  require 'spec_helper'
21
21
  require_relative './proxmox_vcr'
22
22
 
23
- describe Fog::Identity::Proxmox do
23
+ describe Fog::Proxmox::Identity do
24
24
  before :all do
25
25
  @proxmox_vcr = ProxmoxVCR.new(
26
26
  vcr_directory: 'spec/fixtures/proxmox/identity',
27
- service_class: Fog::Identity::Proxmox
27
+ service_class: Fog::Proxmox::Identity
28
28
  )
29
29
  @service = @proxmox_vcr.service
30
30
  @pve_url = @proxmox_vcr.url
@@ -36,7 +36,7 @@ describe Fog::Identity::Proxmox do
36
36
 
37
37
  it 'authenticates with username and password' do
38
38
  VCR.use_cassette('auth') do
39
- identity = Fog::Identity::Proxmox.new(
39
+ identity = Fog::Proxmox::Identity.new(
40
40
  pve_username: @username,
41
41
  pve_password: @password,
42
42
  pve_url: @pve_url.to_s
data/spec/network_spec.rb CHANGED
@@ -20,11 +20,11 @@
20
20
  require 'spec_helper'
21
21
  require_relative './proxmox_vcr'
22
22
 
23
- describe Fog::Network::Proxmox do
23
+ describe Fog::Proxmox::Network do
24
24
  before :all do
25
25
  @proxmox_vcr = ProxmoxVCR.new(
26
26
  vcr_directory: 'spec/fixtures/proxmox/network',
27
- service_class: Fog::Network::Proxmox
27
+ service_class: Fog::Proxmox::Network
28
28
  )
29
29
  @service = @proxmox_vcr.service
30
30
  @pve_url = @proxmox_vcr.url
data/spec/spec_helper.rb CHANGED
@@ -25,6 +25,7 @@ SimpleCov.start do
25
25
  add_group 'Core', 'lib/fog/proxmox'
26
26
  add_group 'Identity', 'lib/fog/identity'
27
27
  add_group 'Compute', 'lib/fog/compute'
28
+ add_group 'Network', 'lib/fog/network'
28
29
  end
29
30
 
30
31
  require 'minitest/autorun'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-proxmox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Robert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2019-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -212,56 +212,56 @@ dependencies:
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '3.0'
215
+ version: '4.0'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '3.0'
222
+ version: '4.0'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: webmock
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '3.4'
229
+ version: '3.5'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '3.4'
236
+ version: '3.5'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: fog-core
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
241
  - - "~>"
242
242
  - !ruby/object:Gem::Version
243
- version: '1.45'
243
+ version: '2.1'
244
244
  type: :runtime
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
- version: '1.45'
250
+ version: '2.1'
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: fog-json
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
255
  - - "~>"
256
256
  - !ruby/object:Gem::Version
257
- version: '1.0'
257
+ version: '1.2'
258
258
  type: :runtime
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
- version: '1.0'
264
+ version: '1.2'
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: ipaddress
267
267
  requirement: !ruby/object:Gem::Requirement