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,98 +17,28 @@
|
|
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/identity/proxmox/models/domain'
|
22
21
|
|
23
22
|
module Fog
|
24
23
|
module Identity
|
25
24
|
class Proxmox
|
26
25
|
# class Domains collection authentication
|
27
|
-
class Domains < Fog::
|
26
|
+
class Domains < Fog::Collection
|
28
27
|
model Fog::Identity::Proxmox::Domain
|
29
28
|
|
30
|
-
def
|
31
|
-
|
32
|
-
type_value = hash['type']
|
33
|
-
tfa_value = hash['tfa']
|
34
|
-
type_hash = hash.reject { |k, _v| %w[realm type tfa].include? k }
|
35
|
-
type = to_type(type_value, type_hash)
|
36
|
-
tfa = to_tfa(tfa_value)
|
37
|
-
type.tfa = tfa if tfa
|
38
|
-
new(realm: realm, type: type)
|
29
|
+
def all
|
30
|
+
load service.list_domains
|
39
31
|
end
|
40
32
|
|
41
|
-
def
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
def find_by_id(id)
|
46
|
-
response = service.get_domain(id)
|
47
|
-
body = JSON.decode(response.body)
|
48
|
-
data = body['data']
|
49
|
-
data.store('realm', id)
|
50
|
-
data.delete_if { |k, _v| k == 'digest' }
|
51
|
-
to_domain(data)
|
33
|
+
def get(id)
|
34
|
+
all.find { |domain| domain.identity === id }
|
52
35
|
end
|
53
36
|
|
54
37
|
def destroy(id)
|
55
|
-
domain =
|
38
|
+
domain = get(id)
|
56
39
|
domain.destroy
|
57
40
|
end
|
58
41
|
|
59
|
-
def create(attributes = {})
|
60
|
-
domain = new(realm: attributes[:realm])
|
61
|
-
type_s = attributes[:type]
|
62
|
-
tfa_s = attributes[:tfa]
|
63
|
-
attr = attributes.reject { |k, _v| %i[realm type tfa].include? k }
|
64
|
-
domain.type = to_type(type_s, attr)
|
65
|
-
tfa = to_tfa(tfa_s)
|
66
|
-
domain.type.tfa = tfa if tfa
|
67
|
-
domain.create
|
68
|
-
end
|
69
|
-
|
70
|
-
def to_type(type, attributes)
|
71
|
-
type_class(type).new(attributes)
|
72
|
-
end
|
73
|
-
|
74
|
-
def to_tfa(tfa_s)
|
75
|
-
oath_rxp = /type=oath,step=(?<step>\d+),digits=(?<digits>\d+)/
|
76
|
-
yubico_rxp = /type=yubico,id=(?<id>\w+),key=(?<key>\w+),url=(?<url>.+)/
|
77
|
-
if oath_rxp.match(tfa_s)
|
78
|
-
attributes = oath_rxp.named_captures
|
79
|
-
type = 'oath'
|
80
|
-
elsif yubico_rxp.match(tfa_s)
|
81
|
-
attributes = yubico_rxp.named_captures
|
82
|
-
type = 'yubico'
|
83
|
-
end
|
84
|
-
tfa_class(type).new(attributes) if type && attributes
|
85
|
-
end
|
86
|
-
|
87
|
-
def type_class(type)
|
88
|
-
if type == 'pam'
|
89
|
-
type_class = Fog::Identity::Proxmox::Pam
|
90
|
-
elsif type == 'pve'
|
91
|
-
type_class = Fog::Identity::Proxmox::Pve
|
92
|
-
elsif type == 'ldap'
|
93
|
-
type_class = Fog::Identity::Proxmox::Ldap
|
94
|
-
elsif type == 'ad'
|
95
|
-
type_class = Fog::Identity::Proxmox::Activedirectory
|
96
|
-
else
|
97
|
-
raise Fog::Proxmox::Errors::NotFound, 'domain type unknown'
|
98
|
-
end
|
99
|
-
type_class
|
100
|
-
end
|
101
|
-
|
102
|
-
def tfa_class(tfa)
|
103
|
-
if tfa == 'oath'
|
104
|
-
tfa_class = Fog::Identity::Proxmox::Oath
|
105
|
-
elsif tfa == 'yubico'
|
106
|
-
tfa_class = Fog::Identity::Proxmox::Yubico
|
107
|
-
else
|
108
|
-
raise Fog::Proxmox::Errors::NotFound, 'domain tfa unknown'
|
109
|
-
end
|
110
|
-
tfa_class
|
111
|
-
end
|
112
42
|
end
|
113
43
|
end
|
114
44
|
end
|
@@ -1,12 +1,3 @@
|
|
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
1
|
# Copyright 2018 Tristan Robert
|
11
2
|
|
12
3
|
# This file is part of Fog::Proxmox.
|
@@ -26,21 +17,17 @@
|
|
26
17
|
|
27
18
|
# frozen_string_literal: true
|
28
19
|
|
29
|
-
require 'fog/proxmox/models/model'
|
30
|
-
|
31
20
|
module Fog
|
32
21
|
module Identity
|
33
22
|
class Proxmox
|
34
23
|
# class Group model authentication
|
35
|
-
class Group < Fog::
|
24
|
+
class Group < Fog::Model
|
36
25
|
identity :groupid
|
37
26
|
attribute :comment
|
38
|
-
def to_s
|
39
|
-
groupid
|
40
|
-
end
|
41
27
|
|
42
|
-
def
|
43
|
-
service.create_group(attributes.merge(
|
28
|
+
def save(options = {})
|
29
|
+
service.create_group(attributes.merge(options))
|
30
|
+
reload
|
44
31
|
end
|
45
32
|
|
46
33
|
def destroy
|
@@ -51,8 +38,8 @@ module Fog
|
|
51
38
|
|
52
39
|
def update
|
53
40
|
requires :groupid
|
54
|
-
|
55
|
-
|
41
|
+
service.update_group(identity, attributes.reject { |attribute| [:groupid].include? attribute })
|
42
|
+
reload
|
56
43
|
end
|
57
44
|
end
|
58
45
|
end
|
@@ -17,31 +17,25 @@
|
|
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/identity/proxmox/models/group'
|
22
21
|
|
23
22
|
module Fog
|
24
23
|
module Identity
|
25
24
|
class Proxmox
|
26
25
|
# class Groups authentication
|
27
|
-
class Groups < Fog::
|
26
|
+
class Groups < Fog::Collection
|
28
27
|
model Fog::Identity::Proxmox::Group
|
29
28
|
|
30
|
-
def all
|
31
|
-
|
29
|
+
def all
|
30
|
+
load service.list_groups
|
32
31
|
end
|
33
32
|
|
34
|
-
def
|
35
|
-
|
36
|
-
return cached_group if cached_group
|
37
|
-
group_hash = service.get_group(id)
|
38
|
-
Fog::Identity::Proxmox::Group.new(
|
39
|
-
group_hash.merge(service: service)
|
40
|
-
)
|
33
|
+
def get(id)
|
34
|
+
all.find { |group| group.identity === id }
|
41
35
|
end
|
42
36
|
|
43
37
|
def destroy(id)
|
44
|
-
group =
|
38
|
+
group = get(id)
|
45
39
|
group.destroy
|
46
40
|
end
|
47
41
|
end
|
@@ -4,14 +4,6 @@
|
|
4
4
|
|
5
5
|
# This file is part of Fog::Proxmox.
|
6
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
7
|
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
16
8
|
# it under the terms of the GNU General Public License as published by
|
17
9
|
# the Free Software Foundation, either version 3 of the License, or
|
@@ -25,43 +17,47 @@
|
|
25
17
|
# You should have received a copy of the GNU General Public License
|
26
18
|
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
27
19
|
|
28
|
-
require 'fog/proxmox/models/model'
|
29
|
-
|
30
20
|
module Fog
|
31
21
|
module Identity
|
32
22
|
class Proxmox
|
33
23
|
# class Permission
|
34
|
-
class Permission < Fog::
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
24
|
+
class Permission < Fog::Model
|
25
|
+
identity :type
|
26
|
+
identity :roleid
|
27
|
+
identity :path
|
28
|
+
identity :ugid
|
39
29
|
attribute :propagate
|
40
30
|
|
41
|
-
def
|
42
|
-
|
31
|
+
def save
|
32
|
+
service.update_permissions(to_update)
|
43
33
|
end
|
44
34
|
|
45
|
-
def
|
46
|
-
|
35
|
+
def destroy
|
36
|
+
service.update_permissions(to_update.merge(delete: 1))
|
47
37
|
end
|
48
38
|
|
49
|
-
|
50
|
-
service.add_permission(to_request)
|
51
|
-
end
|
39
|
+
private
|
52
40
|
|
53
|
-
def
|
54
|
-
|
41
|
+
def initialize_roles(new_attributes = {})
|
42
|
+
roles = new_attributes.delete(:roleid)
|
43
|
+
new_attributes.store(:roles, roles)
|
55
44
|
end
|
56
45
|
|
57
|
-
def
|
58
|
-
|
59
|
-
if type
|
60
|
-
|
61
|
-
elsif type
|
62
|
-
|
46
|
+
def initialize_ugid(new_attributes = {})
|
47
|
+
ugs = new_attributes.delete(:ugid)
|
48
|
+
if type === 'user'
|
49
|
+
new_attributes.store(:users, ugs)
|
50
|
+
elsif type === 'group'
|
51
|
+
new_attributes.store(:groups, ugs)
|
63
52
|
end
|
64
|
-
|
53
|
+
new_attributes.delete(:type)
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_update
|
57
|
+
new_attributes = attributes.clone
|
58
|
+
initialize_roles(new_attributes)
|
59
|
+
initialize_ugid(new_attributes)
|
60
|
+
new_attributes
|
65
61
|
end
|
66
62
|
end
|
67
63
|
end
|
@@ -17,43 +17,26 @@
|
|
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/identity/proxmox/models/permission'
|
22
21
|
|
23
22
|
module Fog
|
24
23
|
module Identity
|
25
24
|
class Proxmox
|
26
25
|
# class Permissions authentication
|
27
|
-
class Permissions < Fog::
|
26
|
+
class Permissions < Fog::Collection
|
28
27
|
model Fog::Identity::Proxmox::Permission
|
29
28
|
|
30
|
-
def all
|
31
|
-
|
29
|
+
def all
|
30
|
+
load service.list_permissions
|
32
31
|
end
|
33
32
|
|
34
|
-
def
|
35
|
-
|
36
|
-
users = permission_hash[:users]
|
37
|
-
roles = permission_hash[:roles]
|
38
|
-
path = permission_hash[:path]
|
39
|
-
propagate ||= 1
|
40
|
-
permission = new(path: path, propagate: propagate, roleid: roles)
|
41
|
-
if groups
|
42
|
-
permission.type = 'group'
|
43
|
-
permission.ugid = groups
|
44
|
-
elsif users
|
45
|
-
permission.type = 'user'
|
46
|
-
permission.ugid = users
|
47
|
-
end
|
48
|
-
permission
|
33
|
+
def get(type, path, roleid, ugid)
|
34
|
+
all.find { |permission| permission.type === type && permission.path === path && permission.roleid === roleid && permission.ugid === ugid }
|
49
35
|
end
|
50
36
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
def remove(permission)
|
56
|
-
create(permission).remove
|
37
|
+
def destroy(permission_hash)
|
38
|
+
permission = new(permission_hash)
|
39
|
+
permission.destroy
|
57
40
|
end
|
58
41
|
end
|
59
42
|
end
|
@@ -1,12 +1,3 @@
|
|
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
1
|
# Copyright 2018 Tristan Robert
|
11
2
|
|
12
3
|
# This file is part of Fog::Proxmox.
|
@@ -26,23 +17,18 @@
|
|
26
17
|
|
27
18
|
# frozen_string_literal: true
|
28
19
|
|
29
|
-
require 'fog/proxmox/models/model'
|
30
|
-
|
31
20
|
module Fog
|
32
21
|
module Identity
|
33
22
|
class Proxmox
|
34
23
|
# class Pool model of VMs
|
35
|
-
class Pool < Fog::
|
24
|
+
class Pool < Fog::Model
|
36
25
|
identity :poolid
|
37
26
|
attribute :comment
|
38
27
|
attribute :members
|
39
28
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def create(new_attributes = {})
|
45
|
-
service.create_pool(attributes.merge(new_attributes))
|
29
|
+
def save(options = {})
|
30
|
+
service.create_pool(attributes.merge(options))
|
31
|
+
reload
|
46
32
|
end
|
47
33
|
|
48
34
|
def destroy
|
@@ -69,10 +55,11 @@ module Fog
|
|
69
55
|
|
70
56
|
def update_with_member(member_name, member_id, delete = false)
|
71
57
|
requires :poolid
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
service.update_pool(poolid,
|
58
|
+
otpions = attributes.reject { |attribute| %i[poolid members].include? attribute }
|
59
|
+
otpions.store(member_name, member_id) if member_name
|
60
|
+
otpions.store('delete', 1) if delete
|
61
|
+
service.update_pool(poolid, otpions)
|
62
|
+
reload
|
76
63
|
end
|
77
64
|
|
78
65
|
def update
|
@@ -17,31 +17,25 @@
|
|
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/identity/proxmox/models/pool'
|
22
21
|
|
23
22
|
module Fog
|
24
23
|
module Identity
|
25
24
|
class Proxmox
|
26
25
|
# class Pools Collection of pools of VMs
|
27
|
-
class Pools < Fog::
|
26
|
+
class Pools < Fog::Collection
|
28
27
|
model Fog::Identity::Proxmox::Pool
|
29
28
|
|
30
|
-
def all
|
31
|
-
|
29
|
+
def all
|
30
|
+
load service.list_pools
|
32
31
|
end
|
33
|
-
|
34
|
-
def
|
35
|
-
|
36
|
-
return cached_pool if cached_pool
|
37
|
-
pool_hash = service.get_pool(id)
|
38
|
-
Fog::Identity::Proxmox::Pool.new(
|
39
|
-
pool_hash.merge(service: service)
|
40
|
-
)
|
32
|
+
|
33
|
+
def get(id)
|
34
|
+
all.find { |pool| pool.identity === id }
|
41
35
|
end
|
42
36
|
|
43
37
|
def destroy(id)
|
44
|
-
pool =
|
38
|
+
pool = get(id)
|
45
39
|
pool.destroy
|
46
40
|
end
|
47
41
|
end
|
@@ -25,22 +25,17 @@
|
|
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 Identity
|
32
30
|
class Proxmox
|
33
31
|
# class Principal current user authenticated
|
34
|
-
class Principal < Fog::
|
32
|
+
class Principal < Fog::Model
|
35
33
|
identity :username
|
36
34
|
attribute :password
|
37
35
|
attribute :privs
|
38
36
|
attribute :path
|
39
37
|
attribute :otp
|
40
38
|
attribute :realm
|
41
|
-
def to_s
|
42
|
-
username
|
43
|
-
end
|
44
39
|
end
|
45
40
|
end
|
46
41
|
end
|