fog-proxmox-configlmm 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +8 -0
- data/LICENSE +674 -0
- data/README.md +110 -0
- data/docs/compute.md +874 -0
- data/docs/connection_parameters.md +45 -0
- data/docs/getting_started.md +53 -0
- data/docs/identity.md +382 -0
- data/examples/compute.rb +276 -0
- data/examples/identity.rb +203 -0
- data/lib/fog/proxmox/attributes.rb +34 -0
- data/lib/fog/proxmox/auth/token/access_ticket.rb +96 -0
- data/lib/fog/proxmox/auth/token/user_token.rb +107 -0
- data/lib/fog/proxmox/auth/token.rb +94 -0
- data/lib/fog/proxmox/compute/models/disk.rb +94 -0
- data/lib/fog/proxmox/compute/models/disks.rb +55 -0
- data/lib/fog/proxmox/compute/models/interface.rb +56 -0
- data/lib/fog/proxmox/compute/models/interfaces.rb +44 -0
- data/lib/fog/proxmox/compute/models/node.rb +93 -0
- data/lib/fog/proxmox/compute/models/nodes.rb +39 -0
- data/lib/fog/proxmox/compute/models/server.rb +271 -0
- data/lib/fog/proxmox/compute/models/server_config.rb +161 -0
- data/lib/fog/proxmox/compute/models/servers.rb +80 -0
- data/lib/fog/proxmox/compute/models/snapshot.rb +83 -0
- data/lib/fog/proxmox/compute/models/snapshots.rb +47 -0
- data/lib/fog/proxmox/compute/models/storage.rb +65 -0
- data/lib/fog/proxmox/compute/models/storages.rb +51 -0
- data/lib/fog/proxmox/compute/models/task.rb +79 -0
- data/lib/fog/proxmox/compute/models/tasks.rb +65 -0
- data/lib/fog/proxmox/compute/models/volume.rb +68 -0
- data/lib/fog/proxmox/compute/models/volumes.rb +58 -0
- data/lib/fog/proxmox/compute/requests/action_server.rb +45 -0
- data/lib/fog/proxmox/compute/requests/clone_server.rb +44 -0
- data/lib/fog/proxmox/compute/requests/create_backup.rb +42 -0
- data/lib/fog/proxmox/compute/requests/create_server.rb +43 -0
- data/lib/fog/proxmox/compute/requests/create_snapshot.rb +46 -0
- data/lib/fog/proxmox/compute/requests/create_spice.rb +44 -0
- data/lib/fog/proxmox/compute/requests/create_term.rb +45 -0
- data/lib/fog/proxmox/compute/requests/create_vnc.rb +44 -0
- data/lib/fog/proxmox/compute/requests/delete_server.rb +45 -0
- data/lib/fog/proxmox/compute/requests/delete_snapshot.rb +47 -0
- data/lib/fog/proxmox/compute/requests/delete_volume.rb +40 -0
- data/lib/fog/proxmox/compute/requests/get_node_statistics.rb +44 -0
- data/lib/fog/proxmox/compute/requests/get_server_config.rb +60 -0
- data/lib/fog/proxmox/compute/requests/get_server_status.rb +63 -0
- data/lib/fog/proxmox/compute/requests/get_snapshot_config.rb +44 -0
- data/lib/fog/proxmox/compute/requests/get_task.rb +41 -0
- data/lib/fog/proxmox/compute/requests/get_vnc.rb +45 -0
- data/lib/fog/proxmox/compute/requests/get_volume.rb +42 -0
- data/lib/fog/proxmox/compute/requests/list_nodes.rb +48 -0
- data/lib/fog/proxmox/compute/requests/list_servers.rb +113 -0
- data/lib/fog/proxmox/compute/requests/list_snapshots.rb +66 -0
- data/lib/fog/proxmox/compute/requests/list_storages.rb +46 -0
- data/lib/fog/proxmox/compute/requests/list_tasks.rb +44 -0
- data/lib/fog/proxmox/compute/requests/list_volumes.rb +44 -0
- data/lib/fog/proxmox/compute/requests/log_task.rb +44 -0
- data/lib/fog/proxmox/compute/requests/migrate_server.rb +44 -0
- data/lib/fog/proxmox/compute/requests/move_disk.rb +43 -0
- data/lib/fog/proxmox/compute/requests/move_volume.rb +43 -0
- data/lib/fog/proxmox/compute/requests/next_vmid.rb +42 -0
- data/lib/fog/proxmox/compute/requests/resize_container.rb +43 -0
- data/lib/fog/proxmox/compute/requests/resize_server.rb +43 -0
- data/lib/fog/proxmox/compute/requests/rollback_snapshot.rb +48 -0
- data/lib/fog/proxmox/compute/requests/status_task.rb +41 -0
- data/lib/fog/proxmox/compute/requests/stop_task.rb +41 -0
- data/lib/fog/proxmox/compute/requests/template_server.rb +44 -0
- data/lib/fog/proxmox/compute/requests/update_server.rb +44 -0
- data/lib/fog/proxmox/compute/requests/update_snapshot.rb +45 -0
- data/lib/fog/proxmox/compute.rb +141 -0
- data/lib/fog/proxmox/core.rb +147 -0
- data/lib/fog/proxmox/errors.rb +65 -0
- data/lib/fog/proxmox/hash.rb +37 -0
- data/lib/fog/proxmox/helpers/controller_helper.rb +63 -0
- data/lib/fog/proxmox/helpers/cpu_helper.rb +88 -0
- data/lib/fog/proxmox/helpers/disk_helper.rb +185 -0
- data/lib/fog/proxmox/helpers/ip_helper.rb +101 -0
- data/lib/fog/proxmox/helpers/nic_helper.rb +132 -0
- data/lib/fog/proxmox/identity/models/domain.rb +69 -0
- data/lib/fog/proxmox/identity/models/domain_type.rb +47 -0
- data/lib/fog/proxmox/identity/models/domains.rb +44 -0
- data/lib/fog/proxmox/identity/models/group.rb +51 -0
- data/lib/fog/proxmox/identity/models/groups.rb +44 -0
- data/lib/fog/proxmox/identity/models/permission.rb +66 -0
- data/lib/fog/proxmox/identity/models/permissions.rb +46 -0
- data/lib/fog/proxmox/identity/models/pool.rb +89 -0
- data/lib/fog/proxmox/identity/models/pools.rb +46 -0
- data/lib/fog/proxmox/identity/models/principal.rb +42 -0
- data/lib/fog/proxmox/identity/models/role.rb +48 -0
- data/lib/fog/proxmox/identity/models/roles.rb +44 -0
- data/lib/fog/proxmox/identity/models/token.rb +72 -0
- data/lib/fog/proxmox/identity/models/token_info.rb +41 -0
- data/lib/fog/proxmox/identity/models/tokens.rb +54 -0
- data/lib/fog/proxmox/identity/models/user.rb +82 -0
- data/lib/fog/proxmox/identity/models/users.rb +44 -0
- data/lib/fog/proxmox/identity/requests/change_password.rb +41 -0
- data/lib/fog/proxmox/identity/requests/check_permissions.rb +41 -0
- data/lib/fog/proxmox/identity/requests/create_domain.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_group.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_pool.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_role.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_token.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_user.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_domain.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_group.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_pool.rb +39 -0
- data/lib/fog/proxmox/identity/requests/delete_role.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_token.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_user.rb +39 -0
- data/lib/fog/proxmox/identity/requests/get_domain.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_group.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_pool.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_role.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_token_info.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_user.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_domains.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_groups.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_permissions.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_pools.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_roles.rb +40 -0
- data/lib/fog/proxmox/identity/requests/list_tokens.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_user_permissions.rb +44 -0
- data/lib/fog/proxmox/identity/requests/list_users.rb +42 -0
- data/lib/fog/proxmox/identity/requests/read_version.rb +39 -0
- data/lib/fog/proxmox/identity/requests/update_domain.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_group.rb +40 -0
- data/lib/fog/proxmox/identity/requests/update_permissions.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_pool.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_role.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_token.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_user.rb +41 -0
- data/lib/fog/proxmox/identity.rb +144 -0
- data/lib/fog/proxmox/json.rb +32 -0
- data/lib/fog/proxmox/network/models/network.rb +76 -0
- data/lib/fog/proxmox/network/models/networks.rb +48 -0
- data/lib/fog/proxmox/network/models/node.rb +75 -0
- data/lib/fog/proxmox/network/models/nodes.rb +39 -0
- data/lib/fog/proxmox/network/requests/create_network.rb +41 -0
- data/lib/fog/proxmox/network/requests/delete_network.rb +42 -0
- data/lib/fog/proxmox/network/requests/get_network.rb +43 -0
- data/lib/fog/proxmox/network/requests/get_node.rb +41 -0
- data/lib/fog/proxmox/network/requests/list_networks.rb +43 -0
- data/lib/fog/proxmox/network/requests/list_nodes.rb +42 -0
- data/lib/fog/proxmox/network/requests/power_node.rb +43 -0
- data/lib/fog/proxmox/network/requests/update_network.rb +42 -0
- data/lib/fog/proxmox/network.rb +90 -0
- data/lib/fog/proxmox/storage/requests/create.rb +23 -0
- data/lib/fog/proxmox/storage/requests/download_appliance.rb +24 -0
- data/lib/fog/proxmox/storage/requests/list.rb +22 -0
- data/lib/fog/proxmox/storage/requests/list_appliances.rb +23 -0
- data/lib/fog/proxmox/storage/requests/upload.rb +44 -0
- data/lib/fog/proxmox/storage.rb +82 -0
- data/lib/fog/proxmox/string.rb +32 -0
- data/lib/fog/proxmox/variables.rb +40 -0
- data/lib/fog/proxmox/version.rb +24 -0
- data/lib/fog/proxmox.rb +53 -0
- data/spec/compute_spec.rb +447 -0
- data/spec/fixtures/proxmox/compute/common_auth.yml +40 -0
- data/spec/fixtures/proxmox/compute/containers.yml +6921 -0
- data/spec/fixtures/proxmox/compute/nodes.yml +115 -0
- data/spec/fixtures/proxmox/compute/servers.yml +19011 -0
- data/spec/fixtures/proxmox/compute/snapshots.yml +1376 -0
- data/spec/fixtures/proxmox/compute/storages.yml +151 -0
- data/spec/fixtures/proxmox/compute/tasks.yml +465 -0
- data/spec/fixtures/proxmox/identity/auth.yml +42 -0
- data/spec/fixtures/proxmox/identity/auth_access_ticket.yml +77 -0
- data/spec/fixtures/proxmox/identity/auth_user_token.yml +77 -0
- data/spec/fixtures/proxmox/identity/common_auth.yml +40 -0
- data/spec/fixtures/proxmox/identity/domains.yml +665 -0
- data/spec/fixtures/proxmox/identity/groups.yml +345 -0
- data/spec/fixtures/proxmox/identity/permissions.yml +911 -0
- data/spec/fixtures/proxmox/identity/pools.yml +946 -0
- data/spec/fixtures/proxmox/identity/read_version.yml +40 -0
- data/spec/fixtures/proxmox/identity/roles.yml +345 -0
- data/spec/fixtures/proxmox/identity/tokens.yml +494 -0
- data/spec/fixtures/proxmox/identity/users.yml +725 -0
- data/spec/fixtures/proxmox/network/common_auth.yml +40 -0
- data/spec/fixtures/proxmox/network/networks.yml +375 -0
- data/spec/fixtures/proxmox/pve.home +34 -0
- data/spec/hash_spec.rb +43 -0
- data/spec/helpers/controller_helper_spec.rb +157 -0
- data/spec/helpers/cpu_helper_spec.rb +82 -0
- data/spec/helpers/disk_helper_spec.rb +304 -0
- data/spec/helpers/ip_helper_spec.rb +177 -0
- data/spec/helpers/nic_helper_spec.rb +144 -0
- data/spec/identity_spec.rb +416 -0
- data/spec/network_spec.rb +67 -0
- data/spec/proxmox_vcr.rb +97 -0
- data/spec/spec_helper.rb +41 -0
- metadata +566 -0
@@ -0,0 +1,65 @@
|
|
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 Compute
|
32
|
+
# class Storage model: https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/storage/{storage}
|
33
|
+
class Storage < Fog::Model
|
34
|
+
identity :storage
|
35
|
+
attribute :node_id, aliases: :node
|
36
|
+
attribute :content
|
37
|
+
attribute :type
|
38
|
+
attribute :avail
|
39
|
+
attribute :total
|
40
|
+
attribute :used
|
41
|
+
attribute :shared
|
42
|
+
attribute :active
|
43
|
+
attribute :enabled
|
44
|
+
attribute :used_fraction
|
45
|
+
attribute :volumes
|
46
|
+
|
47
|
+
def initialize(new_attributes = {})
|
48
|
+
prepare_service_value(new_attributes)
|
49
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
|
50
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('storage', attributes, new_attributes)
|
51
|
+
requires :node_id, :storage
|
52
|
+
initialize_volumes
|
53
|
+
super(new_attributes)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def initialize_volumes
|
59
|
+
attributes[:volumes] =
|
60
|
+
Fog::Proxmox::Compute::Volumes.new(service: service, node_id: node_id, storage_id: identity)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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
|
+
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
|
@@ -0,0 +1,79 @@
|
|
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 Compute
|
32
|
+
# class Task model of a node
|
33
|
+
class Task < Fog::Model
|
34
|
+
identity :upid
|
35
|
+
attribute :node_id, aliases: :node
|
36
|
+
attribute :status
|
37
|
+
attribute :exitstatus
|
38
|
+
attribute :pid
|
39
|
+
attribute :user
|
40
|
+
attribute :id, aliases: :vmid
|
41
|
+
attribute :type
|
42
|
+
attribute :pstart
|
43
|
+
attribute :starttime
|
44
|
+
attribute :endtime
|
45
|
+
attribute :status_details
|
46
|
+
attribute :log
|
47
|
+
|
48
|
+
def initialize(new_attributes = {})
|
49
|
+
prepare_service_value(new_attributes)
|
50
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
|
51
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('upid', attributes, new_attributes)
|
52
|
+
requires :node_id, :upid
|
53
|
+
super(new_attributes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def succeeded?
|
57
|
+
finished? && (exitstatus == 'OK' || exitstatus.include?('WARNING'))
|
58
|
+
end
|
59
|
+
|
60
|
+
def finished?
|
61
|
+
status == 'stopped'
|
62
|
+
end
|
63
|
+
|
64
|
+
def running?
|
65
|
+
status == 'running'
|
66
|
+
end
|
67
|
+
|
68
|
+
def stop
|
69
|
+
service.stop_task(node_id, upid)
|
70
|
+
end
|
71
|
+
|
72
|
+
def reload
|
73
|
+
object = collection.get(upid)
|
74
|
+
merge_attributes(object.attributes)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,65 @@
|
|
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
|
+
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
|
@@ -0,0 +1,68 @@
|
|
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
|
+
require 'fog/proxmox/helpers/disk_helper'
|
30
|
+
|
31
|
+
module Fog
|
32
|
+
module Proxmox
|
33
|
+
class Compute
|
34
|
+
# class Volume model: https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/storage/{storage}/content/{volume}
|
35
|
+
# size is in bytes
|
36
|
+
class Volume < Fog::Model
|
37
|
+
identity :volid
|
38
|
+
attribute :content
|
39
|
+
attribute :size
|
40
|
+
attribute :format
|
41
|
+
attribute :node_id
|
42
|
+
attribute :storage_id
|
43
|
+
attribute :vmid
|
44
|
+
|
45
|
+
def initialize(new_attributes = {})
|
46
|
+
prepare_service_value(new_attributes)
|
47
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
|
48
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('storage_id', attributes, new_attributes)
|
49
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('volid', attributes, new_attributes)
|
50
|
+
requires :node_id, :storage_id, :volid
|
51
|
+
super(new_attributes)
|
52
|
+
end
|
53
|
+
|
54
|
+
def destroy
|
55
|
+
service.delete_volume(node_id, storage_id, volid)
|
56
|
+
end
|
57
|
+
|
58
|
+
def restore(vmid, options = {})
|
59
|
+
service.create_server(node_id, options.merge(archive: volid, storage: storage_id, vmid: vmid))
|
60
|
+
end
|
61
|
+
|
62
|
+
def template?
|
63
|
+
Fog::Proxmox::DiskHelper.template?(volid)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,58 @@
|
|
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
|
+
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
|
@@ -0,0 +1,45 @@
|
|
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
|
+
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
|
@@ -0,0 +1,44 @@
|
|
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
|
+
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
|
@@ -0,0 +1,42 @@
|
|
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
|
+
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
|
@@ -0,0 +1,43 @@
|
|
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
|
+
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
|
@@ -0,0 +1,46 @@
|
|
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
|
+
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
|
@@ -0,0 +1,44 @@
|
|
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
|
+
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
|