fog-proxmox-configlmm 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +8 -0
- data/LICENSE +674 -0
- data/README.md +110 -0
- data/docs/compute.md +874 -0
- data/docs/connection_parameters.md +45 -0
- data/docs/getting_started.md +53 -0
- data/docs/identity.md +382 -0
- data/examples/compute.rb +276 -0
- data/examples/identity.rb +203 -0
- data/lib/fog/proxmox/attributes.rb +34 -0
- data/lib/fog/proxmox/auth/token/access_ticket.rb +96 -0
- data/lib/fog/proxmox/auth/token/user_token.rb +107 -0
- data/lib/fog/proxmox/auth/token.rb +94 -0
- data/lib/fog/proxmox/compute/models/disk.rb +94 -0
- data/lib/fog/proxmox/compute/models/disks.rb +55 -0
- data/lib/fog/proxmox/compute/models/interface.rb +56 -0
- data/lib/fog/proxmox/compute/models/interfaces.rb +44 -0
- data/lib/fog/proxmox/compute/models/node.rb +93 -0
- data/lib/fog/proxmox/compute/models/nodes.rb +39 -0
- data/lib/fog/proxmox/compute/models/server.rb +271 -0
- data/lib/fog/proxmox/compute/models/server_config.rb +161 -0
- data/lib/fog/proxmox/compute/models/servers.rb +80 -0
- data/lib/fog/proxmox/compute/models/snapshot.rb +83 -0
- data/lib/fog/proxmox/compute/models/snapshots.rb +47 -0
- data/lib/fog/proxmox/compute/models/storage.rb +65 -0
- data/lib/fog/proxmox/compute/models/storages.rb +51 -0
- data/lib/fog/proxmox/compute/models/task.rb +79 -0
- data/lib/fog/proxmox/compute/models/tasks.rb +65 -0
- data/lib/fog/proxmox/compute/models/volume.rb +68 -0
- data/lib/fog/proxmox/compute/models/volumes.rb +58 -0
- data/lib/fog/proxmox/compute/requests/action_server.rb +45 -0
- data/lib/fog/proxmox/compute/requests/clone_server.rb +44 -0
- data/lib/fog/proxmox/compute/requests/create_backup.rb +42 -0
- data/lib/fog/proxmox/compute/requests/create_server.rb +43 -0
- data/lib/fog/proxmox/compute/requests/create_snapshot.rb +46 -0
- data/lib/fog/proxmox/compute/requests/create_spice.rb +44 -0
- data/lib/fog/proxmox/compute/requests/create_term.rb +45 -0
- data/lib/fog/proxmox/compute/requests/create_vnc.rb +44 -0
- data/lib/fog/proxmox/compute/requests/delete_server.rb +45 -0
- data/lib/fog/proxmox/compute/requests/delete_snapshot.rb +47 -0
- data/lib/fog/proxmox/compute/requests/delete_volume.rb +40 -0
- data/lib/fog/proxmox/compute/requests/get_node_statistics.rb +44 -0
- data/lib/fog/proxmox/compute/requests/get_server_config.rb +60 -0
- data/lib/fog/proxmox/compute/requests/get_server_status.rb +63 -0
- data/lib/fog/proxmox/compute/requests/get_snapshot_config.rb +44 -0
- data/lib/fog/proxmox/compute/requests/get_task.rb +41 -0
- data/lib/fog/proxmox/compute/requests/get_vnc.rb +45 -0
- data/lib/fog/proxmox/compute/requests/get_volume.rb +42 -0
- data/lib/fog/proxmox/compute/requests/list_nodes.rb +48 -0
- data/lib/fog/proxmox/compute/requests/list_servers.rb +113 -0
- data/lib/fog/proxmox/compute/requests/list_snapshots.rb +66 -0
- data/lib/fog/proxmox/compute/requests/list_storages.rb +46 -0
- data/lib/fog/proxmox/compute/requests/list_tasks.rb +44 -0
- data/lib/fog/proxmox/compute/requests/list_volumes.rb +44 -0
- data/lib/fog/proxmox/compute/requests/log_task.rb +44 -0
- data/lib/fog/proxmox/compute/requests/migrate_server.rb +44 -0
- data/lib/fog/proxmox/compute/requests/move_disk.rb +43 -0
- data/lib/fog/proxmox/compute/requests/move_volume.rb +43 -0
- data/lib/fog/proxmox/compute/requests/next_vmid.rb +42 -0
- data/lib/fog/proxmox/compute/requests/resize_container.rb +43 -0
- data/lib/fog/proxmox/compute/requests/resize_server.rb +43 -0
- data/lib/fog/proxmox/compute/requests/rollback_snapshot.rb +48 -0
- data/lib/fog/proxmox/compute/requests/status_task.rb +41 -0
- data/lib/fog/proxmox/compute/requests/stop_task.rb +41 -0
- data/lib/fog/proxmox/compute/requests/template_server.rb +44 -0
- data/lib/fog/proxmox/compute/requests/update_server.rb +44 -0
- data/lib/fog/proxmox/compute/requests/update_snapshot.rb +45 -0
- data/lib/fog/proxmox/compute.rb +141 -0
- data/lib/fog/proxmox/core.rb +147 -0
- data/lib/fog/proxmox/errors.rb +65 -0
- data/lib/fog/proxmox/hash.rb +37 -0
- data/lib/fog/proxmox/helpers/controller_helper.rb +63 -0
- data/lib/fog/proxmox/helpers/cpu_helper.rb +88 -0
- data/lib/fog/proxmox/helpers/disk_helper.rb +185 -0
- data/lib/fog/proxmox/helpers/ip_helper.rb +101 -0
- data/lib/fog/proxmox/helpers/nic_helper.rb +132 -0
- data/lib/fog/proxmox/identity/models/domain.rb +69 -0
- data/lib/fog/proxmox/identity/models/domain_type.rb +47 -0
- data/lib/fog/proxmox/identity/models/domains.rb +44 -0
- data/lib/fog/proxmox/identity/models/group.rb +51 -0
- data/lib/fog/proxmox/identity/models/groups.rb +44 -0
- data/lib/fog/proxmox/identity/models/permission.rb +66 -0
- data/lib/fog/proxmox/identity/models/permissions.rb +46 -0
- data/lib/fog/proxmox/identity/models/pool.rb +89 -0
- data/lib/fog/proxmox/identity/models/pools.rb +46 -0
- data/lib/fog/proxmox/identity/models/principal.rb +42 -0
- data/lib/fog/proxmox/identity/models/role.rb +48 -0
- data/lib/fog/proxmox/identity/models/roles.rb +44 -0
- data/lib/fog/proxmox/identity/models/token.rb +72 -0
- data/lib/fog/proxmox/identity/models/token_info.rb +41 -0
- data/lib/fog/proxmox/identity/models/tokens.rb +54 -0
- data/lib/fog/proxmox/identity/models/user.rb +82 -0
- data/lib/fog/proxmox/identity/models/users.rb +44 -0
- data/lib/fog/proxmox/identity/requests/change_password.rb +41 -0
- data/lib/fog/proxmox/identity/requests/check_permissions.rb +41 -0
- data/lib/fog/proxmox/identity/requests/create_domain.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_group.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_pool.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_role.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_token.rb +40 -0
- data/lib/fog/proxmox/identity/requests/create_user.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_domain.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_group.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_pool.rb +39 -0
- data/lib/fog/proxmox/identity/requests/delete_role.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_token.rb +40 -0
- data/lib/fog/proxmox/identity/requests/delete_user.rb +39 -0
- data/lib/fog/proxmox/identity/requests/get_domain.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_group.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_pool.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_role.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_token_info.rb +41 -0
- data/lib/fog/proxmox/identity/requests/get_user.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_domains.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_groups.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_permissions.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_pools.rb +41 -0
- data/lib/fog/proxmox/identity/requests/list_roles.rb +40 -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/proxmox/identity/requests/list_users.rb +42 -0
- data/lib/fog/proxmox/identity/requests/read_version.rb +39 -0
- data/lib/fog/proxmox/identity/requests/update_domain.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_group.rb +40 -0
- data/lib/fog/proxmox/identity/requests/update_permissions.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_pool.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_role.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_token.rb +41 -0
- data/lib/fog/proxmox/identity/requests/update_user.rb +41 -0
- data/lib/fog/proxmox/identity.rb +144 -0
- data/lib/fog/proxmox/json.rb +32 -0
- data/lib/fog/proxmox/network/models/network.rb +76 -0
- data/lib/fog/proxmox/network/models/networks.rb +48 -0
- data/lib/fog/proxmox/network/models/node.rb +75 -0
- data/lib/fog/proxmox/network/models/nodes.rb +39 -0
- data/lib/fog/proxmox/network/requests/create_network.rb +41 -0
- data/lib/fog/proxmox/network/requests/delete_network.rb +42 -0
- data/lib/fog/proxmox/network/requests/get_network.rb +43 -0
- data/lib/fog/proxmox/network/requests/get_node.rb +41 -0
- data/lib/fog/proxmox/network/requests/list_networks.rb +43 -0
- data/lib/fog/proxmox/network/requests/list_nodes.rb +42 -0
- data/lib/fog/proxmox/network/requests/power_node.rb +43 -0
- data/lib/fog/proxmox/network/requests/update_network.rb +42 -0
- data/lib/fog/proxmox/network.rb +90 -0
- data/lib/fog/proxmox/storage/requests/create.rb +23 -0
- data/lib/fog/proxmox/storage/requests/download_appliance.rb +24 -0
- data/lib/fog/proxmox/storage/requests/list.rb +22 -0
- data/lib/fog/proxmox/storage/requests/list_appliances.rb +23 -0
- data/lib/fog/proxmox/storage/requests/upload.rb +44 -0
- data/lib/fog/proxmox/storage.rb +82 -0
- data/lib/fog/proxmox/string.rb +32 -0
- data/lib/fog/proxmox/variables.rb +40 -0
- data/lib/fog/proxmox/version.rb +24 -0
- data/lib/fog/proxmox.rb +53 -0
- data/spec/compute_spec.rb +447 -0
- data/spec/fixtures/proxmox/compute/common_auth.yml +40 -0
- data/spec/fixtures/proxmox/compute/containers.yml +6921 -0
- data/spec/fixtures/proxmox/compute/nodes.yml +115 -0
- data/spec/fixtures/proxmox/compute/servers.yml +19011 -0
- data/spec/fixtures/proxmox/compute/snapshots.yml +1376 -0
- data/spec/fixtures/proxmox/compute/storages.yml +151 -0
- data/spec/fixtures/proxmox/compute/tasks.yml +465 -0
- data/spec/fixtures/proxmox/identity/auth.yml +42 -0
- 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 +665 -0
- data/spec/fixtures/proxmox/identity/groups.yml +345 -0
- data/spec/fixtures/proxmox/identity/permissions.yml +911 -0
- data/spec/fixtures/proxmox/identity/pools.yml +946 -0
- data/spec/fixtures/proxmox/identity/read_version.yml +40 -0
- data/spec/fixtures/proxmox/identity/roles.yml +345 -0
- data/spec/fixtures/proxmox/identity/tokens.yml +494 -0
- data/spec/fixtures/proxmox/identity/users.yml +725 -0
- data/spec/fixtures/proxmox/network/common_auth.yml +40 -0
- data/spec/fixtures/proxmox/network/networks.yml +375 -0
- data/spec/fixtures/proxmox/pve.home +34 -0
- data/spec/hash_spec.rb +43 -0
- data/spec/helpers/controller_helper_spec.rb +157 -0
- data/spec/helpers/cpu_helper_spec.rb +82 -0
- data/spec/helpers/disk_helper_spec.rb +304 -0
- data/spec/helpers/ip_helper_spec.rb +177 -0
- data/spec/helpers/nic_helper_spec.rb +144 -0
- data/spec/identity_spec.rb +416 -0
- data/spec/network_spec.rb +67 -0
- data/spec/proxmox_vcr.rb +97 -0
- data/spec/spec_helper.rb +41 -0
- metadata +566 -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,382 @@
|
|
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
|
+
with access ticket:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
identity = Fog::Proxmox::Identity.new(
|
25
|
+
proxmox_url: 'https://localhost:8006/api2/json',
|
26
|
+
proxmox_auth_method: 'access_ticket',
|
27
|
+
proxmox_username: 'your_user@your_realm',
|
28
|
+
proxmox_password: 'his_password',
|
29
|
+
connection_options: { ... }
|
30
|
+
)
|
31
|
+
```
|
32
|
+
|
33
|
+
with API user token:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
identity = Fog::Proxmox::Identity.new(
|
37
|
+
proxmox_url: 'https://localhost:8006/api2/json',
|
38
|
+
proxmox_auth_method: 'user_token',
|
39
|
+
proxmox_userid: 'your_user@your_realm',
|
40
|
+
proxmox_tokenid: 'his_tokenid',
|
41
|
+
proxmox_token: 'his_token',
|
42
|
+
connection_options: { ... }
|
43
|
+
)
|
44
|
+
```
|
45
|
+
|
46
|
+
[connection_options](connection_parameters.md) are also available and optional.
|
47
|
+
|
48
|
+
## Fog Abstractions
|
49
|
+
|
50
|
+
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.
|
51
|
+
|
52
|
+
### Request Layer
|
53
|
+
|
54
|
+
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.
|
55
|
+
|
56
|
+
To see a list of requests supported by the identity service:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
identity.requests
|
60
|
+
```
|
61
|
+
|
62
|
+
To learn more about Identity request methods refer to source files.
|
63
|
+
|
64
|
+
To learn more about Excon refer to [Excon GitHub repo](https://github.com/geemus/excon).
|
65
|
+
|
66
|
+
### Model Layer
|
67
|
+
|
68
|
+
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.
|
69
|
+
|
70
|
+
Here is a summary of common model methods:
|
71
|
+
|
72
|
+
<table>
|
73
|
+
<tr>
|
74
|
+
<th>Method</th>
|
75
|
+
<th>Description</th>
|
76
|
+
</tr>
|
77
|
+
<tr>
|
78
|
+
<td>create</td>
|
79
|
+
<td>
|
80
|
+
Accepts hash of attributes and creates object.<br>
|
81
|
+
Note: creation is a non-blocking call and you will be required to wait for a valid state before using resulting object.
|
82
|
+
</td>
|
83
|
+
</tr>
|
84
|
+
<tr>
|
85
|
+
<td>update</td>
|
86
|
+
<td>Updates object.<br>
|
87
|
+
Note: not all objects support updating object.</td>
|
88
|
+
</tr>
|
89
|
+
<tr>
|
90
|
+
<td>destroy</td>
|
91
|
+
<td>
|
92
|
+
Destroys object.<br>
|
93
|
+
Note: this is a non-blocking call and object deletion might not be instantaneous.
|
94
|
+
</td>
|
95
|
+
<tr>
|
96
|
+
<td>attributes</td>
|
97
|
+
<td>Returns a hash containing the list of model attributes and values.</td>
|
98
|
+
</tr>
|
99
|
+
<td>identity</td>
|
100
|
+
<td>
|
101
|
+
Returns the identity of the object.<br>
|
102
|
+
Note: This might not always be equal to object.id.
|
103
|
+
</td>
|
104
|
+
</tr>
|
105
|
+
</table>
|
106
|
+
|
107
|
+
The remainder of this document details the model abstraction.
|
108
|
+
|
109
|
+
#### Users management
|
110
|
+
|
111
|
+
List all users:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
identity.users.all
|
115
|
+
```
|
116
|
+
|
117
|
+
This returns a collection of `Fog::Proxmox::Identity::User` models:
|
118
|
+
|
119
|
+
Create a user:
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
identity.users.create({
|
123
|
+
userid: 'bobsinclar@pve',
|
124
|
+
password: 'bobsinclar1',
|
125
|
+
firstname: 'Bob',
|
126
|
+
lastname: 'Sinclar',
|
127
|
+
email: 'bobsinclar@proxmox.com'
|
128
|
+
})
|
129
|
+
```
|
130
|
+
|
131
|
+
Get a user:
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
user = identity.users.find_by_id 'bobsinclar@pve'
|
135
|
+
```
|
136
|
+
|
137
|
+
Change his password:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
user.password = 'bobsinclar2'
|
141
|
+
user.change_password
|
142
|
+
```
|
143
|
+
|
144
|
+
Add groups to user:
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
user.groups = %w[group1 group2]
|
148
|
+
user.update
|
149
|
+
```
|
150
|
+
|
151
|
+
Delete user:
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
user.destroy
|
155
|
+
```
|
156
|
+
|
157
|
+
#### Groups management
|
158
|
+
|
159
|
+
Proxmox supports permissions management by group.
|
160
|
+
|
161
|
+
Proxmox recommends to manage permissions by group instead of by user.
|
162
|
+
|
163
|
+
List all groups:
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
identity.groups.all
|
167
|
+
```
|
168
|
+
|
169
|
+
This returns a collection of `Fog::Proxmox::Identity::Group` models:
|
170
|
+
|
171
|
+
Create a group:
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
identity.groups.create({
|
175
|
+
groupid: 'group1'
|
176
|
+
})
|
177
|
+
```
|
178
|
+
|
179
|
+
Get a group:
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
group = identity.groups.find_by_id 'group1'
|
183
|
+
```
|
184
|
+
|
185
|
+
Add a comment:
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
group.comment = 'Group 1'
|
189
|
+
group.update
|
190
|
+
```
|
191
|
+
|
192
|
+
Delete group:
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
group.destroy
|
196
|
+
```
|
197
|
+
|
198
|
+
#### Domains management
|
199
|
+
|
200
|
+
Proxmox supports 4 domains or realms (sources of authentication): PAM, PVE, LDAP and Active Directory.
|
201
|
+
|
202
|
+
Proxmox server has two default domains: PAM and PVE.
|
203
|
+
|
204
|
+
List all domains:
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
identity.domains.all
|
208
|
+
```
|
209
|
+
|
210
|
+
This returns a collection of `Fog::Proxmox::Identity::Domain` models:
|
211
|
+
|
212
|
+
Create a LDAP domain:
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
identity.domains.create({
|
216
|
+
realm: 'LDAP',
|
217
|
+
type: 'ldap',
|
218
|
+
base_dn: 'ou=People,dc=ldap-test,dc=com',
|
219
|
+
user_attr: 'LDAP',
|
220
|
+
server1: 'localhost',
|
221
|
+
port: 389,
|
222
|
+
default: 0,
|
223
|
+
secure: 0
|
224
|
+
})
|
225
|
+
```
|
226
|
+
|
227
|
+
Get a domain:
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
ldap = identity.domains.find_by_id 'LDAP'
|
231
|
+
```
|
232
|
+
|
233
|
+
Add a comment and a two factor authentication (OATH) to LDAP realm:
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
ldap.type.comment = 'Test domain LDAP'
|
237
|
+
ldap.type.tfa = 'type=oath,step=30,digits=8'
|
238
|
+
ldap.update
|
239
|
+
```
|
240
|
+
|
241
|
+
Delete domain:
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
ldap.destroy
|
245
|
+
```
|
246
|
+
|
247
|
+
#### Roles management
|
248
|
+
|
249
|
+
Proxmox supports roles management to give permissions to group of users.
|
250
|
+
|
251
|
+
Proxmox server has several defaults roles already created. See [Proxmox user management wiki page](https://pve.proxmox.com/wiki/User_Management)
|
252
|
+
|
253
|
+
List all roles:
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
identity.roles.all
|
257
|
+
```
|
258
|
+
|
259
|
+
This returns a collection of `Fog::Proxmox::Identity::Role` models:
|
260
|
+
|
261
|
+
Create a new role:
|
262
|
+
|
263
|
+
```ruby
|
264
|
+
identity.roles.create({ roleid: 'PVETestAuditor' })
|
265
|
+
```
|
266
|
+
|
267
|
+
Get the role:
|
268
|
+
|
269
|
+
```ruby
|
270
|
+
role = identity.groups.find_by_id 'PVETestAuditor'
|
271
|
+
```
|
272
|
+
|
273
|
+
Add privileges to this new role:
|
274
|
+
|
275
|
+
```ruby
|
276
|
+
role.privs = 'Datastore.Audit Sys.Audit VM.Audit'
|
277
|
+
role.update
|
278
|
+
```
|
279
|
+
|
280
|
+
List of all available privileges can be seen at [Proxmox user management wiki page](https://pve.proxmox.com/wiki/User_Management)
|
281
|
+
|
282
|
+
Delete role:
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
role.destroy
|
286
|
+
```
|
287
|
+
|
288
|
+
#### Permissions management
|
289
|
+
|
290
|
+
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.
|
291
|
+
|
292
|
+
See more details in [Proxmox user management wiki page](https://pve.proxmox.com/wiki/User_Management)
|
293
|
+
|
294
|
+
List all permissions:
|
295
|
+
|
296
|
+
```ruby
|
297
|
+
identity.permissions.all
|
298
|
+
```
|
299
|
+
|
300
|
+
This returns a collection of `Fog::Proxmox::Identity::Permission` models:
|
301
|
+
|
302
|
+
Add a new permission (manage users) to a user:
|
303
|
+
|
304
|
+
```ruby
|
305
|
+
identity.permissions.add({
|
306
|
+
path: '/access/users',
|
307
|
+
roles: 'PVEUserAdmin',
|
308
|
+
users: 'bobsinclar@pve'
|
309
|
+
})
|
310
|
+
```
|
311
|
+
|
312
|
+
Add a new permission (manage users) to a group of users:
|
313
|
+
|
314
|
+
```ruby
|
315
|
+
identity.permissions.add({
|
316
|
+
path: '/access/users',
|
317
|
+
roles: 'PVEUserAdmin',
|
318
|
+
groups: 'group1'
|
319
|
+
})
|
320
|
+
```
|
321
|
+
|
322
|
+
Remove a permission to a user:
|
323
|
+
|
324
|
+
```ruby
|
325
|
+
identity.permissions.remove({
|
326
|
+
path: '/access/users',
|
327
|
+
roles: 'PVEUserAdmin',
|
328
|
+
users: 'bobsinclar@pve'
|
329
|
+
})
|
330
|
+
```
|
331
|
+
|
332
|
+
User permissions:
|
333
|
+
|
334
|
+
|
335
|
+
```ruby
|
336
|
+
bob = identity.users.get 'bobsinclar@pve'
|
337
|
+
bob.permissions
|
338
|
+
```
|
339
|
+
|
340
|
+
#### Pools management
|
341
|
+
|
342
|
+
Proxmox supports pools management of VMs or storages. It eases managing permissions on these.
|
343
|
+
|
344
|
+
Create a pool:
|
345
|
+
|
346
|
+
```ruby
|
347
|
+
identity.pools.create { poolid: 'pool1' }
|
348
|
+
```
|
349
|
+
|
350
|
+
Get a pool:
|
351
|
+
|
352
|
+
```ruby
|
353
|
+
pool1 = identity.pools.find_by_id 'pool1'
|
354
|
+
```
|
355
|
+
|
356
|
+
Add comment, server 100 and storage local-lvm to the pool:
|
357
|
+
|
358
|
+
```ruby
|
359
|
+
pool1.comment = 'Pool 1'
|
360
|
+
pool1.update
|
361
|
+
pool1.add_server 100
|
362
|
+
pool1.add_storage 'local-lvm '
|
363
|
+
```
|
364
|
+
|
365
|
+
Get all pools:
|
366
|
+
|
367
|
+
```ruby
|
368
|
+
identity.pools.all
|
369
|
+
```
|
370
|
+
|
371
|
+
Delete pool:
|
372
|
+
|
373
|
+
```ruby
|
374
|
+
# you need to remove all members before deleting pool
|
375
|
+
pool1.remove_server 100
|
376
|
+
pool1.remove_storage 'local-lvm '
|
377
|
+
pool1.destroy
|
378
|
+
```
|
379
|
+
|
380
|
+
### Examples
|
381
|
+
|
382
|
+
More examples can be seen at [examples/identity.rb](examples/identity.rb) or [spec/identity_spec.rb](spec/identity_spec.rb).
|