fog-proxmox 0.13.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +34 -49
  3. data/.github/workflows/release.yml +38 -0
  4. data/.rubocop.yml +11 -10
  5. data/.rubocop_todo.yml +255 -0
  6. data/CHANGELOG.md +8 -0
  7. data/README.md +35 -4
  8. data/Rakefile +8 -35
  9. data/bin/console +2 -4
  10. data/bin/setup +2 -4
  11. data/docs/compute.md +23 -7
  12. data/docs/identity.md +31 -6
  13. data/examples/compute.rb +11 -11
  14. data/examples/identity.rb +28 -15
  15. data/fog-proxmox.gemspec +8 -6
  16. data/lib/fog/proxmox/attributes.rb +3 -2
  17. data/lib/fog/proxmox/auth/token/access_ticket.rb +96 -0
  18. data/lib/fog/proxmox/auth/token/user_token.rb +107 -0
  19. data/lib/fog/proxmox/auth/token.rb +94 -0
  20. data/lib/fog/{compute/proxmox → proxmox/compute}/models/disk.rb +21 -3
  21. data/lib/fog/{compute/proxmox → proxmox/compute}/models/disks.rb +6 -2
  22. data/lib/fog/{compute/proxmox → proxmox/compute}/models/interface.rb +5 -1
  23. data/lib/fog/{compute/proxmox → proxmox/compute}/models/interfaces.rb +2 -2
  24. data/lib/fog/{compute/proxmox → proxmox/compute}/models/node.rb +3 -5
  25. data/lib/fog/{compute/proxmox → proxmox/compute}/models/nodes.rb +2 -2
  26. data/lib/fog/{compute/proxmox → proxmox/compute}/models/server.rb +29 -18
  27. data/lib/fog/{compute/proxmox → proxmox/compute}/models/server_config.rb +17 -4
  28. data/lib/fog/{compute/proxmox → proxmox/compute}/models/servers.rb +6 -6
  29. data/lib/fog/{compute/proxmox → proxmox/compute}/models/snapshot.rb +0 -0
  30. data/lib/fog/{compute/proxmox → proxmox/compute}/models/snapshots.rb +2 -2
  31. data/lib/fog/{compute/proxmox → proxmox/compute}/models/storage.rb +3 -2
  32. data/lib/fog/{compute/proxmox → proxmox/compute}/models/storages.rb +3 -3
  33. data/lib/fog/{compute/proxmox → proxmox/compute}/models/task.rb +0 -0
  34. data/lib/fog/{compute/proxmox → proxmox/compute}/models/tasks.rb +2 -1
  35. data/lib/fog/{compute/proxmox → proxmox/compute}/models/volume.rb +8 -1
  36. data/lib/fog/{compute/proxmox → proxmox/compute}/models/volumes.rb +3 -3
  37. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/action_server.rb +0 -0
  38. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/clone_server.rb +0 -0
  39. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_backup.rb +0 -0
  40. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_server.rb +0 -0
  41. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_snapshot.rb +0 -0
  42. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_spice.rb +0 -0
  43. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_term.rb +0 -0
  44. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_vnc.rb +0 -0
  45. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/delete_server.rb +0 -0
  46. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/delete_snapshot.rb +0 -0
  47. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/delete_volume.rb +0 -0
  48. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_node_statistics.rb +0 -0
  49. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_server_config.rb +14 -14
  50. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_server_status.rb +17 -17
  51. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_snapshot_config.rb +0 -0
  52. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_task.rb +0 -0
  53. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_vnc.rb +0 -0
  54. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_volume.rb +0 -0
  55. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_nodes.rb +0 -0
  56. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_servers.rb +0 -0
  57. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_snapshots.rb +0 -0
  58. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_storages.rb +0 -0
  59. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_tasks.rb +0 -0
  60. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_volumes.rb +0 -0
  61. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/log_task.rb +1 -1
  62. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/migrate_server.rb +0 -0
  63. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/move_disk.rb +0 -0
  64. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/move_volume.rb +0 -0
  65. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/next_vmid.rb +0 -0
  66. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/resize_container.rb +0 -0
  67. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/resize_server.rb +0 -0
  68. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/rollback_snapshot.rb +0 -0
  69. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/status_task.rb +0 -0
  70. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/stop_task.rb +0 -0
  71. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/template_server.rb +0 -0
  72. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/update_server.rb +0 -0
  73. data/lib/fog/{compute/proxmox → proxmox/compute}/requests/update_snapshot.rb +0 -0
  74. data/lib/fog/{compute/proxmox.rb → proxmox/compute.rb} +31 -16
  75. data/lib/fog/proxmox/core.rb +76 -64
  76. data/lib/fog/proxmox/errors.rb +2 -1
  77. data/lib/fog/proxmox/hash.rb +2 -4
  78. data/lib/fog/proxmox/helpers/controller_helper.rb +3 -4
  79. data/lib/fog/proxmox/helpers/cpu_helper.rb +55 -9
  80. data/lib/fog/proxmox/helpers/disk_helper.rb +51 -25
  81. data/lib/fog/proxmox/helpers/ip_helper.rb +21 -20
  82. data/lib/fog/proxmox/helpers/nic_helper.rb +37 -27
  83. data/lib/fog/{identity/proxmox → proxmox/identity}/models/domain.rb +7 -3
  84. data/lib/fog/{identity/proxmox → proxmox/identity}/models/domain_type.rb +0 -1
  85. data/lib/fog/{identity/proxmox → proxmox/identity}/models/domains.rb +2 -3
  86. data/lib/fog/{identity/proxmox → proxmox/identity}/models/group.rb +6 -2
  87. data/lib/fog/{identity/proxmox → proxmox/identity}/models/groups.rb +2 -2
  88. data/lib/fog/{identity/proxmox → proxmox/identity}/models/permission.rb +5 -4
  89. data/lib/fog/{identity/proxmox → proxmox/identity}/models/permissions.rb +4 -2
  90. data/lib/fog/{identity/proxmox → proxmox/identity}/models/pool.rb +4 -4
  91. data/lib/fog/{identity/proxmox → proxmox/identity}/models/pools.rb +5 -5
  92. data/lib/fog/{identity/proxmox → proxmox/identity}/models/principal.rb +0 -0
  93. data/lib/fog/{identity/proxmox → proxmox/identity}/models/role.rb +1 -1
  94. data/lib/fog/{identity/proxmox → proxmox/identity}/models/roles.rb +2 -2
  95. data/lib/fog/proxmox/identity/models/token.rb +72 -0
  96. data/lib/fog/proxmox/identity/models/token_info.rb +41 -0
  97. data/lib/fog/proxmox/identity/models/tokens.rb +54 -0
  98. data/lib/fog/{identity/proxmox → proxmox/identity}/models/user.rb +24 -2
  99. data/lib/fog/{identity/proxmox → proxmox/identity}/models/users.rb +2 -2
  100. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/change_password.rb +0 -0
  101. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/check_permissions.rb +0 -0
  102. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_domain.rb +0 -0
  103. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_group.rb +0 -0
  104. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_pool.rb +0 -0
  105. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_role.rb +0 -0
  106. data/lib/fog/proxmox/identity/requests/create_token.rb +40 -0
  107. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_user.rb +0 -0
  108. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_domain.rb +0 -0
  109. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_group.rb +0 -0
  110. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_pool.rb +0 -0
  111. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_role.rb +0 -0
  112. data/lib/fog/proxmox/identity/requests/delete_token.rb +40 -0
  113. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_user.rb +0 -0
  114. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_domain.rb +0 -0
  115. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_group.rb +0 -0
  116. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_pool.rb +0 -0
  117. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_role.rb +0 -0
  118. data/lib/fog/proxmox/identity/requests/get_token_info.rb +41 -0
  119. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_user.rb +1 -0
  120. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_domains.rb +0 -0
  121. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_groups.rb +0 -0
  122. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_permissions.rb +0 -0
  123. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_pools.rb +0 -0
  124. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_roles.rb +0 -0
  125. data/lib/fog/proxmox/identity/requests/list_tokens.rb +41 -0
  126. data/lib/fog/proxmox/identity/requests/list_user_permissions.rb +44 -0
  127. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_users.rb +0 -0
  128. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/read_version.rb +0 -0
  129. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_domain.rb +0 -0
  130. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_group.rb +0 -0
  131. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_permissions.rb +0 -0
  132. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_pool.rb +0 -0
  133. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_role.rb +0 -0
  134. data/lib/fog/proxmox/identity/requests/update_token.rb +41 -0
  135. data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_user.rb +0 -0
  136. data/lib/fog/{identity/proxmox.rb → proxmox/identity.rb} +31 -17
  137. data/lib/fog/{network/proxmox → proxmox/network}/models/network.rb +0 -0
  138. data/lib/fog/{network/proxmox → proxmox/network}/models/networks.rb +2 -2
  139. data/lib/fog/{network/proxmox → proxmox/network}/models/node.rb +2 -1
  140. data/lib/fog/{network/proxmox → proxmox/network}/models/nodes.rb +2 -2
  141. data/lib/fog/{network/proxmox → proxmox/network}/requests/create_network.rb +0 -0
  142. data/lib/fog/{network/proxmox → proxmox/network}/requests/delete_network.rb +0 -0
  143. data/lib/fog/{network/proxmox → proxmox/network}/requests/get_network.rb +0 -0
  144. data/lib/fog/{network/proxmox → proxmox/network}/requests/get_node.rb +0 -0
  145. data/lib/fog/{network/proxmox → proxmox/network}/requests/list_networks.rb +0 -0
  146. data/lib/fog/{network/proxmox → proxmox/network}/requests/list_nodes.rb +0 -0
  147. data/lib/fog/{network/proxmox → proxmox/network}/requests/power_node.rb +0 -0
  148. data/lib/fog/{network/proxmox → proxmox/network}/requests/update_network.rb +0 -0
  149. data/lib/fog/{network/proxmox.rb → proxmox/network.rb} +21 -14
  150. data/lib/fog/{storage/proxmox.rb → proxmox/storage.rb} +1 -1
  151. data/lib/fog/proxmox/string.rb +4 -3
  152. data/lib/fog/proxmox/version.rb +1 -1
  153. data/lib/fog/proxmox.rb +14 -76
  154. data/spec/compute_spec.rb +4 -4
  155. data/spec/fixtures/proxmox/compute/common_auth.yml +40 -0
  156. data/spec/fixtures/proxmox/compute/containers.yml +1752 -7568
  157. data/spec/fixtures/proxmox/compute/nodes.yml +24 -30
  158. data/spec/fixtures/proxmox/compute/servers.yml +5015 -10683
  159. data/spec/fixtures/proxmox/compute/snapshots.yml +479 -1719
  160. data/spec/fixtures/proxmox/compute/storages.yml +32 -40
  161. data/spec/fixtures/proxmox/compute/tasks.yml +118 -338
  162. data/spec/fixtures/proxmox/identity/auth.yml +10 -12
  163. data/spec/fixtures/proxmox/identity/auth_access_ticket.yml +77 -0
  164. data/spec/fixtures/proxmox/identity/auth_user_token.yml +77 -0
  165. data/spec/fixtures/proxmox/identity/common_auth.yml +40 -0
  166. data/spec/fixtures/proxmox/identity/domains.yml +145 -181
  167. data/spec/fixtures/proxmox/identity/groups.yml +72 -90
  168. data/spec/fixtures/proxmox/identity/permissions.yml +297 -189
  169. data/spec/fixtures/proxmox/identity/pools.yml +176 -421
  170. data/spec/fixtures/proxmox/identity/read_version.yml +7 -9
  171. data/spec/fixtures/proxmox/identity/roles.yml +69 -87
  172. data/spec/fixtures/proxmox/identity/tokens.yml +494 -0
  173. data/spec/fixtures/proxmox/identity/users.yml +149 -187
  174. data/spec/fixtures/proxmox/network/common_auth.yml +40 -0
  175. data/spec/fixtures/proxmox/network/networks.yml +99 -96
  176. data/spec/hash_spec.rb +2 -1
  177. data/spec/helpers/controller_helper_spec.rb +135 -123
  178. data/spec/helpers/cpu_helper_spec.rb +57 -45
  179. data/spec/helpers/disk_helper_spec.rb +281 -187
  180. data/spec/helpers/ip_helper_spec.rb +155 -138
  181. data/spec/helpers/nic_helper_spec.rb +122 -114
  182. data/spec/identity_spec.rb +123 -29
  183. data/spec/network_spec.rb +3 -3
  184. data/spec/proxmox_vcr.rb +24 -22
  185. data/spec/spec_helper.rb +4 -3
  186. data/tasks/audit.rake +25 -0
  187. data/tasks/lint.rake +22 -0
  188. data/tasks/test.rake +65 -0
  189. metadata +205 -174
  190. data/.codeclimate.yml +0 -14
  191. data/spec/fixtures/proxmox/compute/identity_ticket.yml +0 -40
  192. data/spec/fixtures/proxmox/identity/identity_ticket.yml +0 -40
  193. data/spec/fixtures/proxmox/identity/renew.yml +0 -40
  194. data/spec/fixtures/proxmox/network/identity_ticket.yml +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c14d0c2b9706b9ccf13d70fb4b3f06496d74ab2469c93eed134e9ec1beffb37
4
- data.tar.gz: d7919eb9e2d9dff9a92f4377ef9bb0b101b5994b8e459b36443bb1881b6a3387
3
+ metadata.gz: fbbd25ac2c953f21c2a4f5b9ab59e30269ab68f9f832abf4dc740743e10a93ec
4
+ data.tar.gz: 3c20988aca648ae685ce5c8e86c17af02ae667bbf6fe53ee012616fec2300ebe
5
5
  SHA512:
6
- metadata.gz: d4fe53a4bd62f5a3664287d9b3a7683379537bddf315a907e8ee80ead4f2c00e76168e9da34c9fb4cdd2a1ad3b31aba4adc465622ca691d7f4db870a5c80755b
7
- data.tar.gz: 77cc6f9f1da87e845ddc442372fe827c58684aab525acf5f4c97fc2793e6f1ae4050cbbbfb3465f7e1e5b615b89c9ad521c1fdc56d143b37fa1a02086d347ef9
6
+ metadata.gz: 813919e970090cde4ccac7ec991b06f4a8380bdf0a1e0e85c0f5b73fce6da91d48da381bcba239ba995e5b706d80bf6b9123823f66420967685deb350dd30a22
7
+ data.tar.gz: 3d638a97782b63a70e12237e6494bf67386e019b287965eb02d36c92f7c097c36a443fe84b2e53464f13895984be7f9141171a4212fab8d3792d08ebab85920d
@@ -1,79 +1,64 @@
1
- name: CI
1
+ name: test
2
2
 
3
3
  on:
4
4
  push:
5
5
  branches: [ master ]
6
6
  pull_request:
7
- branches: [ master ]
8
- release:
9
- types: [created]
10
7
 
11
8
  jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.7
16
+ bundler-cache: true
17
+ - run: bundle install
18
+ - name: rubocop runs
19
+ run: bundle exec rake rubocop
12
20
  test:
21
+ needs: [lint]
13
22
  runs-on: ubuntu-latest
14
23
  steps:
15
- - uses: actions/checkout@v2
24
+ - uses: actions/checkout@v3
16
25
  - name: Set up Ruby
17
26
  uses: ruby/setup-ruby@v1
18
27
  with:
19
- ruby-version: 2.6
28
+ ruby-version: '2.7'
29
+ bundler-cache: true
20
30
  - name: Install dependencies
21
31
  run: bundle install
22
- - name: Run tests
23
- run: bundle exec rake test spec audit
24
- - name: Upload results for coverage
32
+ - name: Run tests with simplecov
33
+ run: bundle exec rake spec
34
+ env:
35
+ CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
36
+ - name: Run vulnerabilities check
37
+ run: bundle exec rake audit
38
+ - name: Upload simplecov results for coverage
25
39
  uses: actions/upload-artifact@v1
26
40
  with:
27
41
  name: coverage
28
42
  path: coverage/
29
43
 
30
44
  coverage:
31
- needs: [ test ]
45
+ needs: [ lint, test ]
32
46
  name: coverage
33
47
  runs-on: ubuntu-latest
34
- steps:
35
- - uses: actions/checkout@v2
48
+ steps:
49
+ - uses: actions/checkout@v3
36
50
  - name: Download tests result from test
37
51
  uses: actions/download-artifact@v1
38
52
  with:
39
53
  name: coverage
40
- - name: Install Code Climate test-reporter
41
- run: |
42
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
43
- chmod +x ./cc-test-reporter
44
- - name: Format code coverage
54
+ - name: Publish code coverage to codeclimate
55
+ uses: paambaati/codeclimate-action@v3.2.0
45
56
  env:
57
+ CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
46
58
  GIT_BRANCH: ${{ github.ref }}
47
59
  GIT_COMMIT_SHA: ${{ github.sha }}
48
- run: |
49
- export GIT_COMMITTED_AT="$(date +%s)"
50
- ./cc-test-reporter format-coverage -d -t simplecov -o coverage/codeclimate.json coverage/.resultset.json
51
- - name: Publish code coverage
52
- env:
53
- GIT_BRANCH: ${{ github.ref }}
54
- GIT_COMMIT_SHA: ${{ github.sha }}
55
- run: |
56
- export GIT_COMMITTED_AT="$(date +%s)"
57
- ./cc-test-reporter upload-coverage -d -r ${{secrets.CC_TEST_REPORTER_ID}}
58
-
59
- publish:
60
- needs: [ test ]
61
- name: publish
62
- runs-on: ubuntu-latest
63
- if: contains(github.ref, '/tags/v')
64
- steps:
65
- - uses: actions/checkout@v2
66
- - name: Set up Ruby 2.6
67
- uses: actions/setup-ruby@v1
68
- with:
69
- version: 2.6.x
70
- - name: Publish to RubyGems
71
- env:
72
- GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
73
- run: |
74
- mkdir -p $HOME/.gem
75
- touch $HOME/.gem/credentials
76
- chmod 0600 $HOME/.gem/credentials
77
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
78
- gem build *.gemspec
79
- gem push *.gem
60
+ with:
61
+ workingDirectory: coverage
62
+ debug: true
63
+ coverageLocations: |
64
+ ${{github.workspace}}/coverage/coverage.json:simplecov
@@ -0,0 +1,38 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ release-please:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: google-github-actions/release-please-action@v3
13
+ id: release
14
+ with:
15
+ release-type: ruby
16
+ package-name: fog-proxmox
17
+ bump-minor-pre-major: true
18
+ version-file: "lib/fog/proxmox/version.rb"
19
+ - uses: actions/checkout@v3
20
+ if: ${{ steps.release.outputs.release_created }}
21
+ - uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: '2.7'
24
+ bundler-cache: true
25
+ if: ${{ steps.release.outputs.release_created }}
26
+ - run: bundle install
27
+ if: ${{ steps.release.outputs.release_created }}
28
+ - name: publish gem
29
+ run: |
30
+ mkdir -p $HOME/.gem
31
+ touch $HOME/.gem/credentials
32
+ chmod 0600 $HOME/.gem/credentials
33
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
34
+ gem build *.gemspec
35
+ gem push *.gem
36
+ env:
37
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
38
+ if: ${{ steps.release.outputs.release_created }}
data/.rubocop.yml CHANGED
@@ -1,13 +1,14 @@
1
+ inherit_from:
2
+ - .rubocop_todo.yml
3
+ require:
4
+ - rubocop-minitest
5
+ - rubocop-rake
6
+ - rubocop-rspec
7
+
1
8
  AllCops:
2
- TargetRubyVersion: 2.4
3
- Include:
4
- - '**/Rakefile'
9
+ TargetRubyVersion: 2.5
10
+ NewCops: disable
5
11
  Exclude:
6
- - 'bin/**/*'
12
+ - 'examples/**/*'
7
13
  - 'vendor/**/*'
8
- - 'coverage/**/*'
9
- - '.bundle/**/*'
10
- - '.vscode/**/*'
11
- - '**/*.gemspec'
12
- - 'Gemfile'
13
- - 'spec/**/*'
14
+ - 'bin/**/*'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,255 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-12-01 11:01:10 UTC using RuboCop version 1.39.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 4
10
+ # Configuration parameters: AllowSafeAssignment.
11
+ Lint/AssignmentInCondition:
12
+ Exclude:
13
+ - 'lib/fog/proxmox/helpers/ip_helper.rb'
14
+
15
+ # Offense count: 1
16
+ Lint/MixedRegexpCaptureTypes:
17
+ Exclude:
18
+ - 'lib/fog/proxmox/helpers/cpu_helper.rb'
19
+
20
+ # Offense count: 1
21
+ # This cop supports unsafe autocorrection (--autocorrect-all).
22
+ Lint/PercentStringArray:
23
+ Exclude:
24
+ - 'lib/fog/proxmox/core.rb'
25
+
26
+ # Offense count: 13
27
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
28
+ Metrics/AbcSize:
29
+ Max: 46
30
+
31
+ # Offense count: 1
32
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, inherit_mode.
33
+ # AllowedMethods: refine
34
+ Metrics/BlockLength:
35
+ Max: 40
36
+
37
+ # Offense count: 2
38
+ # Configuration parameters: CountComments, CountAsOne.
39
+ Metrics/ClassLength:
40
+ Max: 200
41
+
42
+ # Offense count: 5
43
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
44
+ Metrics/CyclomaticComplexity:
45
+ Max: 17
46
+
47
+ # Offense count: 18
48
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
49
+ Metrics/MethodLength:
50
+ Max: 70
51
+
52
+ # Offense count: 2
53
+ # Configuration parameters: CountComments, CountAsOne.
54
+ Metrics/ModuleLength:
55
+ Max: 133
56
+
57
+ # Offense count: 5
58
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
59
+ Metrics/PerceivedComplexity:
60
+ Max: 19
61
+
62
+ # Offense count: 3
63
+ Naming/AccessorMethodName:
64
+ Exclude:
65
+ - 'lib/fog/proxmox/auth/token/user_token.rb'
66
+ - 'lib/fog/proxmox/network/requests/get_network.rb'
67
+ - 'lib/fog/proxmox/network/requests/get_node.rb'
68
+
69
+ # Offense count: 6
70
+ Naming/ConstantName:
71
+ Exclude:
72
+ - 'lib/fog/proxmox/helpers/ip_helper.rb'
73
+
74
+ # Offense count: 6
75
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
76
+ # NamePrefix: is_, has_, have_
77
+ # ForbiddenPrefixes: is_, has_, have_
78
+ # AllowedMethods: is_a?
79
+ # MethodDefinitionMacros: define_method, define_singleton_method
80
+ Naming/PredicateName:
81
+ Exclude:
82
+ - 'spec/**/*'
83
+ - 'lib/fog/proxmox/compute/models/disk.rb'
84
+ - 'lib/fog/proxmox/helpers/nic_helper.rb'
85
+ - 'lib/fog/proxmox/identity/models/pool.rb'
86
+
87
+ # Offense count: 3
88
+ RSpec/BeforeAfterAll:
89
+ Exclude:
90
+ - 'spec/spec_helper.rb'
91
+ - 'spec/rails_helper.rb'
92
+ - 'spec/support/**/*.rb'
93
+ - 'spec/compute_spec.rb'
94
+ - 'spec/identity_spec.rb'
95
+ - 'spec/network_spec.rb'
96
+
97
+ # Offense count: 131
98
+ # This cop supports unsafe autocorrection (--autocorrect-all).
99
+ # Configuration parameters: SkipBlocks, EnforcedStyle.
100
+ # SupportedStyles: described_class, explicit
101
+ RSpec/DescribedClass:
102
+ Exclude:
103
+ - 'spec/compute_spec.rb'
104
+ - 'spec/hash_spec.rb'
105
+ - 'spec/helpers/controller_helper_spec.rb'
106
+ - 'spec/helpers/cpu_helper_spec.rb'
107
+ - 'spec/helpers/disk_helper_spec.rb'
108
+ - 'spec/helpers/ip_helper_spec.rb'
109
+ - 'spec/helpers/nic_helper_spec.rb'
110
+ - 'spec/identity_spec.rb'
111
+ - 'spec/network_spec.rb'
112
+
113
+ # Offense count: 17
114
+ # Configuration parameters: CountAsOne.
115
+ RSpec/ExampleLength:
116
+ Max: 136
117
+
118
+ # Offense count: 9
119
+ # Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
120
+ # Include: **/*_spec*rb*, **/spec/**/*
121
+ RSpec/FilePath:
122
+ Exclude:
123
+ - 'spec/compute_spec.rb'
124
+ - 'spec/hash_spec.rb'
125
+ - 'spec/helpers/controller_helper_spec.rb'
126
+ - 'spec/helpers/cpu_helper_spec.rb'
127
+ - 'spec/helpers/disk_helper_spec.rb'
128
+ - 'spec/helpers/ip_helper_spec.rb'
129
+ - 'spec/helpers/nic_helper_spec.rb'
130
+ - 'spec/identity_spec.rb'
131
+ - 'spec/network_spec.rb'
132
+
133
+ # Offense count: 114
134
+ # Configuration parameters: AssignmentOnly.
135
+ RSpec/InstanceVariable:
136
+ Exclude:
137
+ - 'spec/compute_spec.rb'
138
+ - 'spec/identity_spec.rb'
139
+ - 'spec/network_spec.rb'
140
+
141
+ # Offense count: 32
142
+ # Configuration parameters: AllowSubject.
143
+ RSpec/MultipleMemoizedHelpers:
144
+ Max: 12
145
+
146
+ # Offense count: 2
147
+ RSpec/RepeatedDescription:
148
+ Exclude:
149
+ - 'spec/helpers/cpu_helper_spec.rb'
150
+
151
+ # Offense count: 1
152
+ # This cop supports unsafe autocorrection (--autocorrect-all).
153
+ Style/CaseLikeIf:
154
+ Exclude:
155
+ - 'lib/fog/proxmox/auth/token.rb'
156
+
157
+ # Offense count: 3
158
+ # Configuration parameters: AllowedConstants.
159
+ Style/Documentation:
160
+ Exclude:
161
+ - 'spec/**/*'
162
+ - 'test/**/*'
163
+ - 'lib/fog/proxmox/auth/token.rb'
164
+ - 'lib/fog/proxmox/auth/token/access_ticket.rb'
165
+ - 'lib/fog/proxmox/auth/token/user_token.rb'
166
+
167
+ # Offense count: 2
168
+ # This cop supports unsafe autocorrection (--autocorrect-all).
169
+ # Configuration parameters: EnforcedStyle.
170
+ # SupportedStyles: always, always_true, never
171
+ Style/FrozenStringLiteralComment:
172
+ Exclude:
173
+ - 'lib/fog/proxmox/identity/models/domain.rb'
174
+ - 'lib/fog/proxmox/identity/models/domain_type.rb'
175
+
176
+ # Offense count: 2
177
+ # This cop supports safe autocorrection (--autocorrect).
178
+ Style/IfUnlessModifier:
179
+ Exclude:
180
+ - 'lib/fog/proxmox/auth/token/access_ticket.rb'
181
+ - 'lib/fog/proxmox/compute/models/servers.rb'
182
+
183
+ # Offense count: 12
184
+ # This cop supports unsafe autocorrection (--autocorrect-all).
185
+ # Configuration parameters: EnforcedStyle.
186
+ # SupportedStyles: literals, strict
187
+ Style/MutableConstant:
188
+ Exclude:
189
+ - 'lib/fog/proxmox/helpers/cpu_helper.rb'
190
+ - 'lib/fog/proxmox/helpers/disk_helper.rb'
191
+ - 'lib/fog/proxmox/helpers/ip_helper.rb'
192
+ - 'lib/fog/proxmox/helpers/nic_helper.rb'
193
+
194
+ # Offense count: 2
195
+ # This cop supports unsafe autocorrection (--autocorrect-all).
196
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods.
197
+ # SupportedStyles: predicate, comparison
198
+ Style/NumericPredicate:
199
+ Exclude:
200
+ - 'spec/**/*'
201
+ - 'lib/fog/proxmox/core.rb'
202
+ - 'lib/fog/proxmox/helpers/cpu_helper.rb'
203
+
204
+ # Offense count: 1
205
+ # Configuration parameters: AllowedMethods.
206
+ # AllowedMethods: respond_to_missing?
207
+ Style/OptionalBooleanParameter:
208
+ Exclude:
209
+ - 'lib/fog/proxmox/identity/models/pool.rb'
210
+
211
+ # Offense count: 20
212
+ # This cop supports unsafe autocorrection (--autocorrect-all).
213
+ # Configuration parameters: EnforcedStyle.
214
+ # SupportedStyles: short, verbose
215
+ Style/PreferredHashMethods:
216
+ Exclude:
217
+ - 'lib/fog/proxmox/compute/models/servers.rb'
218
+ - 'lib/fog/proxmox/helpers/nic_helper.rb'
219
+ - 'lib/fog/proxmox/identity/models/domain.rb'
220
+ - 'lib/fog/proxmox/identity/models/pool.rb'
221
+ - 'spec/helpers/controller_helper_spec.rb'
222
+ - 'spec/helpers/nic_helper_spec.rb'
223
+
224
+ # Offense count: 4
225
+ # This cop supports unsafe autocorrection (--autocorrect-all).
226
+ Style/RedundantInterpolation:
227
+ Exclude:
228
+ - 'lib/fog/proxmox/helpers/ip_helper.rb'
229
+
230
+ # Offense count: 11
231
+ # This cop supports unsafe autocorrection (--autocorrect-all).
232
+ # Configuration parameters: Mode.
233
+ Style/StringConcatenation:
234
+ Exclude:
235
+ - 'lib/fog/proxmox/compute/models/server.rb'
236
+ - 'lib/fog/proxmox/compute/models/tasks.rb'
237
+ - 'lib/fog/proxmox/helpers/cpu_helper.rb'
238
+ - 'lib/fog/proxmox/helpers/disk_helper.rb'
239
+ - 'lib/fog/proxmox/helpers/nic_helper.rb'
240
+ - 'lib/fog/proxmox/variables.rb'
241
+
242
+ # Offense count: 2
243
+ # This cop supports unsafe autocorrection (--autocorrect-all).
244
+ # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowComments.
245
+ # AllowedMethods: respond_to, define_method
246
+ Style/SymbolProc:
247
+ Exclude:
248
+ - 'spec/compute_spec.rb'
249
+
250
+ # Offense count: 16
251
+ # This cop supports safe autocorrection (--autocorrect).
252
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
253
+ # URISchemes: http, https
254
+ Layout/LineLength:
255
+ Max: 230
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [0.15.0](https://github.com/fog/fog-proxmox/compare/v0.14.0...v0.15.0) (2022-12-01)
4
+
5
+
6
+ ### Features
7
+
8
+ * :sparkles: memory unit is Mb and disk size is Gb ([c5410b5](https://github.com/fog/fog-proxmox/commit/c5410b5c79ed59a89bb4f0f2188613cbcc6a8f11))
data/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  # Fog::Proxmox
4
4
 
5
5
  ![CI](https://github.com/fog/fog-proxmox/workflows/CI/badge.svg)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/33e619f2167cc9864b61/maintainability)](https://codeclimate.com/github/fog/fog-proxmox/maintainability)
7
- [![Test Coverage](https://api.codeclimate.com/v1/badges/33e619f2167cc9864b61/test_coverage)](https://codeclimate.com/github/fog/fog-proxmox/test_coverage)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/dfcdcc32f096abf1b2b4/maintainability)](https://codeclimate.com/github/fog/fog-proxmox/maintainability)
7
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/dfcdcc32f096abf1b2b4/test_coverage)](https://codeclimate.com/github/fog/fog-proxmox/test_coverage)
8
8
  [![Gem Version](https://badge.fury.io/rb/fog-proxmox.svg)](https://badge.fury.io/rb/fog-proxmox)
9
9
 
10
10
  This is a [FOG](http://fog.io/) (>= 2.1) module gem to support [Proxmox VE](https://www.proxmox.com/en/proxmox-ve)
@@ -22,6 +22,7 @@ It is inspired by the great [fog-openstack](https://github.com/fog/fog-openstack
22
22
  |>=0.8|>=5.4|>=1.45|>=2.3|
23
23
  |>=0.9|>=6.0|>=2.1|>=2.3|
24
24
  |>=0.10|>=6.0|>=2.1|>=2.5|
25
+ |>=0.14|>=6.2|>=2.1|>=2.5|
25
26
 
26
27
  ## Installation
27
28
 
@@ -58,15 +59,45 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
58
59
  To record your VCR cassettes:
59
60
 
60
61
  ```shell
61
- PVE_URL=https://192.168.56.101:8006/api2/json DISABLE_PROXY=true SSL_VERIFY_PEER=false bundle exec rake spec
62
+ PROXMOX_URL=https://192.168.56.101:8006/api2/json DISABLE_PROXY=true SSL_VERIFY_PEER=false bundle exec rake spec
62
63
  ```
63
64
 
64
- To replay your recorded tests:
65
+ To replay all your recorded tests:
65
66
 
66
67
  ```shell
67
68
  USE_VCR=true bundle exec rake spec
68
69
  ```
69
70
 
71
+ To replay one group (compute, identity or network) of your recorded tests:
72
+
73
+ ```shell
74
+ USE_VCR=true bundle exec rake spec:compute
75
+ ```
76
+
77
+ Code formatting:
78
+
79
+ ```shell
80
+ bundle exec rake rubocop
81
+ ```
82
+
83
+ Auto correcting (safe):
84
+
85
+ ```shell
86
+ bundle exec rake rubocop:autocorrect
87
+ ```
88
+
89
+ Exclude cops in todo file:
90
+
91
+ ```shell
92
+ bundle exec rubocop --auto-gen-config
93
+ ```
94
+
95
+ See all available rake tasks:
96
+
97
+ ```shell
98
+ bundle exec rake --tasks
99
+ ```
100
+
70
101
  ## Contributing
71
102
 
72
103
  You can reach the [contributors](.github/CONTRIBUTORS.md).
data/Rakefile CHANGED
@@ -17,42 +17,15 @@
17
17
  # You should have received a copy of the GNU General Public License
18
18
  # along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
- require 'bundler/gem_tasks'
21
- require 'rubocop/rake_task'
22
20
  require 'rake/testtask'
23
- require 'bundler/audit/task'
24
21
 
25
- Bundler::Audit::Task.new
26
- RuboCop::RakeTask.new
27
-
28
- task default: :test
29
-
30
- desc 'Run fog-proxmox unit tests with Minitest'
31
- task :test do
32
- mock = ENV['FOG_MOCK'] || 'true'
33
- sh("export FOG_MOCK=#{mock} && bundle exec rake tests:unit")
22
+ task_dir = File.expand_path('tasks', __dir__)
23
+ Dir["#{task_dir}/**/*.rake"].each do |task_file|
24
+ load task_file
34
25
  end
35
26
 
36
- desc 'Run fog-proxmox spec/ tests (VCR)'
37
- task spec: 'tests:spec'
38
-
39
- desc 'Run audit vulnerabilities'
40
- task audit: 'bundle:audit'
41
-
42
- namespace :tests do
43
- desc 'Run fog-proxmox test/'
44
- Rake::TestTask.new do |t|
45
- t.name = 'unit'
46
- t.libs.push %w[lib test]
47
- t.test_files = FileList['test/**/*.rb']
48
- t.verbose = true
49
- end
50
-
51
- desc 'Run fog-proxmox spec/'
52
- Rake::TestTask.new do |t|
53
- t.name = 'spec'
54
- t.libs.push %w[lib spec]
55
- t.pattern = 'spec/**/*_spec.rb'
56
- t.verbose = true
57
- end
58
- end
27
+ desc 'Default Task'
28
+ task default: :spec
29
+
30
+ desc 'Alias of spec:all'
31
+ task spec: 'spec:all'
data/bin/console CHANGED
@@ -8,11 +8,9 @@
8
8
  # this file is here to facilitate running it.
9
9
  #
10
10
 
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
14
12
 
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
16
14
 
17
15
  if File.file?(bundle_binstub)
18
16
  if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
data/bin/setup CHANGED
@@ -8,11 +8,9 @@
8
8
  # this file is here to facilitate running it.
9
9
  #
10
10
 
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
14
12
 
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
16
14
 
17
15
  if File.file?(bundle_binstub)
18
16
  if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
data/docs/compute.md CHANGED
@@ -18,16 +18,32 @@ require 'fog/proxmox'
18
18
 
19
19
  ## Create compute service
20
20
 
21
+ with access ticket:
22
+
23
+ ```ruby
24
+ identity = Fog::Proxmox::Identity.new(
25
+ proxmox_url: 'https://localhost:8006/api2/json',
26
+ proxmox_auth_method: 'access_ticket',
27
+ proxmox_username: 'your_user@your_realm',
28
+ proxmox_password: 'his_password',
29
+ connection_options: { ... }
30
+ )
31
+ ```
32
+
33
+ with API user token:
34
+
21
35
  ```ruby
22
- compute = Fog::Proxmox::Compute.new(
23
- pve_username: PVE_USERNAME, # your user name
24
- pve_password: PVE_PASSWORD, # your password
25
- pve_url: PVE_URL, # your server url
26
- connection_options: {} # connection options
27
- )
36
+ identity = Fog::Proxmox::Identity.new(
37
+ proxmox_url: 'https://localhost:8006/api2/json',
38
+ proxmox_auth_method: 'user_token',
39
+ proxmox_userid: 'your_user',
40
+ proxmox_tokenid: 'his_tokenid',
41
+ proxmox_token: 'his_token',
42
+ connection_options: { ... }
43
+ )
28
44
  ```
29
45
 
30
- [connection_options](connection_parameters.md) are also available.
46
+ [connection_options](connection_parameters.md) are also available and optional.
31
47
 
32
48
  ## Fog Abstractions
33
49