fog 1.28.0 → 1.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +111 -0
  3. data/CONTRIBUTING.md +255 -1
  4. data/Rakefile +1 -1
  5. data/fog.gemspec +41 -44
  6. data/lib/fog.rb +1 -0
  7. data/lib/fog/bin.rb +1 -0
  8. data/lib/fog/bin/openstack.rb +2 -0
  9. data/lib/fog/cloudsigma/mock_data.rb +37 -33
  10. data/lib/fog/dnsmadeeasy/models/dns/record.rb +1 -1
  11. data/lib/fog/fogdocker/requests/compute/api_version.rb +1 -1
  12. data/lib/fog/glesys/compute.rb +9 -1
  13. data/lib/fog/glesys/models/compute/server.rb +32 -21
  14. data/lib/fog/glesys/models/compute/ssh_key.rb +28 -0
  15. data/lib/fog/glesys/models/compute/ssh_keys.rb +21 -0
  16. data/lib/fog/glesys/requests/compute/edit.rb +11 -0
  17. data/lib/fog/glesys/requests/compute/ssh_key_add.rb +11 -0
  18. data/lib/fog/glesys/requests/compute/ssh_key_list.rb +11 -0
  19. data/lib/fog/glesys/requests/compute/ssh_key_remove.rb +11 -0
  20. data/lib/fog/google/compute.rb +2 -0
  21. data/lib/fog/google/models/compute/server.rb +14 -0
  22. data/lib/fog/google/requests/compute/start_server.rb +24 -0
  23. data/lib/fog/google/requests/compute/stop_server.rb +24 -0
  24. data/lib/fog/linode/compute.rb +7 -0
  25. data/lib/fog/linode/requests/compute/image_delete.rb +42 -0
  26. data/lib/fog/linode/requests/compute/image_list.rb +64 -0
  27. data/lib/fog/linode/requests/compute/linode_disk_createfromimage.rb +37 -0
  28. data/lib/fog/linode/requests/compute/linode_disk_duplicate.rb +33 -0
  29. data/lib/fog/linode/requests/compute/linode_disk_imagize.rb +37 -0
  30. data/lib/fog/linode/requests/compute/linode_disk_resize.rb +36 -0
  31. data/lib/fog/linode/requests/compute/linode_disk_update.rb +34 -0
  32. data/lib/fog/openstack.rb +1 -0
  33. data/lib/fog/openstack/compute.rb +12 -1
  34. data/lib/fog/openstack/core.rb +159 -5
  35. data/lib/fog/openstack/docs/planning.md +270 -0
  36. data/lib/fog/openstack/examples/planning/basics.rb +53 -0
  37. data/lib/fog/openstack/models/planning/plan.rb +81 -0
  38. data/lib/fog/openstack/models/planning/plans.rb +31 -0
  39. data/lib/fog/openstack/models/planning/role.rb +29 -0
  40. data/lib/fog/openstack/models/planning/roles.rb +16 -0
  41. data/lib/fog/openstack/planning.rb +235 -0
  42. data/lib/fog/openstack/requests/compute/get_hypervisor_statistics.rb +39 -0
  43. data/lib/fog/openstack/requests/identity/check_token.rb +4 -2
  44. data/lib/fog/openstack/requests/identity/validate_token.rb +4 -2
  45. data/lib/fog/openstack/requests/planning/add_role_to_plan.rb +40 -0
  46. data/lib/fog/openstack/requests/planning/create_plan.rb +33 -0
  47. data/lib/fog/openstack/requests/planning/delete_plan.rb +23 -0
  48. data/lib/fog/openstack/requests/planning/get_plan.rb +58 -0
  49. data/lib/fog/openstack/requests/planning/get_plan_templates.rb +28 -0
  50. data/lib/fog/openstack/requests/planning/list_plans.rb +60 -0
  51. data/lib/fog/openstack/requests/planning/list_roles.rb +38 -0
  52. data/lib/fog/openstack/requests/planning/patch_plan.rb +51 -0
  53. data/lib/fog/openstack/requests/planning/remove_role_from_plan.rb +32 -0
  54. data/lib/fog/ovirt/compute.rb +10 -0
  55. data/lib/fog/ovirt/models/compute/affinity_group.rb +25 -0
  56. data/lib/fog/ovirt/models/compute/affinity_groups.rb +20 -0
  57. data/lib/fog/ovirt/models/compute/server.rb +12 -0
  58. data/lib/fog/ovirt/models/compute/volume.rb +2 -0
  59. data/lib/fog/ovirt/requests/compute/add_to_affinity_group.rb +21 -0
  60. data/lib/fog/ovirt/requests/compute/create_affinity_group.rb +18 -0
  61. data/lib/fog/ovirt/requests/compute/destroy_affinity_group.rb +19 -0
  62. data/lib/fog/ovirt/requests/compute/get_affinity_group.rb +18 -0
  63. data/lib/fog/ovirt/requests/compute/list_affinity_group_vms.rb +22 -0
  64. data/lib/fog/ovirt/requests/compute/list_affinity_groups.rb +20 -0
  65. data/lib/fog/ovirt/requests/compute/mock_files/affinitygroup.xml +8 -0
  66. data/lib/fog/ovirt/requests/compute/mock_files/affinitygroup_vms.xml +9 -0
  67. data/lib/fog/ovirt/requests/compute/mock_files/affinitygroups.xml +17 -0
  68. data/lib/fog/ovirt/requests/compute/remove_from_affinity_group.rb +21 -0
  69. data/lib/fog/ovirt/requests/compute/update_interface.rb +18 -5
  70. data/lib/fog/rackspace/docs/block_storage.md +1 -1
  71. data/lib/fog/rackspace/docs/cdn_v2.md +1 -1
  72. data/lib/fog/rackspace/docs/compute_v2.md +1 -1
  73. data/lib/fog/rackspace/docs/getting_started.md +1 -1
  74. data/lib/fog/rackspace/docs/networking_v2.md +1 -1
  75. data/lib/fog/rackspace/docs/storage.md +1 -1
  76. data/lib/fog/rackspace/examples/README.md +1 -1
  77. data/lib/fog/rackspace/mock_data.rb +48 -48
  78. data/lib/fog/rackspace/models/networking_v2/security_group.rb +32 -0
  79. data/lib/fog/rackspace/models/networking_v2/security_group_rule.rb +38 -0
  80. data/lib/fog/rackspace/models/networking_v2/security_group_rules.rb +23 -0
  81. data/lib/fog/rackspace/models/networking_v2/security_groups.rb +23 -0
  82. data/lib/fog/rackspace/networking_v2.rb +24 -7
  83. data/lib/fog/rackspace/requests/networking_v2/create_security_group.rb +12 -0
  84. data/lib/fog/rackspace/requests/networking_v2/create_security_group_rule.rb +12 -0
  85. data/lib/fog/rackspace/requests/networking_v2/delete_security_group.rb +5 -0
  86. data/lib/fog/rackspace/requests/networking_v2/delete_security_group_rule.rb +5 -0
  87. data/lib/fog/rackspace/requests/networking_v2/list_security_group_rules.rb +5 -0
  88. data/lib/fog/rackspace/requests/networking_v2/list_security_groups.rb +5 -0
  89. data/lib/fog/rackspace/requests/networking_v2/show_security_group.rb +5 -0
  90. data/lib/fog/rackspace/requests/networking_v2/show_security_group_rule.rb +5 -0
  91. data/lib/fog/rackspace/requests/networking_v2/update_security_group.rb +12 -0
  92. data/lib/fog/rackspace/requests/storage/get_object_https_url.rb +1 -1
  93. data/lib/fog/version.rb +1 -1
  94. data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +13 -4
  95. data/lib/fog/vsphere/requests/compute/vm_clone.rb +19 -6
  96. data/lib/fog/xenserver/requests/compute/create_vdi.rb +16 -6
  97. data/lib/tasks/changelog_task.rb +2 -1
  98. data/spec/fog/account_spec.rb +1 -2
  99. data/spec/fog/billing_spec.rb +1 -2
  100. data/spec/fog/bin/atmos_spec.rb +25 -2
  101. data/spec/fog/bin/aws_spec.rb +1 -2
  102. data/spec/fog/bin/baremetalcloud_spec.rb +25 -2
  103. data/spec/fog/bin/bluebox_spec.rb +47 -2
  104. data/spec/fog/bin/brightbox_spec.rb +1 -2
  105. data/spec/fog/bin/clodo_spec.rb +1 -2
  106. data/spec/fog/bin/cloudsigma_spec.rb +1 -2
  107. data/spec/fog/bin/cloudstack_spec.rb +1 -2
  108. data/spec/fog/bin/digitalocean_spec.rb +1 -2
  109. data/spec/fog/bin/dnsimple_spec.rb +1 -2
  110. data/spec/fog/bin/dnsmadeeasy_spec.rb +1 -2
  111. data/spec/fog/bin/dreamhost_spec.rb +1 -2
  112. data/spec/fog/bin/dynect_spec.rb +1 -2
  113. data/spec/fog/bin/powerdns_spec.rb +9 -0
  114. data/spec/fog/bin_spec.rb +4 -2
  115. data/spec/fog/cdn_spec.rb +1 -2
  116. data/spec/fog/compute_spec.rb +1 -2
  117. data/spec/fog/dns_spec.rb +1 -2
  118. data/spec/fog/identity_spec.rb +1 -2
  119. data/spec/fog/image_spec.rb +1 -2
  120. data/spec/fog/metering_spec.rb +1 -2
  121. data/spec/fog/monitoring_spec.rb +1 -2
  122. data/spec/fog/network_spec.rb +1 -2
  123. data/spec/fog/orchestration_spec.rb +1 -2
  124. data/spec/fog/storage_spec.rb +1 -2
  125. data/spec/fog/support_spec.rb +1 -2
  126. data/spec/fog/volume_spec.rb +1 -2
  127. data/spec/fog/vpn_spec.rb +1 -2
  128. data/spec/fog/xml/connection_spec.rb +1 -2
  129. data/spec/helpers/bin.rb +4 -0
  130. data/spec/spec_helper.rb +15 -0
  131. data/tests/compute/helper.rb +3 -0
  132. data/tests/glesys/requests/compute/helper.rb +66 -2
  133. data/tests/glesys/requests/compute/server_tests.rb +22 -6
  134. data/tests/glesys/requests/compute/ssh_key_tests.rb +47 -0
  135. data/tests/google/credentials_tests.rb +73 -0
  136. data/tests/helper.rb +5 -1
  137. data/tests/linode/requests/compute/linode_tests.rb +76 -3
  138. data/tests/openstack/authenticate_tests.rb +10 -0
  139. data/tests/openstack/models/planning/.gitkeep +0 -0
  140. data/tests/openstack/models/planning/plan_tests.rb +51 -0
  141. data/tests/openstack/models/planning/plans_tests.rb +18 -0
  142. data/tests/openstack/models/planning/role_tests.rb +14 -0
  143. data/tests/openstack/requests/planning/.gitkeep +0 -0
  144. data/tests/openstack/requests/planning/plan_tests.rb +65 -0
  145. data/tests/openstack/requests/planning/role_tests.rb +16 -0
  146. metadata +193 -75
  147. data/lib/fog/bin/atmos.rb +0 -29
  148. data/lib/fog/bin/local.rb +0 -29
  149. data/lib/fog/local.rb +0 -1
  150. data/lib/fog/local/core.rb +0 -9
  151. data/lib/fog/local/models/storage/directories.rb +0 -33
  152. data/lib/fog/local/models/storage/directory.rb +0 -53
  153. data/lib/fog/local/models/storage/file.rb +0 -132
  154. data/lib/fog/local/models/storage/files.rb +0 -84
  155. data/lib/fog/local/storage.rb +0 -96
  156. data/tests/local/models/directories_tests.rb +0 -17
  157. data/tests/local/models/directory_tests.rb +0 -16
  158. data/tests/local/models/file_tests.rb +0 -43
  159. data/tests/local/storage_tests.rb +0 -40
@@ -0,0 +1,16 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/openstack/models/planning/role'
3
+
4
+ module Fog
5
+ module Openstack
6
+ class Planning
7
+ class Roles < Fog::Collection
8
+ model Fog::Openstack::Planning::Role
9
+
10
+ def all
11
+ load(service.list_roles.body)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,235 @@
1
+ require 'fog/openstack/core'
2
+
3
+ module Fog
4
+ module Openstack
5
+ class Planning < Fog::Service
6
+ SUPPORTED_VERSIONS = /v2/
7
+
8
+ requires :openstack_auth_url
9
+ recognizes :openstack_auth_token, :openstack_management_url, :persistent,
10
+ :openstack_service_type, :openstack_service_name, :openstack_tenant,
11
+ :openstack_api_key, :openstack_username,
12
+ :current_user, :current_tenant, :openstack_endpoint_type, :openstack_region
13
+
14
+ ## MODELS
15
+ #
16
+ model_path 'fog/openstack/models/planning'
17
+ model :role
18
+ collection :roles
19
+ model :plan
20
+ collection :plans
21
+
22
+ ## REQUESTS
23
+ #
24
+ request_path 'fog/openstack/requests/planning'
25
+
26
+ # Role requests
27
+ request :list_roles
28
+
29
+ # Plan requests
30
+ request :list_plans
31
+ request :get_plan_templates
32
+ request :get_plan
33
+ request :patch_plan
34
+ request :create_plan
35
+ request :delete_plan
36
+ request :add_role_to_plan
37
+ request :remove_role_from_plan
38
+
39
+ class Mock
40
+ def self.data
41
+ @data ||= Hash.new
42
+ end
43
+
44
+ def self.reset
45
+ @data = nil
46
+ end
47
+
48
+ def initialize(options={})
49
+ @openstack_username = options[:openstack_username]
50
+ @openstack_tenant = options[:openstack_tenant]
51
+ @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
52
+
53
+ @auth_token = Fog::Mock.random_base64(64)
54
+ @auth_token_expiration = (Time.now.utc + 86400).iso8601
55
+
56
+ management_url = URI.parse(options[:openstack_auth_url])
57
+ management_url.port = 9292
58
+ management_url.path = '/v1'
59
+ @openstack_management_url = management_url.to_s
60
+
61
+ @data ||= { :users => {} }
62
+ unless @data[:users].find {|u| u['name'] == options[:openstack_username]}
63
+ id = Fog::Mock.random_numbers(6).to_s
64
+ @data[:users][id] = {
65
+ 'id' => id,
66
+ 'name' => options[:openstack_username],
67
+ 'email' => "#{options[:openstack_username]}@mock.com",
68
+ 'tenantId' => Fog::Mock.random_numbers(6).to_s,
69
+ 'enabled' => true
70
+ }
71
+ end
72
+ end
73
+
74
+ def data
75
+ self.class.data[@openstack_username]
76
+ end
77
+
78
+ def reset_data
79
+ self.class.data.delete(@openstack_username)
80
+ end
81
+
82
+ def credentials
83
+ { :provider => 'openstack',
84
+ :openstack_auth_url => @openstack_auth_uri.to_s,
85
+ :openstack_auth_token => @auth_token,
86
+ :openstack_region => @openstack_region,
87
+ :openstack_management_url => @openstack_management_url }
88
+ end
89
+ end
90
+
91
+ class Real
92
+ attr_reader :current_user
93
+ attr_reader :current_tenant
94
+
95
+ def initialize(options={})
96
+ @openstack_auth_token = options[:openstack_auth_token]
97
+
98
+ unless @openstack_auth_token
99
+ missing_credentials = Array.new
100
+ @openstack_api_key = options[:openstack_api_key]
101
+ @openstack_username = options[:openstack_username]
102
+
103
+ missing_credentials << :openstack_api_key unless @openstack_api_key
104
+ missing_credentials << :openstack_username unless @openstack_username
105
+ raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
106
+ end
107
+
108
+ @openstack_tenant = options[:openstack_tenant]
109
+ @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
110
+ @openstack_management_url = options[:openstack_management_url]
111
+ @openstack_must_reauthenticate = false
112
+ @openstack_service_type = options[:openstack_service_type] || ['management'] # currently Tuskar is configured as 'management' service in Keystone
113
+ @openstack_service_name = options[:openstack_service_name]
114
+ @openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
115
+ @openstack_region = options[:openstack_region]
116
+
117
+ @connection_options = options[:connection_options] || {}
118
+
119
+ @current_user = options[:current_user]
120
+ @current_tenant = options[:current_tenant]
121
+
122
+ authenticate
123
+
124
+ @persistent = options[:persistent] || false
125
+ @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
126
+ end
127
+
128
+ def credentials
129
+ { :provider => 'openstack',
130
+ :openstack_auth_url => @openstack_auth_uri.to_s,
131
+ :openstack_auth_token => @auth_token,
132
+ :openstack_management_url => @openstack_management_url,
133
+ :current_user => @current_user,
134
+ :current_tenant => @current_tenant }
135
+ end
136
+
137
+ def reload
138
+ @connection.reset
139
+ end
140
+
141
+ def request(params)
142
+ begin
143
+ response = @connection.request(params.merge({
144
+ :headers => {
145
+ 'Content-Type' => 'application/json',
146
+ 'X-Auth-Token' => @auth_token
147
+ }.merge!(params[:headers] || {}),
148
+ :path => "#{@path}/#{params[:path]}"#,
149
+ }))
150
+ rescue Excon::Errors::Unauthorized => error
151
+ if error.response.body != 'Bad username or password' # token expiration
152
+ @openstack_must_reauthenticate = true
153
+ authenticate
154
+ retry
155
+ else # bad credentials
156
+ raise error
157
+ end
158
+ rescue Excon::Errors::HTTPStatusError => error
159
+ raise case error
160
+ when Excon::Errors::NotFound
161
+ Fog::Compute::OpenStack::NotFound.slurp(error)
162
+ else
163
+ error
164
+ end
165
+ end
166
+ unless response.body.empty?
167
+ response.body = Fog::JSON.decode(response.body)
168
+ end
169
+ response
170
+ end
171
+
172
+ private
173
+
174
+ def authenticate
175
+ if !@openstack_management_url || @openstack_must_reauthenticate
176
+ options = {
177
+ :openstack_tenant => @openstack_tenant,
178
+ :openstack_api_key => @openstack_api_key,
179
+ :openstack_username => @openstack_username,
180
+ :openstack_auth_uri => @openstack_auth_uri,
181
+ :openstack_region => @openstack_region,
182
+ :openstack_auth_token => @openstack_must_reauthenticate ? nil : @openstack_auth_token,
183
+ :openstack_service_type => @openstack_service_type,
184
+ :openstack_service_name => @openstack_service_name,
185
+ :openstack_endpoint_type => @openstack_endpoint_type
186
+ }
187
+
188
+ credentials = Fog::OpenStack.authenticate_v2(options, @connection_options)
189
+
190
+ @current_user = credentials[:user]
191
+ @current_tenant = credentials[:tenant]
192
+
193
+ @openstack_must_reauthenticate = false
194
+ @auth_token = credentials[:token]
195
+ @openstack_management_url = credentials[:server_management_url]
196
+ uri = URI.parse(@openstack_management_url)
197
+ else
198
+ @auth_token = @openstack_auth_token
199
+ uri = URI.parse(@openstack_management_url)
200
+ end
201
+
202
+ @host = uri.host
203
+ @path = uri.path
204
+ @path.sub!(/\/$/, '')
205
+ unless @path.match(SUPPORTED_VERSIONS)
206
+ @path = "/v2"
207
+ end
208
+ @port = uri.port
209
+ @scheme = uri.scheme
210
+ true
211
+ end
212
+ end
213
+ end
214
+
215
+ def self.[](service)
216
+ new(:service => service)
217
+ end
218
+
219
+ def self.new(attributes)
220
+ attributes = attributes.dup # Prevent delete from having side effects
221
+ service = attributes.delete(:service).to_s.downcase.to_sym
222
+ if services.include?(service)
223
+ require "fog/openstack/#{service}"
224
+ return Fog::Openstack.const_get(service.to_s.capitalize).new(attributes)
225
+ end
226
+ raise ArgumentError, "Openstack has no #{service} service"
227
+ end
228
+
229
+ def self.services
230
+ # Ruby 1.8.7 compatibility for select returning Array of Arrays (pairs)
231
+ Hash[Fog.services.select{|service, providers| providers.include?(:openstack)}].keys
232
+ end
233
+ end
234
+ end
235
+
@@ -0,0 +1,39 @@
1
+ module Fog
2
+ module Compute
3
+ class OpenStack
4
+ class Real
5
+ def get_hypervisor_statistics(tenant_id)
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "os-hypervisors/statistics"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_hypervisor_statistics(tenant_id)
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ response.body = {
19
+ "hypervisor_statistics" => {
20
+ "count" => 1,
21
+ "current_workload" => 0,
22
+ "disk_available_least" => 0,
23
+ "free_disk_gb" => 1028,
24
+ "free_ram_mb" => 7680,
25
+ "local_gb" => 1028,
26
+ "local_gb_used" => 0,
27
+ "memory_mb" => 8192,
28
+ "memory_mb_used" => 512,
29
+ "running_vms" => 0,
30
+ "vcpus" => 1,
31
+ "vcpus_used" => 0
32
+ }
33
+ }
34
+ response
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -2,16 +2,18 @@ module Fog
2
2
  module Identity
3
3
  class OpenStack
4
4
  class Real
5
- def check_token(token_id, tenant_id)
5
+ def check_token(token_id, tenant_id=nil)
6
6
  request(
7
7
  :expects => [200, 203],
8
8
  :method => 'HEAD',
9
- :path => "tokens/#{token_id}?belongsTo=#{tenant_id}"
9
+ :path => "tokens/#{token_id}"+(tenant_id ? "?belongsTo=#{tenant_id}" : '')
10
10
  )
11
11
  end
12
12
  end
13
13
 
14
14
  class Mock
15
+ def check_token(token_id, tenant_id=nil)
16
+ end
15
17
  end
16
18
  end
17
19
  end
@@ -2,16 +2,18 @@ module Fog
2
2
  module Identity
3
3
  class OpenStack
4
4
  class Real
5
- def validate_token(token_id, tenant_id)
5
+ def validate_token(token_id, tenant_id=nil)
6
6
  request(
7
7
  :expects => [200, 203],
8
8
  :method => 'GET',
9
- :path => "tokens/#{token_id}?belongsTo=#{tenant_id}"
9
+ :path => "tokens/#{token_id}"+(tenant_id ? "?belongsTo=#{tenant_id}" : '')
10
10
  )
11
11
  end
12
12
  end
13
13
 
14
14
  class Mock
15
+ def validate_token(token_id, tenant_id=nil)
16
+ end
15
17
  end
16
18
  end
17
19
  end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Openstack
3
+ class Planning
4
+ class Real
5
+ def add_role_to_plan(plan_uuid, role_uuid)
6
+ request(
7
+ :expects => [201],
8
+ :method => 'POST',
9
+ :path => "plans/#{plan_uuid}/roles",
10
+ :body => Fog::JSON.encode({'uuid' => role_uuid})
11
+ )
12
+ end
13
+ end # class Real
14
+
15
+ class Mock
16
+ def add_role_to_plan(plan_uuid, role_uuid)
17
+ response = Excon::Response.new
18
+ response.status = [201][rand(1)]
19
+ response.body = {
20
+ "created_at" => "2014-09-26T20:23:14.222815",
21
+ "description" => "Development testing cloud",
22
+ "name" => "dev-cloud",
23
+ "parameters" => [],
24
+ "roles" => [
25
+ {
26
+ "description" => "OpenStack hypervisor node. Can be wrapped in a ResourceGroup for scaling.\n",
27
+ "name" => "compute",
28
+ "uuid" => "f72c0656-5696-4c66-81a5-d6d88a48e385",
29
+ "version" => 1
30
+ }
31
+ ],
32
+ "updated_at" => nil,
33
+ "uuid" => "53268a27-afc8-4b21-839f-90227dd7a001"
34
+ }
35
+ response
36
+ end # def add_role_to_plans
37
+ end # class Mock
38
+ end # class Planning
39
+ end # module Openstack
40
+ end # module Fog
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module Openstack
3
+ class Planning
4
+ class Real
5
+ def create_plan(parameters)
6
+ request(
7
+ :expects => [201],
8
+ :method => 'POST',
9
+ :path => "plans",
10
+ :body => Fog::JSON.encode(parameters)
11
+ )
12
+ end
13
+ end # class Real
14
+
15
+ class Mock
16
+ def create_plan(parameters)
17
+ response = Excon::Response.new
18
+ response.status = [201][rand(1)]
19
+ response.body = {
20
+ "created_at" => "2014-09-26T20:23:14.222815",
21
+ "description" => "Development testing cloud",
22
+ "name" => "dev-cloud",
23
+ "parameters" => [],
24
+ "roles" => [],
25
+ "updated_at" => nil,
26
+ "uuid" => "53268a27-afc8-4b21-839f-90227dd7a001"
27
+ }
28
+ response
29
+ end # def create_plans
30
+ end # class Mock
31
+ end # class Planning
32
+ end # module Openstack
33
+ end # module Fog
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module Openstack
3
+ class Planning
4
+ class Real
5
+ def delete_plan(plan_uuid)
6
+ request(
7
+ :expects => [204],
8
+ :method => 'DELETE',
9
+ :path => "plans/#{plan_uuid}"
10
+ )
11
+ end
12
+ end # class Real
13
+
14
+ class Mock
15
+ def delete_plan(plan_uuid)
16
+ response = Excon::Response.new
17
+ response.status = [204][rand(1)]
18
+ response
19
+ end # def delete_plans
20
+ end # class Mock
21
+ end # class Planning
22
+ end # module Openstack
23
+ end # module Fog
@@ -0,0 +1,58 @@
1
+ module Fog
2
+ module Openstack
3
+ class Planning
4
+ class Real
5
+ def get_plan(plan_uuid)
6
+ request(
7
+ :expects => [200, 204],
8
+ :method => 'GET',
9
+ :path => "plans/#{plan_uuid}"
10
+ )
11
+ end
12
+ end # class Real
13
+
14
+ class Mock
15
+ def get_plan(parameters=nil)
16
+ response = Excon::Response.new
17
+ response.status = [200, 204][rand(1)]
18
+ response.body = {
19
+ "created_at" => "2014-09-26T20:23:14.222815",
20
+ "description" => "Development testing cloud",
21
+ "name" => "dev-cloud",
22
+ "parameters" =>
23
+ [
24
+ {
25
+ "default" => "guest",
26
+ "description" => "The password for RabbitMQ",
27
+ "hidden" => true,
28
+ "label" => nil,
29
+ "name" => "compute-1 => =>RabbitPassword",
30
+ "value" => "secret-password"
31
+ },
32
+ {
33
+ "default" => "default",
34
+ "description" => "description",
35
+ "hidden" => true,
36
+ "label" => nil,
37
+ "name" => "name",
38
+ "value" => "value"
39
+ },
40
+ ],
41
+ "roles" =>
42
+ [
43
+ {
44
+ "description" => "OpenStack hypervisor node. Can be wrapped in a ResourceGroup for scaling.\n",
45
+ "name" => "compute",
46
+ "uuid" => "b7b1583c-5c80-481f-a25b-708ed4a39734",
47
+ "version" => 1
48
+ }
49
+ ],
50
+ "updated_at" => nil,
51
+ "uuid" => "53268a27-afc8-4b21-839f-90227dd7a001"
52
+ }
53
+ response
54
+ end # def get_plan
55
+ end # class Mock
56
+ end # class Planning
57
+ end # module Openstack
58
+ end # module Fog