misty 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +332 -267
  3. data/lib/misty.rb +1 -1
  4. data/lib/misty/auth.rb +17 -6
  5. data/lib/misty/auth/auth_v2.rb +3 -0
  6. data/lib/misty/auth/auth_v3.rb +13 -5
  7. data/lib/misty/auth/name.rb +3 -3
  8. data/lib/misty/client_pack.rb +2 -2
  9. data/lib/misty/cloud.rb +111 -76
  10. data/lib/misty/config.rb +138 -0
  11. data/lib/misty/{auth/errors.rb → errors.rb} +9 -1
  12. data/lib/misty/http/direct.rb +18 -1
  13. data/lib/misty/http/method_builder.rb +10 -17
  14. data/lib/misty/http/net_http.rb +1 -1
  15. data/lib/misty/http/request.rb +26 -14
  16. data/lib/misty/microversion.rb +22 -41
  17. data/lib/misty/misty.rb +14 -24
  18. data/lib/misty/openstack/cinder/v3.rb +8 -0
  19. data/lib/misty/openstack/ironic/v1.rb +8 -0
  20. data/lib/misty/openstack/magnum/v1.rb +5 -1
  21. data/lib/misty/openstack/manila/v2.rb +8 -0
  22. data/lib/misty/openstack/nova/v2_1.rb +13 -8
  23. data/lib/misty/openstack/service.rb +88 -0
  24. data/lib/misty/openstack/swift/v1.rb +2 -2
  25. data/lib/misty/service.rb +9 -12
  26. data/lib/misty/version.rb +1 -1
  27. data/test/integration/{network_test.rb → networking_test.rb} +8 -8
  28. data/test/integration/test_helper.rb +1 -0
  29. data/test/integration/vcr/{network_using_neutron_v2_0.yml → networking_using_neutron_v2_0.yml} +0 -0
  30. data/test/unit/auth/name_test.rb +31 -27
  31. data/test/unit/auth_helper.rb +4 -4
  32. data/test/unit/auth_test.rb +44 -30
  33. data/test/unit/cloud/config_test.rb +165 -0
  34. data/test/unit/cloud/requests_test.rb +0 -12
  35. data/test/unit/cloud/services_test.rb +41 -12
  36. data/test/unit/cloud_test.rb +35 -44
  37. data/test/unit/http/request_test.rb +1 -1
  38. data/test/unit/microversion_test.rb +59 -35
  39. data/test/unit/misty_test.rb +1 -1
  40. data/test/unit/openstack/service_test.rb +52 -0
  41. data/test/unit/service_helper.rb +23 -20
  42. data/test/unit/services_test.rb +1 -1
  43. data/test/unit/test_helper.rb +0 -4
  44. metadata +37 -22
  45. data/lib/misty/client.rb +0 -104
  46. data/test/unit/client_test.rb +0 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30d8058b1a66f781f30b8f23300c44a68389bda7
4
- data.tar.gz: 3a092c09a00946956a67dbb44bfdaffbe8d92c07
3
+ metadata.gz: ec633eb5c336342f8a86380b8c9b624520ac1e2b
4
+ data.tar.gz: 51a3e89f79256a33c926ed55800135084ab1e0e3
5
5
  SHA512:
6
- metadata.gz: 500690a8ae8ae47b13f89f6489d4a5aea4e9d46f6f6b23b8e517ad4880e1076e4cf116cab52fa8c301dda67e901c939eab38dcee81691512d32c2f4ab894e466
7
- data.tar.gz: 8579eea3d1c537fa84ea91724bbd7bb9971a86a848b901f724265aadb8cccc7d85b69e3f29db7d8bf8e6fd28961917d3a3db0ad65c671f70560fe46e1a3cdb65
6
+ metadata.gz: 0bcb3e7a8b98d4b599700e65d59d89ff83d44fe86c3badee004f6579e4cd3939950c397f042d9c629c92d25ffde06b690a782d4cee803e0886a2861146e2361e
7
+ data.tar.gz: 5360efb6444ee46248d0f4d7467f90d33bf930985044082b7519e1e57935512feb90dd4039ce3ecc6aed4dffa33c60ed28cc82f826ace38082f0f1948a219dda
data/README.md CHANGED
@@ -1,103 +1,264 @@
1
1
  # Introduction
2
- Misty is a HTTP client for OpenStack APIs, aiming to be fast, flexible and exhaustive.
3
- Misty acts as a conduit to OpenStack APIs by handling requests as transparently as possible.
4
-
5
- ## Features
6
- * Flexible Openstack APIs integration
7
- * Standardized Openstack APIs: [Based upon API-ref](https://developer.openstack.org/api-guide/quick-start/)
8
- * Automatically generated API schemas - Any request can be overridden
9
- * Versions and Microversions
10
- * Transparent Request data hanlding
11
- * Response data format of choice: JSON or raw (Ruby)
2
+ Misty is a HTTP client for OpenStack APIs, aiming to be slick and dynamic.
3
+
4
+ Misty handles OpenStack APIs requests as Transparently as possible by:
5
+ * Directly submitting request to Openstack Service endpoints
6
+ * Or by using APIs Schema defined functions which are dynamically extracted from OpenStackAPI reference.
7
+
8
+ ## Main features
9
+ * Standardized OpenStack APIs: [Based upon API-ref](https://developer.openstack.org/api-guide/quick-start/) offering
10
+ flexibility to easily integrate new OpenStack services. Any request can be overridden or completed
11
+ * Microversions & Legacy Versions
12
+ * Transparent request data handling and response data format of choice: JSON or Hash
12
13
  * Custom HTTP Methods for special needs
13
- * On demand services - Auto loads required versions
14
- * Low dependency - Use standard Net/HTTP and JSON gem only
15
- * Persistent HTTP connections (default since HTTP 1.1 anyway)
16
-
17
- ## A solid KISS
18
- For REST transactions Misty relies on standard Net/HTTP library.
19
- No other gems are required besides 'json'.
20
-
21
- Not having to use the help of a more complex HTTP framework is a choice that reduces dependencies.
22
- Meanwhile a better reason would be because Openstack offers a common modus operandi across all APIs.
23
- The authentication process provides a Service Catalog serving all available APIs entry points.
24
-
25
- ## APIs Definitions
26
- The rich variety of OpenStack projects requires lots of Application Program Interfaces to handle.
27
- Maintaining and extending those APIs implies a structural complexity challenge.
28
- Therefore the more automated the process, the better.
29
- Thanks to the help of Phoenix project [OpenStack API-ref](https://developer.openstack.org/api-guide/quick-start/)
30
- providing the latest standard of OpenStack APIs.
31
- The APIs interface definitions are generated automatically from the API-ref reference manuals (misty-builder) which
32
- allows:
33
- * More consistent APIs
34
- * More recent APIs definitions
35
- * Easier addition of a new service's API
36
-
37
- [1] https://developer.openstack.org/api-guide/quick-start/
38
-
39
- # Install & Use
40
-
41
- ## Fetch and install
14
+ * And also: Lazy service loading, Low gem dependency (use only Net/HTTP and JSON), Persistent HTTP connections (default since HTTP 1.1 anyway)
15
+
16
+ ### Current Microversion support
17
+ * Cinder
18
+ v3.44
19
+ * Ironic
20
+ v1.32
21
+ * Magnum
22
+ v1.4
23
+ * Manilla
24
+ v2.40
25
+ * Nova
26
+ v2.60
27
+
28
+
29
+ # How To
30
+ Fetch and install
42
31
  ``` ruby
43
32
  gem install misty
44
33
  ```
34
+ ## Get started
35
+ Create a `Misty::Cloud` object with mandatory `:auth` parameter such as:
45
36
 
46
- ## Quick start
47
37
  ```ruby
48
38
  require 'misty'
39
+ cloud = Misty::Cloud.new(
40
+ :auth => {
41
+ :url => 'http://localhost:5000',
42
+ :user => 'admin',
43
+ :password => 'secret',
44
+ :domain => 'default',
45
+ :project => 'admin',
46
+ :project_domain_id => 'default'
47
+ })
48
+ ```
49
+
50
+ Then requets can be made against OpenStack services:
49
51
 
50
- auth_v3 = {
51
- :url => 'http://localhost:5000',
52
- :user => 'admin',
53
- :password => 'secret',
54
- :domain => 'default',
55
- :project => 'admin',
56
- :project_domain_id => 'default'
52
+ ```
53
+ servers = cloud.compute.list_servers.body
54
+ networks = cloud.networking.list_networks
55
+ first_network_id = networks.body['networks'][0]['id']
56
+ first_network = cloud.networking.show_network_details(first_network_id)
57
+ network = Misty.to_json(:network => {:name => 'misty-example'})
58
+ cloud.network.create_network(network)
59
+ v1 = cloud.baremetal.show_v1_api
60
+ ```
61
+ ## Configuration
62
+ To provide the maximum flexibility, there are 4 levels of configuration which are always propagated from top to bottom.
63
+ * The Cloud global defaults
64
+ * The Cloud global parameters
65
+ * The service level parameters
66
+ * The request level ephemeral parameters
67
+
68
+ No global parameters provided, the defaults are applied.
69
+ ```ruby
70
+ cloud = Misty::Cloud.new(:auth => { ... })
71
+ ```
72
+
73
+ Some provided global parameters, which override respective global and apply at service level.
74
+ ```ruby
75
+ cloud = Misty::Cloud.new(:auth => { ... }, :log_file => './misty.log', :headers => {"x-tra:" => "value"})
76
+ ```
77
+
78
+ Provided service level parameters are applied for all service requests.
79
+ Some such as the headers are cumulative.
80
+ Others such as the microversion feature, don't have global definition.
81
+ ```ruby
82
+ cloud = Misty::Cloud.new(:auth => { ... }, compute {:version => 2.60})
83
+ # All following requests are going to be with version 2.60, unless overridden at request level
84
+ cloud.compute.list_servers
85
+ ```
86
+
87
+ And finally, at requests level, provided parameters are ephemeral
88
+ ```ruby
89
+ cloud = Misty::Cloud.new(:auth => { ... })
90
+ cloud.compute(:version => 'latest', :content_type => :json, :headers => {"key" => "value"}).list_servers
91
+ # Back to defaults (since there are no global or service level parameters provided)
92
+ cloud.compute.list_servers
93
+ ```
94
+
95
+ ### Authentication
96
+ Openstack Identity service Keystone version 3 is the default, version 2.0, although deprecated, is available.
97
+
98
+ #### Parameters
99
+ The following parameters can be used:
100
+ To authenticate with credentials details:
101
+ * `:context` - Allow to provide already authenticated context(catalog, token, expiry time). Used for v2.0 only.
102
+ Exclusive with other parameters.
103
+ * `:domain_id` - Domain id, default: "default"
104
+ * `:domain` - Domain name, default: "Default"
105
+ * `:password` - User password. Exclusive with :token.
106
+ * `:project_id` - Project id
107
+ * `:project` - Project name
108
+ * `:project_domain_id` - Project domain id
109
+ * `:project_domain` - Project domain name
110
+ * `:ssl_verify_mode` - Boolean flag for SSL client verification. SSL is defined when URI scheme => "https://".
111
+ * `:tenant_id` - Tenant id, used for v2.0 only.
112
+ * `:tenant` - Tenant name, used for v2.0 only.
113
+ * `:token` - Allow to provide unscoped token.
114
+ * `:user_id` - User id
115
+ * `:user` - User name
116
+ * `:user_domain_id` - User domain id
117
+ * `:user_domain` - User domain name
118
+
119
+ ##### Keystone v3
120
+ Version 3 relies on the concept of domain name or id to authenticates
121
+
122
+ `Misty::AuthV3` is used by default unless authentication credentials contains a tenant name or id in wich case it
123
+ will use on `Misty::AuthV2`.
124
+
125
+ The credentials are a combination of "id" and "name" used to uniquely identify projects, users and their domains.
126
+ When using only the name, a domain must be specified to guarantee a unique record from the Identity service.
127
+
128
+ ###### Examples
129
+ ```ruby
130
+ auth = {
131
+ :url => 'http://localhost:5000',
132
+ :user => 'admin',
133
+ :user_domain => 'default',
134
+ :password => 'secret',
135
+ :project => 'admin',
136
+ :project_domain => 'default'
137
+ }
57
138
  }
139
+ cloud = Misty::Cloud.new(:auth => auth_v3)
140
+ # The API requests are of course specific to this version:
141
+ cloud.identity.list_projects
142
+ ```
58
143
 
59
- openstack = Misty::Cloud.new(:auth => auth_v3)
144
+ Using IDs:
145
+ ```ruby
146
+ auth = {
147
+ :url => 'http://localhost:5000',
148
+ :user_id => '48985e6b8da145699d411f12a3459fca',
149
+ :password => 'secret',
150
+ :project_id => '8e1e232f6cbb4116bbef715d8a0afe6e',
151
+ }
152
+ }
153
+ ```
60
154
 
61
- puts openstack.compute.list_servers.body
62
- puts openstack.compute.list_flavors.body
63
- networks = openstack.network.list_networks
64
- network_id = networks.body['networks'][0]['id']
65
- network = openstack.network.show_network_details(network_id)
66
- puts network.body
155
+ Or alternatively using a context
156
+ ```ruby
157
+ context = { :context => { :token => token_id, :catalog => service_catalog, :expires => expire_date } }
158
+ cloud = Misty::Cloud.new(:auth => context)
67
159
  ```
68
160
 
69
- ## Services
70
- Once a Misty::Cloud object is created, the Openstack services can be used.
161
+ ##### Keystone v2.0
162
+ By providing tenant details Misty will detect it's using v2.0 for authentication:
163
+
164
+ ```ruby
165
+ auth = {
166
+ :url => 'http://localhost:5000',
167
+ :user => 'admin',
168
+ :password => 'secret',
169
+ :tenant => 'admin',
170
+ }
171
+ cloud = Misty::Cloud.new(:auth => auth_v2)
172
+ # The API requests are of course specific to this version:
173
+ cloud.identity.list_tenants
174
+ ```
175
+
176
+ ##### Note
177
+ It's possible to authenticate against Keystone V3 and use the identity service v2.0, for instance:
178
+ In which case API set for v2.0 applies: tenants are available but not the projects.
179
+ ```ruby
180
+ cloud = Misty::Cloud.new(:auth => auth_v3)
181
+ cloud.identity(:api_version => 'v2.0')
182
+ ```
71
183
 
72
- The Cloud object is authenticated by the identity server (bootstrap) and is provided with a service catalog.
73
- When an OpenStack API service is required, the catalog entry's endpoint is used and the service is dynamically called.
184
+ ### Global configuration options
185
+ The configuration parameters used to initialize `Misty::Cloud` are global. They are optionals and Misty::Config
186
+ defaults are applied if needed.
187
+
188
+ * `:auth` - Authentication credentials hash containing 'auth_url' and user context. See `Misty::Auth`.
189
+ * `:content_type` - HTTP responses body format. :json or :hash structures. Default is `Misty::Config::CONTENT_TYPE`.
190
+ * `:headers` - Hash of extra HTTP headers to be applied to all services
191
+ * `:interface` - Endpoint interface, allowed values are: "public", "internal", "admin".
192
+ * `:log_file` - Log destination, Value is either file path (./misty.log) or IO object (SDOUT). Default is '/dev/null'
193
+ * `:log_level` - Value is Fixnum - Default is 1 (Logger::INFO) - See Logger from Ruby standard Library
194
+ * `:region_id` - Alternative Region identifier. Default is `Misty::Config::REGION_ID`
195
+ Default is `Misty::Config::INTERFACE`
196
+ * `:ssl_verify_mode` - Boolean flag for SSL client verification. SSL is defined when URI scheme => "https://".
197
+ Default is `Misty::Config::SSL_VERIFY_MODE`
198
+ See `Misty::Config` for more details
74
199
 
75
- Each service name (i.e. `compute`) is the object handling API requests.
200
+ ### Headers
201
+ Headers are cumulative, applied from Cloud top level, then at Service level and finally at request level.
202
+
203
+ HTTP headers can effectively be optionally added to any request.
204
+ An Header object must be created and passed as the last parameter of a request.
76
205
 
77
- ```ruby
78
- openstack = Misty::Cloud.new(:auth => { ... })
79
- openstack.compute.list_servers
80
- openstack.network.list_networks
81
- data = Misty.to_json('network': {'name': 'my-network'})
82
- openstack.network.create_network(data)
206
+ For example for an already initialized cloud:
207
+ ```ruby
208
+ header = Misty::HTTP::Header.new(
209
+ 'x-container-meta-web-listings' => false,
210
+ 'x-container-meta-quota-count' => "",
211
+ 'x-container-meta-quota-bytes' => nil,
212
+ 'x-versions-location' => "",
213
+ 'x-container-meta-web-index' => ""
214
+ )
215
+ openstack.object_storage.create_update_or_delete_container_metadata(container_name, header)
83
216
  ```
84
217
 
85
- To obtain the list of supported services:
218
+ ### Service and Request levels configuration parameters
219
+ The same parameters used at the global configuration variables can be applied at Service level or at a Request level.
220
+ The global values passed from `Misty::Cloud` level are then overridden at the Service level.
221
+
222
+ The following parameters can be also used:
223
+ * `:api_version` - String for specifying Openstack API service version to use. Default is latest supported version.
224
+ Applies only at service level as it's needed for service creation.
225
+ * `:base_path` - Allows to force the base path for every URL requests Default nil.
226
+ * `:base_url` - Allows to force the base URL for every requests. Default nil.
227
+ * `:version` - Version to be used when microversion is supported by the service. Default: `nil`
228
+ Allowed values: `'latest'`, or a version number such as '2.10'
229
+
230
+ #### Examples
231
+ Initialize cloud
232
+ ```ruby
233
+ cloud = Misty::Cloud.new(:auth => { ... }, region_id => 'regionOne', :log_level => 0)
234
+ ```
235
+
236
+ Then use different options, for example, the identify service, therefore overriding respective global defaults or
237
+ specified values
86
238
  ```ruby
87
- > require 'misty'
88
- > puts Misty.services
239
+ cloud.identity => {:region_id => 'regionTwo', :interface => 'admin'}
240
+ Provide service specific option
241
+ cloud.compute => {:version => '2.27'})
242
+ ```
243
+
244
+ ## Services
245
+ The latest list of supported service can be obtain from `Misty.services`:
246
+ ```
247
+ require 'misty'
248
+ puts Misty.services
249
+ =>
89
250
  application_catalog: murano, versions: ["v1"]
90
251
  alarming: aodh, versions: ["v2"]
91
252
  backup: freezer, versions: ["v1"]
92
- baremetal: ironic, microversion: v1
93
- block_storage: cinder, versions: ["v2", "v1"], microversion: v3
253
+ baremetal: ironic, versions: ["v1"], microversion: v1
254
+ block_storage: cinder, versions: ["v3", "v2", "v1"], microversion: v3
94
255
  clustering: senlin, versions: ["v1"]
95
- compute: nova, microversion: v2.1
96
- container_infrastructure_management: magnum, microversion: v1
256
+ compute: nova, versions: ["v2.1"], microversion: v2.1
257
+ container_infrastructure_management: magnum, versions: ["v1"], microversion: v1
97
258
  data_processing: sahara, versions: ["v1.1"]
98
259
  data_protection_orchestration: karbor, versions: ["v1"]
99
260
  database: trove, versions: ["v1.0"]
100
- domain_name_server: designate, versions: ["v2"]
261
+ dns: designate, versions: ["v2"]
101
262
  identity: keystone, versions: ["v3", "v2.0"]
102
263
  image: glance, versions: ["v2", "v1"]
103
264
  load_balancer: octavia, versions: ["v2.0"]
@@ -108,35 +269,25 @@ nfv_orchestration: tacker, versions: ["v1.0"]
108
269
  object_storage: swift, versions: ["v1"]
109
270
  orchestration: heat, versions: ["v1"]
110
271
  search: searchlight, versions: ["v1"]
111
- shared_file_systems: manila, microversion: v2
272
+ shared_file_systems: manila, versions: ["v2"], microversion: v2
112
273
  ```
113
274
 
114
- ### Headers
115
- HTTP headers can be defined at 3 different levels:
116
- * Global headers are applied across all services, see `:headers` in "Global parameters" section.
117
- * Service level headers are applied on every request of an involved service, see "Services options" section.
118
- * Request level header are passed on per request basis.
119
-
120
- The Headers are cumulative, therefore a request level header will be added on top of the global and Service levels
121
- headers.
122
-
123
- ### Prefixes
275
+ ### Service Prefix
124
276
  A shorter name can be used to call a service only if it's unique among all services.
125
- For instance `net` or `network` can be used instead of `networking`.
277
+ For instance `net` or `network` can be used instead of `networking` because it's not ambiguous.
126
278
  Meanwhile `data` doesn't work because it's ambiguous between `data_processing` and `data_protection_orchestration`
127
279
 
128
280
  ### Aliases
129
- * `dns` is an alias for `domain_name_server`
130
- * `volume` is an alias for `block_storage`
131
-
132
- ## Openstack service name
133
- Different service names can be used for a specific Openstack Service by using the :service_names option (see below).
281
+ * `domain_name_server` is an alias for `dns`
282
+ * `volume` is an alias for `block_storage`
134
283
 
135
- ## Requests
136
- The #requests method provides the available requests for a service, for example:
137
- ```ruby
138
- openstack.compute.requests
284
+ ### Requests
285
+ The exhaustive list of requests, extracted from the current service API's and cumulated with Misty service defined
286
+ requests if any, is available as follow:
139
287
 
288
+ #### Example (Output truncated)
289
+ ```
290
+ cloud.compute.requests
140
291
  => [:add_a_single_tag,
141
292
  :add_associate_fixed_ip_addfixedip_action_deprecated,
142
293
  :add_associate_floating_ip_addfloatingip_action_deprecated,
@@ -159,204 +310,118 @@ openstack.compute.requests
159
310
  :create_cell,
160
311
  :create_cloudpipe,
161
312
  :create_console,
162
- .../...
163
313
  ```
164
314
 
165
- ## Setup
166
-
167
- ### Authentication information parameter
168
- The URL and credentials details are necessary to authenticate with the identity server (Keystone).
169
-
170
- The credentials are a combination of "id" and "name" used to uniquely identify projects, users and their domains.
171
- When using only the name, a domain must be specified to guarantee a unique record from the Identity service.
172
-
173
- The following parameters can be used:
174
- * `:domain_id`
175
- Domain id used for authentication scope
176
- Default: `"default"`
177
- * `:domain`
178
- Domain name used for authentication scope
179
- Default: `"Default"`
180
- * `:project_id`
181
- Project id
182
- * `:project`
183
- Project name
184
- * `:project_domain_id`
185
- Project domain id
186
- * `:project_domain`
187
- Project domain name
188
- * `:tenant_id`
189
- Tenant id, used only for Keystone v2.0
190
- * `:tenant`
191
- Tenant name, used only for Keystone v2.0
192
- * `:user_id`
193
- User id
194
- * `:user`
195
- User name
196
- * `:user_domain_id`
197
- User domain id
198
- * `:user_domain`
199
- User domain name
200
- * `:password`
201
- Password for user. Cannot be used together with `:token`.
202
- * `:token`
203
- User provided token, overrides all user and password parameters.
204
- * `:context`
205
- Bypass the authentication by providing a proper context with `token id`, `service catalog` and `expire date`.
206
- Overrides all user and password parameters
207
- Example: ``{:context => { :token => token_id, :catalog => service_catalog, :expires => expire_date }}``
208
-
209
- #### Keystone v3
210
- Keystone v3 is default recommended version:
211
-
315
+ ### Direct HTTP requests to REST resources
316
+ To send requests directly use the 'get', 'delete', 'post' and 'put' methods directly:
212
317
  ```ruby
213
- auth = {
214
- :url => 'http://localhost:5000',
215
- :user => 'admin',
216
- :user_domain => 'default',
217
- :password => 'secret',
218
- :project => 'admin',
219
- :project_domain => 'default'
220
- }
221
- }
318
+ openstack.network.post('/v2.0/qos/policies/48985e6b8da145699d411f12a3459fca/dscp_marking_rules', data)
222
319
  ```
223
320
 
224
- Alternatively, using IDs:
225
-
321
+ ### Orchestration
322
+ #### Example
226
323
  ```ruby
227
- auth = {
228
- :url => 'http://localhost:5000',
229
- :user_id => '48985e6b8da145699d411f12a3459fca',
230
- :password => 'secret',
231
- :project_id => '8e1e232f6cbb4116bbef715d8a0afe6e',
232
- }
324
+ heat_template = {
325
+ "files": {},
326
+ "disable_rollback": true,
327
+ "parameters": {
328
+ "flavor": "m1.tiny"
329
+ },
330
+ "stack_name": "test_stack",
331
+ "template": {
332
+ "heat_template_version": "2013-05-23",
333
+ "description": "Template to test heat",
334
+ "parameters": {
335
+ "flavor": {
336
+ "default": "m1.small",
337
+ "type": "string"
338
+ }
339
+ },
340
+ "resources": {
341
+ "hello_world": {
342
+ "type": "OS::Nova::Server",
343
+ "properties": {
344
+ "flavor": { "get_param": "flavor" },
345
+ "image": "50fd6f2b-d9f0-41b6-b0a9-4482bfe61914",
346
+ "user_data": "/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n"
347
+ }
348
+ }
349
+ }
350
+ },
351
+ "timeout_mins": 60
233
352
  }
234
- ```
235
- #### Keystone v2.0
236
- Provide the tenant details, Misty will detect it's using v2.0 for authentication:
237
353
 
238
- ```ruby
239
- auth = {
240
- :url => 'http://localhost:5000',
241
- :user => 'admin',
242
- :password => 'secret',
243
- :tenant => 'admin',
244
- }
354
+ require 'misty'
355
+ require 'pp'
356
+ cloud = Misty::Cloud.new(:auth => { ... })
357
+ data_heat_template = Misty.to_json(heat_template)
358
+ response = cloud.orchestration.create_stack(data_heat_template)
359
+ id = response.body['stack']['id']
360
+ stack = cloud.orchestration.show_stack_details('test_stack', id)
361
+ pp stack.body
245
362
  ```
246
- ### Logging parameters
247
- * :log_file
248
- File name and path for log file.
249
- Value is file path or IO object - Default is `./misty.log`.
250
- For example: use STDOUT for terminal output or alternatively use '/dev/null' to avoid the logs entirely.
251
- * :log_level
252
- Value is Fixnum - Default is 1 (Logger::INFO) - See Logger from Ruby standard Library
253
363
 
364
+ #### Some usage examples
254
365
  ```ruby
255
- openstack = Misty::Cloud.new(:auth => auth, :content_type => :ruby, :log_file => STDOUT)
366
+ cloud = Misty::Cloud.new(:auth => { ... })
367
+ pp cloud.compute.versions
368
+ => [{"status"=>"SUPPORTED",
369
+ "updated"=>"2011-01-21T11:33:21Z",
370
+ "links"=>[{"href"=>"http://192.0.2.1:8774/v2/", "rel"=>"self"}],
371
+ "min_version"=>"",
372
+ "version"=>"",
373
+ "id"=>"v2.0"},
374
+ {"status"=>"CURRENT",
375
+ "updated"=>"2013-07-23T11:33:21Z",
376
+ "links"=>[{"href"=>"http://192.0.2.1:8774/v2.1/", "rel"=>"self"}],
377
+ "min_version"=>"2.1",
378
+ "version"=>"2.53",
379
+ "id"=>"v2.1"}]
256
380
  ```
257
381
 
258
- #### Global parameters
259
- The following options are applied to each service unless specifically provided for a service.
260
-
261
- * :content_type
262
- Format of the body of the successful HTTP responses to be JSON or Ruby structures.
263
- Type: Symbol
264
- Allowed values: `:json`, `:ruby`
265
- Default: `:ruby`
266
- * :headers
267
- HTTP Headers to be applied to all services
268
- Type: Hash
269
- Default: {}
270
- * :region_id
271
- Type: String
272
- Default: "regionOne"
273
- * :interface
274
- Type: String
275
- Allowed values: "public", "internal", "admin"
276
- Default: "public"
277
- * :ssl_verify_mode
278
- When using SSL mode (defined by URI scheme => "https://")
279
- Type: Boolean
280
- Default: `true`
281
-
282
- ### Services Options
283
- Each service can have specific parameters.
284
-
285
382
  ```ruby
286
- openstack = Misty::Cloud.new(:auth => auth, :identity => {}, :compute => {})
383
+ cloud.compute(:version => '2.25')
384
+ data_keypair = Misty.to_json('keypair': {'name': 'admin-keypair'})
385
+ admin_keypair = cloud.compute.create_or_import_keypair(data_keypair)
386
+ user_id = admin_keypair.body['keypair']['user_id']
387
+ keypairs = cloud.compute.list_keypairs
388
+ pp keypairs.body
287
389
  ```
288
390
 
289
- The following options are available:
290
- * :api_version
291
- Type: String
292
- Default: The latest supported version - See Misty.services for other versions.
293
- * :base_path
294
- Allows to force the base path for every URL requests.
295
- Type: String
296
- * :base_url
297
- Allows to force the base URL for every requests.
298
- Type: String
299
- * :headers
300
- Optional headers
301
- Type: Hash
302
- * :interface
303
- Allows to provide an alternate interface. Allowed values are "public", "internal" or "admin"
304
- Type: String
305
- Default: Determined from global value
306
- * :region_id
307
- Type: String
308
- Default: Determined from global value
309
- * :service_names
310
- Allows to use a difference name for the service. For instance "identity3" for the identity service.
311
- Type: String
312
- Default: Determined from Misty.services
313
- * :ssl_verify_mode
314
- Type: Boolean
315
- Default: Determined from global value
316
- * :version
317
- Version to be used when microversion is supported by the service.
318
- Type: String
319
- Allowed values: "CURRENT", "LATEST", "SUPPORTED", or a version number such as "2.0" or "3"
320
- Default: `"CURRENT"`
321
-
322
- Example:
391
+ Nova version 2.10+, a keypair name can be filtered by user_id
323
392
  ```ruby
324
- openstack = Misty::Cloud.new(:auth => auth, :log_level => 0, :identity => {:region_id => 'regionTwo'}, :compute => {:version => '2.27', :interface => 'admin'})
393
+ user_id=1e50c2f0995446fd9b135a1a549cabdb
394
+ cloud.compute(:version => '2.10').show_keypair_details("admin-keypair?user_id=#{user_id}")
325
395
  ```
326
396
 
327
- ### Services Headers
328
- HTTP headers can be optionally added to any request.
329
- A Header object must be created and passed as the last parameter of a request.
330
-
331
- For example for an already initialized cloud:
397
+ With Nova version 2.2+, the type field is also returned when showing keypair details
332
398
  ```ruby
333
- header = Misty::HTTP::Header.new(
334
- 'x-container-meta-web-listings' => false,
335
- 'x-container-meta-quota-count' => "",
336
- 'x-container-meta-quota-bytes' => nil,
337
- 'x-versions-location' => "",
338
- 'x-container-meta-web-index' => ""
339
- )
340
-
341
- openstack.object_storage.create_update_or_delete_container_metadata(container_name, header)
399
+ cloud.compute(:version => '2.2')
400
+ pp admin_keypair.body
401
+ => {'keypair'=>
402
+ {'public_key'=>
403
+ 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDjenEe7B87OQHYjZAdJWmaY13mF0N3VooviHypEXaSDfEmFj4GinXorKD0kdXAL30orT0wgAVtpAvRhH2iFTPF2VKCdq4VMzLuai60e3oB3vsTWdZQIJtvaW0mpTNVUQKczbFhRFUi4CNsAijjmGJJgxhihd6rAfynFtalLO0yNn3dKtEMbsvs7KeMxT9SXbfLmEXD4reAK/WXQBVjrEjJIgpC3+SXOO6vsavaOTFu7/Nbha/p4g4yJ3rHUU+7lj79a7iy0sNeExBSZ2aKTq7FQ5XDmtZjjpUeas16kMMX5HdxISYkbq3QnG9iTrIy+GEAYKkZPzhuAa76Qpze35aV Generated-by-Nova\n',
404
+ 'user_id'=>'1e50c2f0995446fd9b135a1a549cabdb',
405
+ 'name'=>'admin-keypair',
406
+ 'deleted'=>false,
407
+ 'created_at'=>'2016-11-23T01:23:53.000000',
408
+ 'updated_at'=>nil,
409
+ 'fingerprint'=>'4e:db:2d:bd:93:70:01:b8:61:17:96:23:e0:78:e2:69',
410
+ 'deleted_at'=>nil,
411
+ 'type'=>'ssh',
412
+ 'id'=>8}}
342
413
  ```
343
414
 
344
- ## Direct REST HTTP Methods
345
- To send requests directly use the 'get', 'delete', 'post' and 'put' methods directly:
346
- ```ruby
347
- openstack.network.post('/v2.0/qos/policies/48985e6b8da145699d411f12a3459fca/dscp_marking_rules', data)
348
- ```
349
- # Requirements
415
+ # OpenstackAPI notes
416
+ ## Neutron
417
+ Driver Vendor Passthru (drivers) has 2 methods call with same name.
418
+ One for Node Vendor Passthru and one for Drivers Passthru.
419
+ They are respectively associated with the methods #call_a_vendor_method and #call_a_driver_method.
350
420
 
351
- ## Ruby versions tested
421
+ # Ruby versions tested
422
+ * Ruby MRI 2.5.0
352
423
  * Ruby MRI 2.4.2
353
- * Ruby MRI 2.4.1
354
- * Ruby MRI 2.4.0
355
424
  * Ruby MRI 2.3.4
356
- * Ruby MRI 2.3.3
357
- * Ruby MRI 2.3.2
358
- * Ruby MRI 2.3.1
359
- * Ruby MRI 2.3.0
360
425
 
361
426
  # Contributing
362
427
  Contributors are welcome and must adhere to the [Contributor covenant code of conduct](http://contributor-covenant.org/).