fog-openstack 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/examples/volume/backups.rb +41 -0
  3. data/lib/fog/compute/openstack/models/server.rb +5 -1
  4. data/lib/fog/dns/openstack/v2.rb +43 -3
  5. data/lib/fog/dns/openstack/v2/requests/create_recordset.rb +54 -0
  6. data/lib/fog/dns/openstack/v2/requests/create_zone.rb +49 -0
  7. data/lib/fog/dns/openstack/v2/requests/delete_recordset.rb +34 -0
  8. data/lib/fog/dns/openstack/v2/requests/delete_zone.rb +33 -0
  9. data/lib/fog/dns/openstack/v2/requests/get_recordset.rb +34 -0
  10. data/lib/fog/dns/openstack/v2/requests/get_zone.rb +28 -0
  11. data/lib/fog/dns/openstack/v2/requests/list_recordsets.rb +30 -0
  12. data/lib/fog/dns/openstack/v2/requests/update_recordset.rb +37 -0
  13. data/lib/fog/dns/openstack/v2/requests/update_zone.rb +36 -0
  14. data/lib/fog/network/openstack/requests/update_router.rb +6 -4
  15. data/lib/fog/openstack/version.rb +1 -1
  16. data/lib/fog/volume/openstack/models/backup.rb +46 -0
  17. data/lib/fog/volume/openstack/models/backups.rb +26 -0
  18. data/lib/fog/volume/openstack/requests/create_backup.rb +49 -0
  19. data/lib/fog/volume/openstack/requests/delete_backup.rb +23 -0
  20. data/lib/fog/volume/openstack/requests/get_backup_details.rb +34 -0
  21. data/lib/fog/volume/openstack/requests/list_backups.rb +16 -0
  22. data/lib/fog/volume/openstack/requests/list_backups_detailed.rb +45 -0
  23. data/lib/fog/volume/openstack/requests/restore_backup.rb +17 -0
  24. data/lib/fog/volume/openstack/v1.rb +10 -0
  25. data/lib/fog/volume/openstack/v1/models/backup.rb +15 -0
  26. data/lib/fog/volume/openstack/v1/models/backups.rb +16 -0
  27. data/lib/fog/volume/openstack/v1/requests/create_backup.rb +2 -0
  28. data/lib/fog/volume/openstack/v1/requests/delete_backup.rb +2 -0
  29. data/lib/fog/volume/openstack/v1/requests/get_backup_details.rb +2 -0
  30. data/lib/fog/volume/openstack/v1/requests/list_backups.rb +2 -0
  31. data/lib/fog/volume/openstack/v1/requests/list_backups_detailed.rb +2 -0
  32. data/lib/fog/volume/openstack/v1/requests/restore_backup.rb +2 -0
  33. data/lib/fog/volume/openstack/v2.rb +10 -0
  34. data/lib/fog/volume/openstack/v2/models/backup.rb +15 -0
  35. data/lib/fog/volume/openstack/v2/models/backups.rb +16 -0
  36. data/lib/fog/volume/openstack/v2/requests/create_backup.rb +2 -0
  37. data/lib/fog/volume/openstack/v2/requests/delete_backup.rb +2 -0
  38. data/lib/fog/volume/openstack/v2/requests/get_backup_details.rb +2 -0
  39. data/lib/fog/volume/openstack/v2/requests/list_backups.rb +2 -0
  40. data/lib/fog/volume/openstack/v2/requests/list_backups_detailed.rb +2 -0
  41. data/lib/fog/volume/openstack/v2/requests/restore_backup.rb +2 -0
  42. metadata +36 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c387f1e8f0cd35e7874025d2f11ff0ad70c4dea
4
- data.tar.gz: ad86278d35068d29b19931d4e9833a26bb05da65
3
+ metadata.gz: 562236470fef48eeb59f994f20b39968991a886b
4
+ data.tar.gz: 01ae0328e668f1f71851b6bfb8a90e60ace343c1
5
5
  SHA512:
6
- metadata.gz: 6386fea77004cdec7969178a3646d784b15512795c6f69ac8b9e48a591d302fa4aad9587ff09f275c09361765552cbac608e24d6a7af371ca7c563566df05555
7
- data.tar.gz: 3ab984e99befeee71444cb79c77ed109a877b5c9baa943b963fcd9db8d793b77ab9ab502b0b42682e4c664952c0892cd8ebb9d2067fd9a22689e4efce8f47e3d
6
+ metadata.gz: c4d4cbed29e2fa54a229dff53bcdf9902ced680f9dd59c9fa78ed097b79ac1a9db4638ce888e3151ba510705415cbfd66fb6f1235961348263526851aa7581e6
7
+ data.tar.gz: 17e26ef37b2e5e5d1b2704c76d2a02de1168cbb60eec3885cf1e9069f56e1d800f77cecc4e586b8926add7d6329882757c681c2af80128952a2d3112deaca045
@@ -0,0 +1,41 @@
1
+ require 'fog/openstack'
2
+ require 'fog/workflow/openstack/v2'
3
+
4
+ auth_url = "http://192.0.2.1:5000/v3/auth/tokens"
5
+ username = "admin"
6
+ password = "1b1d81f7e25b53e497246b168971823c5754f395"
7
+ project = "admin"
8
+
9
+ @connection_params = {
10
+ :openstack_auth_url => auth_url,
11
+ :openstack_username => username,
12
+ :openstack_api_key => password,
13
+ :openstack_project_name => project,
14
+ :openstack_domain_id => "default",
15
+ }
16
+
17
+ cinder = Fog::Volume::OpenStack.new(@connection_params)
18
+
19
+ puts "INFO: create backup of existing volume named test"
20
+
21
+ response = cinder.create_backup({:name => 'test-backup',
22
+ :volume_id => '82fe2ad5-43a3-4c2b-8464-e57b138ea81c'})
23
+ puts response.body
24
+
25
+ puts "INFO: list backups"
26
+
27
+ backups = cinder.backups
28
+
29
+ puts "INFO: get details of existing backup"
30
+
31
+ backup_id = backups[0].id
32
+ backup = cinder.backups.get(backup_id)
33
+
34
+ puts "INFO: restore backup"
35
+
36
+ response = backup.restore('82fe2ad5-43a3-4c2b-8464-e57b138ea81c')
37
+ puts response.body
38
+
39
+ puts "INFO: delete backup"
40
+
41
+ backup.destroy
@@ -147,7 +147,11 @@ module Fog
147
147
 
148
148
  def public_ip_addresses
149
149
  if floating_ip_addresses.empty?
150
- addresses.select { |s| s[0] =~ /public/i }.collect { |a| a[1][0]['addr'] }
150
+ if addresses
151
+ addresses.select { |s| s[0] =~ /public/i }.collect { |a| a[1][0]['addr'] }
152
+ else
153
+ []
154
+ end
151
155
  else
152
156
  floating_ip_addresses
153
157
  end
@@ -21,6 +21,16 @@ module Fog
21
21
  request_path 'fog/dns/openstack/v2/requests'
22
22
 
23
23
  request :list_zones
24
+ request :get_zone
25
+ request :create_zone
26
+ request :update_zone
27
+ request :delete_zone
28
+
29
+ request :list_recordsets
30
+ request :get_recordset
31
+ request :create_recordset
32
+ request :update_recordset
33
+ request :delete_recordset
24
34
 
25
35
  request :get_quota
26
36
  request :update_quota
@@ -29,7 +39,7 @@ module Fog
29
39
  def self.data
30
40
  @data ||= Hash.new do |hash, key|
31
41
  hash[key] = {
32
- :zones => [{
42
+ :zones => [{
33
43
  "id" => "a86dba58-0043-4cc6-a1bb-69d5e86f3ca3",
34
44
  "pool_id" => "572ba08c-d929-4c70-8e42-03824bb24ca2",
35
45
  "project_id" => "4335d1f0-f793-11e2-b778-0800200c9a66",
@@ -38,7 +48,7 @@ module Fog
38
48
  "ttl" => 7200,
39
49
  "serial" => 1_404_757_531,
40
50
  "status" => "ACTIVE",
41
- "action" => "CREATE",
51
+ "action" => "NONE",
42
52
  "description" => "This is an example zone.",
43
53
  "masters" => [],
44
54
  "type" => "PRIMARY",
@@ -50,12 +60,42 @@ module Fog
50
60
  "self" => "https://127.0.0.1:9001/v2/zones/a86dba58-0043-4cc6-a1bb-69d5e86f3ca3"
51
61
  }
52
62
  }],
53
- :quota => {
63
+ :quota => {
54
64
  "api_export_size" => 1000,
55
65
  "recordset_records" => 20,
56
66
  "zone_records" => 500,
57
67
  "zone_recordsets" => 500,
58
68
  "zones" => 100
69
+ },
70
+ :recordsets => {
71
+ "recordsets" => [{
72
+ "description" => "This is an example record set.",
73
+ "links" => {
74
+ "self" => "https://127.0.0.1:9001/v2/zones/2150b1bf-dee2-4221-9d85-11f7886fb15f/recordsets/f7b10e9b-0cae-4a91-b162-562bc6096648"
75
+ },
76
+ "updated_at" => '',
77
+ "records" => [
78
+ "10.1.0.2"
79
+ ],
80
+ "ttl" => 3600,
81
+ "id" => "f7b10e9b-0cae-4a91-b162-562bc6096648",
82
+ "name" => "example.org.",
83
+ "project_id" => "4335d1f0-f793-11e2-b778-0800200c9a66",
84
+ "zone_id" => "2150b1bf-dee2-4221-9d85-11f7886fb15f",
85
+ "zone_name" => "example.com.",
86
+ "created_at" => "2014-10-24T19:59:44.000000",
87
+ "version" => 1,
88
+ "type" => "A",
89
+ "status" => "ACTIVE",
90
+ "action" => "NONE"
91
+ }],
92
+ "links" => {
93
+ "self" => "http://127.0.0.1:9001/v2/recordsets?limit=1",
94
+ "next" => "http://127.0.0.1:9001/v2/recordsets?limit=1&marker=45fd892d-7a67-4f65-9df0-87273f228d6c"
95
+ },
96
+ "metadata" => {
97
+ "total_count" => 2
98
+ }
59
99
  }
60
100
  }
61
101
  end
@@ -0,0 +1,54 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def create_recordset(zone_id, name, type, records, options = {})
7
+ data = {
8
+ 'name' => name,
9
+ 'type' => type,
10
+ 'records' => records
11
+ }
12
+
13
+ vanilla_options = [:ttl, :description]
14
+
15
+ vanilla_options.select { |o| options[o] }.each do |key|
16
+ data[key] = options[key]
17
+ end
18
+
19
+ request(
20
+ :body => Fog::JSON.encode(data),
21
+ :expects => 202,
22
+ :method => 'POST',
23
+ :path => "zones/#{zone_id}/recordsets"
24
+ )
25
+ end
26
+ end
27
+
28
+ class Mock
29
+ def create_recordset(zone_id, name, type, records, options = {})
30
+ # stringify keys
31
+ options = Hash[options.map { |k, v| [k.to_s, v] }]
32
+
33
+ response = Excon::Response.new
34
+ response.status = 202
35
+
36
+ recordset = data[:recordsets]["recordsets"].first.dup
37
+ recordset_id = recordset["id"]
38
+
39
+ recordset["zone_id"] = zone_id
40
+ recordset["name"] = name
41
+ recordset["type"] = type
42
+ recordset["records"] = records
43
+ recordset["status"] = "PENDING"
44
+ recordset["action"] = "CREATE"
45
+ recordset["links"]["self"] = "https://127.0.0.1:9001/v2/zones/#{zone_id}/recordsets/#{recordset_id}"
46
+
47
+ response.body = recordset.merge(options)
48
+ response
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def create_zone(name, email, options = {})
7
+ data = {
8
+ 'name' => name,
9
+ 'email' => email
10
+ }
11
+
12
+ vanilla_options = [:ttl, :description, :type, :masters]
13
+
14
+ vanilla_options.select { |o| options[o] }.each do |key|
15
+ data[key] = options[key]
16
+ end
17
+
18
+ request(
19
+ :body => Fog::JSON.encode(data),
20
+ :expects => 202,
21
+ :method => 'POST',
22
+ :path => "zones"
23
+ )
24
+ end
25
+ end
26
+
27
+ class Mock
28
+ def create_zone(name, email, options = {})
29
+ # stringify keys
30
+ options = Hash[options.map { |k, v| [k.to_s, v] }]
31
+
32
+ response = Excon::Response.new
33
+ response.status = 202
34
+
35
+ zone = data[:zones].first.dup
36
+
37
+ zone["name"] = name
38
+ zone["email"] = email
39
+ zone["status"] = "PENDING"
40
+ zone["action"] = "CREATE"
41
+
42
+ response.body = zone.merge(options)
43
+ response
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def delete_recordset(zone_id, id)
7
+ request(
8
+ :expects => 202,
9
+ :method => 'DELETE',
10
+ :path => "zones/#{zone_id}/recordsets/#{id}"
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def delete_recordset(zone_id, id)
17
+ response = Excon::Response.new
18
+ response.status = 202
19
+
20
+ recordset = data[:recordset_updated] || data[:recordsets]["recordsets"].first.dup
21
+ recordset["zone_id"] = zone_id
22
+ recordset["id"] = id
23
+ recordset["status"] = "PENDING"
24
+ recordset["action"] = "DELETE"
25
+ recordset["links"]["self"] = "https://127.0.0.1:9001/v2/zones/#{zone_id}/recordsets/#{id}"
26
+
27
+ response.body = recordset
28
+ response
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def delete_zone(id)
7
+ request(
8
+ :expects => 202,
9
+ :method => 'DELETE',
10
+ :path => "zones/#{id}"
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def delete_zone(id)
17
+ response = Excon::Response.new
18
+ response.status = 202
19
+
20
+ zone = data[:zone_updated] || data[:zones].first.dup
21
+ zone["id"] = id
22
+ zone["status"] = "PENDING"
23
+ zone["action"] = "DELETE"
24
+ zone["links"]["self"] = "https://127.0.0.1:9001/v2/zones/#{id}"
25
+
26
+ response.body = zone
27
+ response
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def get_recordset(zone_id, id)
7
+ request(
8
+ :expects => 200,
9
+ :method => 'GET',
10
+ :path => "zones/#{zone_id}/recordsets/#{id}"
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def get_recordset(zone_id, id)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+
20
+ recordset = data[:recordset_updated] || data[:recordsets]["recordsets"].first
21
+ recordset["zone_id"] = zone_id
22
+ recordset["id"] = id
23
+ recordset["action"] = "NONE"
24
+ recordset["status"] = "ACTIVE"
25
+ recordset["links"]["self"] = "https://127.0.0.1:9001/v2/zones/#{zone_id}/recordsets/#{id}"
26
+
27
+ response.body = recordset
28
+ response
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def get_zone(id)
7
+ request(
8
+ :expects => 200,
9
+ :method => 'GET',
10
+ :path => "zones/#{id}"
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def get_zone(id)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ zone = data[:zone_updated] || data[:zones].first
20
+ zone["id"] = id
21
+ response.body = zone
22
+ response
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def list_recordsets(zone_id, options = {})
7
+ request(
8
+ :expects => 200,
9
+ :method => 'GET',
10
+ :path => "zones/#{zone_id}/recordsets",
11
+ :query => options
12
+ )
13
+ end
14
+ end
15
+
16
+ class Mock
17
+ def list_recordsets(zone_id, _options = {})
18
+ response = Excon::Response.new
19
+ response.status = 200
20
+ data[:recordsets]["recordsets"].each do |rs|
21
+ rs["zone_id"] = zone_id
22
+ end
23
+ response.body = data[:recordsets]
24
+ response
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def update_recordset(zone_id, id, options = {})
7
+ request(
8
+ :body => Fog::JSON.encode(options),
9
+ :expects => 202,
10
+ :method => 'PUT',
11
+ :path => "zones/#{zone_id}/recordsets/#{id}"
12
+ )
13
+ end
14
+ end
15
+
16
+ class Mock
17
+ def update_recordset(zone_id, id, options = {})
18
+ # stringify keys
19
+ options = Hash[options.map { |k, v| [k.to_s, v] }]
20
+
21
+ data[:recordset_updated] = data[:recordsets]["recordsets"].first.merge(options)
22
+ data[:recordset_updated]["zone_id"] = zone_id
23
+ data[:recordset_updated]["id"] = id
24
+ data[:recordset_updated]["status"] = "PENDING"
25
+ data[:recordset_updated]["action"] = "UPDATE"
26
+ data[:recordset_updated]["links"]["self"] = "https://127.0.0.1:9001/v2/zones/#{zone_id}/recordsets/#{id}"
27
+
28
+ response = Excon::Response.new
29
+ response.status = 202
30
+ response.body = data[:recordset_updated]
31
+ response
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module DNS
3
+ class OpenStack
4
+ class V2
5
+ class Real
6
+ def update_zone(id, options = {})
7
+ request(
8
+ :body => Fog::JSON.encode(options),
9
+ :expects => 202,
10
+ :method => 'PATCH',
11
+ :path => "zones/#{id}"
12
+ )
13
+ end
14
+ end
15
+
16
+ class Mock
17
+ def update_zone(id, options = {})
18
+ # stringify keys
19
+ options = Hash[options.map { |k, v| [k.to_s, v] }]
20
+
21
+ data[:zone_updated] = data[:zones].first.merge(options)
22
+ data[:zone_updated]["id"] = id
23
+ data[:zone_updated]["status"] = "PENDING"
24
+ data[:zone_updated]["action"] = "UPDATE"
25
+ data[:zone_updated]["links"]["self"] = "https://127.0.0.1:9001/v2/zones/#{id}"
26
+
27
+ response = Excon::Response.new
28
+ response.status = 202
29
+ response.body = data[:zone_updated]
30
+ response
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -11,7 +11,7 @@ module Fog
11
11
  def update_router(router_id, options = {})
12
12
  data = {'router' => {}}
13
13
 
14
- [:name, :admin_state_up].each do |key|
14
+ [:name, :admin_state_up, :routes].each do |key|
15
15
  data['router'][key] = options[key] if options[key]
16
16
  end
17
17
 
@@ -53,9 +53,11 @@ module Fog
53
53
  if egi.kind_of?(Fog::Network::OpenStack::Network)
54
54
  Fog::Logger.deprecation "Passing a model objects into options[:external_gateway_info] is deprecated. \
55
55
  Please pass external external gateway as follows options[:external_gateway_info] = { :network_id => NETWORK_ID }]"
56
- router[:external_gateway_info] = {:network_id => egi.id}
57
- else egi.kind_of?(Hash) && egi[:network_id]
58
- router[:external_gateway_info] = egi
56
+ router[:external_gateway_info] = { :network_id => egi.id }
57
+ elsif egi.is_a?(Hash)
58
+ router[:external_gateway_info] = egi
59
+ else
60
+ raise ArgumentError.new('Invalid external_gateway_info attribute')
59
61
  end
60
62
  end
61
63
 
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Openstack
3
- VERSION = "0.1.11"
3
+ VERSION = "0.1.12"
4
4
  end
5
5
  end
@@ -0,0 +1,46 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module Volume
5
+ class OpenStack
6
+ class Backup < Fog::OpenStack::Model
7
+ attribute :availability_zone
8
+ attribute :container
9
+ attribute :created_at
10
+ attribute :description
11
+ attribute :fail_reason
12
+ attribute :name
13
+ attribute :object_count
14
+ attribute :size
15
+ attribute :status
16
+ attribute :volume_id
17
+ attribute :is_incremental
18
+ attribute :has_dependent_backups
19
+
20
+ def create
21
+ requires :name, :volume_id
22
+ data = service.create_backup(attributes)
23
+ merge_attributes(data.body['backup'])
24
+ true
25
+ end
26
+
27
+ def destroy
28
+ requires :id
29
+ service.delete_backup(id)
30
+ true
31
+ end
32
+
33
+ def restore(volume_id)
34
+ requires :id
35
+ service.restore_backup(id, volume_id)
36
+ true
37
+ end
38
+
39
+ def volume
40
+ requires :id
41
+ service.get_volume_details(volume_id).body['volume']
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,26 @@
1
+ require 'fog/openstack/models/collection'
2
+
3
+ module Fog
4
+ module Volume
5
+ class OpenStack
6
+ module Backups
7
+ def all(options = {})
8
+ load_response(service.list_backups_detailed(options), 'backups')
9
+ end
10
+
11
+ def summary(options = {})
12
+ load_response(service.list_backups(options), 'backups')
13
+ end
14
+
15
+ def get(backup_id)
16
+ backup = service.get_backup_details(backup_id).body['backup']
17
+ if backup
18
+ new(backup)
19
+ end
20
+ rescue Fog::Volume::OpenStack::NotFound
21
+ nil
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Volume
3
+ class OpenStack
4
+ module Real
5
+ def create_backup(attributes)
6
+ desired_options = [
7
+ :container,
8
+ :name,
9
+ :description,
10
+ :volume_id,
11
+ :incremental,
12
+ :force,
13
+ ]
14
+
15
+ # Filter only allowed creation attributes
16
+ data = {
17
+ :backup => attributes.select { |key, _value| desired_options.include?(key.to_sym) }
18
+ }
19
+
20
+ request(
21
+ :body => Fog::JSON.encode(data),
22
+ :expects => [200, 202],
23
+ :method => 'POST',
24
+ :path => 'backups'
25
+ )
26
+ end
27
+ end
28
+
29
+ module Mock
30
+ def create_backup(_options = {})
31
+ response = Excon::Response.new
32
+ response.status = 202
33
+ response.body = {
34
+ "backup" => {
35
+ "id" => "1",
36
+ "volume_id" => "2",
37
+ "name" => "backup 1",
38
+ "status" => "available",
39
+ "size" => 1,
40
+ "object_count" => 16,
41
+ "container" => "testcontainer",
42
+ }
43
+ }
44
+ response
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module Volume
3
+ class OpenStack
4
+ module Real
5
+ def delete_backup(backup_id)
6
+ request(
7
+ :expects => 202,
8
+ :method => 'DELETE',
9
+ :path => "backups/#{backup_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ module Mock
15
+ def delete_backup(_backup_id)
16
+ response = Excon::Response.new
17
+ response.status = 204
18
+ response
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module Volume
3
+ class OpenStack
4
+ module Real
5
+ def get_backup_details(backup_id)
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "backups/#{backup_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ module Mock
15
+ def get_backup_details(_backup_id)
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ response.body = {
19
+ "backup" => {
20
+ "id" => "1",
21
+ "volume_id" => "2",
22
+ "name" => "backup 1",
23
+ "status" => "available",
24
+ "size" => 1,
25
+ "object_count" => 16,
26
+ "container" => "testcontainer",
27
+ }
28
+ }
29
+ response
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,16 @@
1
+ module Fog
2
+ module Volume
3
+ class OpenStack
4
+ module Real
5
+ def list_backups(options = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => 'backups',
10
+ :query => options
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module Volume
3
+ class OpenStack
4
+ module Real
5
+ def list_backups_detailed(options = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => 'backups/detail',
10
+ :query => options
11
+ )
12
+ end
13
+ end
14
+
15
+ module Mock
16
+ def list_backups_detailed(_options = {})
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ data[:backups] ||= [
20
+ {
21
+ "id" => "1",
22
+ "volume_id" => "2",
23
+ "name" => "backup 1",
24
+ "status" => "available",
25
+ "size" => 1,
26
+ "object_count" => 16,
27
+ "container" => "testcontainer",
28
+ },
29
+ {
30
+ "id" => "2",
31
+ "volume_id" => "2",
32
+ "name" => "backup 2",
33
+ "status" => "available",
34
+ "size" => 1,
35
+ "object_count" => 16,
36
+ "container" => "testcontainer",
37
+ }
38
+ ]
39
+ response.body = { 'backups' => data[:backups] }
40
+ response
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,17 @@
1
+ module Fog
2
+ module Volume
3
+ class OpenStack
4
+ module Real
5
+ def restore_backup(backup_id, volume_id)
6
+ data = { 'restore' => { 'volume_id' => volume_id } }
7
+ request(
8
+ :expects => 202,
9
+ :method => 'POST',
10
+ :path => "backups/#{backup_id}/restore",
11
+ :body => Fog::JSON.encode(data)
12
+ )
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -28,6 +28,9 @@ module Fog
28
28
  model :transfer
29
29
  collection :transfers
30
30
 
31
+ model :backup
32
+ collection :backups
33
+
31
34
  request_path 'fog/volume/openstack/v1/requests'
32
35
 
33
36
  # Volume
@@ -62,6 +65,13 @@ module Fog
62
65
  request :accept_transfer
63
66
  request :delete_transfer
64
67
 
68
+ request :list_backups
69
+ request :list_backups_detailed
70
+ request :create_backup
71
+ request :get_backup_details
72
+ request :restore_backup
73
+ request :delete_backup
74
+
65
75
  request :update_quota
66
76
  request :get_quota
67
77
  request :get_quota_defaults
@@ -0,0 +1,15 @@
1
+ require 'fog/volume/openstack/models/backup'
2
+
3
+ module Fog
4
+ module Volume
5
+ class OpenStack
6
+ class V1
7
+ class Backup < Fog::Volume::OpenStack::Backup
8
+ identity :id
9
+
10
+ superclass.attributes.each { |attrib| attribute attrib }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/volume/openstack/v1/models/backup'
3
+ require 'fog/volume/openstack/models/backups'
4
+
5
+ module Fog
6
+ module Volume
7
+ class OpenStack
8
+ class V1
9
+ class Backups < Fog::OpenStack::Collection
10
+ model Fog::Volume::OpenStack::V1::Backup
11
+ include Fog::Volume::OpenStack::Backups
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/create_backup'
2
+ require 'fog/volume/openstack/v1/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/delete_backup'
2
+ require 'fog/volume/openstack/v1/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/get_backup_details'
2
+ require 'fog/volume/openstack/v1/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/list_backups'
2
+ require 'fog/volume/openstack/v1/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/list_backups_detailed'
2
+ require 'fog/volume/openstack/v1/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/restore_backup'
2
+ require 'fog/volume/openstack/v1/requests/real'
@@ -28,6 +28,9 @@ module Fog
28
28
  model :transfer
29
29
  collection :transfers
30
30
 
31
+ model :backup
32
+ collection :backups
33
+
31
34
  request_path 'fog/volume/openstack/v2/requests'
32
35
 
33
36
  # Volume
@@ -63,6 +66,13 @@ module Fog
63
66
  request :accept_transfer
64
67
  request :delete_transfer
65
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
+
66
76
  request :update_quota
67
77
  request :get_quota
68
78
  request :get_quota_defaults
@@ -0,0 +1,15 @@
1
+ require 'fog/volume/openstack/models/backup'
2
+
3
+ module Fog
4
+ module Volume
5
+ class OpenStack
6
+ class V2
7
+ class Backup < Fog::Volume::OpenStack::Backup
8
+ identity :id
9
+
10
+ superclass.attributes.each { |attrib| attribute attrib }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/volume/openstack/v2/models/backup'
3
+ require 'fog/volume/openstack/models/backups'
4
+
5
+ module Fog
6
+ module Volume
7
+ class OpenStack
8
+ class V2
9
+ class Backups < Fog::OpenStack::Collection
10
+ model Fog::Volume::OpenStack::V2::Backup
11
+ include Fog::Volume::OpenStack::Backups
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/create_backup'
2
+ require 'fog/volume/openstack/v2/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/delete_backup'
2
+ require 'fog/volume/openstack/v2/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/get_backup_details'
2
+ require 'fog/volume/openstack/v2/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/list_backups'
2
+ require 'fog/volume/openstack/v2/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/list_backups_detailed'
2
+ require 'fog/volume/openstack/v2/requests/real'
@@ -0,0 +1,2 @@
1
+ require 'fog/volume/openstack/requests/restore_backup'
2
+ require 'fog/volume/openstack/v2/requests/real'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Darby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-10 00:00:00.000000000 Z
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -249,6 +249,7 @@ files:
249
249
  - examples/network/network_subnets_routers.rb
250
250
  - examples/planning/basics.rb
251
251
  - examples/storage/set-account-quota.rb
252
+ - examples/volume/backups.rb
252
253
  - examples/workflow/workflow-examples.rb
253
254
  - fog-openstack.gemspec
254
255
  - gemfiles/Gemfile-1.9
@@ -456,9 +457,18 @@ files:
456
457
  - lib/fog/dns/openstack/v1/requests/list_domains.rb
457
458
  - lib/fog/dns/openstack/v1/requests/update_quota.rb
458
459
  - lib/fog/dns/openstack/v2.rb
460
+ - lib/fog/dns/openstack/v2/requests/create_recordset.rb
461
+ - lib/fog/dns/openstack/v2/requests/create_zone.rb
462
+ - lib/fog/dns/openstack/v2/requests/delete_recordset.rb
463
+ - lib/fog/dns/openstack/v2/requests/delete_zone.rb
459
464
  - lib/fog/dns/openstack/v2/requests/get_quota.rb
465
+ - lib/fog/dns/openstack/v2/requests/get_recordset.rb
466
+ - lib/fog/dns/openstack/v2/requests/get_zone.rb
467
+ - lib/fog/dns/openstack/v2/requests/list_recordsets.rb
460
468
  - lib/fog/dns/openstack/v2/requests/list_zones.rb
461
469
  - lib/fog/dns/openstack/v2/requests/update_quota.rb
470
+ - lib/fog/dns/openstack/v2/requests/update_recordset.rb
471
+ - lib/fog/dns/openstack/v2/requests/update_zone.rb
462
472
  - lib/fog/identity/openstack.rb
463
473
  - lib/fog/identity/openstack/v2.rb
464
474
  - lib/fog/identity/openstack/v2/models/ec2_credential.rb
@@ -921,6 +931,8 @@ files:
921
931
  - lib/fog/volume/openstack.rb
922
932
  - lib/fog/volume/openstack/models/availability_zone.rb
923
933
  - lib/fog/volume/openstack/models/availability_zones.rb
934
+ - lib/fog/volume/openstack/models/backup.rb
935
+ - lib/fog/volume/openstack/models/backups.rb
924
936
  - lib/fog/volume/openstack/models/snapshot.rb
925
937
  - lib/fog/volume/openstack/models/snapshots.rb
926
938
  - lib/fog/volume/openstack/models/transfer.rb
@@ -931,10 +943,12 @@ files:
931
943
  - lib/fog/volume/openstack/models/volumes.rb
932
944
  - lib/fog/volume/openstack/requests/accept_transfer.rb
933
945
  - lib/fog/volume/openstack/requests/action.rb
946
+ - lib/fog/volume/openstack/requests/create_backup.rb
934
947
  - lib/fog/volume/openstack/requests/create_snapshot.rb
935
948
  - lib/fog/volume/openstack/requests/create_transfer.rb
936
949
  - lib/fog/volume/openstack/requests/create_volume.rb
937
950
  - lib/fog/volume/openstack/requests/create_volume_type.rb
951
+ - lib/fog/volume/openstack/requests/delete_backup.rb
938
952
  - lib/fog/volume/openstack/requests/delete_metadata.rb
939
953
  - lib/fog/volume/openstack/requests/delete_snapshot.rb
940
954
  - lib/fog/volume/openstack/requests/delete_snapshot_metadata.rb
@@ -942,6 +956,7 @@ files:
942
956
  - lib/fog/volume/openstack/requests/delete_volume.rb
943
957
  - lib/fog/volume/openstack/requests/delete_volume_type.rb
944
958
  - lib/fog/volume/openstack/requests/extend_volume.rb
959
+ - lib/fog/volume/openstack/requests/get_backup_details.rb
945
960
  - lib/fog/volume/openstack/requests/get_quota.rb
946
961
  - lib/fog/volume/openstack/requests/get_quota_defaults.rb
947
962
  - lib/fog/volume/openstack/requests/get_quota_usage.rb
@@ -949,6 +964,8 @@ files:
949
964
  - lib/fog/volume/openstack/requests/get_transfer_details.rb
950
965
  - lib/fog/volume/openstack/requests/get_volume_details.rb
951
966
  - lib/fog/volume/openstack/requests/get_volume_type_details.rb
967
+ - lib/fog/volume/openstack/requests/list_backups.rb
968
+ - lib/fog/volume/openstack/requests/list_backups_detailed.rb
952
969
  - lib/fog/volume/openstack/requests/list_snapshots.rb
953
970
  - lib/fog/volume/openstack/requests/list_snapshots_detailed.rb
954
971
  - lib/fog/volume/openstack/requests/list_transfers.rb
@@ -958,6 +975,7 @@ files:
958
975
  - lib/fog/volume/openstack/requests/list_volumes_detailed.rb
959
976
  - lib/fog/volume/openstack/requests/list_zones.rb
960
977
  - lib/fog/volume/openstack/requests/replace_metadata.rb
978
+ - lib/fog/volume/openstack/requests/restore_backup.rb
961
979
  - lib/fog/volume/openstack/requests/set_tenant.rb
962
980
  - lib/fog/volume/openstack/requests/update_metadata.rb
963
981
  - lib/fog/volume/openstack/requests/update_quota.rb
@@ -968,6 +986,8 @@ files:
968
986
  - lib/fog/volume/openstack/v1.rb
969
987
  - lib/fog/volume/openstack/v1/models/availability_zone.rb
970
988
  - lib/fog/volume/openstack/v1/models/availability_zones.rb
989
+ - lib/fog/volume/openstack/v1/models/backup.rb
990
+ - lib/fog/volume/openstack/v1/models/backups.rb
971
991
  - lib/fog/volume/openstack/v1/models/snapshot.rb
972
992
  - lib/fog/volume/openstack/v1/models/snapshots.rb
973
993
  - lib/fog/volume/openstack/v1/models/transfer.rb
@@ -978,10 +998,12 @@ files:
978
998
  - lib/fog/volume/openstack/v1/models/volumes.rb
979
999
  - lib/fog/volume/openstack/v1/requests/accept_transfer.rb
980
1000
  - lib/fog/volume/openstack/v1/requests/action.rb
1001
+ - lib/fog/volume/openstack/v1/requests/create_backup.rb
981
1002
  - lib/fog/volume/openstack/v1/requests/create_snapshot.rb
982
1003
  - lib/fog/volume/openstack/v1/requests/create_transfer.rb
983
1004
  - lib/fog/volume/openstack/v1/requests/create_volume.rb
984
1005
  - lib/fog/volume/openstack/v1/requests/create_volume_type.rb
1006
+ - lib/fog/volume/openstack/v1/requests/delete_backup.rb
985
1007
  - lib/fog/volume/openstack/v1/requests/delete_metadata.rb
986
1008
  - lib/fog/volume/openstack/v1/requests/delete_snapshot.rb
987
1009
  - lib/fog/volume/openstack/v1/requests/delete_snapshot_metadata.rb
@@ -989,6 +1011,7 @@ files:
989
1011
  - lib/fog/volume/openstack/v1/requests/delete_volume.rb
990
1012
  - lib/fog/volume/openstack/v1/requests/delete_volume_type.rb
991
1013
  - lib/fog/volume/openstack/v1/requests/extend_volume.rb
1014
+ - lib/fog/volume/openstack/v1/requests/get_backup_details.rb
992
1015
  - lib/fog/volume/openstack/v1/requests/get_quota.rb
993
1016
  - lib/fog/volume/openstack/v1/requests/get_quota_defaults.rb
994
1017
  - lib/fog/volume/openstack/v1/requests/get_quota_usage.rb
@@ -996,6 +1019,8 @@ files:
996
1019
  - lib/fog/volume/openstack/v1/requests/get_transfer_details.rb
997
1020
  - lib/fog/volume/openstack/v1/requests/get_volume_details.rb
998
1021
  - lib/fog/volume/openstack/v1/requests/get_volume_type_details.rb
1022
+ - lib/fog/volume/openstack/v1/requests/list_backups.rb
1023
+ - lib/fog/volume/openstack/v1/requests/list_backups_detailed.rb
999
1024
  - lib/fog/volume/openstack/v1/requests/list_snapshots.rb
1000
1025
  - lib/fog/volume/openstack/v1/requests/list_snapshots_detailed.rb
1001
1026
  - lib/fog/volume/openstack/v1/requests/list_transfers.rb
@@ -1007,6 +1032,7 @@ files:
1007
1032
  - lib/fog/volume/openstack/v1/requests/real.rb
1008
1033
  - lib/fog/volume/openstack/v1/requests/real_mock.rb
1009
1034
  - lib/fog/volume/openstack/v1/requests/replace_metadata.rb
1035
+ - lib/fog/volume/openstack/v1/requests/restore_backup.rb
1010
1036
  - lib/fog/volume/openstack/v1/requests/set_tenant.rb
1011
1037
  - lib/fog/volume/openstack/v1/requests/update_metadata.rb
1012
1038
  - lib/fog/volume/openstack/v1/requests/update_quota.rb
@@ -1016,6 +1042,8 @@ files:
1016
1042
  - lib/fog/volume/openstack/v2.rb
1017
1043
  - lib/fog/volume/openstack/v2/models/availability_zone.rb
1018
1044
  - lib/fog/volume/openstack/v2/models/availability_zones.rb
1045
+ - lib/fog/volume/openstack/v2/models/backup.rb
1046
+ - lib/fog/volume/openstack/v2/models/backups.rb
1019
1047
  - lib/fog/volume/openstack/v2/models/snapshot.rb
1020
1048
  - lib/fog/volume/openstack/v2/models/snapshots.rb
1021
1049
  - lib/fog/volume/openstack/v2/models/transfer.rb
@@ -1026,10 +1054,12 @@ files:
1026
1054
  - lib/fog/volume/openstack/v2/models/volumes.rb
1027
1055
  - lib/fog/volume/openstack/v2/requests/accept_transfer.rb
1028
1056
  - lib/fog/volume/openstack/v2/requests/action.rb
1057
+ - lib/fog/volume/openstack/v2/requests/create_backup.rb
1029
1058
  - lib/fog/volume/openstack/v2/requests/create_snapshot.rb
1030
1059
  - lib/fog/volume/openstack/v2/requests/create_transfer.rb
1031
1060
  - lib/fog/volume/openstack/v2/requests/create_volume.rb
1032
1061
  - lib/fog/volume/openstack/v2/requests/create_volume_type.rb
1062
+ - lib/fog/volume/openstack/v2/requests/delete_backup.rb
1033
1063
  - lib/fog/volume/openstack/v2/requests/delete_metadata.rb
1034
1064
  - lib/fog/volume/openstack/v2/requests/delete_snapshot.rb
1035
1065
  - lib/fog/volume/openstack/v2/requests/delete_snapshot_metadata.rb
@@ -1037,6 +1067,7 @@ files:
1037
1067
  - lib/fog/volume/openstack/v2/requests/delete_volume.rb
1038
1068
  - lib/fog/volume/openstack/v2/requests/delete_volume_type.rb
1039
1069
  - lib/fog/volume/openstack/v2/requests/extend_volume.rb
1070
+ - lib/fog/volume/openstack/v2/requests/get_backup_details.rb
1040
1071
  - lib/fog/volume/openstack/v2/requests/get_quota.rb
1041
1072
  - lib/fog/volume/openstack/v2/requests/get_quota_defaults.rb
1042
1073
  - lib/fog/volume/openstack/v2/requests/get_quota_usage.rb
@@ -1044,6 +1075,8 @@ files:
1044
1075
  - lib/fog/volume/openstack/v2/requests/get_transfer_details.rb
1045
1076
  - lib/fog/volume/openstack/v2/requests/get_volume_details.rb
1046
1077
  - lib/fog/volume/openstack/v2/requests/get_volume_type_details.rb
1078
+ - lib/fog/volume/openstack/v2/requests/list_backups.rb
1079
+ - lib/fog/volume/openstack/v2/requests/list_backups_detailed.rb
1047
1080
  - lib/fog/volume/openstack/v2/requests/list_snapshots.rb
1048
1081
  - lib/fog/volume/openstack/v2/requests/list_snapshots_detailed.rb
1049
1082
  - lib/fog/volume/openstack/v2/requests/list_transfers.rb
@@ -1055,6 +1088,7 @@ files:
1055
1088
  - lib/fog/volume/openstack/v2/requests/real.rb
1056
1089
  - lib/fog/volume/openstack/v2/requests/real_mock.rb
1057
1090
  - lib/fog/volume/openstack/v2/requests/replace_metadata.rb
1091
+ - lib/fog/volume/openstack/v2/requests/restore_backup.rb
1058
1092
  - lib/fog/volume/openstack/v2/requests/set_tenant.rb
1059
1093
  - lib/fog/volume/openstack/v2/requests/update_metadata.rb
1060
1094
  - lib/fog/volume/openstack/v2/requests/update_quota.rb