fog-proxmox 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -17,6 +17,8 @@
|
|
17
17
|
|
18
18
|
# frozen_string_literal: true
|
19
19
|
|
20
|
+
require 'fog/proxmox/attributes'
|
21
|
+
|
20
22
|
module Fog
|
21
23
|
module Proxmox
|
22
24
|
class Identity
|
@@ -32,9 +34,18 @@ module Fog
|
|
32
34
|
attribute :enable
|
33
35
|
attribute :groups
|
34
36
|
attribute :keys
|
37
|
+
attribute :tokens
|
38
|
+
|
39
|
+
def initialize(new_attributes = {})
|
40
|
+
prepare_service_value(new_attributes)
|
41
|
+
Fog::Proxmox::Attributes.set_attr_and_sym('userid', attributes, new_attributes)
|
42
|
+
requires :userid
|
43
|
+
initialize_tokens
|
44
|
+
super(new_attributes)
|
45
|
+
end
|
35
46
|
|
36
47
|
def save(options = {})
|
37
|
-
service.create_user(attributes.merge(options))
|
48
|
+
service.create_user((attributes.reject { |attribute| [:tokens].include? attribute }).merge(options))
|
38
49
|
reload
|
39
50
|
end
|
40
51
|
|
@@ -46,7 +57,7 @@ module Fog
|
|
46
57
|
|
47
58
|
def update
|
48
59
|
requires :userid
|
49
|
-
service.update_user(userid, attributes.reject { |attribute| [:userid].include? attribute })
|
60
|
+
service.update_user(userid, attributes.reject { |attribute| [:userid, :tokens].include? attribute })
|
50
61
|
reload
|
51
62
|
end
|
52
63
|
|
@@ -54,6 +65,18 @@ module Fog
|
|
54
65
|
requires :userid, :password
|
55
66
|
service.change_password(userid, password)
|
56
67
|
end
|
68
|
+
|
69
|
+
def permissions(path = nil)
|
70
|
+
requires :userid
|
71
|
+
attributes[:permissions] = service.list_user_permissions(userid, path)
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def initialize_tokens
|
77
|
+
attributes[:tokens] = Fog::Proxmox::Identity::Tokens.new(service: service, userid: userid)
|
78
|
+
end
|
79
|
+
|
57
80
|
end
|
58
81
|
end
|
59
82
|
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/user'
|
21
21
|
|
22
22
|
module Fog
|
23
23
|
module Proxmox
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,40 @@
|
|
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 Identity
|
23
|
+
# class Real create_token request
|
24
|
+
class Real
|
25
|
+
def create_token(userid, tokenid, options)
|
26
|
+
request(
|
27
|
+
expects: [200],
|
28
|
+
method: 'POST',
|
29
|
+
path: "access/users/#{URI.encode_www_form_component(userid)}/token/#{tokenid}",
|
30
|
+
body: URI.encode_www_form(options)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# class Mock create_token request
|
36
|
+
class Mock
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Copyright 2018 Tristan Robert
|
3
|
+
|
4
|
+
# This file is part of Fog::Proxmox.
|
5
|
+
|
6
|
+
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
|
11
|
+
# Fog::Proxmox is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# frozen_string_literal: true
|
20
|
+
|
21
|
+
module Fog
|
22
|
+
module Proxmox
|
23
|
+
class Identity
|
24
|
+
# class Real delete_token request
|
25
|
+
class Real
|
26
|
+
def delete_token(userid, tokenid)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'DELETE',
|
30
|
+
path: "access/users/#{URI.encode_www_form_component(userid)}/token/#{tokenid}"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# class Mock delete_token request
|
36
|
+
class Mock
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Copyright 2018 Tristan Robert
|
3
|
+
|
4
|
+
# This file is part of Fog::Proxmox.
|
5
|
+
|
6
|
+
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
|
11
|
+
# Fog::Proxmox is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# frozen_string_literal: true
|
20
|
+
|
21
|
+
module Fog
|
22
|
+
module Proxmox
|
23
|
+
class Identity
|
24
|
+
# class Real get_token_info request
|
25
|
+
class Real
|
26
|
+
def get_token_info(userid, tokenid)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'GET',
|
30
|
+
path: "access/users/#{URI.encode_www_form_component(userid)}/token/#{tokenid}"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# class Mock get_token_info request
|
36
|
+
class Mock
|
37
|
+
def get_token_info(realm); end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Copyright 2018 Tristan Robert
|
3
|
+
|
4
|
+
# This file is part of Fog::Proxmox.
|
5
|
+
|
6
|
+
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
|
11
|
+
# Fog::Proxmox is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# frozen_string_literal: true
|
20
|
+
|
21
|
+
module Fog
|
22
|
+
module Proxmox
|
23
|
+
class Identity
|
24
|
+
# class Real list_tokens request
|
25
|
+
class Real
|
26
|
+
def list_tokens(userid)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'GET',
|
30
|
+
path: "access/users/#{URI.encode_www_form_component(userid)}/token"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# class Mock list_tokens request
|
36
|
+
class Mock
|
37
|
+
def list_tokens; end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Copyright 2018 Tristan Robert
|
3
|
+
|
4
|
+
# This file is part of Fog::Proxmox.
|
5
|
+
|
6
|
+
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
|
11
|
+
# Fog::Proxmox is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# frozen_string_literal: true
|
20
|
+
|
21
|
+
module Fog
|
22
|
+
module Proxmox
|
23
|
+
class Identity
|
24
|
+
# class Real list_user_permissions request
|
25
|
+
class Real
|
26
|
+
def list_user_permissions(userid, path)
|
27
|
+
options = { userid: userid }
|
28
|
+
options.store(:path, path) if path
|
29
|
+
request(
|
30
|
+
expects: [200],
|
31
|
+
method: 'GET',
|
32
|
+
path: 'access/permissions',
|
33
|
+
query: URI.encode_www_form(options)
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# class Mock list_user_permissions request
|
39
|
+
class Mock
|
40
|
+
def list_user_permissions; end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Copyright 2018 Tristan Robert
|
3
|
+
|
4
|
+
# This file is part of Fog::Proxmox.
|
5
|
+
|
6
|
+
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
|
11
|
+
# Fog::Proxmox is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# frozen_string_literal: true
|
20
|
+
|
21
|
+
module Fog
|
22
|
+
module Proxmox
|
23
|
+
class Identity
|
24
|
+
# class Real update_token request
|
25
|
+
class Real
|
26
|
+
def update_token(userid, tokenid, attributes)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'PUT',
|
30
|
+
path: "access/users/#{URI.encode_www_form_component(userid)}/token/#{tokenid}",
|
31
|
+
body: URI.encode_www_form(attributes)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# class Mock update_token request
|
37
|
+
class Mock
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
File without changes
|
@@ -21,16 +21,16 @@ module Fog
|
|
21
21
|
module Proxmox
|
22
22
|
# Proxmox network service
|
23
23
|
class Network < Fog::Service
|
24
|
-
requires :
|
25
|
-
recognizes :
|
24
|
+
requires :proxmox_url, :proxmox_auth_method
|
25
|
+
recognizes :proxmox_token, :proxmox_tokenid, :proxmox_userid, :persistent, :proxmox_username, :proxmox_password
|
26
26
|
|
27
|
-
model_path 'fog/network/
|
27
|
+
model_path 'fog/proxmox/network/models'
|
28
28
|
model :node
|
29
29
|
collection :nodes
|
30
30
|
model :network
|
31
31
|
collection :networks
|
32
32
|
|
33
|
-
request_path 'fog/network/
|
33
|
+
request_path 'fog/proxmox/network/requests'
|
34
34
|
|
35
35
|
# Manage nodes cluster
|
36
36
|
request :list_nodes
|
@@ -49,8 +49,14 @@ module Fog
|
|
49
49
|
attr_reader :config
|
50
50
|
|
51
51
|
def initialize(options = {})
|
52
|
-
@
|
53
|
-
@
|
52
|
+
@proxmox_uri = URI.parse(options[:proxmox_url])
|
53
|
+
@proxmox_auth_method = options[:proxmox_auth_method]
|
54
|
+
@proxmox_tokenid = options[:proxmox_tokenid]
|
55
|
+
@proxmox_userid = options[:proxmox_userid]
|
56
|
+
@proxmox_username = options[:proxmox_username]
|
57
|
+
@proxmox_password = options[:proxmox_password]
|
58
|
+
@proxmox_token = options[:proxmox_token]
|
59
|
+
@proxmox_path = @proxmox_uri.path
|
54
60
|
@config = options
|
55
61
|
end
|
56
62
|
end
|
@@ -58,20 +64,21 @@ module Fog
|
|
58
64
|
# Real class
|
59
65
|
class Real
|
60
66
|
include Fog::Proxmox::Core
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
@path_prefix = URI.parse(options[:pve_url]).path
|
65
|
-
authenticate
|
66
|
-
@persistent = options[:persistent] || false
|
67
|
-
url = "#{@scheme}://#{@host}:#{@port}"
|
68
|
-
@connection = Fog::Core::Connection.new(url, @persistent, @connection_options.merge(path_prefix: @path_prefix))
|
67
|
+
|
68
|
+
def self.not_found_class
|
69
|
+
Fog::Proxmox::Network::NotFound
|
69
70
|
end
|
70
71
|
|
71
72
|
def config
|
72
73
|
self
|
73
74
|
end
|
74
75
|
|
76
|
+
def config_service?
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
75
82
|
def configure(source)
|
76
83
|
source.instance_variables.each do |v|
|
77
84
|
instance_variable_set(v, source.instance_variable_get(v))
|