fog-openstack 0.1.15 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -1
  3. data/README.md +36 -5
  4. data/docs/common/connection_params.md +45 -0
  5. data/docs/common/resources.md +11 -0
  6. data/docs/compute.md +2 -46
  7. data/docs/getting_started.md +11 -10
  8. data/docs/network.md +2 -47
  9. data/docs/orchestration.md +2 -2
  10. data/docs/planning.md +2 -47
  11. data/docs/shared_file_system.md +82 -0
  12. data/docs/storage.md +5 -51
  13. data/docs/workflow.md +4 -2
  14. data/examples/metric/basics.rb +42 -0
  15. data/examples/shared_file_system/basics.rb +68 -0
  16. data/gemfiles/Gemfile-1.9 +1 -0
  17. data/lib/fog/identity/openstack/v3/requests/list_groups.rb +1 -1
  18. data/lib/fog/image/openstack/v2/models/image.rb +60 -15
  19. data/lib/fog/image/openstack/v2/models/images.rb +1 -4
  20. data/lib/fog/metric/openstack.rb +126 -0
  21. data/lib/fog/metric/openstack/models/metric.rb +18 -0
  22. data/lib/fog/metric/openstack/models/metrics.rb +31 -0
  23. data/lib/fog/metric/openstack/models/resource.rb +16 -0
  24. data/lib/fog/metric/openstack/models/resources.rb +24 -0
  25. data/lib/fog/metric/openstack/requests/get_metric.rb +62 -0
  26. data/lib/fog/metric/openstack/requests/get_metric_measures.rb +38 -0
  27. data/lib/fog/metric/openstack/requests/get_resource.rb +37 -0
  28. data/lib/fog/metric/openstack/requests/get_resource_metric_measures.rb +46 -0
  29. data/lib/fog/metric/openstack/requests/list_metrics.rb +104 -0
  30. data/lib/fog/metric/openstack/requests/list_resources.rb +70 -0
  31. data/lib/fog/network/openstack.rb +12 -9
  32. data/lib/fog/network/openstack/models/rbac_policy.rb +0 -1
  33. data/lib/fog/network/openstack/requests/create_floating_ip.rb +1 -1
  34. data/lib/fog/network/openstack/requests/create_network.rb +3 -3
  35. data/lib/fog/openstack.rb +25 -15
  36. data/lib/fog/openstack/version.rb +1 -1
  37. data/lib/fog/orchestration/openstack/models/stack.rb +5 -1
  38. data/lib/fog/shared_file_system/openstack.rb +278 -0
  39. data/lib/fog/shared_file_system/openstack/models/network.rb +42 -0
  40. data/lib/fog/shared_file_system/openstack/models/networks.rb +28 -0
  41. data/lib/fog/shared_file_system/openstack/models/share.rb +63 -0
  42. data/lib/fog/shared_file_system/openstack/models/shares.rb +28 -0
  43. data/lib/fog/shared_file_system/openstack/models/snapshot.rb +45 -0
  44. data/lib/fog/shared_file_system/openstack/models/snapshots.rb +28 -0
  45. data/lib/fog/shared_file_system/openstack/requests/create_share.rb +49 -0
  46. data/lib/fog/shared_file_system/openstack/requests/create_share_network.rb +41 -0
  47. data/lib/fog/shared_file_system/openstack/requests/create_snapshot.rb +46 -0
  48. data/lib/fog/shared_file_system/openstack/requests/delete_share.rb +29 -0
  49. data/lib/fog/shared_file_system/openstack/requests/delete_share_network.rb +28 -0
  50. data/lib/fog/shared_file_system/openstack/requests/delete_snapshot.rb +30 -0
  51. data/lib/fog/shared_file_system/openstack/requests/get_share.rb +26 -0
  52. data/lib/fog/shared_file_system/openstack/requests/get_share_network.rb +26 -0
  53. data/lib/fog/shared_file_system/openstack/requests/get_snapshot.rb +26 -0
  54. data/lib/fog/shared_file_system/openstack/requests/list_share_networks.rb +25 -0
  55. data/lib/fog/shared_file_system/openstack/requests/list_share_networks_detail.rb +25 -0
  56. data/lib/fog/shared_file_system/openstack/requests/list_shares.rb +25 -0
  57. data/lib/fog/shared_file_system/openstack/requests/list_shares_detail.rb +25 -0
  58. data/lib/fog/shared_file_system/openstack/requests/list_snapshots.rb +25 -0
  59. data/lib/fog/shared_file_system/openstack/requests/list_snapshots_detail.rb +25 -0
  60. data/lib/fog/shared_file_system/openstack/requests/update_share.rb +39 -0
  61. data/lib/fog/shared_file_system/openstack/requests/update_share_network.rb +31 -0
  62. data/lib/fog/shared_file_system/openstack/requests/update_snapshot.rb +31 -0
  63. metadata +43 -2
@@ -0,0 +1,28 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/shared_file_system/openstack/models/network'
3
+
4
+ module Fog
5
+ module SharedFileSystem
6
+ class OpenStack
7
+ class Networks < Fog::OpenStack::Collection
8
+ model Fog::SharedFileSystem::OpenStack::Network
9
+
10
+ def all(options = {})
11
+ load_response(service.list_share_networks_detail(options), 'share_networks')
12
+ end
13
+
14
+ def find_by_id(id)
15
+ net_hash = service.get_share_network(id).body['share_network']
16
+ new(net_hash.merge(:service => service))
17
+ end
18
+
19
+ alias get find_by_id
20
+
21
+ def destroy(id)
22
+ net = find_by_id(id)
23
+ net.destroy
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module SharedFileSystem
5
+ class OpenStack
6
+ class Share < Fog::OpenStack::Model
7
+ identity :id
8
+
9
+ attribute :share_proto
10
+ attribute :size
11
+ attribute :status
12
+ attribute :links
13
+ attribute :share_type
14
+ attribute :share_type_name
15
+ attribute :availability_zone
16
+ attribute :share_network_id
17
+ attribute :share_server_id
18
+ attribute :host
19
+ attribute :snapshot_id
20
+ attribute :snapshot_support
21
+ attribute :task_state
22
+ attribute :access_rules_status
23
+ attribute :has_replicas
24
+ attribute :consistency_group_id
25
+ attribute :source_cgsnapshot_member_id
26
+ attribute :project_id
27
+ attribute :created_at
28
+
29
+ # optional
30
+ attribute :name
31
+ attribute :description
32
+ attribute :export_location
33
+ attribute :export_locations
34
+ attribute :metadata
35
+ attribute :is_public
36
+ attribute :volume_type
37
+
38
+ def save
39
+ raise Fog::Errors::Error, 'Resaving an existing object may create a duplicate' if persisted?
40
+ requires :size, :share_proto
41
+ merge_attributes(service.create_share(share_proto, size, attributes).body['share'])
42
+ true
43
+ end
44
+
45
+ def update(options = nil)
46
+ requires :id
47
+ merge_attributes(service.update_share(id, options || attributes).body['share'])
48
+ self
49
+ end
50
+
51
+ def destroy
52
+ requires :id
53
+ service.delete_share(id)
54
+ true
55
+ end
56
+
57
+ def ready?
58
+ status == 'available'
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,28 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/shared_file_system/openstack/models/share'
3
+
4
+ module Fog
5
+ module SharedFileSystem
6
+ class OpenStack
7
+ class Shares < Fog::OpenStack::Collection
8
+ model Fog::SharedFileSystem::OpenStack::Share
9
+
10
+ def all(options = {})
11
+ load_response(service.list_shares_detail(options), 'shares')
12
+ end
13
+
14
+ def find_by_id(id)
15
+ share_hash = service.get_share(id).body['share']
16
+ new(share_hash.merge(:service => service))
17
+ end
18
+
19
+ alias get find_by_id
20
+
21
+ def destroy(id)
22
+ share = find_by_id(id)
23
+ share.destroy
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,45 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module SharedFileSystem
5
+ class OpenStack
6
+ class Snapshot < Fog::OpenStack::Model
7
+ identity :id
8
+
9
+ attribute :share_id
10
+ attribute :status
11
+ attribute :name
12
+ attribute :description
13
+ attribute :share_proto
14
+ attribute :share_size
15
+ attribute :size
16
+ attribute :provider_location
17
+ attribute :links
18
+ attribute :created_at
19
+
20
+ def save
21
+ raise Fog::Errors::Error, 'Resaving an existing object may create a duplicate' if persisted?
22
+ requires :share_id
23
+ merge_attributes(service.create_snapshot(share_id, attributes).body['snapshot'])
24
+ true
25
+ end
26
+
27
+ def update(options = nil)
28
+ requires :id
29
+ merge_attributes(service.update_snapshot(id, options || attributes).body['snapshot'])
30
+ self
31
+ end
32
+
33
+ def destroy
34
+ requires :id
35
+ service.delete_snapshot(id)
36
+ true
37
+ end
38
+
39
+ def ready?
40
+ status == 'available'
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,28 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/shared_file_system/openstack/models/snapshot'
3
+
4
+ module Fog
5
+ module SharedFileSystem
6
+ class OpenStack
7
+ class Snapshots < Fog::OpenStack::Collection
8
+ model Fog::SharedFileSystem::OpenStack::Snapshot
9
+
10
+ def all(options = {})
11
+ load_response(service.list_snapshots_detail(options), 'snapshots')
12
+ end
13
+
14
+ def find_by_id(id)
15
+ snapshot_hash = service.get_snapshot(id).body['snapshot']
16
+ new(snapshot_hash.merge(:service => service))
17
+ end
18
+
19
+ alias get find_by_id
20
+
21
+ def destroy(id)
22
+ snapshot = find_by_id(id)
23
+ snapshot.destroy
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module SharedFileSystem
3
+ class OpenStack
4
+ class Real
5
+ def create_share(protocol, size, options = {})
6
+ data = {
7
+ 'share_proto' => protocol,
8
+ 'size' => size
9
+ }
10
+
11
+ vanilla_options = [
12
+ :name, :description, :display_name, :display_description, :share_type, :volume_type, :snapshot_id,
13
+ :is_public, :metadata, :share_network_id, :consistency_group_id, :availability_zone
14
+ ]
15
+
16
+ vanilla_options.select { |o| options[o] }.each do |key|
17
+ data[key] = options[key]
18
+ end
19
+
20
+ request(
21
+ :body => Fog::JSON.encode('share' => data),
22
+ :expects => 200,
23
+ :method => 'POST',
24
+ :path => 'shares'
25
+ )
26
+ end
27
+ end
28
+
29
+ class Mock
30
+ def create_share(protocol, size, options = {})
31
+ # stringify keys
32
+ options = Hash[options.map { |k, v| [k.to_s, v] }]
33
+
34
+ response = Excon::Response.new
35
+ response.status = 200
36
+
37
+ share = data[:shares_detail].first.dup
38
+
39
+ share['share_proto'] = protocol
40
+ share['size'] = size
41
+ share['status'] = 'creating'
42
+
43
+ response.body = {'share' => share.merge(options)}
44
+ response
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,41 @@
1
+ module Fog
2
+ module SharedFileSystem
3
+ class OpenStack
4
+ class Real
5
+ def create_share_network(options = {})
6
+ data = {}
7
+
8
+ vanilla_options = [
9
+ :name, :description, :neutron_net_id, :neutron_subnet_id, :nova_net_id
10
+ ]
11
+
12
+ vanilla_options.select { |o| options[o] }.each do |key|
13
+ data[key] = options[key]
14
+ end
15
+
16
+ request(
17
+ :body => Fog::JSON.encode('share_network' => data),
18
+ :expects => 200,
19
+ :method => 'POST',
20
+ :path => 'share-networks'
21
+ )
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ def create_share_network(options = {})
27
+ # stringify keys
28
+ options = Hash[options.map { |k, v| [k.to_s, v] }]
29
+
30
+ response = Excon::Response.new
31
+ response.status = 200
32
+
33
+ share_net = data[:share_networks_detail].first.dup
34
+
35
+ response.body = {'share_networks' => share_net.merge(options)}
36
+ response
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,46 @@
1
+ module Fog
2
+ module SharedFileSystem
3
+ class OpenStack
4
+ class Real
5
+ def create_snapshot(share_id, options = {})
6
+ data = {
7
+ 'share_id' => share_id
8
+ }
9
+
10
+ vanilla_options = [
11
+ :name, :description, :display_name, :display_description, :force
12
+ ]
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('snapshot' => data),
20
+ :expects => 202,
21
+ :method => 'POST',
22
+ :path => 'snapshots'
23
+ )
24
+ end
25
+ end
26
+
27
+ class Mock
28
+ def create_snapshot(share_id, 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
+ snapshot = data[:snapshots_detail].first.dup
36
+
37
+ snapshot['share_id'] = share_id
38
+ snapshot['status'] = 'creating'
39
+
40
+ response.body = {'snapshot' => snapshot.merge(options)}
41
+ response
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module SharedFileSystem
3
+ class OpenStack
4
+ class Real
5
+ def delete_share(id)
6
+ request(
7
+ :expects => 202,
8
+ :method => 'DELETE',
9
+ :path => "shares/#{id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_share(id)
16
+ response = Excon::Response.new
17
+ response.status = 202
18
+
19
+ share = data[:share_updated] || data[:shares_detail].first.dup
20
+ share['id'] = id
21
+ share['links']['self'] = "https://127.0.0.1:8786/v2/shares/#{id}"
22
+
23
+ response.body = {'share' => share}
24
+ response
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module SharedFileSystem
3
+ class OpenStack
4
+ class Real
5
+ def delete_share_network(id)
6
+ request(
7
+ :expects => 202,
8
+ :method => 'DELETE',
9
+ :path => "share-networks/#{id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_share_network(id)
16
+ response = Excon::Response.new
17
+ response.status = 202
18
+
19
+ share_net = data[:share_net_updated] || data[:share_networks_detail].first.dup
20
+ share_net['id'] = id
21
+
22
+ response.body = {'share_network' => share_net}
23
+ response
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module SharedFileSystem
3
+ class OpenStack
4
+ class Real
5
+ def delete_snapshot(id)
6
+ request(
7
+ :expects => 202,
8
+ :method => 'DELETE',
9
+ :path => "snapshots/#{id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_snapshot(id)
16
+ response = Excon::Response.new
17
+ response.status = 202
18
+
19
+ snapshot = data[:snapshot_updated] || data[:snapshots_detail].first.dup
20
+ snapshot['id'] = id
21
+ snapshot['status'] = 'deleting'
22
+ snapshot['links']['self'] = "https://127.0.0.1:8786/v2/snapshots/#{id}"
23
+
24
+ response.body = {'snapshot' => snapshot}
25
+ response
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module SharedFileSystem
3
+ class OpenStack
4
+ class Real
5
+ def get_share(id)
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "shares/#{id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_share(id)
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ share = data[:share_updated] || data[:shares_detail].first
19
+ share['id'] = id
20
+ response.body = share
21
+ response
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end