fog-proxmox 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +4 -0
- data/.codeclimate.yml +14 -0
- data/.github/CODE_OF_CONDUCT.md +74 -0
- data/.github/CONTRIBUTING.md +20 -0
- data/.github/CONTRIBUTORS.md +9 -0
- data/.github/FUNDING.yml +12 -0
- data/.github/ISSUE_TEMPLATE.md +43 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.github/SUPPORT.md +9 -0
- data/.github/fogproxmox.png +0 -0
- data/.github/workflows/ci.yml +79 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +13 -0
- data/.ruby-gemset +1 -0
- data/.solargraph.yml +10 -0
- data/.vscode/launch.json +96 -0
- data/.vscode/settings.json +45 -0
- data/.vscode/tasks.json +27 -0
- data/Gemfile +23 -0
- data/LICENSE +674 -0
- data/README.md +79 -0
- data/Rakefile +58 -0
- data/docs/compute.md +858 -0
- data/docs/connection_parameters.md +45 -0
- data/docs/getting_started.md +53 -0
- data/docs/identity.md +357 -0
- data/examples/compute.rb +276 -0
- data/examples/identity.rb +190 -0
- data/fog-proxmox.gemspec +63 -0
- data/lib/fog/compute/proxmox.rb +126 -0
- data/lib/fog/compute/proxmox/models/disk.rb +76 -0
- data/lib/fog/compute/proxmox/models/disks.rb +51 -0
- data/lib/fog/compute/proxmox/models/interface.rb +52 -0
- data/lib/fog/compute/proxmox/models/interfaces.rb +44 -0
- data/lib/fog/compute/proxmox/models/node.rb +95 -0
- data/lib/fog/compute/proxmox/models/nodes.rb +39 -0
- data/lib/fog/compute/proxmox/models/server.rb +254 -0
- data/lib/fog/compute/proxmox/models/server_config.rb +148 -0
- data/lib/fog/compute/proxmox/models/servers.rb +80 -0
- data/lib/fog/compute/proxmox/models/snapshot.rb +83 -0
- data/lib/fog/compute/proxmox/models/snapshots.rb +47 -0
- data/lib/fog/compute/proxmox/models/storage.rb +64 -0
- data/lib/fog/compute/proxmox/models/storages.rb +51 -0
- data/lib/fog/compute/proxmox/models/task.rb +79 -0
- data/lib/fog/compute/proxmox/models/tasks.rb +64 -0
- data/lib/fog/compute/proxmox/models/volume.rb +61 -0
- data/lib/fog/compute/proxmox/models/volumes.rb +58 -0
- data/lib/fog/compute/proxmox/requests/action_server.rb +45 -0
- data/lib/fog/compute/proxmox/requests/clone_server.rb +44 -0
- data/lib/fog/compute/proxmox/requests/create_backup.rb +42 -0
- data/lib/fog/compute/proxmox/requests/create_server.rb +43 -0
- data/lib/fog/compute/proxmox/requests/create_snapshot.rb +46 -0
- data/lib/fog/compute/proxmox/requests/create_spice.rb +44 -0
- data/lib/fog/compute/proxmox/requests/create_term.rb +44 -0
- data/lib/fog/compute/proxmox/requests/create_vnc.rb +44 -0
- data/lib/fog/compute/proxmox/requests/delete_server.rb +45 -0
- data/lib/fog/compute/proxmox/requests/delete_snapshot.rb +47 -0
- data/lib/fog/compute/proxmox/requests/delete_volume.rb +40 -0
- data/lib/fog/compute/proxmox/requests/get_node_statistics.rb +44 -0
- data/lib/fog/compute/proxmox/requests/get_server_config.rb +60 -0
- data/lib/fog/compute/proxmox/requests/get_server_status.rb +63 -0
- data/lib/fog/compute/proxmox/requests/get_snapshot_config.rb +44 -0
- data/lib/fog/compute/proxmox/requests/get_task.rb +41 -0
- data/lib/fog/compute/proxmox/requests/get_vnc.rb +44 -0
- data/lib/fog/compute/proxmox/requests/get_volume.rb +42 -0
- data/lib/fog/compute/proxmox/requests/list_nodes.rb +48 -0
- data/lib/fog/compute/proxmox/requests/list_servers.rb +113 -0
- data/lib/fog/compute/proxmox/requests/list_snapshots.rb +66 -0
- data/lib/fog/compute/proxmox/requests/list_storages.rb +46 -0
- data/lib/fog/compute/proxmox/requests/list_tasks.rb +44 -0
- data/lib/fog/compute/proxmox/requests/list_volumes.rb +44 -0
- data/lib/fog/compute/proxmox/requests/log_task.rb +44 -0
- data/lib/fog/compute/proxmox/requests/migrate_server.rb +44 -0
- data/lib/fog/compute/proxmox/requests/move_disk.rb +43 -0
- data/lib/fog/compute/proxmox/requests/move_volume.rb +43 -0
- data/lib/fog/compute/proxmox/requests/next_vmid.rb +42 -0
- data/lib/fog/compute/proxmox/requests/resize_container.rb +43 -0
- data/lib/fog/compute/proxmox/requests/resize_server.rb +43 -0
- data/lib/fog/compute/proxmox/requests/rollback_snapshot.rb +48 -0
- data/lib/fog/compute/proxmox/requests/status_task.rb +41 -0
- data/lib/fog/compute/proxmox/requests/stop_task.rb +41 -0
- data/lib/fog/compute/proxmox/requests/template_server.rb +44 -0
- data/lib/fog/compute/proxmox/requests/update_server.rb +44 -0
- data/lib/fog/compute/proxmox/requests/update_snapshot.rb +45 -0
- data/lib/fog/identity/proxmox.rb +130 -0
- data/lib/fog/identity/proxmox/models/domain.rb +65 -0
- data/lib/fog/identity/proxmox/models/domain_type.rb +48 -0
- data/lib/fog/identity/proxmox/models/domains.rb +45 -0
- data/lib/fog/identity/proxmox/models/group.rb +47 -0
- data/lib/fog/identity/proxmox/models/groups.rb +44 -0
- data/lib/fog/identity/proxmox/models/permission.rb +65 -0
- data/lib/fog/identity/proxmox/models/permissions.rb +44 -0
- data/lib/fog/identity/proxmox/models/pool.rb +89 -0
- data/lib/fog/identity/proxmox/models/pools.rb +46 -0
- data/lib/fog/identity/proxmox/models/principal.rb +42 -0
- data/lib/fog/identity/proxmox/models/role.rb +48 -0
- data/lib/fog/identity/proxmox/models/roles.rb +44 -0
- data/lib/fog/identity/proxmox/models/user.rb +60 -0
- data/lib/fog/identity/proxmox/models/users.rb +44 -0
- data/lib/fog/identity/proxmox/requests/change_password.rb +41 -0
- data/lib/fog/identity/proxmox/requests/check_permissions.rb +41 -0
- data/lib/fog/identity/proxmox/requests/create_domain.rb +40 -0
- data/lib/fog/identity/proxmox/requests/create_group.rb +40 -0
- data/lib/fog/identity/proxmox/requests/create_pool.rb +40 -0
- data/lib/fog/identity/proxmox/requests/create_role.rb +40 -0
- data/lib/fog/identity/proxmox/requests/create_user.rb +40 -0
- data/lib/fog/identity/proxmox/requests/delete_domain.rb +40 -0
- data/lib/fog/identity/proxmox/requests/delete_group.rb +40 -0
- data/lib/fog/identity/proxmox/requests/delete_pool.rb +39 -0
- data/lib/fog/identity/proxmox/requests/delete_role.rb +40 -0
- data/lib/fog/identity/proxmox/requests/delete_user.rb +39 -0
- data/lib/fog/identity/proxmox/requests/get_domain.rb +41 -0
- data/lib/fog/identity/proxmox/requests/get_group.rb +41 -0
- data/lib/fog/identity/proxmox/requests/get_pool.rb +41 -0
- data/lib/fog/identity/proxmox/requests/get_role.rb +41 -0
- data/lib/fog/identity/proxmox/requests/get_user.rb +40 -0
- data/lib/fog/identity/proxmox/requests/list_domains.rb +41 -0
- data/lib/fog/identity/proxmox/requests/list_groups.rb +41 -0
- data/lib/fog/identity/proxmox/requests/list_permissions.rb +41 -0
- data/lib/fog/identity/proxmox/requests/list_pools.rb +41 -0
- data/lib/fog/identity/proxmox/requests/list_roles.rb +40 -0
- data/lib/fog/identity/proxmox/requests/list_users.rb +42 -0
- data/lib/fog/identity/proxmox/requests/read_version.rb +39 -0
- data/lib/fog/identity/proxmox/requests/update_domain.rb +41 -0
- data/lib/fog/identity/proxmox/requests/update_group.rb +40 -0
- data/lib/fog/identity/proxmox/requests/update_permissions.rb +41 -0
- data/lib/fog/identity/proxmox/requests/update_pool.rb +41 -0
- data/lib/fog/identity/proxmox/requests/update_role.rb +41 -0
- data/lib/fog/identity/proxmox/requests/update_user.rb +41 -0
- data/lib/fog/network/proxmox.rb +83 -0
- data/lib/fog/network/proxmox/models/network.rb +76 -0
- data/lib/fog/network/proxmox/models/networks.rb +48 -0
- data/lib/fog/network/proxmox/models/node.rb +74 -0
- data/lib/fog/network/proxmox/models/nodes.rb +39 -0
- data/lib/fog/network/proxmox/requests/create_network.rb +41 -0
- data/lib/fog/network/proxmox/requests/delete_network.rb +42 -0
- data/lib/fog/network/proxmox/requests/get_network.rb +43 -0
- data/lib/fog/network/proxmox/requests/get_node.rb +41 -0
- data/lib/fog/network/proxmox/requests/list_networks.rb +43 -0
- data/lib/fog/network/proxmox/requests/list_nodes.rb +42 -0
- data/lib/fog/network/proxmox/requests/power_node.rb +43 -0
- data/lib/fog/network/proxmox/requests/update_network.rb +42 -0
- data/lib/fog/proxmox.rb +115 -0
- data/lib/fog/proxmox/attributes.rb +33 -0
- data/lib/fog/proxmox/core.rb +135 -0
- data/lib/fog/proxmox/errors.rb +64 -0
- data/lib/fog/proxmox/hash.rb +39 -0
- data/lib/fog/proxmox/helpers/controller_helper.rb +64 -0
- data/lib/fog/proxmox/helpers/cpu_helper.rb +42 -0
- data/lib/fog/proxmox/helpers/disk_helper.rb +159 -0
- data/lib/fog/proxmox/helpers/ip_helper.rb +100 -0
- data/lib/fog/proxmox/helpers/nic_helper.rb +115 -0
- data/lib/fog/proxmox/json.rb +32 -0
- data/lib/fog/proxmox/string.rb +31 -0
- data/lib/fog/proxmox/variables.rb +40 -0
- data/lib/fog/proxmox/version.rb +24 -0
- data/lib/fog/storage/proxmox.rb +29 -0
- data/spec/compute_spec.rb +446 -0
- data/spec/fixtures/proxmox/compute/containers.yml +12737 -0
- data/spec/fixtures/proxmox/compute/identity_ticket.yml +40 -0
- data/spec/fixtures/proxmox/compute/nodes.yml +121 -0
- data/spec/fixtures/proxmox/compute/servers.yml +24679 -0
- data/spec/fixtures/proxmox/compute/snapshots.yml +3321 -0
- data/spec/fixtures/proxmox/compute/storages.yml +159 -0
- data/spec/fixtures/proxmox/compute/tasks.yml +685 -0
- data/spec/fixtures/proxmox/identity/auth.yml +44 -0
- data/spec/fixtures/proxmox/identity/domains.yml +701 -0
- data/spec/fixtures/proxmox/identity/groups.yml +363 -0
- data/spec/fixtures/proxmox/identity/identity_ticket.yml +40 -0
- data/spec/fixtures/proxmox/identity/permissions.yml +803 -0
- data/spec/fixtures/proxmox/identity/pools.yml +1191 -0
- data/spec/fixtures/proxmox/identity/read_version.yml +42 -0
- data/spec/fixtures/proxmox/identity/renew.yml +40 -0
- data/spec/fixtures/proxmox/identity/roles.yml +363 -0
- data/spec/fixtures/proxmox/identity/users.yml +763 -0
- data/spec/fixtures/proxmox/network/identity_ticket.yml +40 -0
- data/spec/fixtures/proxmox/network/networks.yml +372 -0
- data/spec/fixtures/proxmox/pve.home +34 -0
- data/spec/hash_spec.rb +42 -0
- data/spec/helpers/controller_helper_spec.rb +145 -0
- data/spec/helpers/cpu_helper_spec.rb +70 -0
- data/spec/helpers/disk_helper_spec.rb +210 -0
- data/spec/helpers/ip_helper_spec.rb +160 -0
- data/spec/helpers/nic_helper_spec.rb +136 -0
- data/spec/identity_spec.rb +322 -0
- data/spec/network_spec.rb +67 -0
- data/spec/proxmox_vcr.rb +95 -0
- data/spec/spec_helper.rb +40 -0
- metadata +547 -0
@@ -0,0 +1,39 @@
|
|
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 <http://www.gnu.org/licenses/>.
|
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
|
@@ -0,0 +1,41 @@
|
|
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 <http://www.gnu.org/licenses/>.
|
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
|
@@ -0,0 +1,40 @@
|
|
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 <http://www.gnu.org/licenses/>.
|
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
|
@@ -0,0 +1,41 @@
|
|
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 <http://www.gnu.org/licenses/>.
|
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
|
@@ -0,0 +1,41 @@
|
|
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 <http://www.gnu.org/licenses/>.
|
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
|
@@ -0,0 +1,41 @@
|
|
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 <http://www.gnu.org/licenses/>.
|
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
|
@@ -0,0 +1,41 @@
|
|
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 <http://www.gnu.org/licenses/>.
|
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
|
@@ -0,0 +1,83 @@
|
|
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 <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Fog
|
21
|
+
module Proxmox
|
22
|
+
# Proxmox network service
|
23
|
+
class Network < Fog::Service
|
24
|
+
requires :pve_url
|
25
|
+
recognizes :pve_ticket, :pve_path, :pve_ticket_expires, :pve_csrftoken, :persistent, :current_user, :pve_username, :pve_password
|
26
|
+
|
27
|
+
model_path 'fog/network/proxmox/models'
|
28
|
+
model :node
|
29
|
+
collection :nodes
|
30
|
+
model :network
|
31
|
+
collection :networks
|
32
|
+
|
33
|
+
request_path 'fog/network/proxmox/requests'
|
34
|
+
|
35
|
+
# Manage nodes cluster
|
36
|
+
request :list_nodes
|
37
|
+
request :get_node
|
38
|
+
request :power_node
|
39
|
+
|
40
|
+
# CRUD networks
|
41
|
+
request :list_networks
|
42
|
+
request :get_network
|
43
|
+
request :create_network
|
44
|
+
request :update_network
|
45
|
+
request :delete_network
|
46
|
+
|
47
|
+
# Mock class
|
48
|
+
class Mock
|
49
|
+
attr_reader :config
|
50
|
+
|
51
|
+
def initialize(options = {})
|
52
|
+
@pve_uri = URI.parse(options[:pve_url])
|
53
|
+
@pve_path = @pve_uri.path
|
54
|
+
@config = options
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Real class
|
59
|
+
class Real
|
60
|
+
include Fog::Proxmox::Core
|
61
|
+
def initialize(options = {})
|
62
|
+
initialize_identity(options)
|
63
|
+
@connection_options = options[:connection_options] || {}
|
64
|
+
@path_prefix = URI.parse(options[:pve_url]).path
|
65
|
+
authenticate
|
66
|
+
@persistent = options[:persistent] || false
|
67
|
+
url = "#{@scheme}://#{@host}:#{@port}"
|
68
|
+
@connection = Fog::Core::Connection.new(url, @persistent, @connection_options.merge(path_prefix: @path_prefix))
|
69
|
+
end
|
70
|
+
|
71
|
+
def config
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def configure(source)
|
76
|
+
source.instance_variables.each do |v|
|
77
|
+
instance_variable_set(v, source.instance_variable_get(v))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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
|
+
# Copyright 2018 Tristan Robert
|
11
|
+
|
12
|
+
# This file is part of Fog::Proxmox.
|
13
|
+
|
14
|
+
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
15
|
+
# it under the terms of the GNU General Public License as published by
|
16
|
+
# the Free Software Foundation, either version 3 of the License, or
|
17
|
+
# (at your option) any later version.
|
18
|
+
|
19
|
+
# Fog::Proxmox is distributed in the hope that it will be useful,
|
20
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22
|
+
# GNU General Public License for more details.
|
23
|
+
|
24
|
+
# You should have received a copy of the GNU General Public License
|
25
|
+
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
26
|
+
|
27
|
+
# frozen_string_literal: true
|
28
|
+
|
29
|
+
module Fog
|
30
|
+
module Proxmox
|
31
|
+
class Network
|
32
|
+
# class Network model
|
33
|
+
class Network < Fog::Model
|
34
|
+
identity :iface
|
35
|
+
attribute :node_id
|
36
|
+
attribute :comments
|
37
|
+
attribute :active
|
38
|
+
attribute :autostart
|
39
|
+
attribute :type
|
40
|
+
attribute :gateway
|
41
|
+
attribute :priority
|
42
|
+
attribute :exists
|
43
|
+
attribute :method
|
44
|
+
attribute :method6
|
45
|
+
attribute :netmask
|
46
|
+
attribute :address
|
47
|
+
attribute :families
|
48
|
+
attribute :bridge_stp
|
49
|
+
attribute :bridge_fd
|
50
|
+
attribute :bridge_ports
|
51
|
+
|
52
|
+
TYPES = %w[bridge bond eth alias vlan OVSBridge OVSBond OVSPort OVSIntPort any_bridge].freeze
|
53
|
+
|
54
|
+
def save(options = {})
|
55
|
+
requires :node_id
|
56
|
+
path_params = { node: node_id }
|
57
|
+
body_params = options.merge(attributes.reject { |attribute| [:node_id].include? attribute })
|
58
|
+
service.create_network(path_params, body_params)
|
59
|
+
end
|
60
|
+
|
61
|
+
def update(options = {})
|
62
|
+
requires :node_id, :iface, :type
|
63
|
+
path_params = { node: node_id, iface: iface }
|
64
|
+
body_params = options.merge(type: type)
|
65
|
+
service.update_network(path_params, body_params)
|
66
|
+
end
|
67
|
+
|
68
|
+
def destroy
|
69
|
+
requires :node_id, :iface
|
70
|
+
path_params = { node: node_id, iface: iface }
|
71
|
+
service.delete_network(path_params)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|