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,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_domain request
|
25
|
+
class Real
|
26
|
+
def update_domain(realm, attributes)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'PUT',
|
30
|
+
path: "access/domains/#{realm}",
|
31
|
+
body: URI.encode_www_form(attributes)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# class Real update_domain request
|
37
|
+
class Mock
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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 Real update_group request
|
24
|
+
class Real
|
25
|
+
def update_group(groupid, options)
|
26
|
+
request(
|
27
|
+
expects: [200],
|
28
|
+
method: 'PUT',
|
29
|
+
path: "access/groups/#{groupid}",
|
30
|
+
body: URI.encode_www_form(options)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# class Mock update_group request
|
36
|
+
class Mock
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -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_permissions request
|
25
|
+
class Real
|
26
|
+
def update_permissions(body_params)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'PUT',
|
30
|
+
path: 'access/acl',
|
31
|
+
body: URI.encode_www_form(body_params)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# class Mock update_permissions request
|
37
|
+
class Mock
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -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_pool request
|
25
|
+
class Real
|
26
|
+
def update_pool(poolid, attributes)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'PUT',
|
30
|
+
path: "pools/#{poolid}",
|
31
|
+
body: URI.encode_www_form(attributes)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# class Mock update_pool request
|
37
|
+
class Mock
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -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_role request
|
25
|
+
class Real
|
26
|
+
def update_role(roleid, attributes)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'PUT',
|
30
|
+
path: "access/roles/#{roleid}",
|
31
|
+
body: URI.encode_www_form(attributes)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# class Mock update_role request
|
37
|
+
class Mock
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -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
|
@@ -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_user request
|
25
|
+
class Real
|
26
|
+
def update_user(userid, attributes)
|
27
|
+
request(
|
28
|
+
expects: [200],
|
29
|
+
method: 'PUT',
|
30
|
+
path: "access/users/#{userid}",
|
31
|
+
body: URI.encode_www_form(attributes)
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# class Mock update_user request
|
37
|
+
class Mock
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,144 @@
|
|
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
|
+
require 'fog/core'
|
22
|
+
require 'fog/proxmox/string'
|
23
|
+
|
24
|
+
module Fog
|
25
|
+
module Proxmox
|
26
|
+
# Identity and authentication proxmox class
|
27
|
+
class Identity < Fog::Service
|
28
|
+
requires :proxmox_url, :proxmox_auth_method
|
29
|
+
recognizes :proxmox_token, :proxmox_tokenid, :proxmox_userid, :persistent, :proxmox_username, :proxmox_password
|
30
|
+
|
31
|
+
model_path 'fog/proxmox/identity/models'
|
32
|
+
model :principal
|
33
|
+
model :user
|
34
|
+
collection :users
|
35
|
+
model :token
|
36
|
+
collection :tokens
|
37
|
+
model :group
|
38
|
+
collection :groups
|
39
|
+
model :pool
|
40
|
+
collection :pools
|
41
|
+
model :role
|
42
|
+
collection :roles
|
43
|
+
model :domain
|
44
|
+
model :domain_type
|
45
|
+
collection :domains
|
46
|
+
model :permission
|
47
|
+
collection :permissions
|
48
|
+
|
49
|
+
request_path 'fog/proxmox/identity/requests'
|
50
|
+
|
51
|
+
# Manage permissions
|
52
|
+
request :check_permissions
|
53
|
+
request :list_permissions
|
54
|
+
request :list_user_permissions
|
55
|
+
request :update_permissions
|
56
|
+
request :read_version
|
57
|
+
|
58
|
+
# Manage users
|
59
|
+
request :list_users
|
60
|
+
request :get_user
|
61
|
+
request :create_user
|
62
|
+
request :update_user
|
63
|
+
request :delete_user
|
64
|
+
request :change_password
|
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
|
+
|
73
|
+
# CRUD groups
|
74
|
+
request :list_groups
|
75
|
+
request :get_group
|
76
|
+
request :create_group
|
77
|
+
request :update_group
|
78
|
+
request :delete_group
|
79
|
+
|
80
|
+
# CRUD roles
|
81
|
+
request :list_roles
|
82
|
+
request :get_role
|
83
|
+
request :create_role
|
84
|
+
request :update_role
|
85
|
+
request :delete_role
|
86
|
+
|
87
|
+
# CRUD domains
|
88
|
+
request :list_domains
|
89
|
+
request :get_domain
|
90
|
+
request :create_domain
|
91
|
+
request :update_domain
|
92
|
+
request :delete_domain
|
93
|
+
|
94
|
+
# CRUD pools
|
95
|
+
request :list_pools
|
96
|
+
request :get_pool
|
97
|
+
request :create_pool
|
98
|
+
request :update_pool
|
99
|
+
request :delete_pool
|
100
|
+
|
101
|
+
# Mock class
|
102
|
+
class Mock
|
103
|
+
attr_reader :config
|
104
|
+
|
105
|
+
def initialize(options = {})
|
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
|
114
|
+
@config = options
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Real class
|
119
|
+
class Real
|
120
|
+
include Fog::Proxmox::Core
|
121
|
+
|
122
|
+
def self.not_found_class
|
123
|
+
Fog::Proxmox::Identity::NotFound
|
124
|
+
end
|
125
|
+
|
126
|
+
def config
|
127
|
+
self
|
128
|
+
end
|
129
|
+
|
130
|
+
def config_service?
|
131
|
+
true
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def configure(source)
|
137
|
+
source.instance_variables.each do |v|
|
138
|
+
instance_variable_set(v, source.instance_variable_get(v))
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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/json'
|
21
|
+
|
22
|
+
module Fog
|
23
|
+
module Proxmox
|
24
|
+
# module Json mixins
|
25
|
+
module Json
|
26
|
+
def self.get_data(response)
|
27
|
+
body = JSON.decode(response.body)
|
28
|
+
body['data']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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
|
+
# Copyright 2018 Tristan Robert
|
11
|
+
|
12
|
+
# This file is part of Fog::Proxmox.
|
13
|
+
|
14
|
+
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
15
|
+
# it under the terms of the GNU General Public License as published by
|
16
|
+
# the Free Software Foundation, either version 3 of the License, or
|
17
|
+
# (at your option) any later version.
|
18
|
+
|
19
|
+
# Fog::Proxmox is distributed in the hope that it will be useful,
|
20
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22
|
+
# GNU General Public License for more details.
|
23
|
+
|
24
|
+
# You should have received a copy of the GNU General Public License
|
25
|
+
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
26
|
+
|
27
|
+
# frozen_string_literal: true
|
28
|
+
|
29
|
+
module Fog
|
30
|
+
module Proxmox
|
31
|
+
class Network
|
32
|
+
# class Network model
|
33
|
+
class Network < Fog::Model
|
34
|
+
identity :iface
|
35
|
+
attribute :node_id
|
36
|
+
attribute :comments
|
37
|
+
attribute :active
|
38
|
+
attribute :autostart
|
39
|
+
attribute :type
|
40
|
+
attribute :gateway
|
41
|
+
attribute :priority
|
42
|
+
attribute :exists
|
43
|
+
attribute :method
|
44
|
+
attribute :method6
|
45
|
+
attribute :netmask
|
46
|
+
attribute :address
|
47
|
+
attribute :families
|
48
|
+
attribute :bridge_stp
|
49
|
+
attribute :bridge_fd
|
50
|
+
attribute :bridge_ports
|
51
|
+
|
52
|
+
TYPES = %w[bridge bond eth alias vlan OVSBridge OVSBond OVSPort OVSIntPort any_bridge].freeze
|
53
|
+
|
54
|
+
def save(options = {})
|
55
|
+
requires :node_id
|
56
|
+
path_params = { node: node_id }
|
57
|
+
body_params = options.merge(attributes.reject { |attribute| [:node_id].include? attribute })
|
58
|
+
service.create_network(path_params, body_params)
|
59
|
+
end
|
60
|
+
|
61
|
+
def update(options = {})
|
62
|
+
requires :node_id, :iface, :type
|
63
|
+
path_params = { node: node_id, iface: iface }
|
64
|
+
body_params = options.merge(type: type)
|
65
|
+
service.update_network(path_params, body_params)
|
66
|
+
end
|
67
|
+
|
68
|
+
def destroy
|
69
|
+
requires :node_id, :iface
|
70
|
+
path_params = { node: node_id, iface: iface }
|
71
|
+
service.delete_network(path_params)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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/network/models/node'
|
21
|
+
|
22
|
+
module Fog
|
23
|
+
module Proxmox
|
24
|
+
class Network
|
25
|
+
# class Networks Collection of nodes of cluster
|
26
|
+
class Networks < Fog::Collection
|
27
|
+
model Fog::Proxmox::Network::Network
|
28
|
+
attribute :node_id
|
29
|
+
|
30
|
+
def new(attributes = {})
|
31
|
+
requires :node_id
|
32
|
+
super({ node_id: node_id }.merge(attributes))
|
33
|
+
end
|
34
|
+
|
35
|
+
def all(filters = {})
|
36
|
+
requires :node_id
|
37
|
+
path_params = { node: node_id }
|
38
|
+
query_params = filters
|
39
|
+
load service.list_networks(path_params, query_params)
|
40
|
+
end
|
41
|
+
|
42
|
+
def get(id)
|
43
|
+
all.find { |network| network.identity == id }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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
|
+
# Copyright 2018 Tristan Robert
|
11
|
+
|
12
|
+
# This file is part of Fog::Proxmox.
|
13
|
+
|
14
|
+
# Fog::Proxmox is free software: you can redistribute it and/or modify
|
15
|
+
# it under the terms of the GNU General Public License as published by
|
16
|
+
# the Free Software Foundation, either version 3 of the License, or
|
17
|
+
# (at your option) any later version.
|
18
|
+
|
19
|
+
# Fog::Proxmox is distributed in the hope that it will be useful,
|
20
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22
|
+
# GNU General Public License for more details.
|
23
|
+
|
24
|
+
# You should have received a copy of the GNU General Public License
|
25
|
+
# along with Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
26
|
+
|
27
|
+
# frozen_string_literal: true
|
28
|
+
|
29
|
+
module Fog
|
30
|
+
module Proxmox
|
31
|
+
class Network
|
32
|
+
# class Node model of VMs
|
33
|
+
class Node < Fog::Model
|
34
|
+
identity :node
|
35
|
+
attribute :status
|
36
|
+
attribute :wait
|
37
|
+
attribute :uptime
|
38
|
+
attribute :proxmoxversion
|
39
|
+
attribute :ksm
|
40
|
+
attribute :kversion
|
41
|
+
attribute :loadavg
|
42
|
+
attribute :rootfs
|
43
|
+
attribute :cpu
|
44
|
+
attribute :cpuinfo
|
45
|
+
attribute :memory
|
46
|
+
attribute :idle
|
47
|
+
attribute :swap
|
48
|
+
attribute :networks
|
49
|
+
|
50
|
+
def initialize(new_attributes = {})
|
51
|
+
prepare_service_value(new_attributes)
|
52
|
+
attributes[:node] = new_attributes['node'] unless new_attributes['node'].nil?
|
53
|
+
attributes[:node] = new_attributes[:node] unless new_attributes[:node].nil?
|
54
|
+
requires :node
|
55
|
+
initialize_networks
|
56
|
+
super(new_attributes)
|
57
|
+
end
|
58
|
+
|
59
|
+
def power(action)
|
60
|
+
action_known = %w[reboot shutdown].include? action
|
61
|
+
message = "Action #{action} not implemented"
|
62
|
+
raise Fog::Errors::Error, message unless action_known
|
63
|
+
|
64
|
+
service.power_node({ node: node }, command: action)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def initialize_networks
|
70
|
+
attributes[:networks] = Fog::Proxmox::Network::Networks.new(service: service, node_id: node)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|