fog-proxmox 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +4 -0
- data/.codeclimate.yml +14 -0
- data/.github/CODE_OF_CONDUCT.md +74 -0
- data/.github/CONTRIBUTING.md +20 -0
- data/.github/CONTRIBUTORS.md +9 -0
- data/.github/FUNDING.yml +12 -0
- data/.github/ISSUE_TEMPLATE.md +43 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.github/SUPPORT.md +9 -0
- data/.github/fogproxmox.png +0 -0
- data/.github/workflows/ci.yml +79 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +13 -0
- data/.ruby-gemset +1 -0
- data/.solargraph.yml +10 -0
- data/.vscode/launch.json +96 -0
- data/.vscode/settings.json +45 -0
- data/.vscode/tasks.json +27 -0
- data/Gemfile +23 -0
- data/LICENSE +674 -0
- data/README.md +79 -0
- data/Rakefile +58 -0
- data/docs/compute.md +858 -0
- data/docs/connection_parameters.md +45 -0
- data/docs/getting_started.md +53 -0
- data/docs/identity.md +357 -0
- data/examples/compute.rb +276 -0
- data/examples/identity.rb +190 -0
- data/fog-proxmox.gemspec +63 -0
- data/lib/fog/compute/proxmox.rb +126 -0
- data/lib/fog/compute/proxmox/models/disk.rb +76 -0
- data/lib/fog/compute/proxmox/models/disks.rb +51 -0
- data/lib/fog/compute/proxmox/models/interface.rb +52 -0
- data/lib/fog/compute/proxmox/models/interfaces.rb +44 -0
- data/lib/fog/compute/proxmox/models/node.rb +95 -0
- data/lib/fog/compute/proxmox/models/nodes.rb +39 -0
- data/lib/fog/compute/proxmox/models/server.rb +254 -0
- data/lib/fog/compute/proxmox/models/server_config.rb +148 -0
- data/lib/fog/compute/proxmox/models/servers.rb +80 -0
- data/lib/fog/compute/proxmox/models/snapshot.rb +83 -0
- data/lib/fog/compute/proxmox/models/snapshots.rb +47 -0
- data/lib/fog/compute/proxmox/models/storage.rb +64 -0
- data/lib/fog/compute/proxmox/models/storages.rb +51 -0
- data/lib/fog/compute/proxmox/models/task.rb +79 -0
- data/lib/fog/compute/proxmox/models/tasks.rb +64 -0
- data/lib/fog/compute/proxmox/models/volume.rb +61 -0
- data/lib/fog/compute/proxmox/models/volumes.rb +58 -0
- data/lib/fog/compute/proxmox/requests/action_server.rb +45 -0
- data/lib/fog/compute/proxmox/requests/clone_server.rb +44 -0
- data/lib/fog/compute/proxmox/requests/create_backup.rb +42 -0
- data/lib/fog/compute/proxmox/requests/create_server.rb +43 -0
- data/lib/fog/compute/proxmox/requests/create_snapshot.rb +46 -0
- data/lib/fog/compute/proxmox/requests/create_spice.rb +44 -0
- data/lib/fog/compute/proxmox/requests/create_term.rb +44 -0
- data/lib/fog/compute/proxmox/requests/create_vnc.rb +44 -0
- data/lib/fog/compute/proxmox/requests/delete_server.rb +45 -0
- data/lib/fog/compute/proxmox/requests/delete_snapshot.rb +47 -0
- data/lib/fog/compute/proxmox/requests/delete_volume.rb +40 -0
- data/lib/fog/compute/proxmox/requests/get_node_statistics.rb +44 -0
- data/lib/fog/compute/proxmox/requests/get_server_config.rb +60 -0
- data/lib/fog/compute/proxmox/requests/get_server_status.rb +63 -0
- data/lib/fog/compute/proxmox/requests/get_snapshot_config.rb +44 -0
- data/lib/fog/compute/proxmox/requests/get_task.rb +41 -0
- data/lib/fog/compute/proxmox/requests/get_vnc.rb +44 -0
- data/lib/fog/compute/proxmox/requests/get_volume.rb +42 -0
- data/lib/fog/compute/proxmox/requests/list_nodes.rb +48 -0
- data/lib/fog/compute/proxmox/requests/list_servers.rb +113 -0
- data/lib/fog/compute/proxmox/requests/list_snapshots.rb +66 -0
- data/lib/fog/compute/proxmox/requests/list_storages.rb +46 -0
- data/lib/fog/compute/proxmox/requests/list_tasks.rb +44 -0
- data/lib/fog/compute/proxmox/requests/list_volumes.rb +44 -0
- data/lib/fog/compute/proxmox/requests/log_task.rb +44 -0
- data/lib/fog/compute/proxmox/requests/migrate_server.rb +44 -0
- data/lib/fog/compute/proxmox/requests/move_disk.rb +43 -0
- data/lib/fog/compute/proxmox/requests/move_volume.rb +43 -0
- data/lib/fog/compute/proxmox/requests/next_vmid.rb +42 -0
- data/lib/fog/compute/proxmox/requests/resize_container.rb +43 -0
- data/lib/fog/compute/proxmox/requests/resize_server.rb +43 -0
- data/lib/fog/compute/proxmox/requests/rollback_snapshot.rb +48 -0
- data/lib/fog/compute/proxmox/requests/status_task.rb +41 -0
- data/lib/fog/compute/proxmox/requests/stop_task.rb +41 -0
- data/lib/fog/compute/proxmox/requests/template_server.rb +44 -0
- data/lib/fog/compute/proxmox/requests/update_server.rb +44 -0
- data/lib/fog/compute/proxmox/requests/update_snapshot.rb +45 -0
- data/lib/fog/identity/proxmox.rb +130 -0
- data/lib/fog/identity/proxmox/models/domain.rb +65 -0
- data/lib/fog/identity/proxmox/models/domain_type.rb +48 -0
- data/lib/fog/identity/proxmox/models/domains.rb +45 -0
- data/lib/fog/identity/proxmox/models/group.rb +47 -0
- data/lib/fog/identity/proxmox/models/groups.rb +44 -0
- data/lib/fog/identity/proxmox/models/permission.rb +65 -0
- data/lib/fog/identity/proxmox/models/permissions.rb +44 -0
- data/lib/fog/identity/proxmox/models/pool.rb +89 -0
- data/lib/fog/identity/proxmox/models/pools.rb +46 -0
- data/lib/fog/identity/proxmox/models/principal.rb +42 -0
- data/lib/fog/identity/proxmox/models/role.rb +48 -0
- data/lib/fog/identity/proxmox/models/roles.rb +44 -0
- data/lib/fog/identity/proxmox/models/user.rb +60 -0
- data/lib/fog/identity/proxmox/models/users.rb +44 -0
- data/lib/fog/identity/proxmox/requests/change_password.rb +41 -0
- data/lib/fog/identity/proxmox/requests/check_permissions.rb +41 -0
- data/lib/fog/identity/proxmox/requests/create_domain.rb +40 -0
- data/lib/fog/identity/proxmox/requests/create_group.rb +40 -0
- data/lib/fog/identity/proxmox/requests/create_pool.rb +40 -0
- data/lib/fog/identity/proxmox/requests/create_role.rb +40 -0
- data/lib/fog/identity/proxmox/requests/create_user.rb +40 -0
- data/lib/fog/identity/proxmox/requests/delete_domain.rb +40 -0
- data/lib/fog/identity/proxmox/requests/delete_group.rb +40 -0
- data/lib/fog/identity/proxmox/requests/delete_pool.rb +39 -0
- data/lib/fog/identity/proxmox/requests/delete_role.rb +40 -0
- data/lib/fog/identity/proxmox/requests/delete_user.rb +39 -0
- data/lib/fog/identity/proxmox/requests/get_domain.rb +41 -0
- data/lib/fog/identity/proxmox/requests/get_group.rb +41 -0
- data/lib/fog/identity/proxmox/requests/get_pool.rb +41 -0
- data/lib/fog/identity/proxmox/requests/get_role.rb +41 -0
- data/lib/fog/identity/proxmox/requests/get_user.rb +40 -0
- data/lib/fog/identity/proxmox/requests/list_domains.rb +41 -0
- data/lib/fog/identity/proxmox/requests/list_groups.rb +41 -0
- data/lib/fog/identity/proxmox/requests/list_permissions.rb +41 -0
- data/lib/fog/identity/proxmox/requests/list_pools.rb +41 -0
- data/lib/fog/identity/proxmox/requests/list_roles.rb +40 -0
- data/lib/fog/identity/proxmox/requests/list_users.rb +42 -0
- data/lib/fog/identity/proxmox/requests/read_version.rb +39 -0
- data/lib/fog/identity/proxmox/requests/update_domain.rb +41 -0
- data/lib/fog/identity/proxmox/requests/update_group.rb +40 -0
- data/lib/fog/identity/proxmox/requests/update_permissions.rb +41 -0
- data/lib/fog/identity/proxmox/requests/update_pool.rb +41 -0
- data/lib/fog/identity/proxmox/requests/update_role.rb +41 -0
- data/lib/fog/identity/proxmox/requests/update_user.rb +41 -0
- data/lib/fog/network/proxmox.rb +83 -0
- data/lib/fog/network/proxmox/models/network.rb +76 -0
- data/lib/fog/network/proxmox/models/networks.rb +48 -0
- data/lib/fog/network/proxmox/models/node.rb +74 -0
- data/lib/fog/network/proxmox/models/nodes.rb +39 -0
- data/lib/fog/network/proxmox/requests/create_network.rb +41 -0
- data/lib/fog/network/proxmox/requests/delete_network.rb +42 -0
- data/lib/fog/network/proxmox/requests/get_network.rb +43 -0
- data/lib/fog/network/proxmox/requests/get_node.rb +41 -0
- data/lib/fog/network/proxmox/requests/list_networks.rb +43 -0
- data/lib/fog/network/proxmox/requests/list_nodes.rb +42 -0
- data/lib/fog/network/proxmox/requests/power_node.rb +43 -0
- data/lib/fog/network/proxmox/requests/update_network.rb +42 -0
- data/lib/fog/proxmox.rb +115 -0
- data/lib/fog/proxmox/attributes.rb +33 -0
- data/lib/fog/proxmox/core.rb +135 -0
- data/lib/fog/proxmox/errors.rb +64 -0
- data/lib/fog/proxmox/hash.rb +39 -0
- data/lib/fog/proxmox/helpers/controller_helper.rb +64 -0
- data/lib/fog/proxmox/helpers/cpu_helper.rb +42 -0
- data/lib/fog/proxmox/helpers/disk_helper.rb +159 -0
- data/lib/fog/proxmox/helpers/ip_helper.rb +100 -0
- data/lib/fog/proxmox/helpers/nic_helper.rb +115 -0
- data/lib/fog/proxmox/json.rb +32 -0
- data/lib/fog/proxmox/string.rb +31 -0
- data/lib/fog/proxmox/variables.rb +40 -0
- data/lib/fog/proxmox/version.rb +24 -0
- data/lib/fog/storage/proxmox.rb +29 -0
- data/spec/compute_spec.rb +446 -0
- data/spec/fixtures/proxmox/compute/containers.yml +12737 -0
- data/spec/fixtures/proxmox/compute/identity_ticket.yml +40 -0
- data/spec/fixtures/proxmox/compute/nodes.yml +121 -0
- data/spec/fixtures/proxmox/compute/servers.yml +24679 -0
- data/spec/fixtures/proxmox/compute/snapshots.yml +3321 -0
- data/spec/fixtures/proxmox/compute/storages.yml +159 -0
- data/spec/fixtures/proxmox/compute/tasks.yml +685 -0
- data/spec/fixtures/proxmox/identity/auth.yml +44 -0
- data/spec/fixtures/proxmox/identity/domains.yml +701 -0
- data/spec/fixtures/proxmox/identity/groups.yml +363 -0
- data/spec/fixtures/proxmox/identity/identity_ticket.yml +40 -0
- data/spec/fixtures/proxmox/identity/permissions.yml +803 -0
- data/spec/fixtures/proxmox/identity/pools.yml +1191 -0
- data/spec/fixtures/proxmox/identity/read_version.yml +42 -0
- data/spec/fixtures/proxmox/identity/renew.yml +40 -0
- data/spec/fixtures/proxmox/identity/roles.yml +363 -0
- data/spec/fixtures/proxmox/identity/users.yml +763 -0
- data/spec/fixtures/proxmox/network/identity_ticket.yml +40 -0
- data/spec/fixtures/proxmox/network/networks.yml +372 -0
- data/spec/fixtures/proxmox/pve.home +34 -0
- data/spec/hash_spec.rb +42 -0
- data/spec/helpers/controller_helper_spec.rb +145 -0
- data/spec/helpers/cpu_helper_spec.rb +70 -0
- data/spec/helpers/disk_helper_spec.rb +210 -0
- data/spec/helpers/ip_helper_spec.rb +160 -0
- data/spec/helpers/nic_helper_spec.rb +136 -0
- data/spec/identity_spec.rb +322 -0
- data/spec/network_spec.rb +67 -0
- data/spec/proxmox_vcr.rb +95 -0
- data/spec/spec_helper.rb +40 -0
- metadata +547 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
# Optional connection parameters
|
2
|
+
|
3
|
+
Fog supports passing additional connection parameters to its underlying HTTP library (Excon) using the `:connection_options` parameter.
|
4
|
+
|
5
|
+
<table>
|
6
|
+
<tr>
|
7
|
+
<th>Key</th>
|
8
|
+
<th>Description</th>
|
9
|
+
</tr>
|
10
|
+
<tr>
|
11
|
+
<td>:connect_timeout</td>
|
12
|
+
<td>Connection timeout (default: 60 seconds)</td>
|
13
|
+
</tr>
|
14
|
+
<tr>
|
15
|
+
<td>:read_timeout</td>
|
16
|
+
<td>Read timeout for connection (default: 60 seconds)</td> </tr>
|
17
|
+
<tr>
|
18
|
+
<td>:write_timeout</td>
|
19
|
+
<td>Write timeout for connection (default: 60 seconds)</td>
|
20
|
+
</tr>
|
21
|
+
<tr>
|
22
|
+
<td>:proxy</td>
|
23
|
+
<td>Proxy for HTTP and HTTPS connections</td>
|
24
|
+
</tr>
|
25
|
+
<tr>
|
26
|
+
<td>:ssl_ca_path</td>
|
27
|
+
<td>Path to SSL certificate authorities</td>
|
28
|
+
</tr>
|
29
|
+
<tr>
|
30
|
+
<td>:ssl_ca_file</td>
|
31
|
+
<td>SSL certificate authority file</td>
|
32
|
+
</tr>
|
33
|
+
<tr>
|
34
|
+
<td>:ssl_verify_peer</td>
|
35
|
+
<td>SSL verify peer (default: true)</td>
|
36
|
+
</tr>
|
37
|
+
<tr>
|
38
|
+
<td>:debug_request</td>
|
39
|
+
<td>debug print request (default: false)</td>
|
40
|
+
</tr>
|
41
|
+
<tr>
|
42
|
+
<td>:debug_response</td>
|
43
|
+
<td>debug print response (default: false)</td>
|
44
|
+
</tr>
|
45
|
+
</table>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Getting started with Fog proxmox
|
2
|
+
|
3
|
+
## Requirements
|
4
|
+
|
5
|
+
### Ruby
|
6
|
+
|
7
|
+
2.3, 2.4 and 2.5 ruby versions are tested and required.
|
8
|
+
Fog requires 2.0+ for new projects.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
With rubygems:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem install fog-proxmox
|
16
|
+
```
|
17
|
+
|
18
|
+
With bundler:
|
19
|
+
|
20
|
+
Create a Gemfile with:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
source 'https://rubygems.org'
|
24
|
+
|
25
|
+
gem 'fog-proxmox'
|
26
|
+
```
|
27
|
+
|
28
|
+
then:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
bundler install
|
32
|
+
```
|
33
|
+
|
34
|
+
## Exploring capabilities
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
irb
|
38
|
+
```
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
require 'fog/proxmox'
|
42
|
+
```
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
Fog::Proxmox.services
|
46
|
+
```
|
47
|
+
|
48
|
+
This command show you a summary of the available services.
|
49
|
+
|
50
|
+
### Available services in details
|
51
|
+
|
52
|
+
* [Identity](identity.md)
|
53
|
+
* [Compute](compute.md)
|
data/docs/identity.md
ADDED
@@ -0,0 +1,357 @@
|
|
1
|
+
# Identity
|
2
|
+
|
3
|
+
This document shows you the identity service (or user management) available with fog-proxmox.
|
4
|
+
|
5
|
+
Proxmox supports many authentication sources (PAM, LDAP, Active Directory) and an authorization management (ACL, privileges).
|
6
|
+
|
7
|
+
You can see more details in [Proxmox user management wiki page](https://pve.proxmox.com/wiki/User_Management)
|
8
|
+
|
9
|
+
## Starting irb console
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
irb
|
13
|
+
```
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'fog/proxmox'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Create identity service
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
identity = Fog::Proxmox::Identity.new(
|
23
|
+
pve_username: PVE_USERNAME, # your user name
|
24
|
+
pve_password: PVE_PASSWORD, # your password
|
25
|
+
pve_url: PVE_URL, # your server url
|
26
|
+
connection_options: {} # connection options
|
27
|
+
)
|
28
|
+
```
|
29
|
+
|
30
|
+
[connection_options](connection_parameters.md) are also available.
|
31
|
+
|
32
|
+
## Fog Abstractions
|
33
|
+
|
34
|
+
Fog provides both a **model** and **request** abstraction. The request abstraction provides the most efficient interface and the model abstraction wraps the request abstraction to provide a convenient `ActiveModel` like interface.
|
35
|
+
|
36
|
+
### Request Layer
|
37
|
+
|
38
|
+
The request abstraction maps directly to the [Proxmox VE API](https://pve.proxmox.com/wiki/Proxmox_VE_API). It provides an interface to the Proxmox Identity service.
|
39
|
+
|
40
|
+
To see a list of requests supported by the identity service:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
identity.requests
|
44
|
+
```
|
45
|
+
|
46
|
+
To learn more about Identity request methods refer to source files.
|
47
|
+
|
48
|
+
To learn more about Excon refer to [Excon GitHub repo](https://github.com/geemus/excon).
|
49
|
+
|
50
|
+
### Model Layer
|
51
|
+
|
52
|
+
Fog models behave in a manner similar to `ActiveModel`. Models will generally respond to `create`, `save`, `persisted?`, `destroy`, `reload` and `attributes` methods. Additionally, fog will automatically create attribute accessors.
|
53
|
+
|
54
|
+
Here is a summary of common model methods:
|
55
|
+
|
56
|
+
<table>
|
57
|
+
<tr>
|
58
|
+
<th>Method</th>
|
59
|
+
<th>Description</th>
|
60
|
+
</tr>
|
61
|
+
<tr>
|
62
|
+
<td>create</td>
|
63
|
+
<td>
|
64
|
+
Accepts hash of attributes and creates object.<br>
|
65
|
+
Note: creation is a non-blocking call and you will be required to wait for a valid state before using resulting object.
|
66
|
+
</td>
|
67
|
+
</tr>
|
68
|
+
<tr>
|
69
|
+
<td>update</td>
|
70
|
+
<td>Updates object.<br>
|
71
|
+
Note: not all objects support updating object.</td>
|
72
|
+
</tr>
|
73
|
+
<tr>
|
74
|
+
<td>destroy</td>
|
75
|
+
<td>
|
76
|
+
Destroys object.<br>
|
77
|
+
Note: this is a non-blocking call and object deletion might not be instantaneous.
|
78
|
+
</td>
|
79
|
+
<tr>
|
80
|
+
<td>attributes</td>
|
81
|
+
<td>Returns a hash containing the list of model attributes and values.</td>
|
82
|
+
</tr>
|
83
|
+
<td>identity</td>
|
84
|
+
<td>
|
85
|
+
Returns the identity of the object.<br>
|
86
|
+
Note: This might not always be equal to object.id.
|
87
|
+
</td>
|
88
|
+
</tr>
|
89
|
+
</table>
|
90
|
+
|
91
|
+
The remainder of this document details the model abstraction.
|
92
|
+
|
93
|
+
#### Users management
|
94
|
+
|
95
|
+
List all users:
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
identity.users.all
|
99
|
+
```
|
100
|
+
|
101
|
+
This returns a collection of `Fog::Proxmox::Identity::User` models:
|
102
|
+
|
103
|
+
Create a user:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
identity.users.create({
|
107
|
+
userid: 'bobsinclar@pve',
|
108
|
+
password: 'bobsinclar1',
|
109
|
+
firstname: 'Bob',
|
110
|
+
lastname: 'Sinclar',
|
111
|
+
email: 'bobsinclar@proxmox.com'
|
112
|
+
})
|
113
|
+
```
|
114
|
+
|
115
|
+
Get a user:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
user = identity.users.find_by_id 'bobsinclar@pve'
|
119
|
+
```
|
120
|
+
|
121
|
+
Change his password:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
user.password = 'bobsinclar2'
|
125
|
+
user.change_password
|
126
|
+
```
|
127
|
+
|
128
|
+
Add groups to user:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
user.groups = %w[group1 group2]
|
132
|
+
user.update
|
133
|
+
```
|
134
|
+
|
135
|
+
Delete user:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
user.destroy
|
139
|
+
```
|
140
|
+
|
141
|
+
#### Groups management
|
142
|
+
|
143
|
+
Proxmox supports permissions management by group.
|
144
|
+
|
145
|
+
Proxmox recommends to manage permissions by group instead of by user.
|
146
|
+
|
147
|
+
List all groups:
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
identity.groups.all
|
151
|
+
```
|
152
|
+
|
153
|
+
This returns a collection of `Fog::Proxmox::Identity::Group` models:
|
154
|
+
|
155
|
+
Create a group:
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
identity.groups.create({
|
159
|
+
groupid: 'group1'
|
160
|
+
})
|
161
|
+
```
|
162
|
+
|
163
|
+
Get a group:
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
group = identity.groups.find_by_id 'group1'
|
167
|
+
```
|
168
|
+
|
169
|
+
Add a comment:
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
group.comment = 'Group 1'
|
173
|
+
group.update
|
174
|
+
```
|
175
|
+
|
176
|
+
Delete group:
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
group.destroy
|
180
|
+
```
|
181
|
+
|
182
|
+
#### Domains management
|
183
|
+
|
184
|
+
Proxmox supports 4 domains or realms (sources of authentication): PAM, PVE, LDAP and Active Directory.
|
185
|
+
|
186
|
+
Proxmox server has two default domains: PAM and PVE.
|
187
|
+
|
188
|
+
List all domains:
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
identity.domains.all
|
192
|
+
```
|
193
|
+
|
194
|
+
This returns a collection of `Fog::Proxmox::Identity::Domain` models:
|
195
|
+
|
196
|
+
Create a LDAP domain:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
identity.domains.create({
|
200
|
+
realm: 'LDAP',
|
201
|
+
type: 'ldap',
|
202
|
+
base_dn: 'ou=People,dc=ldap-test,dc=com',
|
203
|
+
user_attr: 'LDAP',
|
204
|
+
server1: 'localhost',
|
205
|
+
port: 389,
|
206
|
+
default: 0,
|
207
|
+
secure: 0
|
208
|
+
})
|
209
|
+
```
|
210
|
+
|
211
|
+
Get a domain:
|
212
|
+
|
213
|
+
```ruby
|
214
|
+
ldap = identity.domains.find_by_id 'LDAP'
|
215
|
+
```
|
216
|
+
|
217
|
+
Add a comment and a two factor authentication (OATH) to LDAP realm:
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
ldap.type.comment = 'Test domain LDAP'
|
221
|
+
ldap.type.tfa = 'type=oath,step=30,digits=8'
|
222
|
+
ldap.update
|
223
|
+
```
|
224
|
+
|
225
|
+
Delete domain:
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
ldap.destroy
|
229
|
+
```
|
230
|
+
|
231
|
+
#### Roles management
|
232
|
+
|
233
|
+
Proxmox supports roles management to give permissions to group of users.
|
234
|
+
|
235
|
+
Proxmox server has several defaults roles already created. See [Proxmox user management wiki page](https://pve.proxmox.com/wiki/User_Management)
|
236
|
+
|
237
|
+
List all roles:
|
238
|
+
|
239
|
+
```ruby
|
240
|
+
identity.roles.all
|
241
|
+
```
|
242
|
+
|
243
|
+
This returns a collection of `Fog::Proxmox::Identity::Role` models:
|
244
|
+
|
245
|
+
Create a new role:
|
246
|
+
|
247
|
+
```ruby
|
248
|
+
identity.roles.create({ roleid: 'PVETestAuditor' })
|
249
|
+
```
|
250
|
+
|
251
|
+
Get the role:
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
role = identity.groups.find_by_id 'PVETestAuditor'
|
255
|
+
```
|
256
|
+
|
257
|
+
Add privileges to this new role:
|
258
|
+
|
259
|
+
```ruby
|
260
|
+
role.privs = 'Datastore.Audit Sys.Audit VM.Audit'
|
261
|
+
role.update
|
262
|
+
```
|
263
|
+
|
264
|
+
List of all available privileges can be seen at [Proxmox user management wiki page](https://pve.proxmox.com/wiki/User_Management)
|
265
|
+
|
266
|
+
Delete role:
|
267
|
+
|
268
|
+
```ruby
|
269
|
+
role.destroy
|
270
|
+
```
|
271
|
+
|
272
|
+
#### Permissions management
|
273
|
+
|
274
|
+
Proxmox supports permissions management. Access permissions are assigned to objects, such as a virtual machines, storages or pools of resources. It uses path to identify these objects. Path is the same as REST API path.
|
275
|
+
|
276
|
+
See more details in [Proxmox user management wiki page](https://pve.proxmox.com/wiki/User_Management)
|
277
|
+
|
278
|
+
List all permissions:
|
279
|
+
|
280
|
+
```ruby
|
281
|
+
identity.permissions.all
|
282
|
+
```
|
283
|
+
|
284
|
+
This returns a collection of `Fog::Proxmox::Identity::Permission` models:
|
285
|
+
|
286
|
+
Add a new permission (manage users) to a user:
|
287
|
+
|
288
|
+
```ruby
|
289
|
+
identity.permissions.add({
|
290
|
+
path: '/access/users',
|
291
|
+
roles: 'PVEUserAdmin',
|
292
|
+
users: 'bobsinclar@pve'
|
293
|
+
})
|
294
|
+
```
|
295
|
+
|
296
|
+
Add a new permission (manage users) to a group of users:
|
297
|
+
|
298
|
+
```ruby
|
299
|
+
identity.permissions.add({
|
300
|
+
path: '/access/users',
|
301
|
+
roles: 'PVEUserAdmin',
|
302
|
+
groups: 'group1'
|
303
|
+
})
|
304
|
+
```
|
305
|
+
|
306
|
+
Remove a permission to a user:
|
307
|
+
|
308
|
+
```ruby
|
309
|
+
identity.permissions.remove({
|
310
|
+
path: '/access/users',
|
311
|
+
roles: 'PVEUserAdmin',
|
312
|
+
users: 'bobsinclar@pve'
|
313
|
+
})
|
314
|
+
```
|
315
|
+
#### Pools management
|
316
|
+
|
317
|
+
Proxmox supports pools management of VMs or storages. It eases managing permissions on these.
|
318
|
+
|
319
|
+
Create a pool:
|
320
|
+
|
321
|
+
```ruby
|
322
|
+
identity.pools.create { poolid: 'pool1' }
|
323
|
+
```
|
324
|
+
|
325
|
+
Get a pool:
|
326
|
+
|
327
|
+
```ruby
|
328
|
+
pool1 = identity.pools.find_by_id 'pool1'
|
329
|
+
```
|
330
|
+
|
331
|
+
Add comment, server 100 and storage local-lvm to the pool:
|
332
|
+
|
333
|
+
```ruby
|
334
|
+
pool1.comment = 'Pool 1'
|
335
|
+
pool1.update
|
336
|
+
pool1.add_server 100
|
337
|
+
pool1.add_storage 'local-lvm '
|
338
|
+
```
|
339
|
+
|
340
|
+
Get all pools:
|
341
|
+
|
342
|
+
```ruby
|
343
|
+
identity.pools.all
|
344
|
+
```
|
345
|
+
|
346
|
+
Delete pool:
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
# you need to remove all members before deleting pool
|
350
|
+
pool1.remove_server 100
|
351
|
+
pool1.remove_storage 'local-lvm '
|
352
|
+
pool1.destroy
|
353
|
+
```
|
354
|
+
|
355
|
+
### Examples
|
356
|
+
|
357
|
+
More examples can be seen at [examples/identity.rb](examples/identity.rb) or [spec/identity_spec.rb](spec/identity_spec.rb).
|