fog-proxmox 0.5.5 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +7 -0
- data/.travis.yml +1 -0
- data/.vscode/launch.json +3 -21
- data/.vscode/settings.json +7 -7
- data/Gemfile.lock +39 -39
- data/README.md +9 -2
- data/examples/compute.rb +20 -23
- data/examples/identity.rb +16 -21
- data/fog-proxmox.gemspec +1 -2
- data/lib/fog/compute/proxmox.rb +2 -8
- data/lib/fog/compute/proxmox/models/disk.rb +13 -11
- data/lib/fog/compute/proxmox/models/disks.rb +3 -5
- data/lib/fog/compute/proxmox/models/interface.rb +6 -11
- data/lib/fog/compute/proxmox/models/interfaces.rb +3 -5
- data/lib/fog/compute/proxmox/models/node.rb +38 -43
- data/lib/fog/compute/proxmox/models/nodes.rb +5 -11
- data/lib/fog/compute/proxmox/models/server.rb +123 -80
- data/lib/fog/compute/proxmox/models/server_config.rb +56 -24
- data/lib/fog/compute/proxmox/models/servers.rb +34 -26
- data/lib/fog/compute/proxmox/models/snapshot.rb +28 -14
- data/lib/fog/compute/proxmox/models/snapshots.rb +9 -17
- data/lib/fog/compute/proxmox/models/storage.rb +15 -11
- data/lib/fog/compute/proxmox/models/storages.rb +13 -22
- data/lib/fog/compute/proxmox/models/task.rb +10 -14
- data/lib/fog/compute/proxmox/models/tasks.rb +9 -18
- data/lib/fog/compute/proxmox/models/volume.rb +12 -12
- data/lib/fog/compute/proxmox/models/volumes.rb +10 -19
- data/lib/fog/compute/proxmox/requests/action_server.rb +1 -4
- data/lib/fog/compute/proxmox/requests/clone_server.rb +1 -4
- data/lib/fog/compute/proxmox/requests/create_backup.rb +1 -4
- data/lib/fog/compute/proxmox/requests/create_server.rb +1 -4
- data/lib/fog/compute/proxmox/requests/create_snapshot.rb +1 -4
- data/lib/fog/compute/proxmox/requests/create_spice.rb +1 -4
- data/lib/fog/compute/proxmox/requests/create_term.rb +1 -4
- data/lib/fog/compute/proxmox/requests/create_vnc.rb +1 -4
- data/lib/fog/compute/proxmox/requests/delete_server.rb +1 -4
- data/lib/fog/compute/proxmox/requests/delete_snapshot.rb +1 -4
- data/lib/fog/compute/proxmox/requests/get_node_statistics.rb +1 -4
- data/lib/fog/compute/proxmox/requests/get_server_config.rb +1 -4
- data/lib/fog/compute/proxmox/requests/get_server_status.rb +1 -4
- data/lib/fog/compute/proxmox/requests/{get_snapshot.rb → get_snapshot_config.rb} +5 -8
- data/lib/fog/compute/proxmox/requests/get_task.rb +1 -4
- data/lib/fog/compute/proxmox/requests/get_vnc.rb +1 -4
- data/lib/fog/compute/proxmox/requests/list_nodes.rb +1 -2
- data/lib/fog/compute/proxmox/requests/list_storages.rb +3 -1
- data/lib/fog/compute/proxmox/requests/log_task.rb +1 -4
- data/lib/fog/compute/proxmox/requests/move_disk.rb +1 -4
- data/lib/fog/compute/proxmox/requests/move_volume.rb +1 -4
- data/lib/fog/compute/proxmox/requests/next_vmid.rb +5 -3
- data/lib/fog/compute/proxmox/requests/resize_container.rb +1 -4
- data/lib/fog/compute/proxmox/requests/status_task.rb +1 -4
- data/lib/fog/compute/proxmox/requests/update_server.rb +1 -4
- data/lib/fog/identity/proxmox.rb +2 -8
- data/lib/fog/identity/proxmox/models/domain.rb +25 -21
- data/lib/fog/identity/proxmox/models/{ldap.rb → domain_type.rb} +9 -18
- data/lib/fog/identity/proxmox/models/domains.rb +6 -76
- data/lib/fog/identity/proxmox/models/group.rb +6 -19
- data/lib/fog/identity/proxmox/models/groups.rb +6 -12
- data/lib/fog/identity/proxmox/models/permission.rb +27 -31
- data/lib/fog/identity/proxmox/models/permissions.rb +8 -25
- data/lib/fog/identity/proxmox/models/pool.rb +9 -22
- data/lib/fog/identity/proxmox/models/pools.rb +7 -13
- data/lib/fog/identity/proxmox/models/principal.rb +1 -6
- data/lib/fog/identity/proxmox/models/role.rb +7 -20
- data/lib/fog/identity/proxmox/models/roles.rb +6 -13
- data/lib/fog/identity/proxmox/models/user.rb +7 -21
- data/lib/fog/identity/proxmox/models/users.rb +6 -12
- data/lib/fog/identity/proxmox/requests/check_permissions.rb +1 -4
- data/lib/fog/identity/proxmox/requests/list_roles.rb +0 -1
- data/lib/fog/identity/proxmox/requests/read_version.rb +1 -5
- data/lib/fog/identity/proxmox/requests/update_group.rb +2 -3
- data/lib/fog/identity/proxmox/requests/{add_permission.rb → update_permissions.rb} +4 -4
- data/lib/fog/network/proxmox/models/network.rb +12 -18
- data/lib/fog/network/proxmox/models/networks.rb +11 -17
- data/lib/fog/network/proxmox/models/node.rb +14 -10
- data/lib/fog/network/proxmox/models/nodes.rb +5 -11
- data/lib/fog/network/proxmox/requests/create_network.rb +1 -4
- data/lib/fog/network/proxmox/requests/delete_network.rb +1 -4
- data/lib/fog/network/proxmox/requests/get_network.rb +1 -4
- data/lib/fog/network/proxmox/requests/get_node.rb +1 -4
- data/lib/fog/network/proxmox/requests/power_node.rb +1 -4
- data/lib/fog/network/proxmox/requests/update_network.rb +1 -4
- data/lib/fog/{compute/proxmox/requests/check_vmid.rb → proxmox/attributes.rb} +9 -17
- data/lib/fog/proxmox/core.rb +2 -1
- data/lib/fog/proxmox/helpers/cpu_helper.rb +6 -3
- data/lib/fog/proxmox/helpers/disk_helper.rb +1 -1
- data/lib/fog/proxmox/helpers/nic_helper.rb +37 -22
- data/lib/fog/proxmox/version.rb +1 -1
- data/lib/fog/storage/proxmox.rb +1 -1
- data/spec/compute_spec.rb +64 -45
- data/spec/fixtures/proxmox/compute/containers.yml +1684 -4137
- data/spec/fixtures/proxmox/compute/identity_ticket.yml +4 -4
- data/spec/fixtures/proxmox/compute/nodes.yml +21 -21
- data/spec/fixtures/proxmox/compute/servers.yml +3065 -7741
- data/spec/fixtures/proxmox/compute/snapshots.yml +279 -827
- data/spec/fixtures/proxmox/compute/storages.yml +60 -21
- data/spec/fixtures/proxmox/compute/tasks.yml +56 -98
- data/spec/fixtures/proxmox/identity/auth.yml +6 -6
- data/spec/fixtures/proxmox/identity/domains.yml +252 -84
- data/spec/fixtures/proxmox/identity/groups.yml +93 -54
- data/spec/fixtures/proxmox/identity/identity_ticket.yml +4 -4
- data/spec/fixtures/proxmox/identity/permissions.yml +317 -79
- data/spec/fixtures/proxmox/identity/pools.yml +266 -71
- data/spec/fixtures/proxmox/identity/read_version.yml +6 -6
- data/spec/fixtures/proxmox/identity/roles.yml +96 -57
- data/spec/fixtures/proxmox/identity/users.yml +224 -107
- data/spec/fixtures/proxmox/network/identity_ticket.yml +4 -4
- data/spec/fixtures/proxmox/network/networks.yml +54 -95
- data/spec/helpers/nic_helper_spec.rb +4 -4
- data/spec/identity_spec.rb +38 -46
- data/spec/network_spec.rb +1 -1
- metadata +9 -23
- data/lib/fog/compute/proxmox/models/container.rb +0 -86
- data/lib/fog/compute/proxmox/models/container_config.rb +0 -114
- data/lib/fog/compute/proxmox/models/containers.rb +0 -43
- data/lib/fog/compute/proxmox/requests/get_node.rb +0 -44
- data/lib/fog/compute/proxmox/requests/get_storage.rb +0 -44
- data/lib/fog/identity/proxmox/models/activedirectory.rb +0 -57
- data/lib/fog/identity/proxmox/models/oath.rb +0 -50
- data/lib/fog/identity/proxmox/models/pam.rb +0 -46
- data/lib/fog/identity/proxmox/models/pve.rb +0 -46
- data/lib/fog/identity/proxmox/models/yubico.rb +0 -51
- data/lib/fog/identity/proxmox/requests/remove_permission.rb +0 -42
- data/lib/fog/proxmox/models/collection.rb +0 -85
- data/lib/fog/proxmox/models/model.rb +0 -58
@@ -17,18 +17,16 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
-
require 'fog/proxmox/
|
20
|
+
require 'fog/proxmox/attributes'
|
21
21
|
require 'fog/proxmox/helpers/nic_helper'
|
22
22
|
require 'fog/proxmox/helpers/controller_helper'
|
23
|
-
require 'fog/proxmox/models/model'
|
24
23
|
|
25
24
|
module Fog
|
26
25
|
module Compute
|
27
26
|
class Proxmox
|
28
27
|
# ServerConfig model
|
29
|
-
class ServerConfig < Fog::
|
28
|
+
class ServerConfig < Fog::Model
|
30
29
|
identity :vmid
|
31
|
-
attribute :digest
|
32
30
|
attribute :description
|
33
31
|
attribute :ostype
|
34
32
|
attribute :smbios1
|
@@ -52,24 +50,39 @@ module Fog
|
|
52
50
|
attribute :cpuunits
|
53
51
|
attribute :keyboard
|
54
52
|
attribute :vga
|
53
|
+
attribute :storage
|
54
|
+
attribute :template
|
55
|
+
attribute :arch
|
56
|
+
attribute :swap
|
57
|
+
attribute :hostname
|
58
|
+
attribute :nameserver
|
59
|
+
attribute :searchdomain
|
60
|
+
attribute :password
|
61
|
+
attribute :startup
|
62
|
+
attribute :console
|
63
|
+
attribute :cmode
|
64
|
+
attribute :tty
|
65
|
+
attribute :force
|
66
|
+
attribute :lock
|
67
|
+
attribute :pool
|
68
|
+
attribute :bwlimit
|
69
|
+
attribute :unprivileged
|
55
70
|
attribute :interfaces
|
56
71
|
attribute :disks
|
57
72
|
|
58
|
-
def initialize(
|
59
|
-
prepare_service_value(
|
60
|
-
|
61
|
-
|
62
|
-
|
73
|
+
def initialize(new_attributes = {})
|
74
|
+
prepare_service_value(new_attributes)
|
75
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('vmid', attributes, new_attributes)
|
76
|
+
requires :vmid
|
77
|
+
initialize_interfaces(new_attributes)
|
78
|
+
initialize_disks(new_attributes)
|
79
|
+
super(new_attributes)
|
63
80
|
end
|
64
81
|
|
65
82
|
def mac_addresses
|
66
83
|
Fog::Proxmox::NicHelper.to_mac_adresses_array(interfaces)
|
67
84
|
end
|
68
85
|
|
69
|
-
attr_reader :disks
|
70
|
-
|
71
|
-
attr_reader :interfaces
|
72
|
-
|
73
86
|
def type_console
|
74
87
|
console = 'vnc' if %w[std cirrus vmware].include?(vga)
|
75
88
|
console = 'spice' if %w[qxl qxl2 qxl3 qxl4].include?(vga)
|
@@ -77,26 +90,45 @@ module Fog
|
|
77
90
|
console
|
78
91
|
end
|
79
92
|
|
93
|
+
def flatten
|
94
|
+
flat_hash = attributes.reject { |attribute| [:node_id, :type, :vmid, :disks, :interfaces].include? attribute }
|
95
|
+
flat_hash.merge(interfaces_flatten)
|
96
|
+
flat_hash.merge(disks_flatten)
|
97
|
+
flat_hash
|
98
|
+
end
|
99
|
+
|
80
100
|
private
|
81
101
|
|
82
|
-
def
|
83
|
-
|
84
|
-
|
102
|
+
def interfaces_flatten
|
103
|
+
flat_hash = {}
|
104
|
+
interfaces.each { |interface| flat_hash.merge(interface.flatten) }
|
105
|
+
flat_hash
|
106
|
+
end
|
107
|
+
|
108
|
+
def disks_flatten
|
109
|
+
flat_hash = {}
|
110
|
+
disks.each { |disk| flat_hash.merge(disk.flatten) }
|
111
|
+
flat_hash
|
112
|
+
end
|
113
|
+
|
114
|
+
def initialize_interfaces(new_attributes)
|
115
|
+
nets = Fog::Proxmox::NicHelper.collect_nics(new_attributes)
|
116
|
+
attributes[:interfaces] = Fog::Compute::Proxmox::Interfaces.new
|
85
117
|
nets.each do |key, value|
|
86
118
|
nic_hash = {
|
87
119
|
id: key.to_s,
|
88
|
-
model: Fog::Proxmox::NicHelper.
|
120
|
+
model: Fog::Proxmox::NicHelper.extract_nic_id(value),
|
89
121
|
mac: Fog::Proxmox::NicHelper.extract_mac_address(value)
|
90
122
|
}
|
91
|
-
names = Fog::Compute::Proxmox::Interface.attributes.reject { |
|
123
|
+
names = Fog::Compute::Proxmox::Interface.attributes.reject { |attribute| [:id, :mac, :model].include? attribute }
|
92
124
|
names.each { |name| nic_hash.store(name.to_sym, Fog::Proxmox::ControllerHelper.extract(name, value)) }
|
93
|
-
|
125
|
+
attributes[:interfaces] << Fog::Compute::Proxmox::Interface.new(nic_hash)
|
94
126
|
end
|
95
127
|
end
|
96
128
|
|
97
|
-
def
|
98
|
-
controllers = Fog::Proxmox::ControllerHelper.collect_controllers(
|
99
|
-
|
129
|
+
def initialize_disks(new_attributes)
|
130
|
+
controllers = Fog::Proxmox::ControllerHelper.collect_controllers(new_attributes)
|
131
|
+
attributes[:disks] = Fog::Compute::Proxmox::Disks.new
|
100
132
|
controllers.each do |key, value|
|
101
133
|
storage, volid, size = Fog::Proxmox::DiskHelper.extract_storage_volid_size(value)
|
102
134
|
disk_hash = {
|
@@ -105,9 +137,9 @@ module Fog
|
|
105
137
|
volid: volid,
|
106
138
|
storage: storage
|
107
139
|
}
|
108
|
-
names = Fog::Compute::Proxmox::Disk.attributes.reject { |
|
140
|
+
names = Fog::Compute::Proxmox::Disk.attributes.reject { |attribute| [:id, :size, :storage, :volid].include? attribute }
|
109
141
|
names.each { |name| disk_hash.store(name.to_sym, Fog::Proxmox::ControllerHelper.extract(name, value)) }
|
110
|
-
|
142
|
+
attributes[:disks] << Fog::Compute::Proxmox::Disk.new(disk_hash)
|
111
143
|
end
|
112
144
|
end
|
113
145
|
end
|
@@ -23,48 +23,56 @@ module Fog
|
|
23
23
|
module Compute
|
24
24
|
class Proxmox
|
25
25
|
# Servers Collection
|
26
|
-
class Servers < Fog::
|
26
|
+
class Servers < Fog::Collection
|
27
27
|
model Fog::Compute::Proxmox::Server
|
28
|
-
attribute :
|
28
|
+
attribute :node_id
|
29
|
+
attribute :type
|
29
30
|
|
30
|
-
def
|
31
|
-
super(
|
32
|
-
end
|
33
|
-
|
34
|
-
def type
|
35
|
-
'qemu'
|
36
|
-
end
|
37
|
-
|
38
|
-
def new(attributes = {})
|
39
|
-
super({ node: node, type: type }.merge(attributes))
|
31
|
+
def new(new_attributes = {})
|
32
|
+
super({ node_id: node_id, type: type }.merge(new_attributes))
|
40
33
|
end
|
41
34
|
|
42
35
|
def next_id
|
43
|
-
|
44
|
-
body = JSON.decode(response.body)
|
45
|
-
data = body['data']
|
46
|
-
Integer(data)
|
36
|
+
service.next_vmid
|
47
37
|
end
|
48
38
|
|
49
39
|
def id_valid?(vmid)
|
50
|
-
service.
|
40
|
+
service.next_vmid(vmid: vmid)
|
51
41
|
true
|
52
42
|
rescue Excon::Errors::BadRequest
|
53
43
|
false
|
54
44
|
end
|
55
45
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
46
|
+
def containers?
|
47
|
+
type == 'lxc'
|
48
|
+
end
|
49
|
+
|
50
|
+
def get(id)
|
51
|
+
path_params = { node: node_id, type: type, vmid: id }
|
52
|
+
begin
|
53
|
+
status_data = service.get_server_status path_params
|
54
|
+
config_data = service.get_server_config path_params
|
55
|
+
rescue => e
|
56
|
+
if e.respond_to?('response') && e.response.respond_to?('data') && e.response.data.has_key?(:reason_phrase) && e.response.data[:reason_phrase].end_with?('does not exist')
|
57
|
+
raise(Fog::Errors::NotFound)
|
58
|
+
else
|
59
|
+
raise(e)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
data = status_data.merge(config_data).merge(node: node_id, vmid: id)
|
63
|
+
new(data)
|
64
|
+
end
|
63
65
|
end
|
64
66
|
|
65
67
|
def all(options = {})
|
66
|
-
body_params = options.merge(node:
|
67
|
-
|
68
|
+
body_params = options.merge(node: node_id, type: type)
|
69
|
+
load service.list_servers(body_params)
|
70
|
+
end
|
71
|
+
|
72
|
+
def create(new_attributes = {})
|
73
|
+
object = new(new_attributes.select { |key, _value| [:node_id, :vmid, :type].include? key.to_sym })
|
74
|
+
object.save(new_attributes.reject { |key, _value| [:node_id, :vmid, :type].include? key.to_sym })
|
75
|
+
object
|
68
76
|
end
|
69
77
|
end
|
70
78
|
end
|
@@ -25,45 +25,59 @@
|
|
25
25
|
# You should have received a copy of the GNU General Public License
|
26
26
|
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
27
27
|
|
28
|
-
require 'fog/proxmox/models/model'
|
29
|
-
|
30
28
|
module Fog
|
31
29
|
module Compute
|
32
30
|
class Proxmox
|
33
31
|
# class Snapshot model
|
34
|
-
class Snapshot < Fog::
|
32
|
+
class Snapshot < Fog::Model
|
35
33
|
identity :name
|
36
34
|
attribute :description
|
37
35
|
attribute :snaptime
|
38
36
|
attribute :vmstate
|
39
|
-
attribute :
|
37
|
+
attribute :node_id
|
38
|
+
attribute :server_id
|
39
|
+
attribute :server_type
|
40
|
+
attribute :vmgenid
|
41
|
+
|
42
|
+
def initialize(new_attributes = {})
|
43
|
+
prepare_service_value(new_attributes)
|
44
|
+
attributes[:node_id] = new_attributes[:node_id] unless new_attributes[:node_id].nil?
|
45
|
+
attributes[:server_id] = new_attributes[:server_id] unless new_attributes[:server_id].nil?
|
46
|
+
attributes[:server_type] = new_attributes[:server_type] unless new_attributes[:server_type].nil?
|
47
|
+
attributes[:name] = new_attributes[:name] unless new_attributes[:name].nil?
|
48
|
+
attributes[:name] = new_attributes['name'] unless new_attributes['name'].nil?
|
49
|
+
requires :node_id, :server_id, :server_type, :name
|
50
|
+
super(new_attributes)
|
51
|
+
end
|
40
52
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
body_params = options
|
53
|
+
def save
|
54
|
+
path_params = { node: node_id, type: server_type, vmid: server_id }
|
55
|
+
body_params = { snapname: name }
|
45
56
|
server.tasks.wait_for(service.create_snapshot(path_params, body_params))
|
46
57
|
end
|
47
58
|
|
48
59
|
def update
|
49
|
-
|
50
|
-
path_params = { node: server.node, type: server.type, vmid: server.vmid, snapname: name }
|
60
|
+
path_params = { node: node_id, type: server_type, vmid: server_id, snapname: name }
|
51
61
|
body_params = { description: description }
|
52
62
|
service.update_snapshot(path_params, body_params)
|
53
63
|
end
|
54
64
|
|
55
65
|
def rollback
|
56
|
-
|
57
|
-
path_params = { node: server.node, type: server.type, vmid: server.vmid, snapname: name }
|
66
|
+
path_params = { node: node_id, type: server_type, vmid: server_id, snapname: name }
|
58
67
|
server.tasks.wait_for(service.rollback_snapshot(path_params))
|
59
68
|
end
|
60
69
|
|
61
70
|
def destroy(force = 0)
|
62
|
-
|
63
|
-
path_params = { node: server.node, type: server.type, vmid: server.vmid, snapname: name }
|
71
|
+
path_params = { node: node_id, type: server_type, vmid: server_id, snapname: name }
|
64
72
|
query_params = { force: force }
|
65
73
|
server.tasks.wait_for(service.delete_snapshot(path_params, query_params))
|
66
74
|
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def server
|
79
|
+
Fog::Compute::Proxmox::Server.new(service: service, node_id: node_id, type: server_type, vmid: server_id)
|
80
|
+
end
|
67
81
|
end
|
68
82
|
end
|
69
83
|
end
|
@@ -17,37 +17,29 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
-
require 'fog/proxmox/models/collection'
|
21
20
|
require 'fog/compute/proxmox/models/snapshot'
|
22
21
|
|
23
22
|
module Fog
|
24
23
|
module Compute
|
25
24
|
class Proxmox
|
26
25
|
# class Snapshots Collection of snapshots
|
27
|
-
class Snapshots < Fog::
|
26
|
+
class Snapshots < Fog::Collection
|
28
27
|
model Fog::Compute::Proxmox::Snapshot
|
29
|
-
attribute :
|
28
|
+
attribute :server_id
|
29
|
+
attribute :server_type
|
30
|
+
attribute :node_id
|
30
31
|
|
31
|
-
def new(
|
32
|
-
|
33
|
-
super({ server: server }.merge!(attributes))
|
32
|
+
def new(new_attributes = {})
|
33
|
+
super({ node_id: node_id, server_id: server_id, server_type: server_type }.merge(new_attributes))
|
34
34
|
end
|
35
35
|
|
36
36
|
def all
|
37
|
-
|
38
|
-
|
39
|
-
load_response(service.list_snapshots(path_params), 'snapshots')
|
37
|
+
path_params = { node: node_id, type: server_type, vmid: server_id }
|
38
|
+
load service.list_snapshots(path_params)
|
40
39
|
end
|
41
40
|
|
42
41
|
def get(name)
|
43
|
-
|
44
|
-
cached_snapshot = find { |snapshot| snapshot.name == name }
|
45
|
-
return cached_snapshot if cached_snapshot
|
46
|
-
path_params = { node: server.node, type: server.type, vmid: server.vmid, snapname: name }
|
47
|
-
snapshot_hash = service.get_snapshot(path_params)
|
48
|
-
Fog::Compute::Proxmox::Snapshot.new(
|
49
|
-
snapshot_hash.merge(service: service, server: server, name: name)
|
50
|
-
)
|
42
|
+
all.find { |snapshot| snapshot.identity === name }
|
51
43
|
end
|
52
44
|
end
|
53
45
|
end
|
@@ -26,15 +26,13 @@
|
|
26
26
|
|
27
27
|
# frozen_string_literal: true
|
28
28
|
|
29
|
-
require 'fog/proxmox/models/model'
|
30
|
-
|
31
29
|
module Fog
|
32
30
|
module Compute
|
33
31
|
class Proxmox
|
34
32
|
# class Storage model
|
35
|
-
class Storage < Fog::
|
33
|
+
class Storage < Fog::Model
|
36
34
|
identity :storage
|
37
|
-
attribute :node
|
35
|
+
attribute :node_id, aliases: :node
|
38
36
|
attribute :content
|
39
37
|
attribute :type
|
40
38
|
attribute :avail
|
@@ -43,17 +41,23 @@ module Fog
|
|
43
41
|
attribute :shared
|
44
42
|
attribute :active
|
45
43
|
attribute :enabled
|
44
|
+
attribute :used_fraction
|
46
45
|
attribute :volumes
|
47
46
|
|
48
|
-
def
|
49
|
-
|
47
|
+
def initialize(new_attributes = {})
|
48
|
+
prepare_service_value(new_attributes)
|
49
|
+
attributes[:node_id] = new_attributes[:node_id] unless new_attributes[:node_id].nil?
|
50
|
+
attributes[:storage] = new_attributes[:storage] unless new_attributes[:storage].nil?
|
51
|
+
attributes[:storage] = new_attributes['storage'] unless new_attributes['storage'].nil?
|
52
|
+
requires :node_id, :storage
|
53
|
+
initialize_volumes
|
54
|
+
super(new_attributes)
|
50
55
|
end
|
51
56
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
+
private
|
58
|
+
|
59
|
+
def initialize_volumes
|
60
|
+
attributes[:volumes] = Fog::Compute::Proxmox::Volumes.new(service: service, node_id: node_id, storage_id: identity)
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
@@ -17,42 +17,33 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
-
require 'fog/proxmox/models/collection'
|
21
20
|
require 'fog/compute/proxmox/models/storage'
|
22
21
|
|
23
22
|
module Fog
|
24
23
|
module Compute
|
25
24
|
class Proxmox
|
26
25
|
# class Storages Collection of storages
|
27
|
-
class Storages < Fog::
|
26
|
+
class Storages < Fog::Collection
|
28
27
|
model Fog::Compute::Proxmox::Storage
|
29
|
-
attribute :
|
30
|
-
|
31
|
-
def new(
|
32
|
-
|
33
|
-
super({ node: node }.merge(attributes))
|
34
|
-
end
|
35
|
-
|
36
|
-
def all
|
37
|
-
search
|
28
|
+
attribute :node_id
|
29
|
+
|
30
|
+
def new(new_attributes = {})
|
31
|
+
super({ node_id: node_id }.merge(new_attributes))
|
38
32
|
end
|
39
33
|
|
40
|
-
def
|
41
|
-
requires :
|
42
|
-
|
34
|
+
def all(filters = {})
|
35
|
+
requires :node_id
|
36
|
+
load service.list_storages(node_id, filters)
|
43
37
|
end
|
44
38
|
|
45
39
|
def list_by_content_type(content)
|
46
|
-
|
40
|
+
requires :node_id
|
41
|
+
all.select { |storage| storage.content.include? content }
|
47
42
|
end
|
48
43
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
storage_hash = service.get_storage(node, id, {})
|
53
|
-
Fog::Compute::Proxmox::Storage.new(
|
54
|
-
storage_hash.merge(service: service)
|
55
|
-
)
|
44
|
+
def get(id)
|
45
|
+
requires :node_id
|
46
|
+
all.find { |storage| storage.identity === id }
|
56
47
|
end
|
57
48
|
end
|
58
49
|
end
|
@@ -26,15 +26,13 @@
|
|
26
26
|
|
27
27
|
# frozen_string_literal: true
|
28
28
|
|
29
|
-
require 'fog/proxmox/models/model'
|
30
|
-
|
31
29
|
module Fog
|
32
30
|
module Compute
|
33
31
|
class Proxmox
|
34
32
|
# class Task model of a node
|
35
|
-
class Task < Fog::
|
33
|
+
class Task < Fog::Model
|
36
34
|
identity :upid
|
37
|
-
attribute :node
|
35
|
+
attribute :node_id, aliases: :node
|
38
36
|
attribute :status
|
39
37
|
attribute :exitstatus
|
40
38
|
attribute :pid
|
@@ -47,13 +45,13 @@ module Fog
|
|
47
45
|
attribute :status_details
|
48
46
|
attribute :log
|
49
47
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
def initialize(new_attributes = {})
|
49
|
+
prepare_service_value(new_attributes)
|
50
|
+
attributes[:node_id] = new_attributes[:node_id] unless new_attributes[:node_id].nil?
|
51
|
+
attributes[:upid] = new_attributes[:upid] unless new_attributes[:upid].nil?
|
52
|
+
attributes[:upid] = new_attributes['upid'] unless new_attributes['upid'].nil?
|
53
|
+
requires :node_id, :upid
|
54
|
+
super(new_attributes)
|
57
55
|
end
|
58
56
|
|
59
57
|
def succeeded?
|
@@ -69,12 +67,10 @@ module Fog
|
|
69
67
|
end
|
70
68
|
|
71
69
|
def stop
|
72
|
-
|
73
|
-
service.stop_task(node, upid)
|
70
|
+
service.stop_task(node_id, upid)
|
74
71
|
end
|
75
72
|
|
76
73
|
def reload
|
77
|
-
requires :upid
|
78
74
|
object = collection.get(upid)
|
79
75
|
merge_attributes(object.attributes)
|
80
76
|
end
|