fog-proxmox 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/docs/compute.md +23 -7
- data/docs/identity.md +31 -6
- data/examples/compute.rb +11 -11
- data/examples/identity.rb +28 -15
- data/fog-proxmox.gemspec +1 -1
- data/lib/fog/proxmox.rb +16 -76
- data/lib/fog/proxmox/auth/token.rb +88 -0
- data/lib/fog/proxmox/auth/token/access_ticket.rb +85 -0
- data/lib/fog/proxmox/auth/token/user_token.rb +94 -0
- data/lib/fog/{compute/proxmox.rb → proxmox/compute.rb} +31 -16
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/disk.rb +15 -2
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/disks.rb +5 -1
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/interface.rb +4 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/interfaces.rb +1 -1
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/node.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/nodes.rb +1 -1
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/server.rb +2 -2
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/server_config.rb +8 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/servers.rb +1 -1
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/snapshot.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/snapshots.rb +1 -1
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/storage.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/storages.rb +1 -1
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/task.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/tasks.rb +1 -1
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/volume.rb +6 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/models/volumes.rb +1 -1
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/action_server.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/clone_server.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_backup.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_server.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_snapshot.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_spice.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_term.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/create_vnc.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/delete_server.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/delete_snapshot.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/delete_volume.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_node_statistics.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_server_config.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_server_status.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_snapshot_config.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_task.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_vnc.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/get_volume.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_nodes.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_servers.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_snapshots.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_storages.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_tasks.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/list_volumes.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/log_task.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/migrate_server.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/move_disk.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/move_volume.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/next_vmid.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/resize_container.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/resize_server.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/rollback_snapshot.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/status_task.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/stop_task.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/template_server.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/update_server.rb +0 -0
- data/lib/fog/{compute/proxmox → proxmox/compute}/requests/update_snapshot.rb +0 -0
- data/lib/fog/proxmox/core.rb +66 -57
- data/lib/fog/proxmox/hash.rb +2 -2
- data/lib/fog/proxmox/helpers/cpu_helper.rb +48 -9
- data/lib/fog/proxmox/helpers/disk_helper.rb +42 -22
- data/lib/fog/proxmox/helpers/nic_helper.rb +28 -20
- data/lib/fog/{identity/proxmox.rb → proxmox/identity.rb} +31 -17
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/domain.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/domain_type.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/domains.rb +1 -1
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/group.rb +4 -2
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/groups.rb +1 -1
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/permission.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/permissions.rb +1 -1
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/pool.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/pools.rb +1 -1
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/principal.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/role.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/roles.rb +1 -1
- data/lib/fog/proxmox/identity/models/token.rb +71 -0
- data/lib/fog/proxmox/identity/models/token_info.rb +41 -0
- data/lib/fog/proxmox/identity/models/tokens.rb +58 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/user.rb +25 -2
- data/lib/fog/{identity/proxmox → proxmox/identity}/models/users.rb +1 -1
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/change_password.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/check_permissions.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_domain.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_group.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_pool.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_role.rb +0 -0
- data/lib/fog/proxmox/identity/requests/create_token.rb +40 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/create_user.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_domain.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_group.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_pool.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_role.rb +0 -0
- data/lib/fog/proxmox/identity/requests/delete_token.rb +40 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/delete_user.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_domain.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_group.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_pool.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_role.rb +0 -0
- data/lib/fog/proxmox/identity/requests/get_token_info.rb +41 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/get_user.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_domains.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_groups.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_permissions.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_pools.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/list_roles.rb +0 -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/{identity/proxmox → proxmox/identity}/requests/list_users.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/read_version.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_domain.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_group.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_permissions.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_pool.rb +0 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_role.rb +0 -0
- data/lib/fog/proxmox/identity/requests/update_token.rb +41 -0
- data/lib/fog/{identity/proxmox → proxmox/identity}/requests/update_user.rb +0 -0
- data/lib/fog/{network/proxmox.rb → proxmox/network.rb} +21 -14
- data/lib/fog/{network/proxmox → proxmox/network}/models/network.rb +0 -0
- data/lib/fog/{network/proxmox → proxmox/network}/models/networks.rb +1 -1
- data/lib/fog/{network/proxmox → proxmox/network}/models/node.rb +1 -1
- data/lib/fog/{network/proxmox → proxmox/network}/models/nodes.rb +1 -1
- data/lib/fog/{network/proxmox → proxmox/network}/requests/create_network.rb +0 -0
- data/lib/fog/{network/proxmox → proxmox/network}/requests/delete_network.rb +0 -0
- data/lib/fog/{network/proxmox → proxmox/network}/requests/get_network.rb +0 -0
- data/lib/fog/{network/proxmox → proxmox/network}/requests/get_node.rb +0 -0
- data/lib/fog/{network/proxmox → proxmox/network}/requests/list_networks.rb +0 -0
- data/lib/fog/{network/proxmox → proxmox/network}/requests/list_nodes.rb +0 -0
- data/lib/fog/{network/proxmox → proxmox/network}/requests/power_node.rb +0 -0
- data/lib/fog/{network/proxmox → proxmox/network}/requests/update_network.rb +0 -0
- data/lib/fog/{storage/proxmox.rb → proxmox/storage.rb} +1 -1
- data/lib/fog/proxmox/version.rb +1 -1
- data/spec/compute_spec.rb +4 -4
- data/spec/fixtures/proxmox/compute/common_auth.yml +40 -0
- data/spec/fixtures/proxmox/compute/containers.yml +1752 -7568
- data/spec/fixtures/proxmox/compute/nodes.yml +24 -30
- data/spec/fixtures/proxmox/compute/servers.yml +5015 -10683
- data/spec/fixtures/proxmox/compute/snapshots.yml +479 -1719
- data/spec/fixtures/proxmox/compute/storages.yml +32 -40
- data/spec/fixtures/proxmox/compute/tasks.yml +118 -338
- data/spec/fixtures/proxmox/identity/auth.yml +10 -12
- 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 +145 -181
- data/spec/fixtures/proxmox/identity/groups.yml +72 -90
- data/spec/fixtures/proxmox/identity/permissions.yml +297 -189
- data/spec/fixtures/proxmox/identity/pools.yml +176 -421
- data/spec/fixtures/proxmox/identity/read_version.yml +7 -9
- data/spec/fixtures/proxmox/identity/roles.yml +69 -87
- data/spec/fixtures/proxmox/identity/tokens.yml +494 -0
- data/spec/fixtures/proxmox/identity/users.yml +149 -187
- data/spec/fixtures/proxmox/network/common_auth.yml +40 -0
- data/spec/fixtures/proxmox/network/networks.yml +99 -96
- data/spec/helpers/cpu_helper_spec.rb +27 -20
- data/spec/helpers/disk_helper_spec.rb +231 -187
- data/spec/helpers/nic_helper_spec.rb +113 -114
- data/spec/identity_spec.rb +110 -28
- data/spec/network_spec.rb +3 -3
- data/spec/proxmox_vcr.rb +24 -22
- data/spec/spec_helper.rb +4 -3
- metadata +155 -139
- data/spec/fixtures/proxmox/compute/identity_ticket.yml +0 -40
- data/spec/fixtures/proxmox/identity/identity_ticket.yml +0 -40
- data/spec/fixtures/proxmox/identity/renew.yml +0 -40
- data/spec/fixtures/proxmox/network/identity_ticket.yml +0 -40
@@ -23,7 +23,6 @@ module Fog
|
|
23
23
|
module Proxmox
|
24
24
|
# module NicHelper mixins
|
25
25
|
module NicHelper
|
26
|
-
|
27
26
|
NICS_REGEXP = /^(net)(\d+)/
|
28
27
|
|
29
28
|
def self.extract_mac_address(nic_value)
|
@@ -47,24 +46,24 @@ module Fog
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def self.has_model?(nic_value)
|
50
|
-
nic_value.match?(
|
49
|
+
nic_value.match?(model_regexp)
|
51
50
|
end
|
52
51
|
|
53
52
|
def self.has_name?(nic_value)
|
54
|
-
nic_value.match?(
|
53
|
+
nic_value.match?(name_regexp)
|
55
54
|
end
|
56
55
|
|
57
56
|
def self.has_ip?(nic_value)
|
58
|
-
nic_value.match?(
|
57
|
+
nic_value.match?(ip_regexp)
|
59
58
|
end
|
60
59
|
|
61
60
|
def self.extract_nic_id(nic_value)
|
62
|
-
if
|
63
|
-
nic_value.scan(
|
64
|
-
elsif
|
65
|
-
nic_value.scan(
|
61
|
+
if has_model?(nic_value)
|
62
|
+
nic_value.scan(model_regexp).first.first
|
63
|
+
elsif has_name?(nic_value)
|
64
|
+
nic_value.scan(name_regexp).first.first
|
66
65
|
else
|
67
|
-
nic_value.scan(
|
66
|
+
nic_value.scan(nic_update_regexp).first.first
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
@@ -84,29 +83,38 @@ module Fog
|
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
87
|
-
def self.
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
def self.set_mac(nic_id, nic_hash)
|
87
|
+
mac_keys = [:macaddr, :hwaddr]
|
88
|
+
nic_value = ''
|
89
|
+
if (nic_hash.keys & mac_keys).empty?
|
90
|
+
nic_value = nic_name(nic_hash) + "=" + nic_id
|
91
91
|
else
|
92
|
-
|
92
|
+
mac_value = nic_hash[mac_keys[0]] if nic_hash.key?(mac_keys[0])
|
93
|
+
mac_value ||= nic_hash[mac_keys[1]] if nic_hash.key?(mac_keys[1])
|
94
|
+
nic_value = nic_id + "=" + mac_value
|
93
95
|
end
|
94
|
-
|
95
|
-
|
96
|
-
|
96
|
+
nic_value
|
97
|
+
end
|
98
|
+
|
99
|
+
# Convert nic attributes hash into API Proxmox parameters string
|
100
|
+
def self.flatten(nic_hash)
|
101
|
+
nic_id = nic_hash[nic_name(nic_hash).to_sym]
|
102
|
+
nic_value = set_mac(nic_id, nic_hash)
|
103
|
+
options = nic_hash.reject { |key, _value| [nic_name(nic_hash).to_sym, :id, :macaddr, :hwaddr].include? key.to_sym }
|
104
|
+
nic_value += ',' + Fog::Proxmox::Hash.stringify(options) unless options.empty?
|
97
105
|
{ "#{nic_hash[:id]}": nic_value }
|
98
106
|
end
|
99
107
|
|
100
|
-
def self.collect_nics(attributes)
|
108
|
+
def self.collect_nics(attributes)
|
101
109
|
attributes.select { |key| nic?(key.to_s) }
|
102
110
|
end
|
103
|
-
|
111
|
+
|
104
112
|
def self.nic?(id)
|
105
113
|
NICS_REGEXP.match(id) ? true : false
|
106
114
|
end
|
107
115
|
|
108
116
|
def self.extract_ip(nic_value)
|
109
|
-
|
117
|
+
ip_regexp.match(nic_value) do |ip|
|
110
118
|
ip[2]
|
111
119
|
end
|
112
120
|
end
|
@@ -25,13 +25,15 @@ module Fog
|
|
25
25
|
module Proxmox
|
26
26
|
# Identity and authentication proxmox class
|
27
27
|
class Identity < Fog::Service
|
28
|
-
requires :
|
29
|
-
recognizes :
|
28
|
+
requires :proxmox_url, :proxmox_auth_method
|
29
|
+
recognizes :proxmox_token, :proxmox_tokenid, :proxmox_userid, :persistent, :proxmox_username, :proxmox_password
|
30
30
|
|
31
|
-
model_path 'fog/identity/
|
31
|
+
model_path 'fog/proxmox/identity/models'
|
32
32
|
model :principal
|
33
33
|
model :user
|
34
34
|
collection :users
|
35
|
+
model :token
|
36
|
+
collection :tokens
|
35
37
|
model :group
|
36
38
|
collection :groups
|
37
39
|
model :pool
|
@@ -44,11 +46,12 @@ module Fog
|
|
44
46
|
model :permission
|
45
47
|
collection :permissions
|
46
48
|
|
47
|
-
request_path 'fog/identity/
|
49
|
+
request_path 'fog/proxmox/identity/requests'
|
48
50
|
|
49
51
|
# Manage permissions
|
50
52
|
request :check_permissions
|
51
53
|
request :list_permissions
|
54
|
+
request :list_user_permissions
|
52
55
|
request :update_permissions
|
53
56
|
request :read_version
|
54
57
|
|
@@ -60,6 +63,13 @@ module Fog
|
|
60
63
|
request :delete_user
|
61
64
|
request :change_password
|
62
65
|
|
66
|
+
# Manage user tokens
|
67
|
+
request :list_tokens
|
68
|
+
request :get_token_info
|
69
|
+
request :create_token
|
70
|
+
request :update_token
|
71
|
+
request :delete_token
|
72
|
+
|
63
73
|
# CRUD groups
|
64
74
|
request :list_groups
|
65
75
|
request :get_group
|
@@ -93,8 +103,14 @@ module Fog
|
|
93
103
|
attr_reader :config
|
94
104
|
|
95
105
|
def initialize(options = {})
|
96
|
-
@
|
97
|
-
@
|
106
|
+
@proxmox_uri = URI.parse(options[:proxmox_url])
|
107
|
+
@proxmox_auth_method = options[:proxmox_auth_method]
|
108
|
+
@proxmox_tokenid = options[:proxmox_tokenid]
|
109
|
+
@proxmox_userid = options[:proxmox_userid]
|
110
|
+
@proxmox_username = options[:proxmox_username]
|
111
|
+
@proxmox_password = options[:proxmox_password]
|
112
|
+
@proxmox_token = options[:proxmox_token]
|
113
|
+
@proxmox_path = @proxmox_uri.path
|
98
114
|
@config = options
|
99
115
|
end
|
100
116
|
end
|
@@ -102,23 +118,21 @@ module Fog
|
|
102
118
|
# Real class
|
103
119
|
class Real
|
104
120
|
include Fog::Proxmox::Core
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
@path_prefix = URI.parse(options[:pve_url]).path
|
109
|
-
authenticate
|
110
|
-
@persistent = options[:persistent] || false
|
111
|
-
url = "#{@scheme}://#{@host}:#{@port}"
|
112
|
-
if ENV.has_key?('SSL_VERIFY_PEER')
|
113
|
-
Excon.defaults[:ssl_verify_peer] = Fog::Proxmox::String.to_boolean(ENV['SSL_VERIFY_PEER'])
|
114
|
-
end
|
115
|
-
@connection = Fog::Core::Connection.new(url, @persistent, @connection_options.merge(path_prefix: @path_prefix))
|
121
|
+
|
122
|
+
def self.not_found_class
|
123
|
+
Fog::Proxmox::Identity::NotFound
|
116
124
|
end
|
117
125
|
|
118
126
|
def config
|
119
127
|
self
|
120
128
|
end
|
121
129
|
|
130
|
+
def config_service?
|
131
|
+
true
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
122
136
|
def configure(source)
|
123
137
|
source.instance_variables.each do |v|
|
124
138
|
instance_variable_set(v, source.instance_variable_get(v))
|
File without changes
|
File without changes
|
@@ -17,7 +17,7 @@
|
|
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/identity/
|
20
|
+
require 'fog/proxmox/identity/models/domain'
|
21
21
|
|
22
22
|
module Fog
|
23
23
|
module Proxmox
|
@@ -24,9 +24,11 @@ module Fog
|
|
24
24
|
class Group < Fog::Model
|
25
25
|
identity :groupid
|
26
26
|
attribute :comment
|
27
|
+
attribute :users
|
28
|
+
attribute :members
|
27
29
|
|
28
30
|
def save(options = {})
|
29
|
-
service.create_group(attributes.merge(options))
|
31
|
+
service.create_group((attributes.reject { |attribute| [:users, :members].include? attribute }).merge(options))
|
30
32
|
reload
|
31
33
|
end
|
32
34
|
|
@@ -38,7 +40,7 @@ module Fog
|
|
38
40
|
|
39
41
|
def update
|
40
42
|
requires :groupid
|
41
|
-
service.update_group(identity, attributes.reject { |attribute| [:groupid].include? attribute })
|
43
|
+
service.update_group(identity, attributes.reject { |attribute| [:groupid, :users, :members].include? attribute })
|
42
44
|
reload
|
43
45
|
end
|
44
46
|
end
|
@@ -17,7 +17,7 @@
|
|
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/identity/
|
20
|
+
require 'fog/proxmox/identity/models/group'
|
21
21
|
|
22
22
|
module Fog
|
23
23
|
module Proxmox
|
File without changes
|
@@ -17,7 +17,7 @@
|
|
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/identity/
|
20
|
+
require 'fog/proxmox/identity/models/permission'
|
21
21
|
|
22
22
|
module Fog
|
23
23
|
module Proxmox
|
File without changes
|
@@ -17,7 +17,7 @@
|
|
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/identity/
|
20
|
+
require 'fog/proxmox/identity/models/pool'
|
21
21
|
|
22
22
|
module Fog
|
23
23
|
module Proxmox
|
File without changes
|
File without changes
|
@@ -17,7 +17,7 @@
|
|
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/identity/
|
20
|
+
require 'fog/proxmox/identity/models/role'
|
21
21
|
|
22
22
|
module Fog
|
23
23
|
module Proxmox
|
@@ -0,0 +1,71 @@
|
|
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
|
+
require 'fog/proxmox/identity/models/token_info'
|
21
|
+
|
22
|
+
module Fog
|
23
|
+
module Proxmox
|
24
|
+
class Identity
|
25
|
+
# class Token model
|
26
|
+
class Token < Fog::Model
|
27
|
+
identity :tokenid
|
28
|
+
identity :userid
|
29
|
+
attribute :privsep
|
30
|
+
attribute :comment
|
31
|
+
attribute :expire
|
32
|
+
attribute :info
|
33
|
+
|
34
|
+
def initialize(new_attributes = {})
|
35
|
+
prepare_service_value(new_attributes)
|
36
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('tokenid', attributes, new_attributes)
|
37
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('userid', attributes, new_attributes)
|
38
|
+
requires :userid, :tokenid
|
39
|
+
initialize_info
|
40
|
+
super(new_attributes)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def save(options = {})
|
45
|
+
requires :tokenid, :userid
|
46
|
+
token_hash = (attributes.reject { |attribute| [:userid, :tokenid, :info].include? attribute }).merge(options)
|
47
|
+
service.create_token(userid, tokenid, token_hash)
|
48
|
+
reload
|
49
|
+
end
|
50
|
+
|
51
|
+
def destroy
|
52
|
+
requires :tokenid, :userid
|
53
|
+
service.delete_token(userid, tokenid)
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
def update
|
58
|
+
requires :tokenid, :userid
|
59
|
+
service.update_token(userid, tokenid, attributes.reject { |attribute| [:userid, :tokenid, :info].include? attribute })
|
60
|
+
reload
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def initialize_info
|
66
|
+
attributes[:info] = Fog::Proxmox::Identity::TokenInfo.new(service: service, tokenid: tokenid, userid: userid)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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 TokenInfo model
|
24
|
+
class TokenInfo < Fog::Model
|
25
|
+
identity :tokenid
|
26
|
+
identity :userid
|
27
|
+
attribute :fulltokenid
|
28
|
+
attribute :info
|
29
|
+
attribute :value
|
30
|
+
|
31
|
+
def initialize(new_attributes = {})
|
32
|
+
prepare_service_value(new_attributes)
|
33
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('tokenid', attributes, new_attributes)
|
34
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('userid', attributes, new_attributes)
|
35
|
+
requires :userid, :tokenid
|
36
|
+
super(new_attributes)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -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/identity/models/user'
|
21
|
+
|
22
|
+
module Fog
|
23
|
+
module Proxmox
|
24
|
+
class Identity
|
25
|
+
# class Tokens model collection
|
26
|
+
class Tokens < Fog::Collection
|
27
|
+
model Fog::Proxmox::Identity::Token
|
28
|
+
attribute :userid
|
29
|
+
|
30
|
+
def new(new_attributes = {})
|
31
|
+
super({ userid: userid }.merge(new_attributes))
|
32
|
+
end
|
33
|
+
|
34
|
+
def get(tokenid)
|
35
|
+
all.find { |token| token.tokenid === tokenid && token.userid == userid }
|
36
|
+
end
|
37
|
+
|
38
|
+
def all(options = {})
|
39
|
+
begin
|
40
|
+
load service.list_tokens(userid)
|
41
|
+
rescue Excon::Error::InternalServerError => error
|
42
|
+
if error.response.status_line.include? "no such user"
|
43
|
+
return []
|
44
|
+
else
|
45
|
+
raise error
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def create(new_attributes = {})
|
51
|
+
object = new(new_attributes.select { |key, _value| [:userid, :tokenid].include? key.to_sym })
|
52
|
+
object.save(new_attributes.reject { |key, _value| [:userid, :tokenid].include? key.to_sym })
|
53
|
+
object
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|