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
@@ -220,17 +220,20 @@ module Fog
220
220
  'router:external' => false,
221
221
  'admin_state_up' => true,
222
222
  'qos_policy_id' => qos_policy_id,
223
- 'port_security_enabled' => 'port_security_enabled'
223
+ 'port_security_enabled' => true
224
224
  },
225
225
  'e624a36d-762b-481f-9b50-4154ceb78bbb' => {
226
- 'id' => 'e624a36d-762b-481f-9b50-4154ceb78bbb',
227
- 'name' => 'network_1',
228
- 'subnets' => ['2e4ec6a4-0150-47f5-8523-e899ac03026e'],
229
- 'shared' => false,
230
- 'status' => 'ACTIVE',
231
- 'admin_state_up' => true,
232
- 'tenant_id' => 'f8b26a6032bc47718a7702233ac708b9',
233
- 'router:external' => false,
226
+ 'id' => 'e624a36d-762b-481f-9b50-4154ceb78bbb',
227
+ 'name' => 'network_1',
228
+ 'subnets' => ['2e4ec6a4-0150-47f5-8523-e899ac03026e'],
229
+ 'shared' => false,
230
+ 'status' => 'ACTIVE',
231
+ 'tenant_id' => 'f8b26a6032bc47718a7702233ac708b9',
232
+ 'provider:network:type' => 'vlan',
233
+ 'router:external' => false,
234
+ 'admin_state_up' => true,
235
+ 'qos_policy_id' => qos_policy_id,
236
+ 'port_security_enabled' => true
234
237
  }
235
238
  },
236
239
  :ports => {},
@@ -7,7 +7,6 @@ module Fog
7
7
  identity :id
8
8
 
9
9
  attribute :object_type
10
- attribute :object_id
11
10
  attribute :tenant_id
12
11
  attribute :target_tenant
13
12
  attribute :action
@@ -9,7 +9,7 @@ module Fog
9
9
  }
10
10
  }
11
11
 
12
- vanilla_options = [:port_id, :tenant_id, :fixed_ip_address]
12
+ vanilla_options = [:port_id, :tenant_id, :fixed_ip_address, :floating_ip_address]
13
13
  vanilla_options.reject { |o| options[o].nil? }.each do |key|
14
14
  data['floatingip'][key] = options[key]
15
15
  end
@@ -69,13 +69,13 @@ module Fog
69
69
  data = {
70
70
  'id' => Fog::Mock.random_numbers(6).to_s,
71
71
  'name' => options[:name],
72
- 'shared' => options[:shared],
72
+ 'shared' => options[:shared] || false,
73
73
  'subnets' => [],
74
74
  'status' => 'ACTIVE',
75
- 'admin_state_up' => options[:admin_state_up],
75
+ 'admin_state_up' => options[:admin_state_up] || false,
76
76
  'tenant_id' => options[:tenant_id],
77
77
  'qos_policy_id' => options[:qos_policy_id],
78
- 'port_security_enabled' => options[:port_security_enabled]
78
+ 'port_security_enabled' => options[:port_security_enabled] || false
79
79
  }
80
80
  data.merge!(Fog::Network::OpenStack::Real.create(options))
81
81
  self.data[:networks][data['id']] = data
data/lib/fog/openstack.rb CHANGED
@@ -51,6 +51,10 @@ module Fog
51
51
  autoload :OpenStack, File.expand_path('../metering/openstack', __FILE__)
52
52
  end
53
53
 
54
+ module Metric
55
+ autoload :OpenStack, File.expand_path('../metric/openstack', __FILE__)
56
+ end
57
+
54
58
  module Monitoring
55
59
  autoload :OpenStack, File.expand_path('../monitoring/openstack', __FILE__)
56
60
  end
@@ -67,6 +71,10 @@ module Fog
67
71
  autoload :OpenStack, File.expand_path('../orchestration/openstack', __FILE__)
68
72
  end
69
73
 
74
+ module SharedFileSystem
75
+ autoload :OpenStack, File.expand_path('../shared_file_system/openstack', __FILE__)
76
+ end
77
+
70
78
  module Storage
71
79
  autoload :OpenStack, File.expand_path('../storage/openstack', __FILE__)
72
80
  end
@@ -91,21 +99,23 @@ module Fog
91
99
  module OpenStack
92
100
  extend Fog::Provider
93
101
 
94
- service(:compute, 'Compute')
95
- service(:image, 'Image')
96
- service(:identity, 'Identity')
97
- service(:network, 'Network')
98
- service(:storage, 'Storage')
99
- service(:volume, 'Volume')
100
- service(:metering, 'Metering')
101
- service(:orchestration, 'Orchestration')
102
- service(:nfv, 'NFV')
103
- service(:baremetal, 'Baremetal')
104
- service(:planning, 'Planning')
105
- service(:introspection, 'Introspection')
106
- service(:monitoring, 'Monitoring')
107
- service(:workflow, 'Workflow')
108
- service(:dns, 'DNS')
102
+ service(:compute, 'Compute')
103
+ service(:image, 'Image')
104
+ service(:identity, 'Identity')
105
+ service(:network, 'Network')
106
+ service(:storage, 'Storage')
107
+ service(:volume, 'Volume')
108
+ service(:metering, 'Metering')
109
+ service(:metric, 'Metric')
110
+ service(:orchestration, 'Orchestration')
111
+ service(:nfv, 'NFV')
112
+ service(:baremetal, 'Baremetal')
113
+ service(:planning, 'Planning')
114
+ service(:introspection, 'Introspection')
115
+ service(:monitoring, 'Monitoring')
116
+ service(:workflow, 'Workflow')
117
+ service(:dns, 'DNS')
118
+ service(:shared_file_system, 'SharedFileSystem')
109
119
 
110
120
  @token_cache = {}
111
121
 
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Openstack
3
- VERSION = "0.1.15"
3
+ VERSION = "0.1.17"
4
4
  end
5
5
  end
@@ -14,7 +14,11 @@ module Fog
14
14
 
15
15
  def save(options = {})
16
16
  if persisted?
17
- service.update_stack(self, default_options.merge(options)).body['stack']
17
+ stack_default_options = default_options
18
+ if (options.key?(:template_url))
19
+ stack_default_options.delete(:template)
20
+ end
21
+ service.update_stack(self, stack_default_options.merge(options)).body['stack']
18
22
  else
19
23
  service.stacks.create(default_options.merge(options))
20
24
  end
@@ -0,0 +1,278 @@
1
+ module Fog
2
+ module SharedFileSystem
3
+ class OpenStack < Fog::Service
4
+ SUPPORTED_VERSIONS = /v2(\.0)*/
5
+
6
+ requires :openstack_auth_url
7
+ recognizes :openstack_auth_token, :openstack_management_url,
8
+ :persistent, :openstack_service_type, :openstack_service_name,
9
+ :openstack_tenant, :openstack_tenant_id,
10
+ :openstack_api_key, :openstack_username, :openstack_identity_endpoint,
11
+ :current_user, :current_tenant, :openstack_region,
12
+ :openstack_endpoint_type, :openstack_cache_ttl,
13
+ :openstack_project_name, :openstack_project_id,
14
+ :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
15
+ :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
16
+ :openstack_identity_prefix
17
+
18
+ model_path 'fog/shared_file_system/openstack/models'
19
+ model :network
20
+ collection :networks
21
+ model :share
22
+ collection :shares
23
+ model :snapshot
24
+ collection :snapshots
25
+
26
+ request_path 'fog/shared_file_system/openstack/requests'
27
+ # share networks
28
+ request :list_share_networks
29
+ request :list_share_networks_detail
30
+ request :get_share_network
31
+ request :create_share_network
32
+ request :update_share_network
33
+ request :delete_share_network
34
+
35
+ # shares
36
+ request :list_shares
37
+ request :list_shares_detail
38
+ request :get_share
39
+ request :create_share
40
+ request :update_share
41
+ request :delete_share
42
+
43
+ # snapshots
44
+ request :list_snapshots
45
+ request :list_snapshots_detail
46
+ request :get_snapshot
47
+ request :create_snapshot
48
+ request :update_snapshot
49
+ request :delete_snapshot
50
+
51
+ # rubocop:disable LineLength, Metrics/MethodLength, Metrics/ClassLength, Metrics/AbcSize
52
+ class Mock
53
+ def self.data
54
+ @data ||= Hash.new do |hash, key|
55
+ hash[key] = {
56
+ :shares => [
57
+ {
58
+ "id" => "d94a8548-2079-4be0-b21c-0a887acd31ca",
59
+ "links" => [
60
+ {
61
+ "href" => "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/shares/d94a8548-2079-4be0-b21c-0a887acd31ca",
62
+ "rel" => "self"
63
+ },
64
+ {
65
+ "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/d94a8548-2079-4be0-b21c-0a887acd31ca",
66
+ "rel" => "bookmark"
67
+ }
68
+ ],
69
+ "name" => "My_share"
70
+ },
71
+ {
72
+ "id" => "406ea93b-32e9-4907-a117-148b3945749f",
73
+ "links" => [
74
+ {
75
+ "href" => "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/shares/406ea93b-32e9-4907-a117-148b3945749f",
76
+ "rel" => "self"
77
+ },
78
+ {
79
+ "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/406ea93b-32e9-4907-a117-148b3945749f",
80
+ "rel" => "bookmark"
81
+ }
82
+ ],
83
+ "name" => "Share1"
84
+ }
85
+ ],
86
+ :shares_detail => [
87
+ {
88
+ "links" => [
89
+ {
90
+ "href" => "http://172.18.198.54:8786/v2/16e1ab15c35a457e9c2b2aa189f544e1/shares/f45cc5b2-d1bb-4a3e-ba5b-5c4125613adc",
91
+ "rel" => "self"
92
+ },
93
+ {
94
+ "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/f45cc5b2-d1bb-4a3e-ba5b-5c4125613adc",
95
+ "rel" => "bookmark"
96
+ }
97
+ ],
98
+ "availability_zone" => "nova",
99
+ "share_network_id" => "f9b2e754-ac01-4466-86e1-5c569424754e",
100
+ "export_locations" => [],
101
+ "share_server_id" => "87d8943a-f5da-47a4-b2f2-ddfa6794aa82",
102
+ "snapshot_id" => '',
103
+ "id" => "f45cc5b2-d1bb-4a3e-ba5b-5c4125613adc",
104
+ "size" => 1,
105
+ "share_type" => "25747776-08e5-494f-ab40-a64b9d20d8f7",
106
+ "share_type_name" => "default",
107
+ "export_location" => '',
108
+ "consistency_group_id" => "9397c191-8427-4661-a2e8-b23820dc01d4",
109
+ "project_id" => "16e1ab15c35a457e9c2b2aa189f544e1",
110
+ "metadata" => {},
111
+ "status" => "available",
112
+ "access_rules_status" => "active",
113
+ "description" => "There is a share description.",
114
+ "host" => "manila2@generic1#GENERIC1",
115
+ "task_state" => '',
116
+ "is_public" => 'true',
117
+ "snapshot_support" => 'true',
118
+ "name" => "my_share4",
119
+ "has_replicas" => 'false',
120
+ "replication_type" => '',
121
+ "created_at" => "2015-09-16T18:19:50.000000",
122
+ "share_proto" => "NFS",
123
+ "volume_type" => "default",
124
+ "source_cgsnapshot_member_id" => ''
125
+ }
126
+ ],
127
+ :share_networks => [
128
+ {
129
+ "id" => "32763294-e3d4-456a-998d-60047677c2fb",
130
+ "name" => "net_my1"
131
+ },
132
+ {
133
+ "id" => "713df749-aac0-4a54-af52-10f6c991e80c",
134
+ "name" => "net_my"
135
+ }
136
+ ],
137
+ :share_networks_detail => [
138
+ {
139
+ "name" => "net_my1",
140
+ "segmentation_id" => '',
141
+ "created_at" => "2015-09-04T14:57:13.000000",
142
+ "neutron_subnet_id" => "53482b62-2c84-4a53-b6ab-30d9d9800d06",
143
+ "updated_at" => '',
144
+ "id" => "32763294-e3d4-456a-998d-60047677c2fb",
145
+ "neutron_net_id" => "998b42ee-2cee-4d36-8b95-67b5ca1f2109",
146
+ "ip_version" => '',
147
+ "nova_net_id" => '',
148
+ "cidr" => '',
149
+ "project_id" => "16e1ab15c35a457e9c2b2aa189f544e1",
150
+ "network_type" => '',
151
+ "description" => "descr"
152
+ }
153
+ ],
154
+ :snapshots => [
155
+ {
156
+ "id" => "086a1aa6-c425-4ecd-9612-391a3b1b9375",
157
+ "links" => [
158
+ {
159
+ "href" => "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/snapshots/086a1aa6-c425-4ecd-9612-391a3b1b9375",
160
+ "rel" => "self"
161
+ },
162
+ {
163
+ "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/snapshots/086a1aa6-c425-4ecd-9612-391a3b1b9375",
164
+ "rel" => "bookmark"
165
+ }
166
+ ],
167
+ "name" => "snapshot_My_share"
168
+ }
169
+ ],
170
+ :snapshots_detail => [
171
+ {
172
+ "status" => "available",
173
+ "share_id" => "d94a8548-2079-4be0-b21c-0a887acd31ca",
174
+ "name" => "snapshot_My_share",
175
+ "links" => [
176
+ {
177
+ "href" => "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/snapshots/086a1aa6-c425-4ecd-9612-391a3b1b9375",
178
+ "rel" => "self"
179
+ },
180
+ {
181
+ "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/snapshots/086a1aa6-c425-4ecd-9612-391a3b1b9375",
182
+ "rel" => "bookmark"
183
+ }
184
+ ],
185
+ "created_at" => "2015-09-07T11:55:09.000000",
186
+ "description" => "Here is a snapshot of share My_share",
187
+ "share_proto" => "NFS",
188
+ "share_size" => 1,
189
+ "id" => "086a1aa6-c425-4ecd-9612-391a3b1b9375",
190
+ "size" => 1
191
+ }
192
+ ]
193
+ }
194
+ end
195
+ end
196
+
197
+ def self.reset
198
+ @data = nil
199
+ end
200
+
201
+ def initialize(options = {})
202
+ @openstack_username = options[:openstack_username]
203
+ @openstack_tenant = options[:openstack_tenant]
204
+ @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
205
+
206
+ @auth_token = Fog::Mock.random_base64(64)
207
+ @auth_token_expiration = (Time.now.utc + 86400).iso8601
208
+
209
+ management_url = URI.parse(options[:openstack_auth_url])
210
+ management_url.port = 8786
211
+ management_url.path = '/v2'
212
+ @openstack_management_url = management_url.to_s
213
+
214
+ @data ||= {:users => {}}
215
+ unless @data[:users].detect { |u| u['name'] == options[:openstack_username] }
216
+ id = Fog::Mock.random_numbers(6).to_s
217
+ @data[:users][id] = {
218
+ 'id' => id,
219
+ 'name' => options[:openstack_username],
220
+ 'email' => "#{options[:openstack_username]}@mock.com",
221
+ 'tenantId' => Fog::Mock.random_numbers(6).to_s,
222
+ 'enabled' => true
223
+ }
224
+ end
225
+ end
226
+
227
+ def data
228
+ self.class.data[@openstack_username]
229
+ end
230
+
231
+ def reset_data
232
+ self.class.data.delete(@openstack_username)
233
+ end
234
+
235
+ def credentials
236
+ {:provider => 'openstack',
237
+ :openstack_auth_url => @openstack_auth_uri.to_s,
238
+ :openstack_auth_token => @auth_token,
239
+ :openstack_region => @openstack_region,
240
+ :openstack_management_url => @openstack_management_url}
241
+ end
242
+ end
243
+ # rubocop:enable LineLength, Metrics/MethodLength, Metrics/ClassLength, Metrics/AbcSize
244
+
245
+ class Real
246
+ include Fog::OpenStack::Core
247
+
248
+ def self.not_found_class
249
+ Fog::SharedFileSystem::OpenStack::NotFound
250
+ end
251
+
252
+ def initialize(options = {})
253
+ initialize_identity options
254
+
255
+ @openstack_service_type = options[:openstack_service_type] || ['sharev2']
256
+ @openstack_service_name = options[:openstack_service_name]
257
+
258
+ @connection_options = options[:connection_options] || {}
259
+
260
+ authenticate
261
+ set_api_path
262
+
263
+ @persistent = options[:persistent] || false
264
+ @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
265
+ end
266
+
267
+ def set_api_path
268
+ unless @path.match(SUPPORTED_VERSIONS)
269
+ @path = Fog::OpenStack.get_supported_version_path(SUPPORTED_VERSIONS,
270
+ @openstack_management_uri,
271
+ @auth_token,
272
+ @connection_options)
273
+ end
274
+ end
275
+ end
276
+ end
277
+ end
278
+ end
@@ -0,0 +1,42 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module SharedFileSystem
5
+ class OpenStack
6
+ class Network < Fog::OpenStack::Model
7
+ identity :id
8
+
9
+ attribute :name
10
+ attribute :description
11
+ attribute :neutron_net_id
12
+ attribute :neutron_subnet_id
13
+ attribute :nova_net_id
14
+ attribute :network_type
15
+ attribute :segmentation_id
16
+ attribute :cidr
17
+ attribute :ip_version
18
+ attribute :project_id
19
+ attribute :created_at
20
+ attribute :updated_at
21
+
22
+ def save
23
+ raise Fog::Errors::Error, 'Resaving an existing object may create a duplicate' if persisted?
24
+ merge_attributes(service.create_share_network(attributes).body['share_network'])
25
+ true
26
+ end
27
+
28
+ def update(options = nil)
29
+ requires :id
30
+ merge_attributes(service.update_share_network(id, options || attributes).body['share_network'])
31
+ self
32
+ end
33
+
34
+ def destroy
35
+ requires :id
36
+ service.delete_share_network(id)
37
+ true
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end