fog-openstack 1.0.10 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linting.yml +20 -0
- data/.github/workflows/main.yml +37 -0
- data/.rubocop.yml +65 -66
- data/fog-openstack.gemspec +1 -2
- data/lib/fog/openstack/auth/name.rb +1 -1
- data/lib/fog/openstack/core.rb +1 -1
- data/lib/fog/openstack/orchestration/models/stacks.rb +4 -3
- data/lib/fog/openstack/orchestration/requests/show_stack.rb +26 -0
- data/lib/fog/openstack/orchestration.rb +1 -0
- data/lib/fog/openstack/shared_file_system.rb +2 -2
- data/lib/fog/openstack/version.rb +1 -1
- data/lib/fog/openstack/volume/v3/mock.rb +68 -0
- data/lib/fog/openstack/volume/v3/models/availability_zone.rb +15 -0
- data/lib/fog/openstack/volume/v3/models/availability_zones.rb +16 -0
- data/lib/fog/openstack/volume/v3/models/backup.rb +15 -0
- data/lib/fog/openstack/volume/v3/models/backups.rb +16 -0
- data/lib/fog/openstack/volume/v3/models/snapshot.rb +44 -0
- data/lib/fog/openstack/volume/v3/models/snapshots.rb +16 -0
- data/lib/fog/openstack/volume/v3/models/transfer.rb +18 -0
- data/lib/fog/openstack/volume/v3/models/transfers.rb +16 -0
- data/lib/fog/openstack/volume/v3/models/volume.rb +37 -0
- data/lib/fog/openstack/volume/v3/models/volume_type.rb +16 -0
- data/lib/fog/openstack/volume/v3/models/volume_types.rb +16 -0
- data/lib/fog/openstack/volume/v3/models/volumes.rb +16 -0
- data/lib/fog/openstack/volume/v3/real.rb +23 -0
- data/lib/fog/openstack/volume/v3/requests/accept_transfer.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/action.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/create_backup.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/create_snapshot.rb +45 -0
- data/lib/fog/openstack/volume/v3/requests/create_transfer.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/create_volume.rb +49 -0
- data/lib/fog/openstack/volume/v3/requests/create_volume_type.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/delete_backup.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/delete_metadata.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/delete_snapshot.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/delete_snapshot_metadata.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/delete_transfer.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/delete_volume.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/delete_volume_type.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/extend_volume.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/get_backup_details.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/get_quota.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/get_quota_defaults.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/get_quota_usage.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/get_snapshot_details.rb +32 -0
- data/lib/fog/openstack/volume/v3/requests/get_transfer_details.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/get_volume_details.rb +35 -0
- data/lib/fog/openstack/volume/v3/requests/get_volume_type_details.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/list_backups.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/list_backups_detailed.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/list_snapshots.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/list_snapshots_detailed.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/list_transfers.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/list_transfers_detailed.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/list_volume_types.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/list_volumes.rb +46 -0
- data/lib/fog/openstack/volume/v3/requests/list_volumes_detailed.rb +46 -0
- data/lib/fog/openstack/volume/v3/requests/list_zones.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/real.rb +11 -0
- data/lib/fog/openstack/volume/v3/requests/real_mock.rb +14 -0
- data/lib/fog/openstack/volume/v3/requests/replace_metadata.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/restore_backup.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/set_tenant.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/snapshot_action.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/update_metadata.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/update_quota.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/update_snapshot.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/update_snapshot_metadata.rb +2 -0
- data/lib/fog/openstack/volume/v3/requests/update_volume.rb +20 -0
- data/lib/fog/openstack/volume/v3/requests/update_volume_type.rb +2 -0
- data/lib/fog/openstack/volume/v3.rb +94 -0
- data/lib/fog/openstack/volume.rb +11 -10
- data/supported.md +1 -2
- metadata +72 -23
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fog/openstack/models/collection'
|
2
|
+
require 'fog/openstack/volume/v3/models/volume'
|
3
|
+
require 'fog/openstack/volume/models/volumes'
|
4
|
+
|
5
|
+
module Fog
|
6
|
+
module OpenStack
|
7
|
+
class Volume
|
8
|
+
class V3
|
9
|
+
class Volumes < Fog::OpenStack::Collection
|
10
|
+
model Fog::OpenStack::Volume::V3::Volume
|
11
|
+
include Fog::OpenStack::Volume::Volumes
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Fog
|
2
|
+
module OpenStack
|
3
|
+
class Volume
|
4
|
+
class V3 < Fog::OpenStack::Volume
|
5
|
+
class Real
|
6
|
+
include Fog::OpenStack::Core
|
7
|
+
|
8
|
+
def self.not_found_class
|
9
|
+
Fog::OpenStack::Volume::NotFound
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_endtpoint_type
|
13
|
+
'admin'
|
14
|
+
end
|
15
|
+
|
16
|
+
def default_service_type
|
17
|
+
%w[volumev3]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'fog/openstack/volume/requests/create_snapshot'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module OpenStack
|
5
|
+
class Volume
|
6
|
+
class V3
|
7
|
+
class Real
|
8
|
+
include Fog::OpenStack::Volume::Real
|
9
|
+
|
10
|
+
def create_snapshot(volume_id, name, description, force = false)
|
11
|
+
data = {
|
12
|
+
'snapshot' => {
|
13
|
+
'volume_id' => volume_id,
|
14
|
+
'name' => name,
|
15
|
+
'description' => description,
|
16
|
+
'force' => force.nil? ? false : force
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
_create_snapshot(data)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Mock
|
25
|
+
def create_snapshot(volume_id, name, description, _force = false)
|
26
|
+
response = Excon::Response.new
|
27
|
+
response.status = 202
|
28
|
+
response.body = {
|
29
|
+
"snapshot" => {
|
30
|
+
"status" => "creating",
|
31
|
+
"name" => name,
|
32
|
+
"created_at" => Time.now,
|
33
|
+
"description" => description,
|
34
|
+
"volume_id" => volume_id,
|
35
|
+
"id" => "5",
|
36
|
+
"size" => 1
|
37
|
+
}
|
38
|
+
}
|
39
|
+
response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'fog/openstack/volume/requests/create_volume'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module OpenStack
|
5
|
+
class Volume
|
6
|
+
class V3
|
7
|
+
class Real
|
8
|
+
def create_volume(name, description, size, options = {})
|
9
|
+
data = {
|
10
|
+
'volume' => {
|
11
|
+
'name' => name,
|
12
|
+
'description' => description,
|
13
|
+
'size' => size
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
_create_volume(data, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
include Fog::OpenStack::Volume::Real
|
21
|
+
end
|
22
|
+
|
23
|
+
class Mock
|
24
|
+
def create_volume(name, description, size, options = {})
|
25
|
+
response = Excon::Response.new
|
26
|
+
response.status = 202
|
27
|
+
response.body = {
|
28
|
+
'volume' => {
|
29
|
+
'id' => Fog::Mock.random_numbers(2),
|
30
|
+
'name' => name,
|
31
|
+
'description' => description,
|
32
|
+
'metadata' => options['metadata'] || {},
|
33
|
+
'size' => size,
|
34
|
+
'status' => 'creating',
|
35
|
+
'snapshot_id' => options[:snapshot_id] || nil,
|
36
|
+
'image_id' => options[:imageRef] || nil,
|
37
|
+
'volume_type' => nil,
|
38
|
+
'availability_zone' => 'nova',
|
39
|
+
'created_at' => Time.now,
|
40
|
+
'attachments' => []
|
41
|
+
}
|
42
|
+
}
|
43
|
+
response
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fog/openstack/volume/requests/get_snapshot_details'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module OpenStack
|
5
|
+
class Volume
|
6
|
+
class V3
|
7
|
+
class Real
|
8
|
+
include Fog::OpenStack::Volume::Real
|
9
|
+
end
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
def get_snapshot_details(_detailed = true)
|
13
|
+
response = Excon::Response.new
|
14
|
+
response.status = 200
|
15
|
+
response.body = {
|
16
|
+
'snapshot' => {
|
17
|
+
'id' => '1',
|
18
|
+
'name' => 'Snapshot1',
|
19
|
+
'description' => 'Volume1 snapshot',
|
20
|
+
'size' => 1,
|
21
|
+
'volume_id' => '1',
|
22
|
+
'status' => 'available',
|
23
|
+
'created_at' => Time.now
|
24
|
+
}
|
25
|
+
}
|
26
|
+
response
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'fog/openstack/volume/requests/get_volume_details'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module OpenStack
|
5
|
+
class Volume
|
6
|
+
class V3
|
7
|
+
class Real
|
8
|
+
include Fog::OpenStack::Volume::Real
|
9
|
+
end
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
def get_volume_details(_detailed = true)
|
13
|
+
response = Excon::Response.new
|
14
|
+
response.status = 200
|
15
|
+
response.body = {
|
16
|
+
'volume' => {
|
17
|
+
'id' => '1',
|
18
|
+
'name' => Fog::Mock.random_letters(rand(8) + 5),
|
19
|
+
'description' => Fog::Mock.random_letters(rand(12) + 10),
|
20
|
+
'size' => 3,
|
21
|
+
'volume_type' => nil,
|
22
|
+
'snapshot_id' => '4',
|
23
|
+
'status' => 'online',
|
24
|
+
'availability_zone' => 'nova',
|
25
|
+
'created_at' => Time.now,
|
26
|
+
'attachments' => []
|
27
|
+
}
|
28
|
+
}
|
29
|
+
response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fog/openstack/volume/requests/list_volumes'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module OpenStack
|
5
|
+
class Volume
|
6
|
+
class V3
|
7
|
+
class Real
|
8
|
+
include Fog::OpenStack::Volume::Real
|
9
|
+
end
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
def list_volumes(_options = true, _options_deprecated = {})
|
13
|
+
response = Excon::Response.new
|
14
|
+
response.status = 200
|
15
|
+
data[:volumes] ||= [
|
16
|
+
{"status" => "available",
|
17
|
+
"description" => "test 1 desc",
|
18
|
+
"availability_zone" => "nova",
|
19
|
+
"name" => "Volume1",
|
20
|
+
"attachments" => [{}],
|
21
|
+
"volume_type" => nil,
|
22
|
+
"snapshot_id" => nil,
|
23
|
+
"size" => 1,
|
24
|
+
"id" => 1,
|
25
|
+
"created_at" => Time.now,
|
26
|
+
"metadata" => {}},
|
27
|
+
{"status" => "available",
|
28
|
+
"description" => "test 2 desc",
|
29
|
+
"availability_zone" => "nova",
|
30
|
+
"name" => "Volume2",
|
31
|
+
"attachments" => [{}],
|
32
|
+
"volume_type" => nil,
|
33
|
+
"snapshot_id" => nil,
|
34
|
+
"size" => 1,
|
35
|
+
"id" => 2,
|
36
|
+
"created_at" => Time.now,
|
37
|
+
"metadata" => {}}
|
38
|
+
]
|
39
|
+
response.body = {'volumes' => data[:volumes]}
|
40
|
+
response
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fog/openstack/volume/requests/list_volumes_detailed'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module OpenStack
|
5
|
+
class Volume
|
6
|
+
class V3
|
7
|
+
class Real
|
8
|
+
include Fog::OpenStack::Volume::Real
|
9
|
+
end
|
10
|
+
|
11
|
+
class Mock
|
12
|
+
def list_volumes_detailed(_options = {})
|
13
|
+
response = Excon::Response.new
|
14
|
+
response.status = 200
|
15
|
+
data[:volumes] ||= [
|
16
|
+
{"status" => "available",
|
17
|
+
"description" => "test 1 desc",
|
18
|
+
"availability_zone" => "nova",
|
19
|
+
"name" => "Volume1",
|
20
|
+
"attachments" => [{}],
|
21
|
+
"volume_type" => nil,
|
22
|
+
"snapshot_id" => nil,
|
23
|
+
"size" => 1,
|
24
|
+
"id" => 1,
|
25
|
+
"created_at" => Time.now,
|
26
|
+
"metadata" => {}},
|
27
|
+
{"status" => "available",
|
28
|
+
"description" => "test 2 desc",
|
29
|
+
"availability_zone" => "nova",
|
30
|
+
"name" => "Volume2",
|
31
|
+
"attachments" => [{}],
|
32
|
+
"volume_type" => nil,
|
33
|
+
"snapshot_id" => nil,
|
34
|
+
"size" => 1,
|
35
|
+
"id" => 2,
|
36
|
+
"created_at" => Time.now,
|
37
|
+
"metadata" => {}}
|
38
|
+
]
|
39
|
+
response.body = {'volumes' => data[:volumes]}
|
40
|
+
response
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fog/openstack/volume/requests/update_volume'
|
2
|
+
require 'fog/openstack/volume/v3/requests/real'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module OpenStack
|
6
|
+
class Volume
|
7
|
+
module Real
|
8
|
+
def update_volume(volume_id, data = {})
|
9
|
+
data = data.select { |key| key == :name || key == :description || key == :metadata }
|
10
|
+
request(
|
11
|
+
:body => Fog::JSON.encode('volume' => data),
|
12
|
+
:expects => 200,
|
13
|
+
:method => 'PUT',
|
14
|
+
:path => "volumes/#{volume_id}"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'fog/openstack/core'
|
2
|
+
require 'fog/openstack/volume'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module OpenStack
|
6
|
+
class Volume
|
7
|
+
class V3 < Fog::OpenStack::Volume
|
8
|
+
SUPPORTED_VERSIONS = /v3(\.(0-9))*/
|
9
|
+
|
10
|
+
requires :openstack_auth_url
|
11
|
+
|
12
|
+
recognizes *@@recognizes
|
13
|
+
|
14
|
+
model_path 'fog/openstack/volume/v3/models'
|
15
|
+
|
16
|
+
model :volume
|
17
|
+
collection :volumes
|
18
|
+
|
19
|
+
model :availability_zone
|
20
|
+
collection :availability_zones
|
21
|
+
|
22
|
+
model :volume_type
|
23
|
+
collection :volume_types
|
24
|
+
|
25
|
+
model :snapshot
|
26
|
+
collection :snapshots
|
27
|
+
|
28
|
+
model :transfer
|
29
|
+
collection :transfers
|
30
|
+
|
31
|
+
model :backup
|
32
|
+
collection :backups
|
33
|
+
|
34
|
+
request_path 'fog/openstack/volume/v3/requests'
|
35
|
+
|
36
|
+
# Volume
|
37
|
+
request :list_volumes
|
38
|
+
request :list_volumes_detailed
|
39
|
+
request :create_volume
|
40
|
+
request :update_volume
|
41
|
+
request :get_volume_details
|
42
|
+
request :extend_volume
|
43
|
+
request :delete_volume
|
44
|
+
|
45
|
+
request :list_zones
|
46
|
+
|
47
|
+
request :list_volume_types
|
48
|
+
request :create_volume_type
|
49
|
+
request :update_volume_type
|
50
|
+
request :delete_volume_type
|
51
|
+
request :get_volume_type_details
|
52
|
+
|
53
|
+
request :create_snapshot
|
54
|
+
request :update_snapshot
|
55
|
+
request :list_snapshots
|
56
|
+
request :list_snapshots_detailed
|
57
|
+
request :get_snapshot_details
|
58
|
+
request :delete_snapshot
|
59
|
+
request :update_snapshot_metadata
|
60
|
+
request :delete_snapshot_metadata
|
61
|
+
|
62
|
+
request :list_transfers
|
63
|
+
request :list_transfers_detailed
|
64
|
+
request :create_transfer
|
65
|
+
request :get_transfer_details
|
66
|
+
request :accept_transfer
|
67
|
+
request :delete_transfer
|
68
|
+
|
69
|
+
request :list_backups
|
70
|
+
request :list_backups_detailed
|
71
|
+
request :create_backup
|
72
|
+
request :get_backup_details
|
73
|
+
request :restore_backup
|
74
|
+
request :delete_backup
|
75
|
+
|
76
|
+
request :update_quota
|
77
|
+
request :get_quota
|
78
|
+
request :get_quota_defaults
|
79
|
+
request :get_quota_usage
|
80
|
+
|
81
|
+
request :update_metadata
|
82
|
+
request :replace_metadata
|
83
|
+
request :delete_metadata
|
84
|
+
|
85
|
+
request :set_tenant
|
86
|
+
request :action
|
87
|
+
request :snapshot_action
|
88
|
+
|
89
|
+
autoload :Mock, 'fog/openstack/volume/v3/mock'
|
90
|
+
autoload :Real, 'fog/openstack/volume/v3/real'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/fog/openstack/volume.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
module Fog
|
4
2
|
module OpenStack
|
5
3
|
class Volume < Fog::Service
|
6
4
|
autoload :V1, 'fog/openstack/volume/v1'
|
7
5
|
autoload :V2, 'fog/openstack/volume/v2'
|
6
|
+
autoload :V3, 'fog/openstack/volume/v3'
|
8
7
|
|
9
8
|
@@recognizes = [:openstack_auth_token, :openstack_management_url,
|
10
9
|
:persistent, :openstack_service_type, :openstack_service_name,
|
@@ -17,16 +16,18 @@ module Fog
|
|
17
16
|
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
|
18
17
|
:openstack_identity_api_version]
|
19
18
|
|
20
|
-
# Fog::OpenStack::Image.new() will return a Fog::OpenStack::Volume::
|
21
|
-
# choosing the
|
19
|
+
# Fog::OpenStack::Image.new() will return a Fog::OpenStack::Volume::V3 or a Fog::OpenStack::Volume::V2 or a
|
20
|
+
# Fog::OpenStack::Volume::V1, choosing the V3 by default, as V2 is deprecated since OpenStackWallaby and V1 is
|
21
|
+
# deprecated since OpenStack Juno
|
22
22
|
def self.new(args = {})
|
23
23
|
@openstack_auth_uri = URI.parse(args[:openstack_auth_url]) if args[:openstack_auth_url]
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
if inspect == 'Fog::OpenStack::Volume'
|
25
|
+
Fog::OpenStack::Volume::V3.new(args) \
|
26
|
+
|| Fog::OpenStack::Volume::V2.new(args) \
|
27
|
+
|| Fog::OpenStack::Volume::V1.new(args)
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|