fog-proxmox 0.14.0 → 0.15.1

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +28 -4
  4. data/lib/fog/proxmox/attributes.rb +3 -2
  5. data/lib/fog/proxmox/auth/token/access_ticket.rb +68 -57
  6. data/lib/fog/proxmox/auth/token/user_token.rb +79 -66
  7. data/lib/fog/proxmox/auth/token.rb +66 -60
  8. data/lib/fog/proxmox/compute/models/disk.rb +6 -1
  9. data/lib/fog/proxmox/compute/models/disks.rb +1 -1
  10. data/lib/fog/proxmox/compute/models/interface.rb +1 -1
  11. data/lib/fog/proxmox/compute/models/interfaces.rb +1 -1
  12. data/lib/fog/proxmox/compute/models/node.rb +3 -5
  13. data/lib/fog/proxmox/compute/models/nodes.rb +1 -1
  14. data/lib/fog/proxmox/compute/models/server.rb +33 -16
  15. data/lib/fog/proxmox/compute/models/server_config.rb +9 -4
  16. data/lib/fog/proxmox/compute/models/servers.rb +5 -5
  17. data/lib/fog/proxmox/compute/models/snapshot.rb +1 -1
  18. data/lib/fog/proxmox/compute/models/snapshots.rb +1 -1
  19. data/lib/fog/proxmox/compute/models/storage.rb +3 -2
  20. data/lib/fog/proxmox/compute/models/storages.rb +2 -2
  21. data/lib/fog/proxmox/compute/models/task.rb +1 -1
  22. data/lib/fog/proxmox/compute/models/tasks.rb +1 -0
  23. data/lib/fog/proxmox/compute/models/volume.rb +2 -1
  24. data/lib/fog/proxmox/compute/models/volumes.rb +2 -2
  25. data/lib/fog/proxmox/compute/requests/get_server_config.rb +14 -14
  26. data/lib/fog/proxmox/compute/requests/get_server_status.rb +17 -17
  27. data/lib/fog/proxmox/compute/requests/log_task.rb +1 -1
  28. data/lib/fog/proxmox/core.rb +28 -24
  29. data/lib/fog/proxmox/errors.rb +2 -1
  30. data/lib/fog/proxmox/hash.rb +0 -2
  31. data/lib/fog/proxmox/helpers/controller_helper.rb +3 -4
  32. data/lib/fog/proxmox/helpers/cpu_helper.rb +13 -6
  33. data/lib/fog/proxmox/helpers/disk_helper.rb +18 -12
  34. data/lib/fog/proxmox/helpers/ip_helper.rb +21 -20
  35. data/lib/fog/proxmox/helpers/nic_helper.rb +23 -14
  36. data/lib/fog/proxmox/identity/models/domain.rb +7 -3
  37. data/lib/fog/proxmox/identity/models/domain_type.rb +0 -1
  38. data/lib/fog/proxmox/identity/models/domains.rb +1 -2
  39. data/lib/fog/proxmox/identity/models/group.rb +4 -2
  40. data/lib/fog/proxmox/identity/models/groups.rb +1 -1
  41. data/lib/fog/proxmox/identity/models/permission.rb +5 -4
  42. data/lib/fog/proxmox/identity/models/permissions.rb +3 -1
  43. data/lib/fog/proxmox/identity/models/pool.rb +4 -4
  44. data/lib/fog/proxmox/identity/models/pools.rb +4 -4
  45. data/lib/fog/proxmox/identity/models/role.rb +1 -1
  46. data/lib/fog/proxmox/identity/models/roles.rb +1 -1
  47. data/lib/fog/proxmox/identity/models/token.rb +4 -3
  48. data/lib/fog/proxmox/identity/models/token_info.rb +2 -2
  49. data/lib/fog/proxmox/identity/models/tokens.rb +9 -13
  50. data/lib/fog/proxmox/identity/models/user.rb +1 -2
  51. data/lib/fog/proxmox/identity/models/users.rb +1 -1
  52. data/lib/fog/proxmox/identity/requests/get_user.rb +1 -0
  53. data/lib/fog/proxmox/identity/requests/list_user_permissions.rb +1 -1
  54. data/lib/fog/proxmox/network/models/networks.rb +1 -1
  55. data/lib/fog/proxmox/network/models/node.rb +1 -0
  56. data/lib/fog/proxmox/network/models/nodes.rb +1 -1
  57. data/lib/fog/proxmox/string.rb +4 -3
  58. data/lib/fog/proxmox/version.rb +1 -1
  59. data/lib/fog/proxmox.rb +1 -3
  60. data/spec/compute_spec.rb +3 -2
  61. data/spec/fixtures/proxmox/compute/snapshots.yml +350 -1055
  62. data/spec/hash_spec.rb +2 -1
  63. data/spec/helpers/controller_helper_spec.rb +135 -123
  64. data/spec/helpers/cpu_helper_spec.rb +58 -53
  65. data/spec/helpers/disk_helper_spec.rb +104 -54
  66. data/spec/helpers/ip_helper_spec.rb +155 -138
  67. data/spec/helpers/nic_helper_spec.rb +29 -20
  68. data/spec/identity_spec.rb +86 -74
  69. data/spec/proxmox_vcr.rb +3 -3
  70. metadata +89 -90
  71. data/.bundle/config +0 -4
  72. data/.codeclimate.yml +0 -14
  73. data/.github/CODE_OF_CONDUCT.md +0 -74
  74. data/.github/CONTRIBUTING.md +0 -20
  75. data/.github/CONTRIBUTORS.md +0 -9
  76. data/.github/FUNDING.yml +0 -12
  77. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -35
  78. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  79. data/.github/ISSUE_TEMPLATE.md +0 -43
  80. data/.github/SUPPORT.md +0 -9
  81. data/.github/fogproxmox.png +0 -0
  82. data/.github/workflows/ci.yml +0 -79
  83. data/.gitignore +0 -8
  84. data/.rubocop.yml +0 -13
  85. data/.ruby-gemset +0 -1
  86. data/.solargraph.yml +0 -10
  87. data/.vscode/launch.json +0 -96
  88. data/.vscode/settings.json +0 -45
  89. data/.vscode/tasks.json +0 -27
  90. data/Gemfile +0 -23
  91. data/Rakefile +0 -58
  92. data/bin/console +0 -29
  93. data/bin/setup +0 -29
  94. data/fog-proxmox.gemspec +0 -63
data/spec/hash_spec.rb CHANGED
@@ -30,7 +30,8 @@ describe Fog::Proxmox::Hash do
30
30
 
31
31
  describe '#flatten' do
32
32
  it 'returns string net_vm' do
33
- assert_equal 'net0: virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1', Fog::Proxmox::Hash.flatten(net_vm)
33
+ assert_equal 'net0: virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1',
34
+ Fog::Proxmox::Hash.flatten(net_vm)
34
35
  end
35
36
  end
36
37
 
@@ -20,126 +20,138 @@
20
20
  require 'spec_helper'
21
21
  require 'fog/proxmox/helpers/controller_helper'
22
22
 
23
- describe Fog::Proxmox::ControllerHelper do
24
-
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' }
27
- end
28
- let(:net_no_options) do
29
- { net0: 'virtio=66:89:C5:59:AA:96' }
30
- end
31
- let(:net_lxc) do
32
- { net0: 'virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1,ip=192.168.56.100/31,ip6=2001:0000:1234:0000:0000:C1C0:ABCD:0876/31' }
33
- end
34
- let(:scsi) do
35
- { scsi10: 'local-lvm:1,cache=none' }
36
- end
37
- let(:cdrom) do
38
- { ide2: 'none,media=cdrom' }
39
- end
40
- let(:mp) do
41
- { mp0: 'local-lvm:1,mp=/opt/path' }
42
- end
43
- let(:rootfs) do
44
- { rootfs: 'local-lvm:1' }
45
- end
46
-
47
- describe '#extract' do
48
- it "returns bridge" do
49
- bridge = Fog::Proxmox::ControllerHelper.extract('bridge',net[:net0])
50
- assert_equal 'vmbr0', bridge
51
- end
52
- it "returns nil" do
53
- bridge = Fog::Proxmox::ControllerHelper.extract('bridge',net_no_options[:net0])
54
- assert !bridge
55
- end
56
- it "returns firewall" do
57
- firewall = Fog::Proxmox::ControllerHelper.extract('firewall',net[:net0])
58
- assert_equal '1', firewall
59
- end
60
- it "returns cache" do
61
- cache = Fog::Proxmox::ControllerHelper.extract('cache',scsi[:scsi10])
62
- assert_equal 'none', cache
63
- end
64
- it "returns mp" do
65
- path = Fog::Proxmox::ControllerHelper.extract('mp',mp[:mp0])
66
- assert_equal '/opt/path', path
67
- end
68
- it "returns cidr ip" do
69
- path = Fog::Proxmox::ControllerHelper.extract('ip',net_lxc[:net0])
70
- assert_equal '192.168.56.100/31', path
71
- end
72
- it "returns cidr ip6" do
73
- path = Fog::Proxmox::ControllerHelper.extract('ip6',net_lxc[:net0])
74
- assert_equal '2001:0000:1234:0000:0000:C1C0:ABCD:0876/31', path
75
- end
76
- end
77
-
78
- describe '#extract_index' do
79
- it "net0 returns 0" do
80
- index = Fog::Proxmox::ControllerHelper.extract_index('net',:net0)
81
- assert index == 0
82
- end
83
- it "scsi10 returns 10" do
84
- index = Fog::Proxmox::ControllerHelper.extract_index('scsi',:scsi10)
85
- assert index == 10
86
- end
87
- end
88
-
89
- describe '#last_index' do
90
- it "returns -1" do
91
- last = Fog::Proxmox::ControllerHelper.last_index('net',{})
92
- assert last == -1
93
- end
94
- it "returns 0" do
95
- last = Fog::Proxmox::ControllerHelper.last_index('net',net)
96
- assert last == 0
97
- end
98
- it "returns 10" do
99
- last = Fog::Proxmox::ControllerHelper.last_index('scsi',scsi)
100
- assert last == 10
101
- end
102
- end
103
-
104
- describe '#valid?' do
105
- it "returns true" do
106
- assert Fog::Proxmox::ControllerHelper.valid?('net','net0')
107
- end
108
- it "returns false" do
109
- assert !Fog::Proxmox::ControllerHelper.valid?('net','sdfdsf')
110
- end
111
- end
112
-
113
- describe '#select' do
114
- it "returns scsi10" do
115
- controllers = Fog::Proxmox::ControllerHelper.select(scsi,'scsi')
116
- assert controllers.has_key?(:scsi10)
117
- assert controllers.has_value?(scsi[:scsi10])
118
- end
119
- it "returns empty" do
120
- controllers = Fog::Proxmox::ControllerHelper.select(net,'scsi')
121
- assert controllers.empty?
122
- end
123
- end
124
-
125
- describe '#collect_controllers' do
126
- it "returns scsi0 and ide2" do
127
- controllers = Fog::Proxmox::ControllerHelper.collect_controllers(scsi.merge(cdrom))
128
- assert controllers.has_key?(:scsi10)
129
- assert controllers.has_value?(scsi[:scsi10])
130
- assert controllers.has_key?(:ide2)
131
- assert controllers.has_value?(cdrom[:ide2])
132
- end
133
- it "returns rootfs and mp0" do
134
- controllers = Fog::Proxmox::ControllerHelper.collect_controllers(rootfs.merge(mp))
135
- assert controllers.has_key?(:mp0)
136
- assert controllers.has_value?(mp[:mp0])
137
- assert controllers.has_key?(:rootfs)
138
- assert controllers.has_value?(rootfs[:rootfs])
139
- end
140
- it "returns empty" do
141
- controllers = Fog::Proxmox::ControllerHelper.collect_controllers(net)
142
- assert controllers.empty?
143
- end
144
- end
145
- end
23
+ describe Fog::Proxmox::ControllerHelper do
24
+ let(:net) do
25
+ { net0: 'virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1' }
26
+ end
27
+ let(:net_no_options) do
28
+ { net0: 'virtio=66:89:C5:59:AA:96' }
29
+ end
30
+ let(:net_lxc) do
31
+ { net0: 'virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1,ip=192.168.56.100/31,ip6=2001:0000:1234:0000:0000:C1C0:ABCD:0876/31' }
32
+ end
33
+ let(:scsi) do
34
+ { scsi10: 'local-lvm:1,cache=none' }
35
+ end
36
+ let(:cdrom) do
37
+ { ide2: 'none,media=cdrom' }
38
+ end
39
+ let(:mp) do
40
+ { mp0: 'local-lvm:1,mp=/opt/path' }
41
+ end
42
+ let(:rootfs) do
43
+ { rootfs: 'local-lvm:1' }
44
+ end
45
+
46
+ describe '#extract' do
47
+ it 'returns bridge' do
48
+ bridge = Fog::Proxmox::ControllerHelper.extract('bridge', net[:net0])
49
+ assert_equal 'vmbr0', bridge
50
+ end
51
+
52
+ it 'returns nil' do
53
+ bridge = Fog::Proxmox::ControllerHelper.extract('bridge', net_no_options[:net0])
54
+ assert !bridge
55
+ end
56
+
57
+ it 'returns firewall' do
58
+ firewall = Fog::Proxmox::ControllerHelper.extract('firewall', net[:net0])
59
+ assert_equal '1', firewall
60
+ end
61
+
62
+ it 'returns cache' do
63
+ cache = Fog::Proxmox::ControllerHelper.extract('cache', scsi[:scsi10])
64
+ assert_equal 'none', cache
65
+ end
66
+
67
+ it 'returns mp' do
68
+ path = Fog::Proxmox::ControllerHelper.extract('mp', mp[:mp0])
69
+ assert_equal '/opt/path', path
70
+ end
71
+
72
+ it 'returns cidr ip' do
73
+ path = Fog::Proxmox::ControllerHelper.extract('ip', net_lxc[:net0])
74
+ assert_equal '192.168.56.100/31', path
75
+ end
76
+
77
+ it 'returns cidr ip6' do
78
+ path = Fog::Proxmox::ControllerHelper.extract('ip6', net_lxc[:net0])
79
+ assert_equal '2001:0000:1234:0000:0000:C1C0:ABCD:0876/31', path
80
+ end
81
+ end
82
+
83
+ describe '#extract_index' do
84
+ it 'net0 returns 0' do
85
+ index = Fog::Proxmox::ControllerHelper.extract_index('net', :net0)
86
+ assert index == 0
87
+ end
88
+
89
+ it 'scsi10 returns 10' do
90
+ index = Fog::Proxmox::ControllerHelper.extract_index('scsi', :scsi10)
91
+ assert index == 10
92
+ end
93
+ end
94
+
95
+ describe '#last_index' do
96
+ it 'returns -1' do
97
+ last = Fog::Proxmox::ControllerHelper.last_index('net', {})
98
+ assert last == -1
99
+ end
100
+
101
+ it 'returns 0' do
102
+ last = Fog::Proxmox::ControllerHelper.last_index('net', net)
103
+ assert last == 0
104
+ end
105
+
106
+ it 'returns 10' do
107
+ last = Fog::Proxmox::ControllerHelper.last_index('scsi', scsi)
108
+ assert last == 10
109
+ end
110
+ end
111
+
112
+ describe '#valid?' do
113
+ it 'returns true' do
114
+ assert Fog::Proxmox::ControllerHelper.valid?('net', 'net0')
115
+ end
116
+
117
+ it 'returns false' do
118
+ assert !Fog::Proxmox::ControllerHelper.valid?('net', 'sdfdsf')
119
+ end
120
+ end
121
+
122
+ describe '#select' do
123
+ it 'returns scsi10' do
124
+ controllers = Fog::Proxmox::ControllerHelper.select(scsi, 'scsi')
125
+ assert controllers.has_key?(:scsi10)
126
+ assert controllers.has_value?(scsi[:scsi10])
127
+ end
128
+
129
+ it 'returns empty' do
130
+ controllers = Fog::Proxmox::ControllerHelper.select(net, 'scsi')
131
+ assert controllers.empty?
132
+ end
133
+ end
134
+
135
+ describe '#collect_controllers' do
136
+ it 'returns scsi0 and ide2' do
137
+ controllers = Fog::Proxmox::ControllerHelper.collect_controllers(scsi.merge(cdrom))
138
+ assert controllers.has_key?(:scsi10)
139
+ assert controllers.has_value?(scsi[:scsi10])
140
+ assert controllers.has_key?(:ide2)
141
+ assert controllers.has_value?(cdrom[:ide2])
142
+ end
143
+
144
+ it 'returns rootfs and mp0' do
145
+ controllers = Fog::Proxmox::ControllerHelper.collect_controllers(rootfs.merge(mp))
146
+ assert controllers.has_key?(:mp0)
147
+ assert controllers.has_value?(mp[:mp0])
148
+ assert controllers.has_key?(:rootfs)
149
+ assert controllers.has_value?(rootfs[:rootfs])
150
+ end
151
+
152
+ it 'returns empty' do
153
+ controllers = Fog::Proxmox::ControllerHelper.collect_controllers(net)
154
+ assert controllers.empty?
155
+ end
156
+ end
157
+ end
@@ -20,58 +20,63 @@
20
20
  require 'spec_helper'
21
21
  require 'fog/proxmox/helpers/cpu_helper'
22
22
 
23
- describe Fog::Proxmox::CpuHelper do
24
-
25
- let(:cpu) do
26
- 'cputype=Skylake-Client,flags=+spec-ctrl;+pcid;+ssbd;-aes'
27
- end
28
- let(:cpu_nocputype) do
29
- 'kvm64,flags=+spec-ctrl;+pcid;+ssbd'
30
- end
31
- let(:cpu_nospectre) do
32
- 'cputype=kvm64,flags=+pcid'
33
- end
34
- let(:cpu_nopcid) do
35
- 'cputype=kvm64,flags=+spec-ctrl'
36
- end
37
- let(:cpu_nossbd) do
38
- 'cputype=kvm64,flags=+pcid'
39
- end
23
+ describe Fog::Proxmox::CpuHelper do
24
+ let(:cpu) do
25
+ 'cputype=Skylake-Client,flags=+spec-ctrl;+pcid;+ssbd;-aes'
26
+ end
27
+ let(:cpu_nocputype) do
28
+ 'kvm64,flags=+spec-ctrl;+pcid;+ssbd'
29
+ end
30
+ let(:cpu_nospectre) do
31
+ 'cputype=kvm64,flags=+pcid'
32
+ end
33
+ let(:cpu_nopcid) do
34
+ 'cputype=kvm64,flags=+spec-ctrl'
35
+ end
36
+ let(:cpu_nossbd) do
37
+ 'cputype=kvm64,flags=+pcid'
38
+ end
40
39
 
41
- describe '#extract_cputype' do
42
- it "returns string" do
43
- result = Fog::Proxmox::CpuHelper.extract_cputype(cpu)
44
- assert_equal('Skylake-Client', result)
45
- end
46
- it "returns string" do
47
- result = Fog::Proxmox::CpuHelper.extract_cputype(cpu_nocputype)
48
- assert_equal('kvm64', result)
49
- end
50
- end
40
+ describe '#extract_cputype' do
41
+ it 'returns string' do
42
+ result = Fog::Proxmox::CpuHelper.extract_cputype(cpu)
43
+ assert_equal('Skylake-Client', result)
44
+ end
51
45
 
52
- describe '#flag_value' do
53
- it "returns +1" do
54
- result = Fog::Proxmox::CpuHelper.flag_value(cpu, 'spec-ctrl')
55
- assert_equal('+1', result)
56
- end
57
- it "returns -1" do
58
- result = Fog::Proxmox::CpuHelper.flag_value(cpu, 'aes')
59
- assert_equal('-1', result)
60
- end
61
- it "returns 0" do
62
- result = Fog::Proxmox::CpuHelper.flag_value(cpu, 'amd-ssbd')
63
- assert_equal('0', result)
64
- end
65
- end
66
-
67
- describe '#flatten ' do
68
- it "returns cputype=kvm64,flags=+pcid;+ibpb;-hv-tlbflush" do
69
- result = Fog::Proxmox::CpuHelper.flatten("cpu_type"=>"kvm64", "spectre"=>"0", "pcid"=>"+1", "ssbd"=>"0", "ibpb"=>"+1", "virt_ssbd"=>"0", "amd_ssbd"=>"0", "amd_no_ssb"=>"0", "md_clear"=>"0", "pdpe1gb"=>"0", "hv_tlbflush"=>"-1", "aes"=>"0", "hv_evmcs"=>"0")
70
- assert_equal('cputype=kvm64,flags=+pcid;+ibpb;-hv-tlbflush', result)
71
- end
72
- it "returns cputype=Skylake-Client,flags=+spec-ctrl;+pcid;+amd-no-ssbd'" do
73
- result = Fog::Proxmox::CpuHelper.flatten('cpu_type' => 'Skylake-Client', 'pcid' => '+1', 'spectre' => '+1', 'amd_no_ssb' => '-1')
74
- assert_equal('cputype=Skylake-Client,flags=+spec-ctrl;+pcid;-amd-no-ssb', result)
75
- end
76
- end
77
- end
46
+ it 'returns string' do
47
+ result = Fog::Proxmox::CpuHelper.extract_cputype(cpu_nocputype)
48
+ assert_equal('kvm64', result)
49
+ end
50
+ end
51
+
52
+ describe '#flag_value' do
53
+ it 'returns +1' do
54
+ result = Fog::Proxmox::CpuHelper.flag_value(cpu, 'spec-ctrl')
55
+ assert_equal('+1', result)
56
+ end
57
+
58
+ it 'returns -1' do
59
+ result = Fog::Proxmox::CpuHelper.flag_value(cpu, 'aes')
60
+ assert_equal('-1', result)
61
+ end
62
+
63
+ it 'returns 0' do
64
+ result = Fog::Proxmox::CpuHelper.flag_value(cpu, 'amd-ssbd')
65
+ assert_equal('0', result)
66
+ end
67
+ end
68
+
69
+ describe '#flatten ' do
70
+ it 'returns cputype=kvm64,flags=+pcid;+ibpb;-hv-tlbflush' do
71
+ result = Fog::Proxmox::CpuHelper.flatten('cpu_type' => 'kvm64', 'spectre' => '0', 'pcid' => '+1',
72
+ 'ssbd' => '0', 'ibpb' => '+1', 'virt_ssbd' => '0', 'amd_ssbd' => '0', 'amd_no_ssb' => '0', 'md_clear' => '0', 'pdpe1gb' => '0', 'hv_tlbflush' => '-1', 'aes' => '0', 'hv_evmcs' => '0')
73
+ assert_equal('cputype=kvm64,flags=+pcid;+ibpb;-hv-tlbflush', result)
74
+ end
75
+
76
+ it "returns cputype=Skylake-Client,flags=+spec-ctrl;+pcid;+amd-no-ssbd'" do
77
+ result = Fog::Proxmox::CpuHelper.flatten('cpu_type' => 'Skylake-Client', 'pcid' => '+1',
78
+ 'spectre' => '+1', 'amd_no_ssb' => '-1')
79
+ assert_equal('cputype=Skylake-Client,flags=+spec-ctrl;+pcid;-amd-no-ssb', result)
80
+ end
81
+ end
82
+ end