├── .bundle └── config ├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── SUPPORT.md ├── fogproxmox.png └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── .rubocop.yml ├── .rubocop_todo.yml ├── .ruby-gemset ├── .solargraph.yml ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── CHANGELOG.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── bin ├── console └── setup ├── docs ├── compute.md ├── connection_parameters.md ├── getting_started.md └── identity.md ├── examples ├── compute.rb └── identity.rb ├── fog-proxmox.gemspec ├── lib └── fog │ ├── proxmox.rb │ └── proxmox │ ├── attributes.rb │ ├── auth │ ├── token.rb │ └── token │ │ ├── access_ticket.rb │ │ └── user_token.rb │ ├── compute.rb │ ├── compute │ ├── models │ │ ├── disk.rb │ │ ├── disks.rb │ │ ├── interface.rb │ │ ├── interfaces.rb │ │ ├── node.rb │ │ ├── nodes.rb │ │ ├── server.rb │ │ ├── server_config.rb │ │ ├── servers.rb │ │ ├── snapshot.rb │ │ ├── snapshots.rb │ │ ├── storage.rb │ │ ├── storages.rb │ │ ├── task.rb │ │ ├── tasks.rb │ │ ├── volume.rb │ │ └── volumes.rb │ └── requests │ │ ├── action_server.rb │ │ ├── clone_server.rb │ │ ├── create_backup.rb │ │ ├── create_server.rb │ │ ├── create_snapshot.rb │ │ ├── create_spice.rb │ │ ├── create_term.rb │ │ ├── create_vnc.rb │ │ ├── delete_server.rb │ │ ├── delete_snapshot.rb │ │ ├── delete_volume.rb │ │ ├── get_node_statistics.rb │ │ ├── get_server_config.rb │ │ ├── get_server_status.rb │ │ ├── get_snapshot_config.rb │ │ ├── get_task.rb │ │ ├── get_vnc.rb │ │ ├── get_volume.rb │ │ ├── list_nodes.rb │ │ ├── list_servers.rb │ │ ├── list_snapshots.rb │ │ ├── list_storages.rb │ │ ├── list_tasks.rb │ │ ├── list_volumes.rb │ │ ├── log_task.rb │ │ ├── migrate_server.rb │ │ ├── move_disk.rb │ │ ├── move_volume.rb │ │ ├── next_vmid.rb │ │ ├── resize_container.rb │ │ ├── resize_server.rb │ │ ├── rollback_snapshot.rb │ │ ├── status_task.rb │ │ ├── stop_task.rb │ │ ├── template_server.rb │ │ ├── update_server.rb │ │ └── update_snapshot.rb │ ├── core.rb │ ├── errors.rb │ ├── hash.rb │ ├── helpers │ ├── controller_helper.rb │ ├── cpu_helper.rb │ ├── disk_helper.rb │ ├── ip_helper.rb │ └── nic_helper.rb │ ├── identity.rb │ ├── identity │ ├── models │ │ ├── domain.rb │ │ ├── domain_type.rb │ │ ├── domains.rb │ │ ├── group.rb │ │ ├── groups.rb │ │ ├── permission.rb │ │ ├── permissions.rb │ │ ├── pool.rb │ │ ├── pools.rb │ │ ├── principal.rb │ │ ├── role.rb │ │ ├── roles.rb │ │ ├── token.rb │ │ ├── token_info.rb │ │ ├── tokens.rb │ │ ├── user.rb │ │ └── users.rb │ └── requests │ │ ├── change_password.rb │ │ ├── check_permissions.rb │ │ ├── create_domain.rb │ │ ├── create_group.rb │ │ ├── create_pool.rb │ │ ├── create_role.rb │ │ ├── create_token.rb │ │ ├── create_user.rb │ │ ├── delete_domain.rb │ │ ├── delete_group.rb │ │ ├── delete_pool.rb │ │ ├── delete_role.rb │ │ ├── delete_token.rb │ │ ├── delete_user.rb │ │ ├── get_domain.rb │ │ ├── get_group.rb │ │ ├── get_pool.rb │ │ ├── get_role.rb │ │ ├── get_token_info.rb │ │ ├── get_user.rb │ │ ├── list_domains.rb │ │ ├── list_groups.rb │ │ ├── list_permissions.rb │ │ ├── list_pools.rb │ │ ├── list_roles.rb │ │ ├── list_tokens.rb │ │ ├── list_user_permissions.rb │ │ ├── list_users.rb │ │ ├── read_version.rb │ │ ├── update_domain.rb │ │ ├── update_group.rb │ │ ├── update_permissions.rb │ │ ├── update_pool.rb │ │ ├── update_role.rb │ │ ├── update_token.rb │ │ └── update_user.rb │ ├── json.rb │ ├── network.rb │ ├── network │ ├── models │ │ ├── network.rb │ │ ├── networks.rb │ │ ├── node.rb │ │ └── nodes.rb │ └── requests │ │ ├── create_network.rb │ │ ├── delete_network.rb │ │ ├── get_network.rb │ │ ├── get_node.rb │ │ ├── list_networks.rb │ │ ├── list_nodes.rb │ │ ├── power_node.rb │ │ └── update_network.rb │ ├── storage.rb │ ├── string.rb │ ├── variables.rb │ └── version.rb ├── spec ├── compute_spec.rb ├── fixtures │ └── proxmox │ │ ├── compute │ │ ├── common_auth.yml │ │ ├── containers.yml │ │ ├── nodes.yml │ │ ├── servers.yml │ │ ├── snapshots.yml │ │ ├── storages.yml │ │ └── tasks.yml │ │ ├── identity │ │ ├── auth.yml │ │ ├── auth_access_ticket.yml │ │ ├── auth_user_token.yml │ │ ├── common_auth.yml │ │ ├── domains.yml │ │ ├── groups.yml │ │ ├── permissions.yml │ │ ├── pools.yml │ │ ├── read_version.yml │ │ ├── roles.yml │ │ ├── tokens.yml │ │ └── users.yml │ │ ├── network │ │ ├── common_auth.yml │ │ └── networks.yml │ │ └── pve.home ├── hash_spec.rb ├── helpers │ ├── controller_helper_spec.rb │ ├── cpu_helper_spec.rb │ ├── disk_helper_spec.rb │ ├── ip_helper_spec.rb │ └── nic_helper_spec.rb ├── identity_spec.rb ├── network_spec.rb ├── proxmox_vcr.rb └── spec_helper.rb └── tasks ├── audit.rake ├── lint.rake └── test.rake /.bundle/config: -------------------------------------------------------------------------------- 1 | --- 2 | BUNDLE_BIN: "bin" 3 | BUNDLE_PATH: "vendor/bundle" 4 | BUNDLE_CACHE_ALL: "true" 5 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Getting Involved 2 | 3 | New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another. 4 | 5 | Please read the [code of conduct](CODE_OF_CONDUCT.md) 6 | 7 | ## Coding 8 | 9 | * Pick a task: 10 | * Offer feedback on open [pull requests](https://github.com/tristanrobert/fog-proxmox/pulls). 11 | * Review open [issues](https://github.com/tristanrobert/fog-proxmox/issues) for things to help on. 12 | * [Create an issue](https://github.com/tristanrobert/fog-proxmox/issues/new) to start a discussion on additions or features. 13 | * Fork the project, add your changes and tests to cover them in a topic branch. 14 | * Commit your changes and rebase against `fog/fog-proxmox` to ensure everything is up to date. 15 | * [Submit a pull request](https://github.com/tristanrobert/fog-proxmox/compare/). 16 | 17 | ## Non-Coding 18 | 19 | * Offer feedback on open [issues](https://github.com/tristanrobert/fog-proxmox/issues). 20 | * [Donate](SUPPORT.md) 21 | -------------------------------------------------------------------------------- /.github/CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Developers 2 | 3 | * Tristan Robert 4 | 5 | # Donators 6 | 7 | Thanks to all generous donators that support the developers effort: 8 | 9 | * [Tobias Köck](https://github.com/tkoeck) -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [tristanrobert] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ["https://paypal.me/TristanRobert"]# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # [TITLE ISSUE] 2 | 3 | ## Prerequisites 4 | 5 | Please check (put an X between the brackets) the following items before posting any issue: 6 | 7 | * [] Have you check that no [issue](https://github.com/tristanrobert/fog-proxmox/issues) already exists and could match yours? 8 | 9 | * [] Have you read the [contributing code](https://github.com/tristanrobert/fog-proxmox/blob/develop/CONTRIBUTING.md)? 10 | 11 | ## Description 12 | 13 | [Describe your issue] 14 | 15 | ## Environment 16 | 17 | [Describe your environment: OS, ruby -v, ...] 18 | 19 | ## Version 20 | 21 | [Give the milestone or the precise version of the gem used] 22 | 23 | ## Steps to reproduce 24 | 25 | 1. [First Step] 26 | 2. [Second Step] 27 | 3. [and so on...] 28 | 29 | ### Expected behavior 30 | 31 | [What you expect to happen] 32 | 33 | ### Actual behavior 34 | 35 | [What actually happens] 36 | 37 | ### Reproduces how often: 38 | 39 | [What percentage of the time does it reproduce?] 40 | 41 | ## Additional Information 42 | 43 | Any additional information, configuration or data that might be necessary to reproduce the issue. 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Sponsor Fog::Proxmox development 2 | 3 | Fog::Proxmox is an [GPL-3](LICENSE) licensed open source project and completely free to use. 4 | 5 | However, the amount of effort needed to maintain and develop the project could be support by donations. 6 | 7 | You can support Fog::Proxmox development via the following methods: 8 | 9 | * [Donate by PayPal](https://paypal.me/TristanRobert) -------------------------------------------------------------------------------- /.github/fogproxmox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fog/fog-proxmox/b90788fefec52d7ba1fcdea632e36cf1834773a6/.github/fogproxmox.png -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | 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 20 | test: 21 | needs: [lint] 22 | runs-on: ubuntu-latest 23 | steps: 24 | - uses: actions/checkout@v3 25 | - name: Set up Ruby 26 | uses: ruby/setup-ruby@v1 27 | with: 28 | ruby-version: '2.7' 29 | bundler-cache: true 30 | - name: Install dependencies 31 | run: bundle install 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 39 | uses: actions/upload-artifact@v4 40 | with: 41 | name: coverage 42 | path: coverage/ 43 | 44 | coverage: 45 | needs: [ lint, test ] 46 | name: coverage 47 | runs-on: ubuntu-latest 48 | steps: 49 | - uses: actions/checkout@v3 50 | - name: Download tests result from test 51 | uses: actions/download-artifact@v4.1.7 52 | with: 53 | name: coverage 54 | - name: Publish code coverage to codeclimate 55 | uses: paambaati/codeclimate-action@v3.2.0 56 | env: 57 | CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} 58 | GIT_BRANCH: ${{ github.ref }} 59 | GIT_COMMIT_SHA: ${{ github.sha }} 60 | with: 61 | workingDirectory: ${{github.workspace}} 62 | debug: true 63 | coverageLocations: | 64 | ${{github.workspace}}/coverage/coverage.json:simplecov 65 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 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 }} 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | bin/ 3 | pkg/ 4 | spec/debug/ 5 | coverage/ 6 | TAGS 7 | Gemfile.lock 8 | *.gem 9 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | inherit_from: 2 | - .rubocop_todo.yml 3 | require: 4 | - rubocop-minitest 5 | - rubocop-rake 6 | - rubocop-rspec 7 | 8 | Migration/DepartmentName: 9 | Enabled: false 10 | 11 | AllCops: 12 | TargetRubyVersion: 2.5 13 | NewCops: disable 14 | Exclude: 15 | - 'examples/**/*' 16 | - 'vendor/**/*' 17 | - 'bin/**/*' 18 | -------------------------------------------------------------------------------- /.ruby-gemset: -------------------------------------------------------------------------------- 1 | fog-proxmox -------------------------------------------------------------------------------- /.solargraph.yml: -------------------------------------------------------------------------------- 1 | --- 2 | include: 3 | - "**/*.rb" 4 | exclude: 5 | - spec/**/* 6 | - test/**/* 7 | domains: [] 8 | required: [] 9 | plugins: 10 | -runtime 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Placez vos paramètres dans ce fichier pour remplacer les paramètres par défaut et les paramètres utilisateur. 2 | { 3 | "ruby.pathToBundler": "~/.asdf/shims/bundle", 4 | "ruby.useBundler": true, 5 | "solargraph.commandPath": "~/.asdf/shims/solargraph", 6 | "solargraph.bundlerPath": "~/.asdf/shims/bundle", 7 | "workbench.startupEditor": "newUntitledFile", 8 | "workbench.iconTheme": "vscode-icons", 9 | "git.autofetch": true, 10 | "git.confirmSync": false, 11 | "workbench.colorTheme": "Visual Studio Dark", 12 | "solargraph.useBundler": true, 13 | "ruby.lint": { 14 | "reek": true, 15 | "rubocop": { 16 | "lint": true, //enable all lint cops. 17 | "rails": true //Run extra rails cops 18 | }, 19 | "ruby": true, //Runs ruby -wc 20 | "fasterer": true, 21 | "debride": true, 22 | "ruby-lint": false 23 | }, 24 | "ruby.locate": { 25 | "include": "**/*.erb,**/*.rb,**/vendor/*.*", 26 | "exclude": "{**/@(test|spec|tmp|.*),**/@(test|spec|tmp|.*)/**,**/*_spec.rb}" 27 | }, 28 | "ruby.interpreter.commandPath": "~/.asdf/shims/ruby", 29 | "ruby.pathToBundler": "~/.asdf/shims/bundle", 30 | "ruby.useBundler": true, 31 | "solargraph.commandPath": "~/.asdf/shims/solargraph", 32 | "solargraph.bundlerPath": "~/.asdf/shims/bundle", 33 | "gitlens.advanced.messages": { 34 | "suppressCommitHasNoPreviousCommitWarning": false, 35 | "suppressCommitNotFoundWarning": false, 36 | "suppressFileNotUnderSourceControlWarning": false, 37 | "suppressGitVersionWarning": false, 38 | "suppressLineUncommittedWarning": false, 39 | "suppressNoRepositoryWarning": false, 40 | "suppressResultsExplorerNotice": false, 41 | "suppressShowKeyBindingsNotice": true 42 | }, 43 | "explorer.confirmDragAndDrop": false, 44 | "ruby.format": "rubocop" 45 | } 46 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "command": "bundler", 6 | "args": ["exec"], 7 | "echoCommand": true, 8 | "tasks": [ 9 | { 10 | "taskName": "echo", 11 | "type": "shell", 12 | "command": "echo Hello" 13 | }, 14 | { 15 | "taskName": "Run Script", 16 | "args": ["ruby", "${file}"] 17 | }, 18 | { 19 | "taskName": "Exec", 20 | "args": ["ruby", "main.rb"] 21 | }, 22 | { 23 | "taskName": "Test", 24 | "args": ["rspec"] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.15.1](https://github.com/fog/fog-proxmox/compare/v0.15.0...v0.15.1) (2025-02-25) 4 | 5 | 6 | ### Bug Fixes 7 | 8 | * 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)) 9 | 10 | ## [0.15.0](https://github.com/fog/fog-proxmox/compare/v0.14.0...v0.15.0) (2022-12-01) 11 | 12 | 13 | ### Features 14 | 15 | * :sparkles: memory unit is Mb and disk size is Gb ([c5410b5](https://github.com/fog/fog-proxmox/commit/c5410b5c79ed59a89bb4f0f2188613cbcc6a8f11)) 16 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | source 'https://rubygems.org' 21 | 22 | # Specify your gem's dependencies in fog-proxmox.gemspec 23 | gemspec 24 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'rake/testtask' 21 | 22 | task_dir = File.expand_path('tasks', __dir__) 23 | Dir["#{task_dir}/**/*.rake"].each do |task_file| 24 | load task_file 25 | end 26 | 27 | desc 'Default Task' 28 | task default: :spec 29 | 30 | desc 'Alias of spec:all' 31 | task spec: 'spec:all' 32 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'console' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 12 | 13 | bundle_binstub = File.expand_path("bundle", __dir__) 14 | 15 | if File.file?(bundle_binstub) 16 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 17 | load(bundle_binstub) 18 | else 19 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 20 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 21 | end 22 | end 23 | 24 | require "rubygems" 25 | require "bundler/setup" 26 | 27 | load Gem.bin_path("fog-proxmox", "console") 28 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'setup' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 12 | 13 | bundle_binstub = File.expand_path("bundle", __dir__) 14 | 15 | if File.file?(bundle_binstub) 16 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ 17 | load(bundle_binstub) 18 | else 19 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. 20 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") 21 | end 22 | end 23 | 24 | require "rubygems" 25 | require "bundler/setup" 26 | 27 | load Gem.bin_path("fog-proxmox", "setup") 28 | -------------------------------------------------------------------------------- /docs/connection_parameters.md: -------------------------------------------------------------------------------- 1 | # Optional connection parameters 2 | 3 | Fog supports passing additional connection parameters to its underlying HTTP library (Excon) using the `:connection_options` parameter. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
KeyDescription
:connect_timeoutConnection timeout (default: 60 seconds)
:read_timeoutRead timeout for connection (default: 60 seconds)
:write_timeoutWrite timeout for connection (default: 60 seconds)
:proxyProxy for HTTP and HTTPS connections
:ssl_ca_pathPath to SSL certificate authorities
:ssl_ca_fileSSL certificate authority file
:ssl_verify_peerSSL verify peer (default: true)
:debug_requestdebug print request (default: false)
:debug_responsedebug print response (default: false)
-------------------------------------------------------------------------------- /docs/getting_started.md: -------------------------------------------------------------------------------- 1 | # Getting started with Fog proxmox 2 | 3 | ## Requirements 4 | 5 | ### Ruby 6 | 7 | 2.3, 2.4 and 2.5 ruby versions are tested and required. 8 | Fog requires 2.0+ for new projects. 9 | 10 | ## Installation 11 | 12 | With rubygems: 13 | 14 | ```ruby 15 | gem install fog-proxmox 16 | ``` 17 | 18 | With bundler: 19 | 20 | Create a Gemfile with: 21 | 22 | ```ruby 23 | source 'https://rubygems.org' 24 | 25 | gem 'fog-proxmox' 26 | ``` 27 | 28 | then: 29 | 30 | ```ruby 31 | bundler install 32 | ``` 33 | 34 | ## Exploring capabilities 35 | 36 | ```ruby 37 | irb 38 | ``` 39 | 40 | ```ruby 41 | require 'fog/proxmox' 42 | ``` 43 | 44 | ```ruby 45 | Fog::Proxmox.services 46 | ``` 47 | 48 | This command show you a summary of the available services. 49 | 50 | ### Available services in details 51 | 52 | * [Identity](identity.md) 53 | * [Compute](compute.md) -------------------------------------------------------------------------------- /lib/fog/proxmox.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | require 'fog/core' 22 | require 'fog/json' 23 | 24 | module Fog 25 | # Proxmox module 26 | module Proxmox 27 | require 'fog/proxmox/auth/token' 28 | 29 | autoload :Core, 'fog/proxmox/core' 30 | autoload :Errors, 'fog/proxmox/errors' 31 | autoload :Identity, 'fog/proxmox/identity' 32 | autoload :Compute, 'fog/proxmox/compute' 33 | autoload :Storage, 'fog/proxmox/storage' 34 | autoload :Network, 'fog/proxmox/network' 35 | 36 | extend Fog::Provider 37 | 38 | service(:identity, 'Identity') 39 | service(:compute, 'Compute') 40 | service(:storage, 'Storage') 41 | service(:network, 'Network') 42 | 43 | @token_cache = {} 44 | 45 | class << self 46 | attr_accessor :token_cache 47 | end 48 | 49 | def self.clear_token_cache 50 | Fog::Proxmox.token_cache = {} 51 | end 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /lib/fog/proxmox/attributes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | # module Attributes mixins 23 | module Attributes 24 | def self.set_attr(attr_name, attributes, new_attributes) 25 | attributes[attr_name.to_sym] = new_attributes[attr_name] unless new_attributes[attr_name].nil? 26 | end 27 | 28 | def self.set_attr_and_sym(attr_name, attributes, new_attributes) 29 | set_attr(attr_name, attributes, new_attributes) 30 | set_attr(attr_name.to_sym, attributes, new_attributes) 31 | end 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/models/disks.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/compute/models/disk' 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Disks Collection of disk 26 | class Disks < Fog::Collection 27 | model Fog::Proxmox::Compute::Disk 28 | 29 | def all 30 | self 31 | end 32 | 33 | def get(id) 34 | all.find { |disk| disk.identity == id } 35 | end 36 | 37 | def next_device(controller) 38 | Fog::Proxmox::ControllerHelper.last_index(controller, self) + 1 39 | end 40 | 41 | def cdrom 42 | find(&:cdrom?) 43 | end 44 | 45 | def rootfs 46 | find(&:rootfs?) 47 | end 48 | 49 | def cloudinit 50 | find(&:cloud_init?) 51 | end 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/models/interface.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Tristan Robert 2 | 3 | # This file is part of Fog::Proxmox. 4 | 5 | # Fog::Proxmox is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # Fog::Proxmox is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with Fog::Proxmox. If not, see . 17 | 18 | # frozen_string_literal: true 19 | 20 | require 'fog/proxmox/helpers/nic_helper' 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Interface model 26 | class Interface < Fog::Model 27 | identity :id 28 | attribute :macaddr 29 | attribute :hwaddr 30 | attribute :model 31 | attribute :name 32 | attribute :ip 33 | attribute :ip6 34 | attribute :gw 35 | attribute :gw6 36 | attribute :bridge 37 | attribute :firewall 38 | attribute :link_down 39 | attribute :rate 40 | attribute :queues 41 | attribute :tag 42 | attribute :mtu 43 | attribute :trunks 44 | attribute :type 45 | 46 | def flatten 47 | Fog::Proxmox::NicHelper.flatten(attributes) 48 | end 49 | 50 | def to_s 51 | Fog::Proxmox::Hash.flatten(flatten) 52 | end 53 | end 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/models/interfaces.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/compute/models/interface' 21 | require 'fog/proxmox/helpers/controller_helper' 22 | 23 | module Fog 24 | module Proxmox 25 | class Compute 26 | # class Interfaces Collection of nodes of cluster 27 | class Interfaces < Fog::Collection 28 | model Fog::Proxmox::Compute::Interface 29 | 30 | def all 31 | self 32 | end 33 | 34 | def get(id) 35 | all.find { |interface| interface.identity == id } 36 | end 37 | 38 | def next_nicid 39 | Fog::Proxmox::ControllerHelper.last_index(Fog::Proxmox::Compute::Interface::NAME, self) + 1 40 | end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/models/nodes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/compute/models/node' 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Nodes Collection of nodes of cluster 26 | class Nodes < Fog::Collection 27 | model Fog::Proxmox::Compute::Node 28 | 29 | def all 30 | load service.list_nodes 31 | end 32 | 33 | def get(id) 34 | all.find { |node| node.identity == id } 35 | end 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/models/snapshots.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/compute/models/snapshot' 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Snapshots Collection of snapshots 26 | class Snapshots < Fog::Collection 27 | model Fog::Proxmox::Compute::Snapshot 28 | attribute :server_id 29 | attribute :server_type 30 | attribute :node_id 31 | 32 | def new(new_attributes = {}) 33 | super({ node_id: node_id, server_id: server_id, server_type: server_type }.merge(new_attributes)) 34 | end 35 | 36 | def all 37 | path_params = { node: node_id, type: server_type, vmid: server_id } 38 | load service.list_snapshots(path_params) 39 | end 40 | 41 | def get(name) 42 | all.find { |snapshot| snapshot.identity == name } 43 | end 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/models/storages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/compute/models/storage' 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Storages Collection of storages 26 | class Storages < Fog::Collection 27 | model Fog::Proxmox::Compute::Storage 28 | attribute :node_id 29 | 30 | def new(new_attributes = {}) 31 | super({ node_id: node_id }.merge(new_attributes)) 32 | end 33 | 34 | def all(filters = {}) 35 | requires :node_id 36 | load service.list_storages(node_id, filters) 37 | end 38 | 39 | def list_by_content_type(content) 40 | requires :node_id 41 | all.select { |storage| storage.content.include? content } 42 | end 43 | 44 | def get(id) 45 | requires :node_id 46 | all.find { |storage| storage.identity == id } 47 | end 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/models/tasks.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/compute/models/task' 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Tasks Collection of node 26 | class Tasks < Fog::Collection 27 | model Fog::Proxmox::Compute::Task 28 | attribute :node_id 29 | 30 | def new(new_attributes = {}) 31 | super({ node_id: node_id }.merge(new_attributes)) 32 | end 33 | 34 | def all(filters = {}) 35 | load service.list_tasks(node_id, filters) 36 | end 37 | 38 | def log(id) 39 | log = '' 40 | log_array = service.log_task(node_id, id, {}) 41 | log_array.each do |line_hash| 42 | log += line_hash['t'].to_s + "\n" 43 | end 44 | log 45 | end 46 | 47 | def get(id) 48 | status_details = service.status_task(node_id, id) 49 | task_hash = status_details.merge(log: log(id)) 50 | task_data = task_hash.merge(node_id: node_id, upid: id) 51 | new(task_data) 52 | end 53 | 54 | def wait_for(task_upid) 55 | task = get(task_upid) 56 | task.wait_for { finished? } 57 | message = "Task #{task_upid} failed because #{task.exitstatus}" 58 | raise Fog::Errors::Error, message unless task.succeeded? 59 | 60 | task.succeeded? 61 | end 62 | end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/models/volumes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/compute/models/volume' 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Volumes Collection of volumes 26 | class Volumes < Fog::Collection 27 | model Fog::Proxmox::Compute::Volume 28 | attribute :node_id 29 | attribute :storage_id 30 | 31 | def new(new_attributes = {}) 32 | super({ node_id: node_id, storage_id: storage_id }.merge(new_attributes)) 33 | end 34 | 35 | def all(filters = {}) 36 | load service.list_volumes(node_id, storage_id, filters) 37 | end 38 | 39 | def list_by_content_type(content) 40 | all.select { |volume| volume.content.include? content } 41 | end 42 | 43 | def list_by_content_type_and_by_server(_content, vmid) 44 | all(vmid: vmid) 45 | end 46 | 47 | def get(id) 48 | new service.get_volume(node: node_id, storage: storage_id, volume: id) 49 | end 50 | 51 | def destroy(id) 52 | volume = get(id) 53 | volume.destroy 54 | end 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/action_server.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real action_server request 24 | class Real 25 | def action_server(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | action = path_params[:action] 29 | vmid = path_params[:vmid] 30 | request( 31 | expects: [200], 32 | method: 'POST', 33 | path: "nodes/#{node}/#{type}/#{vmid}/status/#{action}", 34 | body: URI.encode_www_form(body_params) 35 | ) 36 | end 37 | end 38 | 39 | # class Mock action_server request 40 | class Mock 41 | def action_server(_path_params, _body_params); end 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/clone_server.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real clone_server request 24 | class Real 25 | def clone_server(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'POST', 32 | path: "nodes/#{node}/#{type}/#{vmid}/clone", 33 | body: URI.encode_www_form(body_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock clone_server request 39 | class Mock 40 | def clone_server(_path_params, _body_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/create_backup.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real create_backup request 24 | class Real 25 | def create_backup(path_params, body_params) 26 | node = path_params[:node] 27 | request( 28 | expects: [200], 29 | method: 'POST', 30 | path: "nodes/#{node}/vzdump", 31 | body: URI.encode_www_form(body_params) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock create_backup request 37 | class Mock 38 | def create_backup(_path_params, _body_params); end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/create_server.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real create_server request 24 | class Real 25 | def create_server(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | request( 29 | expects: [200], 30 | method: 'POST', 31 | path: "nodes/#{node}/#{type}", 32 | body: URI.encode_www_form(body_params) 33 | ) 34 | end 35 | end 36 | 37 | # class Mock create_server request 38 | class Mock 39 | def create_server(_path_params, _body_params); end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/create_snapshot.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real create_snapshot request 24 | class Real 25 | def create_snapshot(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'POST', 32 | path: "nodes/#{node}/#{type}/#{vmid}/snapshot", 33 | body: URI.encode_www_form(body_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock create_snapshot request 39 | class Mock 40 | def create_snapshot(_path_params, _body_params) 41 | 'UPID:proxmox:00003E13:6F21770F:5E37E2D0:qmsnapshot:100:root@pam:' 42 | end 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/create_spice.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real create_spice request 24 | class Real 25 | def create_spice(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'POST', 32 | path: "nodes/#{node}/#{type}/#{vmid}/spiceproxy", 33 | body: URI.encode_www_form(body_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock create_spice request 39 | class Mock 40 | def create_spice(_path_params, _body_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/create_term.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real create_term request 24 | class Real 25 | def create_term(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'POST', 32 | path: "nodes/#{node}/#{type}/#{vmid}/termproxy", 33 | body: URI.encode_www_form(body_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock create_term request 39 | class Mock 40 | def create_term(_path_params, _body_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/create_vnc.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real create_vnc request 24 | class Real 25 | def create_vnc(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'POST', 32 | path: "nodes/#{node}/#{type}/#{vmid}/vncproxy", 33 | body: URI.encode_www_form(body_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock create_vnc request 39 | class Mock 40 | def create_vnc(_path_params, _body_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/delete_server.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real delete_server request 25 | class Real 26 | def delete_server(path_params, body_params) 27 | node = path_params[:node] 28 | type = path_params[:type] 29 | vmid = path_params[:vmid] 30 | request( 31 | expects: [200], 32 | method: 'DELETE', 33 | path: "nodes/#{node}/#{type}/#{vmid}", 34 | body: URI.encode_www_form(body_params) 35 | ) 36 | end 37 | end 38 | 39 | # class Mock delete_server request 40 | class Mock 41 | def delete_server(_path_params, _body_params); end 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/delete_snapshot.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real delete_snapshot request 24 | class Real 25 | def delete_snapshot(path_params, query_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | snapname = path_params[:snapname] 30 | request( 31 | expects: [200], 32 | method: 'DELETE', 33 | path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}", 34 | query: URI.encode_www_form(query_params) 35 | ) 36 | end 37 | end 38 | 39 | # class Mock delete_snapshot request 40 | class Mock 41 | def delete_snapshot(_path_params, _query_params) 42 | 'UPID:proxmox:00002CC5:646E24B1:5E1C7E26:qmdelsnapshot:100:root@pam:' 43 | end 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/delete_volume.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real delete_volume request 24 | class Real 25 | def delete_volume(node, storage, volume) 26 | request( 27 | expects: [200], 28 | method: 'DELETE', 29 | path: "nodes/#{node}/storage/#{storage}/content/#{volume}" 30 | ) 31 | end 32 | end 33 | 34 | # class Mock delete_volume request 35 | class Mock 36 | def delete_volume(_node, _storage, _volume); end 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/get_node_statistics.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real get_node_statistics request 25 | class Real 26 | def get_node_statistics(path_params, query_params) 27 | node = path_params[:node] 28 | output = path_params[:output] 29 | request( 30 | expects: [200], 31 | method: 'GET', 32 | path: "nodes/#{node}/#{output}", 33 | query: URI.encode_www_form(query_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock get_statistics request 39 | class Mock 40 | def get_node_statistics(_path_params, _query_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/get_server_config.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real get_server_config request 24 | class Real 25 | def get_server_config(path_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'GET', 32 | path: "nodes/#{node}/#{type}/#{vmid}/config" 33 | ) 34 | end 35 | end 36 | 37 | # class Mock get_server_config request 38 | class Mock 39 | def get_server_config(_path_params) 40 | { 41 | onboot: 0, 42 | memory: 512, 43 | ostype: 'l26', 44 | cores: 1, 45 | keyboard: 'en-us', 46 | digest: nil, 47 | smbios1: nil, 48 | vmgenid: nil, 49 | balloon: 0, 50 | kvm: 0, 51 | cpu: 'cputype=kvm64', 52 | sockets: 1, 53 | bootdisk: 'scsi0', 54 | vga: 'std' 55 | } 56 | end 57 | end 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/get_server_status.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real get_server_status request 24 | class Real 25 | def get_server_status(path_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'GET', 32 | path: "nodes/#{node}/#{type}/#{vmid}/status/current" 33 | ) 34 | end 35 | end 36 | 37 | # class Mock get_server_status request 38 | class Mock 39 | def get_server_status(_path_params) 40 | { 41 | netout: 0, 42 | ha: { 'managed' => 0 }, 43 | mem: 0, 44 | vmid: '100', 45 | maxdisk: 8_589_934_592, 46 | diskread: 0, 47 | template: '', 48 | qmpstatus: 'stopped', 49 | diskwrite: 0, 50 | maxmem: 536_870_912, 51 | pid: nil, 52 | uptime: 0, 53 | status: 'stopped', 54 | cpu: 'cputype=kvm64', 55 | cpus: 1, 56 | disk: 0, 57 | netin: 0 58 | } 59 | end 60 | end 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/get_snapshot_config.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real get_snapshot_config request 24 | class Real 25 | def get_snapshot_config(path_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | snapname = path_params[:snapname] 30 | request( 31 | expects: [200], 32 | method: 'GET', 33 | path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}/config" 34 | ) 35 | end 36 | end 37 | 38 | # class Mock get_snapshot_config request 39 | class Mock 40 | def get_snapshot_config(_path_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/get_task.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real get_task collection 25 | class Real 26 | def get_task(node, upid) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "nodes/#{node}/tasks/#{upid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_task collection 36 | class Mock 37 | def get_task(_node, _upid); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/get_vnc.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real get_vnc request 24 | class Real 25 | def get_vnc(path_params, query_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [101, 200], 31 | method: 'GET', 32 | path: "nodes/#{node}/#{type}/#{vmid}/vncwebsocket", 33 | query: URI.encode_www_form(query_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock get_vnc request 39 | class Mock 40 | def get_vnc(_path_params, _query_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/get_volume.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | # frozen_string_literal: true 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Real get_volume request 26 | class Real 27 | def get_volume(node, storage, volume) 28 | request( 29 | expects: [200], 30 | method: 'GET', 31 | path: "nodes/#{node}/storage/#{storage}/content/#{volume}" 32 | ) 33 | end 34 | end 35 | 36 | # class Mock get_volume request 37 | class Mock 38 | def get_volume(_node, _storage, _volume); end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/list_nodes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real list_nodes request 25 | class Real 26 | def list_nodes 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: 'nodes' 31 | ) 32 | end 33 | end 34 | 35 | # class Mock list_nodes request 36 | class Mock 37 | def list_nodes 38 | [ 39 | { 40 | 'node' => 'proxmox', 41 | 'type' => 'node' 42 | } 43 | ] 44 | end 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/list_snapshots.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real list_snapshots request 24 | class Real 25 | def list_snapshots(path_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'GET', 32 | path: "nodes/#{node}/#{type}/#{vmid}/snapshot" 33 | ) 34 | end 35 | end 36 | 37 | # class Mock list_snapshots request 38 | class Mock 39 | def list_snapshots(_path_params) 40 | [ 41 | { 42 | 'name' => 'snapshot1', 43 | 'description' => 'latest snapshot', 44 | 'snaptime' => 1_578_057_452, 45 | 'vmstate' => 0, 46 | 'node_id' => 'proxmox', 47 | 'server_id' => '100', 48 | 'server_type' => 'qemu', 49 | 'vmgenid' => nil 50 | }, 51 | { 52 | 'name' => 'snapshot2', 53 | 'description' => 'latest snapshot2', 54 | 'snaptime' => 1_578_058_452, 55 | 'vmstate' => 0, 56 | 'node_id' => 'proxmox', 57 | 'server_id' => '100', 58 | 'server_type' => 'qemu', 59 | 'vmgenid' => nil 60 | } 61 | ] 62 | end 63 | end 64 | end 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/list_storages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | require 'fog/proxmox/json' 22 | 23 | module Fog 24 | module Proxmox 25 | class Compute 26 | # class Real list_storages request 27 | class Real 28 | def list_storages(node, options = {}) 29 | request( 30 | expects: [200], 31 | method: 'GET', 32 | path: "nodes/#{node}/storage", 33 | query: URI.encode_www_form(options) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock list_storages request 39 | class Mock 40 | def list_storages(_node, _options = {}) 41 | [] 42 | end 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/list_tasks.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real list_tasks request 25 | class Real 26 | def list_tasks(node, options) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "nodes/#{node}/tasks", 31 | query: URI.encode_www_form(options) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock list_tasks request 37 | class Mock 38 | def list_tasks(_node, _options = {}) 39 | [] 40 | end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/list_volumes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real list_volumes request 25 | class Real 26 | def list_volumes(node, storage, options) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "/nodes/#{node}/storage/#{storage}/content", 31 | query: URI.encode_www_form(options) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock list_volumes request 37 | class Mock 38 | def list_volumes(_node, _storage, _options = {}) 39 | [] 40 | end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/log_task.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real log_task 25 | class Real 26 | def log_task(node, upid, options) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "nodes/#{node}/tasks/#{upid}/log", 31 | query: URI.encode_www_form(options) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock status_task 37 | class Mock 38 | def log_task(_node, _upid, _options = {}) 39 | [{ 't' => 'TASK OK', 'n' => 1 }] 40 | end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/migrate_server.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real migrate_server request 24 | class Real 25 | def migrate_server(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'POST', 32 | path: "nodes/#{node}/#{type}/#{vmid}/migrate", 33 | body: URI.encode_www_form(body_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock migrate_server request 39 | class Mock 40 | def migrate_server(_path_params, _body_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/move_disk.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real move_disk request 24 | class Real 25 | def move_disk(path_params, body_params) 26 | node = path_params[:node] 27 | vmid = path_params[:vmid] 28 | request( 29 | expects: [200], 30 | method: 'POST', 31 | path: "nodes/#{node}/qemu/#{vmid}/move_disk", 32 | body: URI.encode_www_form(body_params) 33 | ) 34 | end 35 | end 36 | 37 | # class Mock move_disk request 38 | class Mock 39 | def move_disk(_path_params, _body_params); end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/move_volume.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real move_volume request 24 | class Real 25 | def move_volume(path_params, body_params) 26 | node = path_params[:node] 27 | vmid = path_params[:vmid] 28 | request( 29 | expects: [200], 30 | method: 'POST', 31 | path: "nodes/#{node}/lxc/#{vmid}/move_volume", 32 | body: URI.encode_www_form(body_params) 33 | ) 34 | end 35 | end 36 | 37 | # class Mock move_volume request 38 | class Mock 39 | def move_volume(_path_params, _body_params); end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/next_vmid.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real next_vmid collection 25 | class Real 26 | def next_vmid(options = {}) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: 'cluster/nextid', 31 | query: URI.encode_www_form(options) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock next_vmid collection 37 | class Mock 38 | def next_vmid; end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/resize_container.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real resize_container request 24 | class Real 25 | def resize_container(path_params, body_params) 26 | node = path_params[:node] 27 | vmid = path_params[:vmid] 28 | request( 29 | expects: [200], 30 | method: 'PUT', 31 | path: "nodes/#{node}/lxc/#{vmid}/resize", 32 | body: URI.encode_www_form(body_params) 33 | ) 34 | end 35 | end 36 | 37 | # class Mock resize_container request 38 | class Mock 39 | def resize_container(_path_params, _body_params); end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/resize_server.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real resize_server request 24 | class Real 25 | def resize_server(path_params, body_params) 26 | node = path_params[:node] 27 | vmid = path_params[:vmid] 28 | request( 29 | expects: [200], 30 | method: 'PUT', 31 | path: "nodes/#{node}/qemu/#{vmid}/resize", 32 | body: URI.encode_www_form(body_params) 33 | ) 34 | end 35 | end 36 | 37 | # class Mock resize_server request 38 | class Mock 39 | def resize_server(_path_params, _body_params); end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/rollback_snapshot.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | # frozen_string_literal: true 21 | 22 | module Fog 23 | module Proxmox 24 | class Compute 25 | # class Real rollback_snapshot request 26 | class Real 27 | def rollback_snapshot(path_params) 28 | node = path_params[:node] 29 | type = path_params[:type] 30 | vmid = path_params[:vmid] 31 | snapname = path_params[:snapname] 32 | request( 33 | expects: [200], 34 | method: 'POST', 35 | path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}/rollback" 36 | ) 37 | end 38 | end 39 | 40 | # class Mock rollback_snapshot request 41 | class Mock 42 | def rollback_snapshot(_path_params) 43 | 'UPID:proxmox:00002EBF:646E2BF3:5E1C7E39:qmrollback:100:root@pam:' 44 | end 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/status_task.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real status_task 25 | class Real 26 | def status_task(node, upid) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "nodes/#{node}/tasks/#{upid}/status" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock status_task 36 | class Mock 37 | def status_task(_node, _upid); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/stop_task.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Compute 24 | # class Real stop_task collection 25 | class Real 26 | def stop_task(node, upid) 27 | request( 28 | expects: [200], 29 | method: 'DELETE', 30 | path: "nodes/#{node}/tasks/#{upid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_task collection 36 | class Mock 37 | def stop_task(_node, _taskid); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/template_server.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real template_server request 24 | class Real 25 | def template_server(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: 'POST', 32 | path: "nodes/#{node}/#{type}/#{vmid}/template", 33 | body: URI.encode_www_form(body_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock template_server request 39 | class Mock 40 | def template_server(_path_params, _body_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/update_server.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real update_server request 24 | class Real 25 | def update_server(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | request( 30 | expects: [200], 31 | method: type == 'qemu' ? 'POST' : 'PUT', 32 | path: "nodes/#{node}/#{type}/#{vmid}/config", 33 | body: URI.encode_www_form(body_params) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock update_server request 39 | class Mock 40 | def update_server(_path_params, _body_params); end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/compute/requests/update_snapshot.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Compute 23 | # class Real update_snapshot request 24 | class Real 25 | def update_snapshot(path_params, body_params) 26 | node = path_params[:node] 27 | type = path_params[:type] 28 | vmid = path_params[:vmid] 29 | snapname = path_params[:snapname] 30 | request( 31 | expects: [200], 32 | method: 'PUT', 33 | path: "nodes/#{node}/#{type}/#{vmid}/snapshot/#{snapname}/config", 34 | body: URI.encode_www_form(body_params) 35 | ) 36 | end 37 | end 38 | 39 | # class Mock update_snapshot request 40 | class Mock 41 | def update_snapshot(_path_params, _body_params); end 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/fog/proxmox/errors.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | module Errors 23 | # class ServiceError 24 | class ServiceError < Fog::Errors::Error 25 | attr_reader :response_data 26 | 27 | def self.slurp(error) 28 | if error.response.body.empty? 29 | data = nil 30 | message = nil 31 | else 32 | data = Fog::JSON.decode(error.response.body) 33 | message = data['message'] 34 | data1 = data.values.first 35 | message = data1['message'] if message.nil? && !data1.nil? 36 | end 37 | 38 | new_error = super(error, message) 39 | new_error.instance_variable_set(:@response_data, data) 40 | new_error 41 | end 42 | end 43 | 44 | # class ServiceUnavailable error 45 | class ServiceUnavailable < ServiceError; end 46 | 47 | # class BadRequest error 48 | class BadRequest < ServiceError 49 | attr_reader :validation_errors 50 | 51 | def self.slurp(error) 52 | new_error = super(error) 53 | unless new_error.response_data.nil? || new_error.response_data['badRequest'].nil? 54 | new_error.instance_variable_set(:@validation_errors, 55 | new_error.response_data['badRequest']['validationErrors']) 56 | end 57 | new_error 58 | end 59 | end 60 | 61 | # class InterfaceNotImplemented error 62 | class InterfaceNotImplemented < Fog::Errors::Error; end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /lib/fog/proxmox/hash.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | # module Hash mixins 23 | module Hash 24 | def self.stringify(hash) 25 | filtered = hash.reject { |_key, value| value.nil? } 26 | a = filtered.to_a.collect { |item| item.join('=') } 27 | a.join(',') 28 | end 29 | 30 | def self.flatten(hash) 31 | filtered = hash.reject { |_key, value| value.nil? } 32 | a = filtered.to_a.collect { |item| item.join(': ') } 33 | a.join(',') 34 | end 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /lib/fog/proxmox/helpers/controller_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | # module ControllerHelper mixins 23 | module ControllerHelper 24 | CONTROLLERS = %w[ide sata scsi virtio mp rootfs].freeze 25 | def self.extract(name, controller_value) 26 | matches = controller_value.match(%r{,{0,1}#{name}={1}(?[\w/.:]+)}) 27 | matches ? matches[:name_value] : matches 28 | end 29 | 30 | def self.extract_index(name, key) 31 | matches = key.to_s.match(/#{name}(?\d+)/) 32 | index = matches ? matches[:index] : matches 33 | index ? index.to_i : -1 34 | end 35 | 36 | def self.valid?(name, key) 37 | key.to_s.match(/^#{name}(\d*)$/) 38 | end 39 | 40 | def self.last_index(name, values) 41 | return -1 if values.empty? 42 | 43 | indexes = [] 44 | values.each do |value| 45 | index = extract_index(name, value) 46 | indexes.push(index) if index 47 | end 48 | indexes.sort 49 | indexes.empty? ? -1 : indexes.last 50 | end 51 | 52 | def self.select(hash, name) 53 | hash.select { |key| valid?(name, key.to_s) } 54 | end 55 | 56 | def self.collect_controllers(attributes) 57 | controllers = {} 58 | CONTROLLERS.each { |controller| controllers.merge!(select(attributes, controller)) } 59 | controllers 60 | end 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/domain_type.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Tristan Robert 2 | 3 | # This file is part of Fog::Proxmox. 4 | 5 | # Fog::Proxmox is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # Fog::Proxmox is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with Fog::Proxmox. If not, see . 17 | 18 | module Fog 19 | module Proxmox 20 | class Identity 21 | # class Domain type model authentication 22 | class DomainType < Fog::Model 23 | identity :type 24 | attribute :id 25 | attribute :key 26 | attribute :url 27 | attribute :base_dn 28 | attribute :bind_dn 29 | attribute :capath 30 | attribute :cert 31 | attribute :certkey 32 | attribute :comment 33 | attribute :default 34 | attribute :domain 35 | attribute :port 36 | attribute :secure 37 | attribute :server1 38 | attribute :server2 39 | attribute :tfa 40 | attribute :user_attr 41 | attribute :verify 42 | attribute :step 43 | attribute :digits 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/domains.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/identity/models/domain' 21 | 22 | module Fog 23 | module Proxmox 24 | class Identity 25 | # class Domains collection authentication 26 | class Domains < Fog::Collection 27 | model Fog::Proxmox::Identity::Domain 28 | 29 | def all 30 | load service.list_domains 31 | end 32 | 33 | def get(id) 34 | all.find { |domain| domain.identity == id } 35 | end 36 | 37 | def destroy(id) 38 | domain = get(id) 39 | domain.destroy 40 | end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/group.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Tristan Robert 2 | 3 | # This file is part of Fog::Proxmox. 4 | 5 | # Fog::Proxmox is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # Fog::Proxmox is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with Fog::Proxmox. If not, see . 17 | 18 | # frozen_string_literal: true 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Group model authentication 24 | class Group < Fog::Model 25 | identity :groupid 26 | attribute :comment 27 | attribute :users 28 | attribute :members 29 | 30 | def save(options = {}) 31 | service.create_group((attributes.reject { |attribute| %i[users members].include? attribute }).merge(options)) 32 | reload 33 | end 34 | 35 | def destroy 36 | requires :groupid 37 | service.delete_group(groupid) 38 | true 39 | end 40 | 41 | def update 42 | requires :groupid 43 | service.update_group(identity, attributes.reject do |attribute| 44 | %i[groupid users members].include? attribute 45 | end) 46 | reload 47 | end 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/groups.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/identity/models/group' 21 | 22 | module Fog 23 | module Proxmox 24 | class Identity 25 | # class Groups authentication 26 | class Groups < Fog::Collection 27 | model Fog::Proxmox::Identity::Group 28 | 29 | def all 30 | load service.list_groups 31 | end 32 | 33 | def get(id) 34 | all.find { |group| group.identity == id } 35 | end 36 | 37 | def destroy(id) 38 | group = get(id) 39 | group.destroy 40 | end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/permission.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Permission 24 | class Permission < Fog::Model 25 | identity :type 26 | identity :roleid 27 | identity :path 28 | identity :ugid 29 | attribute :propagate 30 | 31 | def save 32 | service.update_permissions(to_update) 33 | end 34 | 35 | def destroy 36 | service.update_permissions(to_update.merge(delete: 1)) 37 | end 38 | 39 | private 40 | 41 | def initialize_roles(new_attributes = {}) 42 | roles = new_attributes.delete(:roleid) 43 | new_attributes.store(:roles, roles) 44 | end 45 | 46 | def initialize_ugid(new_attributes = {}) 47 | ugs = new_attributes.delete(:ugid) 48 | case type 49 | when 'user' 50 | new_attributes.store(:users, ugs) 51 | when 'group' 52 | new_attributes.store(:groups, ugs) 53 | end 54 | new_attributes.delete(:type) 55 | end 56 | 57 | def to_update 58 | new_attributes = attributes.clone 59 | initialize_roles(new_attributes) 60 | initialize_ugid(new_attributes) 61 | new_attributes 62 | end 63 | end 64 | end 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/permissions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/identity/models/permission' 21 | 22 | module Fog 23 | module Proxmox 24 | class Identity 25 | # class Permissions authentication 26 | class Permissions < Fog::Collection 27 | model Fog::Proxmox::Identity::Permission 28 | 29 | def all 30 | load service.list_permissions 31 | end 32 | 33 | def get(type, path, roleid, ugid) 34 | all.find do |permission| 35 | permission.type == type && permission.path == path && permission.roleid == roleid && permission.ugid == ugid 36 | end 37 | end 38 | 39 | def destroy(permission_hash) 40 | permission = new(permission_hash) 41 | permission.destroy 42 | end 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/pools.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/identity/models/pool' 21 | 22 | module Fog 23 | module Proxmox 24 | class Identity 25 | # class Pools Collection of pools of VMs 26 | class Pools < Fog::Collection 27 | model Fog::Proxmox::Identity::Pool 28 | 29 | def all 30 | pools_with_members = [] 31 | service.list_pools.each { |pool| pools_with_members.push(pool.merge(service.get_pool(pool['poolid']))) } 32 | load pools_with_members 33 | end 34 | 35 | def get(id) 36 | all.find { |pool| pool.identity == id } 37 | end 38 | 39 | def destroy(id) 40 | pool = get(id) 41 | pool.destroy 42 | end 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/principal.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # Copyright 2018 Tristan Robert 12 | 13 | # This file is part of Fog::Proxmox. 14 | 15 | # Fog::Proxmox is free software: you can redistribute it and/or modify 16 | # it under the terms of the GNU General Public License as published by 17 | # the Free Software Foundation, either version 3 of the License, or 18 | # (at your option) any later version. 19 | 20 | # Fog::Proxmox is distributed in the hope that it will be useful, 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | # GNU General Public License for more details. 24 | 25 | # You should have received a copy of the GNU General Public License 26 | # along with Fog::Proxmox. If not, see . 27 | 28 | module Fog 29 | module Proxmox 30 | class Identity 31 | # class Principal current user authenticated 32 | class Principal < Fog::Model 33 | identity :username 34 | attribute :password 35 | attribute :privs 36 | attribute :path 37 | attribute :otp 38 | attribute :realm 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/role.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Tristan Robert 2 | 3 | # This file is part of Fog::Proxmox. 4 | 5 | # Fog::Proxmox is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # Fog::Proxmox is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with Fog::Proxmox. If not, see . 17 | 18 | # frozen_string_literal: true 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Role model authentication 24 | class Role < Fog::Model 25 | identity :roleid 26 | attribute :privs 27 | attribute :special 28 | 29 | def save(options = {}) 30 | service.create_role(attributes.merge(options)) 31 | reload 32 | end 33 | 34 | def destroy 35 | requires :roleid 36 | service.delete_role(roleid) 37 | true 38 | end 39 | 40 | def update 41 | requires :roleid 42 | service.update_role(roleid, attributes.reject { |attribute| %i[roleid special].include? attribute }) 43 | reload 44 | end 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/roles.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/identity/models/role' 21 | 22 | module Fog 23 | module Proxmox 24 | class Identity 25 | # class Roles model collection authentication 26 | class Roles < Fog::Collection 27 | model Fog::Proxmox::Identity::Role 28 | 29 | def all 30 | load service.list_roles 31 | end 32 | 33 | def get(id) 34 | all.find { |role| role.identity == id } 35 | end 36 | 37 | def destroy(id) 38 | role = get(id) 39 | role.destroy 40 | end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/token_info.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Tristan Robert 2 | 3 | # This file is part of Fog::Proxmox. 4 | 5 | # Fog::Proxmox is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # Fog::Proxmox is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with Fog::Proxmox. If not, see . 17 | 18 | # frozen_string_literal: true 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class TokenInfo model 24 | class TokenInfo < Fog::Model 25 | identity :tokenid 26 | identity :userid 27 | attribute :fulltokenid 28 | attribute :info 29 | attribute :value 30 | 31 | def initialize(new_attributes = {}) 32 | prepare_service_value(new_attributes) 33 | Fog::Proxmox::Attributes.set_attr_and_sym('tokenid', attributes, new_attributes) 34 | Fog::Proxmox::Attributes.set_attr_and_sym('userid', attributes, new_attributes) 35 | requires :userid, :tokenid 36 | super(new_attributes) 37 | end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/tokens.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/identity/models/user' 21 | 22 | module Fog 23 | module Proxmox 24 | class Identity 25 | # class Tokens model collection 26 | class Tokens < Fog::Collection 27 | model Fog::Proxmox::Identity::Token 28 | attribute :userid 29 | 30 | def new(new_attributes = {}) 31 | super({ userid: userid }.merge(new_attributes)) 32 | end 33 | 34 | def get(tokenid) 35 | all.find { |token| token.tokenid == tokenid && token.userid == userid } 36 | end 37 | 38 | def all(_options = {}) 39 | load service.list_tokens(userid) 40 | rescue Excon::Error::InternalServerError => e 41 | raise e unless e.response.status_line.include? 'no such user' 42 | 43 | [] 44 | end 45 | 46 | def create(new_attributes = {}) 47 | object = new(new_attributes.select { |key, _value| %i[userid tokenid].include? key.to_sym }) 48 | object.save(new_attributes.reject { |key, _value| %i[userid tokenid].include? key.to_sym }) 49 | object 50 | end 51 | end 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/models/users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/identity/models/user' 21 | 22 | module Fog 23 | module Proxmox 24 | class Identity 25 | # class Users model collection 26 | class Users < Fog::Collection 27 | model Fog::Proxmox::Identity::User 28 | 29 | def all(filters = {}) 30 | load service.list_users(filters) 31 | end 32 | 33 | def get(id) 34 | all.find { |user| user.identity == id } 35 | end 36 | 37 | def destroy(id) 38 | user = get(id) 39 | user.destroy 40 | end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/change_password.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real change_password request 25 | class Real 26 | def change_password(userid, password) 27 | request( 28 | expects: [200], 29 | method: 'PUT', 30 | path: 'access/password', 31 | body: URI.encode_www_form(userid: userid, password: password) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock change_password request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/check_permissions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real check_permissions request 25 | class Real 26 | def check_permissions(principal) 27 | request( 28 | expects: [200], 29 | method: 'POST', 30 | path: 'access/ticket', 31 | body: URI.encode_www_form(principal) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock check_permissions request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/create_domain.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real create_domain collection 24 | class Real 25 | def create_domain(domain) 26 | request( 27 | expects: [200], 28 | method: 'POST', 29 | path: 'access/domains', 30 | body: URI.encode_www_form(domain) 31 | ) 32 | end 33 | end 34 | 35 | # class Mock create_domain collection 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/create_group.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real create_group request 24 | class Real 25 | def create_group(group) 26 | request( 27 | expects: [200], 28 | method: 'POST', 29 | path: 'access/groups', 30 | body: URI.encode_www_form(group) 31 | ) 32 | end 33 | end 34 | 35 | # class Mock create_group request 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/create_pool.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real create_pool request 24 | class Real 25 | def create_pool(pool) 26 | request( 27 | expects: [200], 28 | method: 'POST', 29 | path: 'pools', 30 | body: URI.encode_www_form(pool) 31 | ) 32 | end 33 | end 34 | 35 | # class Mock create_pool request 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/create_role.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real create_role request 24 | class Real 25 | def create_role(role) 26 | request( 27 | expects: [200], 28 | method: 'POST', 29 | path: 'access/roles', 30 | body: URI.encode_www_form(role) 31 | ) 32 | end 33 | end 34 | 35 | # class Mock create_role request 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/create_token.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real create_token request 24 | class Real 25 | def create_token(userid, tokenid, options) 26 | request( 27 | expects: [200], 28 | method: 'POST', 29 | path: "access/users/#{URI.encode_www_form_component(userid)}/token/#{tokenid}", 30 | body: URI.encode_www_form(options) 31 | ) 32 | end 33 | end 34 | 35 | # class Mock create_token request 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/create_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real create_user request 24 | class Real 25 | def create_user(user) 26 | request( 27 | expects: [200], 28 | method: 'POST', 29 | path: 'access/users', 30 | body: URI.encode_www_form(user) 31 | ) 32 | end 33 | end 34 | 35 | # class Mock create_user request 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/delete_domain.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real delete_domain collection 25 | class Real 26 | def delete_domain(realm) 27 | request( 28 | expects: [200], 29 | method: 'DELETE', 30 | path: "access/domains/#{realm}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock delete_domain collection 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/delete_group.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real delete_group request 25 | class Real 26 | def delete_group(groupid) 27 | request( 28 | expects: [200], 29 | method: 'DELETE', 30 | path: "access/groups/#{groupid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock delete_group request 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/delete_pool.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real delete_pool request 24 | class Real 25 | def delete_pool(poolid) 26 | request( 27 | expects: [200], 28 | method: 'DELETE', 29 | path: "pools/#{poolid}" 30 | ) 31 | end 32 | end 33 | 34 | # class Mock delete_pool request 35 | class Mock 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/delete_role.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real delete_role collection 25 | class Real 26 | def delete_role(roleid) 27 | request( 28 | expects: [200], 29 | method: 'DELETE', 30 | path: "access/roles/#{roleid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock delete_role collection 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/delete_token.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real delete_token request 25 | class Real 26 | def delete_token(userid, tokenid) 27 | request( 28 | expects: [200], 29 | method: 'DELETE', 30 | path: "access/users/#{URI.encode_www_form_component(userid)}/token/#{tokenid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock delete_token request 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/delete_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real delete_user request 24 | class Real 25 | def delete_user(userid) 26 | request( 27 | expects: [200], 28 | method: 'DELETE', 29 | path: "access/users/#{userid}" 30 | ) 31 | end 32 | end 33 | 34 | # class Real delete_user request 35 | class Mock 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/get_domain.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real get_domain request 25 | class Real 26 | def get_domain(realm) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "access/domains/#{realm}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_domain request 36 | class Mock 37 | def get_domain(realm); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/get_group.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real get_group collection 25 | class Real 26 | def get_group(groupid) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "access/groups/#{groupid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_group collection 36 | class Mock 37 | def get_group(groupid); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/get_pool.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real get_pool collection 25 | class Real 26 | def get_pool(poolid) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "pools/#{poolid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_pool collection 36 | class Mock 37 | def get_pool(poolid); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/get_role.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real get_role request 25 | class Real 26 | def get_role(roleid) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "access/roles/#{roleid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_role request 36 | class Mock 37 | def get_role(roleid); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/get_token_info.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real get_token_info request 25 | class Real 26 | def get_token_info(userid, tokenid) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "access/users/#{URI.encode_www_form_component(userid)}/token/#{tokenid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_token_info request 36 | class Mock 37 | def get_token_info(realm); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/get_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real get_user request 25 | class Real 26 | def get_user(userid) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "access/users/#{userid}" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_user request 36 | class Mock 37 | def get_user(userid); end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/list_domains.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real list_domains request 25 | class Real 26 | def list_domains 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: 'access/domains' 31 | ) 32 | end 33 | end 34 | 35 | # class Mock list_domains request 36 | class Mock 37 | def list_domains; end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/list_groups.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real list_groups request 25 | class Real 26 | def list_groups 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: 'access/groups' 31 | ) 32 | end 33 | end 34 | 35 | # class Mock list_groups request 36 | class Mock 37 | def list_groups; end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/list_permissions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real list_permissions request 25 | class Real 26 | def list_permissions 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: 'access/acl' 31 | ) 32 | end 33 | end 34 | 35 | # class Mock list_permissions request 36 | class Mock 37 | def list_permissions; end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/list_pools.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real list_pools request 25 | class Real 26 | def list_pools 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: 'pools' 31 | ) 32 | end 33 | end 34 | 35 | # class Mock list_pools request 36 | class Mock 37 | def list_pools; end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/list_roles.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Tristan Robert 2 | 3 | # This file is part of Fog::Proxmox. 4 | 5 | # Fog::Proxmox is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # Fog::Proxmox is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with Fog::Proxmox. If not, see . 17 | 18 | # frozen_string_literal: true 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real list_roles request 24 | class Real 25 | def list_roles 26 | request( 27 | expects: [200], 28 | method: 'GET', 29 | path: 'access/roles' 30 | ) 31 | end 32 | end 33 | 34 | # class Mock list_roles request 35 | class Mock 36 | def list_roles; end 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/list_tokens.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real list_tokens request 25 | class Real 26 | def list_tokens(userid) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "access/users/#{URI.encode_www_form_component(userid)}/token" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock list_tokens request 36 | class Mock 37 | def list_tokens; end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/list_user_permissions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real list_user_permissions request 25 | class Real 26 | def list_user_permissions(userid, path) 27 | options = { userid: userid } 28 | options.store(:path, path) if path 29 | request( 30 | expects: [200], 31 | method: 'GET', 32 | path: 'access/permissions', 33 | query: URI.encode_www_form(options) 34 | ) 35 | end 36 | end 37 | 38 | # class Mock list_user_permissions request 39 | class Mock 40 | def list_user_permissions; end 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/list_users.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real list_users request 25 | class Real 26 | def list_users(options = {}) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: 'access/users', 31 | query: options 32 | ) 33 | end 34 | end 35 | 36 | # class Mock list_users request 37 | class Mock 38 | def list_users(options = {}); end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/read_version.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Tristan Robert 2 | 3 | # This file is part of Fog::Proxmox. 4 | 5 | # Fog::Proxmox is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # Fog::Proxmox is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with Fog::Proxmox. If not, see . 17 | 18 | # frozen_string_literal: true 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real read_version request 24 | class Real 25 | def read_version 26 | request( 27 | expects: [200], 28 | method: 'GET', 29 | path: 'version' 30 | ) 31 | end 32 | end 33 | 34 | # class Mock read_version request 35 | class Mock 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/update_domain.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real update_domain request 25 | class Real 26 | def update_domain(realm, attributes) 27 | request( 28 | expects: [200], 29 | method: 'PUT', 30 | path: "access/domains/#{realm}", 31 | body: URI.encode_www_form(attributes) 32 | ) 33 | end 34 | end 35 | 36 | # class Real update_domain request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/update_group.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Tristan Robert 2 | 3 | # This file is part of Fog::Proxmox. 4 | 5 | # Fog::Proxmox is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | 10 | # Fog::Proxmox is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with Fog::Proxmox. If not, see . 17 | 18 | # frozen_string_literal: true 19 | 20 | module Fog 21 | module Proxmox 22 | class Identity 23 | # class Real update_group request 24 | class Real 25 | def update_group(groupid, options) 26 | request( 27 | expects: [200], 28 | method: 'PUT', 29 | path: "access/groups/#{groupid}", 30 | body: URI.encode_www_form(options) 31 | ) 32 | end 33 | end 34 | 35 | # class Mock update_group request 36 | class Mock 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/update_permissions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real update_permissions request 25 | class Real 26 | def update_permissions(body_params) 27 | request( 28 | expects: [200], 29 | method: 'PUT', 30 | path: 'access/acl', 31 | body: URI.encode_www_form(body_params) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock update_permissions request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/update_pool.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real update_pool request 25 | class Real 26 | def update_pool(poolid, attributes) 27 | request( 28 | expects: [200], 29 | method: 'PUT', 30 | path: "pools/#{poolid}", 31 | body: URI.encode_www_form(attributes) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock update_pool request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/update_role.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real update_role request 25 | class Real 26 | def update_role(roleid, attributes) 27 | request( 28 | expects: [200], 29 | method: 'PUT', 30 | path: "access/roles/#{roleid}", 31 | body: URI.encode_www_form(attributes) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock update_role request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/update_token.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real update_token request 25 | class Real 26 | def update_token(userid, tokenid, attributes) 27 | request( 28 | expects: [200], 29 | method: 'PUT', 30 | path: "access/users/#{URI.encode_www_form_component(userid)}/token/#{tokenid}", 31 | body: URI.encode_www_form(attributes) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock update_token request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/identity/requests/update_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Identity 24 | # class Real update_user request 25 | class Real 26 | def update_user(userid, attributes) 27 | request( 28 | expects: [200], 29 | method: 'PUT', 30 | path: "access/users/#{userid}", 31 | body: URI.encode_www_form(attributes) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock update_user request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/json.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/json' 21 | 22 | module Fog 23 | module Proxmox 24 | # module Json mixins 25 | module Json 26 | def self.get_data(response) 27 | body = JSON.decode(response.body) 28 | body['data'] 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/models/networks.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/network/models/node' 21 | 22 | module Fog 23 | module Proxmox 24 | class Network 25 | # class Networks Collection of nodes of cluster 26 | class Networks < Fog::Collection 27 | model Fog::Proxmox::Network::Network 28 | attribute :node_id 29 | 30 | def new(attributes = {}) 31 | requires :node_id 32 | super({ node_id: node_id }.merge(attributes)) 33 | end 34 | 35 | def all(filters = {}) 36 | requires :node_id 37 | path_params = { node: node_id } 38 | query_params = filters 39 | load service.list_networks(path_params, query_params) 40 | end 41 | 42 | def get(id) 43 | all.find { |network| network.identity == id } 44 | end 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/models/nodes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'fog/proxmox/network/models/node' 21 | 22 | module Fog 23 | module Proxmox 24 | class Network 25 | # class Nodes Collection of nodes of cluster 26 | class Nodes < Fog::Collection 27 | model Fog::Proxmox::Network::Node 28 | 29 | def all 30 | load service.list_nodes 31 | end 32 | 33 | def get(id) 34 | all.find { |node| node.identity == id } 35 | end 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/requests/create_network.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Network 23 | # class Real create_network request 24 | class Real 25 | def create_network(path_params, body_params) 26 | node = path_params[:node] 27 | request( 28 | expects: [200], 29 | method: 'POST', 30 | path: "nodes/#{node}/network", 31 | body: URI.encode_www_form(body_params) 32 | ) 33 | end 34 | end 35 | 36 | # class Mock create_network request 37 | class Mock 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/requests/delete_network.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Network 24 | # class Real delete_network request 25 | class Real 26 | def delete_network(path_params) 27 | node = path_params[:node] 28 | iface = path_params[:iface] 29 | request( 30 | expects: [200], 31 | method: 'DELETE', 32 | path: "nodes/#{node}/network/#{iface}" 33 | ) 34 | end 35 | end 36 | 37 | # class Mock delete_network request 38 | class Mock 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/requests/get_network.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Network 24 | # class Real get_node request 25 | class Real 26 | def get_network(path_params) 27 | node = path_params[:node] 28 | iface = path_params[:iface] 29 | request( 30 | expects: [200], 31 | method: 'GET', 32 | path: "nodes/#{node}/network/#{iface}" 33 | ) 34 | end 35 | end 36 | 37 | # class Mock get_network request 38 | class Mock 39 | def get_network; end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/requests/get_node.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Network 24 | # class Real get_node request 25 | class Real 26 | def get_node(node) 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: "nodes/#{node}/status" 31 | ) 32 | end 33 | end 34 | 35 | # class Mock get_node request 36 | class Mock 37 | def get_node; end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/requests/list_networks.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Network 24 | # class Real list_networks request 25 | class Real 26 | def list_networks(path_params, query_params) 27 | node = path_params[:node] 28 | request( 29 | expects: [200], 30 | method: 'GET', 31 | path: "nodes/#{node}/network", 32 | query: URI.encode_www_form(query_params) 33 | ) 34 | end 35 | end 36 | 37 | # class Mock list_networks request 38 | class Mock 39 | def list_networks; end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/requests/list_nodes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Network 24 | # class Real list_nodes request 25 | class Real 26 | def list_nodes 27 | request( 28 | expects: [200], 29 | method: 'GET', 30 | path: 'cluster/resources', 31 | query: 'type=node' 32 | ) 33 | end 34 | end 35 | 36 | # class Mock list_nodes request 37 | class Mock 38 | def list_nodes; end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/requests/power_node.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | class Network 24 | # class Real power_node request 25 | class Real 26 | def power_node(path_params, body_params) 27 | node = path_params[:node] 28 | request( 29 | expects: [200], 30 | method: 'POST', 31 | path: "nodes/#{node}/status", 32 | body: URI.encode_www_form(body_params) 33 | ) 34 | end 35 | end 36 | 37 | # class Mock power_node request 38 | class Mock 39 | def power_node; end 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/fog/proxmox/network/requests/update_network.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | class Network 23 | # class Real update_network request 24 | class Real 25 | def update_network(path_params, body_params) 26 | node = path_params[:node] 27 | iface = path_params[:iface] 28 | request( 29 | expects: [200], 30 | method: 'PUT', 31 | path: "nodes/#{node}/network/#{iface}", 32 | body: URI.encode_www_form(body_params) 33 | ) 34 | end 35 | end 36 | 37 | # class Mock update_network request 38 | class Mock 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/fog/proxmox/storage.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | module Fog 22 | module Proxmox 23 | # Procmox storage service 24 | class Storage < Fog::Service 25 | # Models 26 | model_path 'fog/proxmox/storage' 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/fog/proxmox/string.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | # module String mixins 23 | module String 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 27 | 28 | raise ArgumentError, "invalid value for Boolean: \"#{text}\"" 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /lib/fog/proxmox/variables.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | # module Variables mixins 23 | module Variables 24 | def self.to_variables(instance, hash, prefix) 25 | hash.select { |key| key.to_s.start_with? prefix }.each do |key, value| 26 | instance.instance_variable_set "@#{key}".to_sym, value 27 | end 28 | end 29 | 30 | def self.to_hash(instance, prefix) 31 | hash = {} 32 | instance.instance_variables.select { |variable| variable.to_s.start_with? '@' + prefix }.each do |param| 33 | name = param.to_s[1..-1] 34 | hash.store(name.to_sym, instance.instance_variable_get(param)) 35 | end 36 | hash 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/fog/proxmox/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | module Fog 21 | module Proxmox 22 | VERSION = '0.15.1' 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /spec/fixtures/proxmox/compute/common_auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: post 5 | uri: https://192.168.56.101:8006/api2/json/access/ticket 6 | body: 7 | encoding: US-ASCII 8 | string: username=root%40pam&password=proxmox01 9 | headers: 10 | User-Agent: 11 | - fog-core/2.2.3 12 | Accept: 13 | - application/json 14 | response: 15 | status: 16 | code: 200 17 | message: OK 18 | headers: 19 | Cache-Control: 20 | - max-age=0 21 | Connection: 22 | - close, Keep-Alive 23 | Date: 24 | - Wed, 25 Nov 2020 13:40:06 GMT 25 | Pragma: 26 | - no-cache 27 | Server: 28 | - pve-api-daemon/3.0 29 | Content-Length: 30 | - '1167' 31 | Content-Type: 32 | - application/json;charset=UTF-8 33 | Expires: 34 | - Wed, 25 Nov 2020 13:40:06 GMT 35 | body: 36 | encoding: ASCII-8BIT 37 | string: '{"data":{"username":"root@pam","cap":{"storage":{"Datastore.AllocateSpace":1,"Datastore.Allocate":1,"Permissions.Modify":1,"Datastore.Audit":1,"Datastore.AllocateTemplate":1},"vms":{"VM.Config.Memory":1,"VM.Config.Disk":1,"VM.Migrate":1,"VM.Config.HWType":1,"VM.Snapshot.Rollback":1,"VM.Config.CPU":1,"VM.Allocate":1,"VM.Clone":1,"VM.Config.Network":1,"Permissions.Modify":1,"VM.Config.Options":1,"VM.Snapshot":1,"VM.Console":1,"VM.Backup":1,"VM.PowerMgmt":1,"VM.Monitor":1,"VM.Config.CDROM":1,"VM.Audit":1},"dc":{"Sys.Audit":1},"nodes":{"Sys.Audit":1,"Sys.Console":1,"Permissions.Modify":1,"Sys.Syslog":1,"Sys.Modify":1,"Sys.PowerMgmt":1},"access":{"User.Modify":1,"Permissions.Modify":1,"Group.Allocate":1}},"ticket":"PVE:root@pam:5FBE5EB6::g4qMFg0e3MKdn9WVHBLmbv0nBEx/ABBWlk4Gfe/wae+YGWnaw3XRUDvHbZudrd1UDYXpszaCbwIR2YJPhHMU8coLAFAYqIE3wtbfMQzGwwuHPPiNm3EeVOKx4SPtRqXJOSE9LBuAnDo9tmhEmZ7m8i0y4XVEwV68VghDAqxInStyIbI/1rIlMikgMKx1JApaK9+UlT5K7eAP7Lxpi8n+2wmcLgVaC34A+C8r2eJFiO+99zbEGjE6JZZLO384biMUbpoR0K56tuRxFE3Df9sRCLkEHQWD+AewWg887r3n3VMpcM250Fw7boFvRGjvFLlP0nBylFYmgf5AMrxbEI2eUw==","CSRFPreventionToken":"5FBE5EB6:VSdRDpLPnZZ5sus603Nds5Nu3o4VE02VdkljtT0/YHk"}}' 38 | http_version: 39 | recorded_at: Wed, 25 Nov 2020 13:40:08 GMT 40 | recorded_with: VCR 4.0.0 41 | -------------------------------------------------------------------------------- /spec/fixtures/proxmox/identity/auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: post 5 | uri: https://192.168.56.101:8006/api2/json/access/ticket 6 | body: 7 | encoding: US-ASCII 8 | string: username=root%40pam&password=proxmox01&privs=User.Modify&path=access&otp=proxmox01 9 | headers: 10 | User-Agent: 11 | - fog-core/2.2.3 12 | Cookie: 13 | - PVEAuthCookie=PVE:root@pam:5FBE5C9E::EhfVyMNwMTFijsEKxKntnYvXA0p6/xlCxG0hFU86+DdyenhV9kPrUvThmw7jAySfY0gdVEc1Jit2I8Ud3AEiJgLYMKLfQy2ruKslJXJb+WLct+JkkX9Yc6N4nHvVD0HsTkKPRgw8LSKAfaJRbfJ217GvOXO710IdLauP5QlZLBSatXwOY5AU4YmBN8D5TBAKzFZhzvOl5VwvRqzYlSWpcWVZ0XeNRlC+E9c42ivzQYbhRIZwhH1SlheJPejMzeiy8WsKJXLjbwKgpUUDGTf+RAzufTfss/mbEztqbUMVBQshvD/78my1eDF3x4YN+cuG4hFcCt+/piOMiS/fBCV1xg== 14 | Csrfpreventiontoken: 15 | - 5FBE5C9E:LqNLX5YAQF2AsSPReLeDtBYINrF6B/gHIZsYM6uAhTI 16 | response: 17 | status: 18 | code: 200 19 | message: OK 20 | headers: 21 | Cache-Control: 22 | - max-age=0 23 | Connection: 24 | - close, Keep-Alive 25 | Date: 26 | - Wed, 25 Nov 2020 13:31:10 GMT 27 | Pragma: 28 | - no-cache 29 | Server: 30 | - pve-api-daemon/3.0 31 | Content-Length: 32 | - '711' 33 | Content-Type: 34 | - application/json;charset=UTF-8 35 | Expires: 36 | - Wed, 25 Nov 2020 13:31:10 GMT 37 | body: 38 | encoding: ASCII-8BIT 39 | string: '{"data":{"username":"root@pam","cap":{"access":{"Group.Allocate":1,"Permissions.Modify":1,"User.Modify":1},"nodes":{"Sys.Audit":1,"Permissions.Modify":1,"Sys.Syslog":1,"Sys.Modify":1,"Sys.PowerMgmt":1,"Sys.Console":1},"dc":{"Sys.Audit":1},"vms":{"VM.Config.Disk":1,"VM.Config.Memory":1,"VM.Config.HWType":1,"VM.Migrate":1,"VM.Snapshot.Rollback":1,"VM.Config.Network":1,"Permissions.Modify":1,"VM.Clone":1,"VM.Allocate":1,"VM.Config.CPU":1,"VM.Console":1,"VM.Snapshot":1,"VM.Config.Options":1,"VM.Monitor":1,"VM.PowerMgmt":1,"VM.Backup":1,"VM.Audit":1,"VM.Config.CDROM":1},"storage":{"Datastore.AllocateTemplate":1,"Datastore.AllocateSpace":1,"Datastore.Audit":1,"Permissions.Modify":1,"Datastore.Allocate":1}}}}' 40 | http_version: 41 | recorded_at: Wed, 25 Nov 2020 13:31:12 GMT 42 | recorded_with: VCR 4.0.0 43 | -------------------------------------------------------------------------------- /spec/fixtures/proxmox/identity/auth_user_token.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: https://192.168.56.101:8006/api2/json/access/users/root@pam/token/root1 6 | body: 7 | encoding: UTF-8 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - fog-core/2.2.3 12 | Authorization: 13 | - PVEAPIToken=root@pam!root1=ed6402b4-641d-46b1-b20a-33ba9ba12f54 14 | Accept: 15 | - application/json 16 | response: 17 | status: 18 | code: 200 19 | message: OK 20 | headers: 21 | Cache-Control: 22 | - max-age=0 23 | Connection: 24 | - Keep-Alive 25 | Date: 26 | - Wed, 25 Nov 2020 13:31:10 GMT 27 | Pragma: 28 | - no-cache 29 | Server: 30 | - pve-api-daemon/3.0 31 | Content-Length: 32 | - '33' 33 | Content-Type: 34 | - application/json;charset=UTF-8 35 | Expires: 36 | - Wed, 25 Nov 2020 13:31:10 GMT 37 | body: 38 | encoding: ASCII-8BIT 39 | string: '{"data":{"privsep":0,"expire":0}}' 40 | http_version: 41 | recorded_at: Wed, 25 Nov 2020 13:31:12 GMT 42 | - request: 43 | method: get 44 | uri: https://192.168.56.101:8006/api2/json/access/users/root@pam/token/root1 45 | body: 46 | encoding: UTF-8 47 | string: '' 48 | headers: 49 | User-Agent: 50 | - fog-core/2.2.3 51 | Authorization: 52 | - PVEAPIToken=root@pam!root1=wrong_token 53 | Accept: 54 | - application/json 55 | response: 56 | status: 57 | code: 401 58 | message: invalid token value! 59 | headers: 60 | Cache-Control: 61 | - max-age=0 62 | Connection: 63 | - close 64 | Date: 65 | - Wed, 25 Nov 2020 13:31:10 GMT 66 | Pragma: 67 | - no-cache 68 | Server: 69 | - pve-api-daemon/3.0 70 | Expires: 71 | - Wed, 25 Nov 2020 13:31:10 GMT 72 | body: 73 | encoding: ASCII-8BIT 74 | string: '' 75 | http_version: 76 | recorded_at: Wed, 25 Nov 2020 13:31:15 GMT 77 | recorded_with: VCR 4.0.0 78 | -------------------------------------------------------------------------------- /spec/fixtures/proxmox/identity/common_auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: post 5 | uri: https://192.168.56.101:8006/api2/json/access/ticket 6 | body: 7 | encoding: US-ASCII 8 | string: username=root%40pam&password=proxmox01 9 | headers: 10 | User-Agent: 11 | - fog-core/2.2.3 12 | Accept: 13 | - application/json 14 | response: 15 | status: 16 | code: 200 17 | message: OK 18 | headers: 19 | Cache-Control: 20 | - max-age=0 21 | Connection: 22 | - close, Keep-Alive 23 | Date: 24 | - Wed, 25 Nov 2020 13:31:13 GMT 25 | Pragma: 26 | - no-cache 27 | Server: 28 | - pve-api-daemon/3.0 29 | Content-Length: 30 | - '1167' 31 | Content-Type: 32 | - application/json;charset=UTF-8 33 | Expires: 34 | - Wed, 25 Nov 2020 13:31:13 GMT 35 | body: 36 | encoding: ASCII-8BIT 37 | string: '{"data":{"CSRFPreventionToken":"5FBE5CA1:2wSP3B+yBkKcNAmclMMAg5dSN77eDCAsw6FKkloozig","username":"root@pam","ticket":"PVE:root@pam:5FBE5CA1::NIjZenTNJji1/kvngW1msoDJnS9qb8C7X0YJ/0budYl2Wr+KZY2y/qCFp23q9GYpjXQgWME0ArXwLKo26wQYpnCnPu1RfDVjBZYm+ynAlEU0f6GXUGWJo5SFXKcVRgG33PdlL79eQePF4E1hOpZvJ79r0EzGtBW3autHMOHtpAJMdgGO0HOxUhF1aEN4i3R/ysn8VQ1NVEMKKhRA/CYkExHRLi8yyMOxoVQ/YoBHMBEEZZz0BdASjk3sBFaDdm4tBMvjpY5kR7oH+X5878jmb6dXjpM6+iImacaR68ApPBSPPYYDlxpvqXaacjeVI8Ybu6485Mc90isfL3A0bfm+TA==","cap":{"storage":{"Datastore.AllocateTemplate":1,"Datastore.AllocateSpace":1,"Datastore.Allocate":1,"Datastore.Audit":1,"Permissions.Modify":1},"vms":{"VM.Config.Disk":1,"VM.Config.Memory":1,"VM.Snapshot.Rollback":1,"VM.Config.HWType":1,"VM.Migrate":1,"VM.Console":1,"VM.Snapshot":1,"VM.Config.Options":1,"Permissions.Modify":1,"VM.Clone":1,"VM.Config.Network":1,"VM.Allocate":1,"VM.Config.CPU":1,"VM.Audit":1,"VM.Config.CDROM":1,"VM.Monitor":1,"VM.PowerMgmt":1,"VM.Backup":1},"nodes":{"Sys.Console":1,"Sys.Syslog":1,"Sys.Modify":1,"Permissions.Modify":1,"Sys.PowerMgmt":1,"Sys.Audit":1},"access":{"User.Modify":1,"Permissions.Modify":1,"Group.Allocate":1},"dc":{"Sys.Audit":1}}}}' 38 | http_version: 39 | recorded_at: Wed, 25 Nov 2020 13:31:15 GMT 40 | recorded_with: VCR 4.0.0 41 | -------------------------------------------------------------------------------- /spec/fixtures/proxmox/identity/read_version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: get 5 | uri: https://192.168.56.101:8006/api2/json/version 6 | body: 7 | encoding: US-ASCII 8 | string: '' 9 | headers: 10 | User-Agent: 11 | - fog-core/2.2.3 12 | Cookie: 13 | - PVEAuthCookie=PVE:root@pam:5FBE5C9E::EhfVyMNwMTFijsEKxKntnYvXA0p6/xlCxG0hFU86+DdyenhV9kPrUvThmw7jAySfY0gdVEc1Jit2I8Ud3AEiJgLYMKLfQy2ruKslJXJb+WLct+JkkX9Yc6N4nHvVD0HsTkKPRgw8LSKAfaJRbfJ217GvOXO710IdLauP5QlZLBSatXwOY5AU4YmBN8D5TBAKzFZhzvOl5VwvRqzYlSWpcWVZ0XeNRlC+E9c42ivzQYbhRIZwhH1SlheJPejMzeiy8WsKJXLjbwKgpUUDGTf+RAzufTfss/mbEztqbUMVBQshvD/78my1eDF3x4YN+cuG4hFcCt+/piOMiS/fBCV1xg== 14 | response: 15 | status: 16 | code: 200 17 | message: OK 18 | headers: 19 | Cache-Control: 20 | - max-age=0 21 | Connection: 22 | - Keep-Alive 23 | Date: 24 | - Wed, 25 Nov 2020 13:31:10 GMT 25 | Pragma: 26 | - no-cache 27 | Server: 28 | - pve-api-daemon/3.0 29 | Content-Length: 30 | - '80' 31 | Content-Type: 32 | - application/json;charset=UTF-8 33 | Expires: 34 | - Wed, 25 Nov 2020 13:31:10 GMT 35 | body: 36 | encoding: ASCII-8BIT 37 | string: '{"data":{"release":"6.2","keyboard":"fr","repoid":"9824574a","version":"6.2-4"}}' 38 | http_version: 39 | recorded_at: Wed, 25 Nov 2020 13:31:12 GMT 40 | recorded_with: VCR 4.0.0 41 | -------------------------------------------------------------------------------- /spec/fixtures/proxmox/network/common_auth.yml: -------------------------------------------------------------------------------- 1 | --- 2 | http_interactions: 3 | - request: 4 | method: post 5 | uri: https://192.168.56.101:8006/api2/json/access/ticket 6 | body: 7 | encoding: US-ASCII 8 | string: username=root%40pam&password=proxmox01 9 | headers: 10 | User-Agent: 11 | - fog-core/2.2.3 12 | Accept: 13 | - application/json 14 | response: 15 | status: 16 | code: 200 17 | message: OK 18 | headers: 19 | Cache-Control: 20 | - max-age=0 21 | Connection: 22 | - close, Keep-Alive 23 | Date: 24 | - Wed, 25 Nov 2020 13:43:47 GMT 25 | Pragma: 26 | - no-cache 27 | Server: 28 | - pve-api-daemon/3.0 29 | Content-Length: 30 | - '1167' 31 | Content-Type: 32 | - application/json;charset=UTF-8 33 | Expires: 34 | - Wed, 25 Nov 2020 13:43:47 GMT 35 | body: 36 | encoding: ASCII-8BIT 37 | string: '{"data":{"CSRFPreventionToken":"5FBE5F93:tNCo7nHYIIdA46RVo8yPQg9ZcbtzibFl3lhAwDPkSqc","ticket":"PVE:root@pam:5FBE5F93::J4UGO/cW6NJLxU0fQy8AnxuJhKDkIa+ZLBLUIxlXYO3Nb1ocZ15jqoPl0EEOQpI2sohhmtGYo9bptqaPPH48rmaNKzIUtHjDAg/c425GgbhkSo2jYVeCWcTTEC+nDskOiMkjdE4HIiFLpk71IMEP93hGWJ4+mnUxOLfHsRDodWdJXoGoBlxiUBu0zirFLXR60i6WCK2oX82nPYXRJbsl4VRLYcOkYXnnfaUxYgOL0veZhKRcAWlVRKQ7/lkdG1iu3XlOvEeynqcT2xHs+Z158zALA+ZzAEQ6GYdvFFKr/xR57Kd8hfOhRumKx5EaDfdeYkZP/8ZVH48tEbTXrOEQHg==","cap":{"nodes":{"Sys.Console":1,"Sys.Audit":1,"Sys.PowerMgmt":1,"Permissions.Modify":1,"Sys.Modify":1,"Sys.Syslog":1},"access":{"Group.Allocate":1,"Permissions.Modify":1,"User.Modify":1},"dc":{"Sys.Audit":1},"vms":{"VM.Config.HWType":1,"VM.Migrate":1,"VM.Snapshot.Rollback":1,"VM.Config.Memory":1,"VM.Config.Disk":1,"VM.PowerMgmt":1,"VM.Monitor":1,"VM.Backup":1,"VM.Audit":1,"VM.Config.CDROM":1,"VM.Config.Network":1,"Permissions.Modify":1,"VM.Clone":1,"VM.Allocate":1,"VM.Config.CPU":1,"VM.Console":1,"VM.Config.Options":1,"VM.Snapshot":1},"storage":{"Datastore.Allocate":1,"Permissions.Modify":1,"Datastore.Audit":1,"Datastore.AllocateSpace":1,"Datastore.AllocateTemplate":1}},"username":"root@pam"}}' 38 | http_version: 39 | recorded_at: Wed, 25 Nov 2020 13:43:48 GMT 40 | recorded_with: VCR 4.0.0 41 | -------------------------------------------------------------------------------- /spec/fixtures/proxmox/pve.home: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFzTCCA7WgAwIBAgIUa5Qd49Zt/GzIid0nAlTcqvnGjXMwDQYJKoZIhvcNAQEL 3 | BQAwdjEkMCIGA1UEAwwbUHJveG1veCBWaXJ0dWFsIEVudmlyb25tZW50MS0wKwYD 4 | VQQLDCQzMjZiYjhhNC02OGFhLTQ4NTEtOGI1Mi04ZTNkNDVmNTE2ZjgxHzAdBgNV 5 | BAoMFlBWRSBDbHVzdGVyIE1hbmFnZXIgQ0EwHhcNMTkxMTIxMTQyMDI2WhcNMjkx 6 | MTE4MTQyMDI2WjB2MSQwIgYDVQQDDBtQcm94bW94IFZpcnR1YWwgRW52aXJvbm1l 7 | bnQxLTArBgNVBAsMJDMyNmJiOGE0LTY4YWEtNDg1MS04YjUyLThlM2Q0NWY1MTZm 8 | ODEfMB0GA1UECgwWUFZFIENsdXN0ZXIgTWFuYWdlciBDQTCCAiIwDQYJKoZIhvcN 9 | AQEBBQADggIPADCCAgoCggIBAKjNB3rlIr5HuKTAeKyxfodUMqiygEsIukEj0UEh 10 | ZcZQkFzNomVGB0C3S9hOWy1isW9lAr2I0lPmQqiZrs8qbFRJY0CBVRmzTIhr1ufo 11 | pZygEMzIBETEuMwm4Xe1qZE75N+JgwY2T1YNYZIsLDuxekU17K1SMCAldxoC+gKd 12 | x5a1AHUanowIHmy1MFmYPjWQI1+1UcJS7cK+g/Ro84sb+zTXtpeT/4dO1x9n6o7F 13 | bq3cJKmXakRFxIeD4zeYktt+1VSxnwoKaTxO1zhk99kGQ3PpVfZ0tzpb97T8m+BQ 14 | pAkUYpk/3cNGMW4x7XV21lD7bDtJFN/wH6vYxal61qTsZVVtxzXnKYviC69mLaCh 15 | W+L4Ph2P4VqdzQLFaIjoNyFN7kqwBkFGwe0nReP5+L3y/tBn2od3aKsOE1NazfNH 16 | m2rJ94nc20g0PLmVKFshuoDAlL0byaBBnfN86rJsIyON9kyWsOGBIGxTtc46q7xO 17 | w8YjSdkZ9tSRklr/+eqWdpnY6zSxROUBC22HubgIVBCuA4Ddql8ZcSpILotcaJnr 18 | H+Gcfzj5tYrLlQR1P2W1bRLcV9NEud5550vkj84qXLKF8Le6PHLmdMm+f5qwOzMN 19 | 1A7/Mhpv4nCbGZSVTf6amRwlYO2BYppPBfThFUxh4RTSVRuu8xeTUKZ0Sn2SbIJw 20 | 6oinAgMBAAGjUzBRMB0GA1UdDgQWBBQhUE8yP/5NnaEc3k6wWCnZcl42JDAfBgNV 21 | HSMEGDAWgBQhUE8yP/5NnaEc3k6wWCnZcl42JDAPBgNVHRMBAf8EBTADAQH/MA0G 22 | CSqGSIb3DQEBCwUAA4ICAQBUeugrWLHwqgv0DZNy9DsY+Z9yazuYlBdAI8nucbBJ 23 | DJvV/DmRnL66vQL9fmsfBxOTIDhtuZmu8RhxfQ6n1RiFkh2J87R3p9sf5+FRQ2tt 24 | bFBlLbbk9HxiIIhhL1/r6+A6huO49iC56Payu3ipJaGyacXkhXD8DwLNahO/lAZx 25 | g/7etkJIEQe5Rd6s0cwINq8VfwXC2WgSNzF4o5bej6uIOZP6ax19IyU4h3DDelYt 26 | rUPv7e3SsixfMwkuFL9giNhqubxffG/p/eTB5yzm89jMCDO1s5uIb/devGrXSVBA 27 | T7iLQraosiFB9/8si4pwOmkFVnyF2/9cQEzht78WQEP16t5bbpgTNvmd7f7oPHPR 28 | uB/W3qB/AGCKhlqm+/ZkJ9pvxm+jjb0X0SHf6tMXi8qBV7bnlqPyQJBG1ST+Vm/a 29 | KqALPcOieSl9VnlqesO5Axnflw07fOUb0VahvJm9qSTSWi1XR645tRt4UHs8nDAg 30 | DZyBXwboL5IvLg/pF1R/7V3srgyQ9sReoOrFZdjshS7u8SECy5sywIkPovxVOMhi 31 | yQylee3A+myNATvZpg8WZi0nLeTagCTNYv8jVQpQ+tHFNn9o8Jsy0pQ1sMWzwltI 32 | 6yxC+k11bRCKHYpHAdypeP154LtrHbbEmzCeF/4ZCDsAHr0XEsGQkXUrBtOzEwIM 33 | pw== 34 | -----END CERTIFICATE----- 35 | -------------------------------------------------------------------------------- /spec/hash_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'spec_helper' 21 | require 'fog/proxmox/hash' 22 | 23 | describe Fog::Proxmox::Hash do 24 | let(:net_vm) 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) do 28 | { id: 'net0', model: 'virtio', macaddr: '66:89:C5:59:AA:96', z: nil } 29 | end 30 | 31 | describe '#flatten' do 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', 34 | Fog::Proxmox::Hash.flatten(net_vm) 35 | end 36 | end 37 | 38 | describe '#stringify' do 39 | it 'returns stringify hash' do 40 | assert_equal 'id=net0,model=virtio,macaddr=66:89:C5:59:AA:96', Fog::Proxmox::Hash.stringify(net) 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /spec/network_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'spec_helper' 21 | require_relative './proxmox_vcr' 22 | 23 | describe Fog::Proxmox::Network do 24 | before :all do 25 | @proxmox_vcr = ProxmoxVCR.new( 26 | vcr_directory: 'spec/fixtures/proxmox/network', 27 | service_class: Fog::Proxmox::Network 28 | ) 29 | @service = @proxmox_vcr.service 30 | @proxmox_url = @proxmox_vcr.url 31 | @username = @proxmox_vcr.username 32 | @password = @proxmox_vcr.password 33 | @tokenid = @proxmox_vcr.tokenid 34 | @token = @proxmox_vcr.token 35 | end 36 | 37 | it 'CRUD networks' do 38 | VCR.use_cassette('networks') do 39 | net_hash = { 40 | iface: 'enp0s10', 41 | type: 'eth' 42 | } 43 | node = @service.nodes.all.first 44 | # Create 1st time 45 | node.networks.create(net_hash) 46 | # Find by id 47 | network = node.networks.get net_hash[:iface] 48 | _(network).wont_be_nil 49 | # Create 2nd time 50 | _(proc do 51 | node.networks.create(net_hash) 52 | end).must_raise Excon::Error::BadRequest 53 | # all networks 54 | networks_all = node.networks.all 55 | _(networks_all).wont_be_nil 56 | _(networks_all).wont_be_empty 57 | _(networks_all).must_include network 58 | # Update 59 | network.update(comments: 'test') 60 | node.power('reboot') 61 | sleep 60 62 | # Delete 63 | network.destroy 64 | node.power('reboot') 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Copyright 2018 Tristan Robert 3 | 4 | # This file is part of Fog::Proxmox. 5 | 6 | # Fog::Proxmox is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | 11 | # Fog::Proxmox is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | 16 | # You should have received a copy of the GNU General Public License 17 | # along with Fog::Proxmox. If not, see . 18 | 19 | # frozen_string_literal: true 20 | 21 | require 'simplecov' 22 | 23 | SimpleCov.start do 24 | add_filter '/spec/' 25 | add_group 'Core', 'lib/fog/proxmox' 26 | add_group 'Auth', 'lib/fog/proxmox/auth' 27 | add_group 'Identity', 'lib/fog/proxmox/identity' 28 | add_group 'Compute', 'lib/fog/proxmox/compute' 29 | add_group 'Network', 'lib/fog/proxmox/network' 30 | end 31 | 32 | require 'minitest/autorun' 33 | require 'vcr' 34 | require 'fog/core' 35 | require 'fog/proxmox' 36 | 37 | VCR.configure do |c| 38 | c.cassette_library_dir = 'spec/fixtures/proxmox' 39 | c.hook_into :webmock 40 | c.debug_logger = nil # use $stderr to debug 41 | end 42 | -------------------------------------------------------------------------------- /tasks/audit.rake: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'bundler/audit/task' 21 | 22 | Bundler::Audit::Task.new 23 | 24 | desc 'Run audit vulnerabilities' 25 | task audit: 'bundle:audit' 26 | -------------------------------------------------------------------------------- /tasks/lint.rake: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | require 'rubocop/rake_task' 21 | 22 | RuboCop::RakeTask.new 23 | -------------------------------------------------------------------------------- /tasks/test.rake: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Copyright 2018 Tristan Robert 4 | 5 | # This file is part of Fog::Proxmox. 6 | 7 | # Fog::Proxmox is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | 12 | # Fog::Proxmox is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | 17 | # You should have received a copy of the GNU General Public License 18 | # along with Fog::Proxmox. If not, see . 19 | 20 | namespace :spec do 21 | desc 'Run fog-proxmox spec/*' 22 | Rake::TestTask.new do |t| 23 | t.name = 'all' 24 | t.description = 'Run all specs' 25 | t.libs.push %w[lib spec] 26 | t.pattern = 'spec/**/*_spec.rb' 27 | t.verbose = true 28 | end 29 | 30 | desc 'Run fog-proxmox spec/helpers/*' 31 | Rake::TestTask.new do |t| 32 | t.name = 'helpers' 33 | t.description = 'Run helpers tests' 34 | t.libs.push %w[lib spec] 35 | t.pattern = 'spec/helpers/**/*_spec.rb' 36 | t.verbose = true 37 | end 38 | 39 | desc 'Run fog-proxmox spec/compute' 40 | Rake::TestTask.new do |t| 41 | t.name = 'compute' 42 | t.description = 'Run compute API tests' 43 | t.libs.push %w[lib spec] 44 | t.pattern = 'spec/**/compute_spec.rb' 45 | t.verbose = true 46 | end 47 | 48 | desc 'Run fog-proxmox spec/identity' 49 | Rake::TestTask.new do |t| 50 | t.name = 'identity' 51 | t.description = 'Run identity API tests' 52 | t.libs.push %w[lib spec] 53 | t.pattern = 'spec/**/identity_spec.rb' 54 | t.verbose = true 55 | end 56 | 57 | desc 'Run fog-proxmox spec/network' 58 | Rake::TestTask.new do |t| 59 | t.name = 'network' 60 | t.description = 'Run network API tests' 61 | t.libs.push %w[lib spec] 62 | t.pattern = 'spec/**/network_spec.rb' 63 | t.verbose = true 64 | end 65 | end 66 | --------------------------------------------------------------------------------